aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2019-08-13 12:11:35 -0700
committerPaul Eggert2019-08-13 12:12:38 -0700
commita354736e1dfe5a7e4ddbb1ee7f1373be2b5bbe09 (patch)
tree14e9597e69a7367c9880e39b16f9bd5a7c7840e9 /src/alloc.c
parent8882761440c3227850043dddf5aec5394c8cbe28 (diff)
downloademacs-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.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c21
1 files changed, 10 insertions, 11 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
227object_ct consing_until_gc; 227consing_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
237bool gc_in_progress; 237bool gc_in_progress;
238 238
239/* System byte counts reported by GC. */ 239/* System byte and object counts reported by GC. */
240 240
241typedef uintptr_t byte_ct; 241typedef uintptr_t byte_ct;
242typedef 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)
5501static void 5502static void
5502allow_garbage_collection (intmax_t consing) 5503allow_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;