[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master a354736: Let consing_until_gc exceed INTPTR_MAX
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master a354736: Let consing_until_gc exceed INTPTR_MAX |
Date: |
Tue, 13 Aug 2019 15:12:42 -0400 (EDT) |
branch: master
commit a354736e1dfe5a7e4ddbb1ee7f1373be2b5bbe09
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
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.
---
src/alloc.c | 21 ++++++++++-----------
src/lisp.h | 10 +++++++---
2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index c7419e2..7bed3f4 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -224,7 +224,7 @@ struct emacs_globals globals;
/* maybe_gc collects garbage if this goes negative. */
-object_ct consing_until_gc;
+consing_ct consing_until_gc;
#ifdef HAVE_PDUMPER
/* Number of finalizers run: used to loop over GC until we stop
@@ -236,9 +236,10 @@ int number_finalizers_run;
bool gc_in_progress;
-/* System byte counts reported by GC. */
+/* System byte and object counts reported by GC. */
typedef uintptr_t byte_ct;
+typedef intptr_t object_ct;
/* Number of live and free conses etc. */
@@ -2546,7 +2547,7 @@ free_cons (struct Lisp_Cons *ptr)
might incorrectly return non-zero. */
int incr = sizeof *ptr;
if (INT_ADD_WRAPV (consing_until_gc, incr, &consing_until_gc))
- consing_until_gc = OBJECT_CT_MAX;
+ consing_until_gc = CONSING_CT_MAX;
gcstat.total_free_conses++;
}
@@ -5501,7 +5502,7 @@ staticpro (Lisp_Object const *varaddress)
static void
allow_garbage_collection (intmax_t consing)
{
- consing_until_gc = consing - (OBJECT_CT_MAX - consing_until_gc);
+ consing_until_gc = consing - (CONSING_CT_MAX - consing_until_gc);
garbage_collection_inhibited--;
}
@@ -5511,7 +5512,7 @@ inhibit_garbage_collection (void)
ptrdiff_t count = SPECPDL_INDEX ();
record_unwind_protect_intmax (allow_garbage_collection, consing_until_gc);
garbage_collection_inhibited++;
- consing_until_gc = OBJECT_CT_MAX;
+ consing_until_gc = CONSING_CT_MAX;
return count;
}
@@ -5817,7 +5818,7 @@ garbage_collect_1 (struct gcstat *gcst)
/* In case user calls debug_print during GC,
don't let that cause a recursive GC. */
- consing_until_gc = OBJECT_CT_MAX;
+ consing_until_gc = CONSING_CT_MAX;
/* Save what's currently displayed in the echo area. Don't do that
if we are GC'ing because we've run out of memory, since
@@ -5932,19 +5933,17 @@ garbage_collect_1 (struct gcstat *gcst)
consing_until_gc = memory_full_cons_threshold;
else
{
- intptr_t threshold = min (max (GC_DEFAULT_THRESHOLD / 10,
- gc_cons_threshold),
- OBJECT_CT_MAX);
+ consing_ct threshold = max (gc_cons_threshold, GC_DEFAULT_THRESHOLD /
10);
if (FLOATP (Vgc_cons_percentage))
{
double tot = (XFLOAT_DATA (Vgc_cons_percentage)
* total_bytes_of_live_objects ());
if (threshold < tot)
{
- if (tot < OBJECT_CT_MAX)
+ if (tot < CONSING_CT_MAX)
threshold = tot;
else
- threshold = OBJECT_CT_MAX;
+ threshold = CONSING_CT_MAX;
}
}
consing_until_gc = threshold;
diff --git a/src/lisp.h b/src/lisp.h
index 63baab5..043f2f7 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);
extern void garbage_collect (void);
extern const char *pending_malloc_warning;
extern Lisp_Object zero_vector;
-typedef intptr_t object_ct; /* Signed type of object counts reported by GC. */
-#define OBJECT_CT_MAX INTPTR_MAX
-extern object_ct consing_until_gc;
+#define CONSING_CT_MAX max (INTPTR_MAX, EMACS_INT_MAX)
+#if CONSING_CT_MAX == INTPTR_MAX
+typedef intptr_t consing_ct;
+#else
+typedef EMACS_INT consing_ct;
+#endif
+extern consing_ct consing_until_gc;
#ifdef HAVE_PDUMPER
extern int number_finalizers_run;
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master a354736: Let consing_until_gc exceed INTPTR_MAX,
Paul Eggert <=