diff options
| author | Paul Eggert | 2019-08-13 12:11:35 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-08-13 12:12:38 -0700 |
| commit | a354736e1dfe5a7e4ddbb1ee7f1373be2b5bbe09 (patch) | |
| tree | 14e9597e69a7367c9880e39b16f9bd5a7c7840e9 | |
| parent | 8882761440c3227850043dddf5aec5394c8cbe28 (diff) | |
| download | emacs-a354736e1dfe5a7e4ddbb1ee7f1373be2b5bbe09.tar.gz emacs-a354736e1dfe5a7e4ddbb1ee7f1373be2b5bbe09.zip | |
Let consing_until_gc exceed INTPTR_MAX
Suggested by Eli Zaretskii (Bug#37006#46).
* src/alloc.c (consing_until_gc): Now of type consing_ct.
All uses changed, so gc-cons-threshold no longer saturates
against OBJECT_CT_MAX.
(object_ct): Move typedef here from lisp.h.
* src/lisp.h (consing_ct, CONSING_CT_MAX): New type and macro.
(OBJECT_CT_MAX): Remove. Replace all uses with CONSING_CT_MAX.
| -rw-r--r-- | src/alloc.c | 21 | ||||
| -rw-r--r-- | src/lisp.h | 10 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/alloc.c b/src/alloc.c index c7419e2fa5f..7bed3f4488d 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -224,7 +224,7 @@ struct emacs_globals globals; | |||
| 224 | 224 | ||
| 225 | /* maybe_gc collects garbage if this goes negative. */ | 225 | /* maybe_gc collects garbage if this goes negative. */ |
| 226 | 226 | ||
| 227 | object_ct consing_until_gc; | 227 | consing_ct consing_until_gc; |
| 228 | 228 | ||
| 229 | #ifdef HAVE_PDUMPER | 229 | #ifdef HAVE_PDUMPER |
| 230 | /* Number of finalizers run: used to loop over GC until we stop | 230 | /* Number of finalizers run: used to loop over GC until we stop |
| @@ -236,9 +236,10 @@ int number_finalizers_run; | |||
| 236 | 236 | ||
| 237 | bool gc_in_progress; | 237 | bool gc_in_progress; |
| 238 | 238 | ||
| 239 | /* System byte counts reported by GC. */ | 239 | /* System byte and object counts reported by GC. */ |
| 240 | 240 | ||
| 241 | typedef uintptr_t byte_ct; | 241 | typedef uintptr_t byte_ct; |
| 242 | typedef intptr_t object_ct; | ||
| 242 | 243 | ||
| 243 | /* Number of live and free conses etc. */ | 244 | /* Number of live and free conses etc. */ |
| 244 | 245 | ||
| @@ -2546,7 +2547,7 @@ free_cons (struct Lisp_Cons *ptr) | |||
| 2546 | might incorrectly return non-zero. */ | 2547 | might incorrectly return non-zero. */ |
| 2547 | int incr = sizeof *ptr; | 2548 | int incr = sizeof *ptr; |
| 2548 | if (INT_ADD_WRAPV (consing_until_gc, incr, &consing_until_gc)) | 2549 | if (INT_ADD_WRAPV (consing_until_gc, incr, &consing_until_gc)) |
| 2549 | consing_until_gc = OBJECT_CT_MAX; | 2550 | consing_until_gc = CONSING_CT_MAX; |
| 2550 | gcstat.total_free_conses++; | 2551 | gcstat.total_free_conses++; |
| 2551 | } | 2552 | } |
| 2552 | 2553 | ||
| @@ -5501,7 +5502,7 @@ staticpro (Lisp_Object const *varaddress) | |||
| 5501 | static void | 5502 | static void |
| 5502 | allow_garbage_collection (intmax_t consing) | 5503 | allow_garbage_collection (intmax_t consing) |
| 5503 | { | 5504 | { |
| 5504 | consing_until_gc = consing - (OBJECT_CT_MAX - consing_until_gc); | 5505 | consing_until_gc = consing - (CONSING_CT_MAX - consing_until_gc); |
| 5505 | garbage_collection_inhibited--; | 5506 | garbage_collection_inhibited--; |
| 5506 | } | 5507 | } |
| 5507 | 5508 | ||
| @@ -5511,7 +5512,7 @@ inhibit_garbage_collection (void) | |||
| 5511 | ptrdiff_t count = SPECPDL_INDEX (); | 5512 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5512 | record_unwind_protect_intmax (allow_garbage_collection, consing_until_gc); | 5513 | record_unwind_protect_intmax (allow_garbage_collection, consing_until_gc); |
| 5513 | garbage_collection_inhibited++; | 5514 | garbage_collection_inhibited++; |
| 5514 | consing_until_gc = OBJECT_CT_MAX; | 5515 | consing_until_gc = CONSING_CT_MAX; |
| 5515 | return count; | 5516 | return count; |
| 5516 | } | 5517 | } |
| 5517 | 5518 | ||
| @@ -5817,7 +5818,7 @@ garbage_collect_1 (struct gcstat *gcst) | |||
| 5817 | 5818 | ||
| 5818 | /* In case user calls debug_print during GC, | 5819 | /* In case user calls debug_print during GC, |
| 5819 | don't let that cause a recursive GC. */ | 5820 | don't let that cause a recursive GC. */ |
| 5820 | consing_until_gc = OBJECT_CT_MAX; | 5821 | consing_until_gc = CONSING_CT_MAX; |
| 5821 | 5822 | ||
| 5822 | /* Save what's currently displayed in the echo area. Don't do that | 5823 | /* Save what's currently displayed in the echo area. Don't do that |
| 5823 | if we are GC'ing because we've run out of memory, since | 5824 | if we are GC'ing because we've run out of memory, since |
| @@ -5932,19 +5933,17 @@ garbage_collect_1 (struct gcstat *gcst) | |||
| 5932 | consing_until_gc = memory_full_cons_threshold; | 5933 | consing_until_gc = memory_full_cons_threshold; |
| 5933 | else | 5934 | else |
| 5934 | { | 5935 | { |
| 5935 | intptr_t threshold = min (max (GC_DEFAULT_THRESHOLD / 10, | 5936 | consing_ct threshold = max (gc_cons_threshold, GC_DEFAULT_THRESHOLD / 10); |
| 5936 | gc_cons_threshold), | ||
| 5937 | OBJECT_CT_MAX); | ||
| 5938 | if (FLOATP (Vgc_cons_percentage)) | 5937 | if (FLOATP (Vgc_cons_percentage)) |
| 5939 | { | 5938 | { |
| 5940 | double tot = (XFLOAT_DATA (Vgc_cons_percentage) | 5939 | double tot = (XFLOAT_DATA (Vgc_cons_percentage) |
| 5941 | * total_bytes_of_live_objects ()); | 5940 | * total_bytes_of_live_objects ()); |
| 5942 | if (threshold < tot) | 5941 | if (threshold < tot) |
| 5943 | { | 5942 | { |
| 5944 | if (tot < OBJECT_CT_MAX) | 5943 | if (tot < CONSING_CT_MAX) |
| 5945 | threshold = tot; | 5944 | threshold = tot; |
| 5946 | else | 5945 | else |
| 5947 | threshold = OBJECT_CT_MAX; | 5946 | threshold = CONSING_CT_MAX; |
| 5948 | } | 5947 | } |
| 5949 | } | 5948 | } |
| 5950 | consing_until_gc = threshold; | 5949 | consing_until_gc = threshold; |
diff --git a/src/lisp.h b/src/lisp.h index 63baab5d636..043f2f738e4 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3793,9 +3793,13 @@ extern void flush_stack_call_func (void (*func) (void *arg), void *arg); | |||
| 3793 | extern void garbage_collect (void); | 3793 | extern void garbage_collect (void); |
| 3794 | extern const char *pending_malloc_warning; | 3794 | extern const char *pending_malloc_warning; |
| 3795 | extern Lisp_Object zero_vector; | 3795 | extern Lisp_Object zero_vector; |
| 3796 | typedef intptr_t object_ct; /* Signed type of object counts reported by GC. */ | 3796 | #define CONSING_CT_MAX max (INTPTR_MAX, EMACS_INT_MAX) |
| 3797 | #define OBJECT_CT_MAX INTPTR_MAX | 3797 | #if CONSING_CT_MAX == INTPTR_MAX |
| 3798 | extern object_ct consing_until_gc; | 3798 | typedef intptr_t consing_ct; |
| 3799 | #else | ||
| 3800 | typedef EMACS_INT consing_ct; | ||
| 3801 | #endif | ||
| 3802 | extern consing_ct consing_until_gc; | ||
| 3799 | #ifdef HAVE_PDUMPER | 3803 | #ifdef HAVE_PDUMPER |
| 3800 | extern int number_finalizers_run; | 3804 | extern int number_finalizers_run; |
| 3801 | #endif | 3805 | #endif |