[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master d02c2f7 4/4: Speed up maybe_gc when GC is inhibited
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master d02c2f7 4/4: Speed up maybe_gc when GC is inhibited |
Date: |
Sun, 21 Jul 2019 14:24:20 -0400 (EDT) |
branch: master
commit d02c2f7f6507105605ed0596a7e26acd5b3b8122
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Speed up maybe_gc when GC is inhibited
* src/alloc.c (allow_garbage_collection)
(inhibit_garbage_collection): Temporarily bump
consing_until_gc, to improve performance of maybe_gc while
garbage collection is inhibited. Suggested by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00511.html
---
src/alloc.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index b7ba886..5001580 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5501,11 +5501,14 @@ staticpro (Lisp_Object const *varaddress)
Protection from GC
***********************************************************************/
-/* Temporarily prevent garbage collection. */
+/* Temporarily prevent garbage collection. Temporarily bump
+ consing_until_gc to speed up maybe_gc when GC is inhibited. */
static void
-allow_garbage_collection (void)
+allow_garbage_collection (void *ptr)
{
+ object_ct *p = ptr;
+ consing_until_gc = *p;
garbage_collection_inhibited--;
}
@@ -5513,9 +5516,10 @@ ptrdiff_t
inhibit_garbage_collection (void)
{
ptrdiff_t count = SPECPDL_INDEX ();
-
- record_unwind_protect_void (allow_garbage_collection);
+ object_ct consing = consing_until_gc;
+ record_unwind_protect_ptr (allow_garbage_collection, &consing);
garbage_collection_inhibited++;
+ consing_until_gc = OBJECT_CT_MAX;
return count;
}