]> git.eshelyaron.com Git - emacs.git/commit
Make printing mostly non-recursive (bug#55481)
authorMattias Engdegård <mattiase@acm.org>
Fri, 13 May 2022 11:36:13 +0000 (13:36 +0200)
committerMattias Engdegård <mattiase@acm.org>
Wed, 18 May 2022 08:40:15 +0000 (10:40 +0200)
commit97400c4c2446f00ee0783249b9c4f1fbfaf65fb2
treef6e0254e698e90fc007a615dc2dba6a6f7f61dff
parent24f7719cb66e8fa45f3746f22f938dceff94a576
Make printing mostly non-recursive (bug#55481)

Introduce explicit stacks for traversing common data types during
printing: conses, vectors, records, byte-code, hash-tables and
char-tables, all previously traversed using recursion in C.  This
greatly reduces the risk of crashing Emacs from C stack overflow
when printing deeply nested data.

* src/print.c (Fprinc, print, PRINT_CIRCLE_CANDIDATE_P):
Special-case Fprinc with a plain string argument to eliminate the need
for keeping track of print_depth during the preprocessing phase.
This also improves performance.
(struct print_pp_entry, struct print_pp_stack, ppstack)
(grow_pp_stack, pp_stack_push_value, pp_stack_push_values)
(pp_stack_empty_p, pp_stack_pop):
New stack for preprocessing.
(print_preprocess):
Make mostly nonrecursive, except for string properties.
(enum print_entry_type, struct print_stack_entry)
(struct print_stack, prstack, grow_print_stack)
(print_stack_push, print_stack_push_vector):
New stack for printing.
(print_vectorlike, print_object):
Make mostly nonrecursive, except for string properties and some less
heavily used types.
* test/src/print-tests.el (print-deeply-nested):
New test.
src/print.c
test/src/print-tests.el