diff options
| author | Paul Eggert | 2019-07-21 11:20:07 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-21 11:24:11 -0700 |
| commit | d02c2f7f6507105605ed0596a7e26acd5b3b8122 (patch) | |
| tree | 7341ddd7c2e2f20aa5857d950684c07f8b7f4955 /src/alloc.c | |
| parent | c72e6328b408805953a5adf832b5c5cc9f3a75e7 (diff) | |
| download | emacs-d02c2f7f6507105605ed0596a7e26acd5b3b8122.tar.gz emacs-d02c2f7f6507105605ed0596a7e26acd5b3b8122.zip | |
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
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/alloc.c b/src/alloc.c index b7ba886482e..50015808e59 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -5501,11 +5501,14 @@ staticpro (Lisp_Object const *varaddress) | |||
| 5501 | Protection from GC | 5501 | Protection from GC |
| 5502 | ***********************************************************************/ | 5502 | ***********************************************************************/ |
| 5503 | 5503 | ||
| 5504 | /* Temporarily prevent garbage collection. */ | 5504 | /* Temporarily prevent garbage collection. Temporarily bump |
| 5505 | consing_until_gc to speed up maybe_gc when GC is inhibited. */ | ||
| 5505 | 5506 | ||
| 5506 | static void | 5507 | static void |
| 5507 | allow_garbage_collection (void) | 5508 | allow_garbage_collection (void *ptr) |
| 5508 | { | 5509 | { |
| 5510 | object_ct *p = ptr; | ||
| 5511 | consing_until_gc = *p; | ||
| 5509 | garbage_collection_inhibited--; | 5512 | garbage_collection_inhibited--; |
| 5510 | } | 5513 | } |
| 5511 | 5514 | ||
| @@ -5513,9 +5516,10 @@ ptrdiff_t | |||
| 5513 | inhibit_garbage_collection (void) | 5516 | inhibit_garbage_collection (void) |
| 5514 | { | 5517 | { |
| 5515 | ptrdiff_t count = SPECPDL_INDEX (); | 5518 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5516 | 5519 | object_ct consing = consing_until_gc; | |
| 5517 | record_unwind_protect_void (allow_garbage_collection); | 5520 | record_unwind_protect_ptr (allow_garbage_collection, &consing); |
| 5518 | garbage_collection_inhibited++; | 5521 | garbage_collection_inhibited++; |
| 5522 | consing_until_gc = OBJECT_CT_MAX; | ||
| 5519 | return count; | 5523 | return count; |
| 5520 | } | 5524 | } |
| 5521 | 5525 | ||