aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorStefan Monnier2022-11-17 17:00:22 -0500
committerStefan Monnier2022-11-17 17:00:22 -0500
commitfb7f1864da4aa4c09756cfe47db6c56b4e87bd14 (patch)
tree4ccd8ca7e29c5609fa437884c739106a4f1b2cc2 /src/alloc.c
parent13003105a8edf746a8e8819122bd1bcdf7f9ecdd (diff)
downloademacs-fb7f1864da4aa4c09756cfe47db6c56b4e87bd14.tar.gz
emacs-fb7f1864da4aa4c09756cfe47db6c56b4e87bd14.zip
itree.c: Make the iterator reentrant (bug#59183)
Get rid of the global iterator object and instead allocate a separate iterator for every loop. This still uses the "duplicate iterator" code, including the old iterator which needs a stack, make ITREE_FOREACH a bit more expensive than we'd like. * src/itree.h (init_itree, forget_itree, itree_iterator_busy_p): Delete declarations. (itree_iterator_start): Add iterator arg and remove `line` and `file` args. (struct itree_iterator): Move from `itree.c`. Remove `line` and `file` fields. (ITREE_FOREACH): Stack allocate an iterator object and pass it to `itree_iterator_start`. * src/itree.c (struct itree_iterator): Move to itree.h. (iter): Delete global variable. (itree_iterator_create, init_itree, forget_itree, itree_iterator_busy_p): Delete functions. (itree_contains): Adjust assertion. (itree_iterator_finish): Deallocate the iterator's stack. (itree_iterator_start): Take the (uninitialized) iterator as argument. Allocate a fresh new stack. Remove `file` and `line` arguments. Don't check `running` any more since the iterator is not expected to be initialized at all. * src/eval.c (signal_or_quit): * src/alloc.c (garbage_collect): Don't check `itree_iterator_busy_p` any more. * src/emacs.c (main): No need to `init_itree` any more. (Fdump_emacs): No need to `forget_itree` any more.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c5
1 files changed, 0 insertions, 5 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 6862cf916fb..b9d12dff7e0 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6279,11 +6279,6 @@ garbage_collect (void)
6279 image_prune_animation_caches (false); 6279 image_prune_animation_caches (false);
6280#endif 6280#endif
6281 6281
6282 /* ELisp code run by `gc-post-hook' could result in itree iteration,
6283 which must not happen while the itree is already busy. See
6284 bug#58639. */
6285 eassert (!itree_iterator_busy_p ());
6286
6287 if (!NILP (Vpost_gc_hook)) 6282 if (!NILP (Vpost_gc_hook))
6288 { 6283 {
6289 specpdl_ref gc_count = inhibit_garbage_collection (); 6284 specpdl_ref gc_count = inhibit_garbage_collection ();