From 88e7e54b5b415c7ab4e6fedd3e3e519d8bf3a68b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 18 Oct 2014 20:12:23 -0700 Subject: Deal with situation when GC is disabled and the freshobj array runs out of room. This could happen when parsing a really large TXR program, since gc is disabled during parsing. Currently it asserts, which is not acceptable. * gc.c (make_obj): If after gc, the freshobj array has not been emptied (obviously because gc is disabled), do not assert. Rather, set the full_gc flag to request a full garbage collection when gc is re-enabled. Furthermore, only place newly allocated objects into freshobj if full_gc has not been set. Thus, if we exhaust the freshobj array while gc is off, the full_gc flag is set, and we discontinue use of that array. When gc is re-enabled, we will do a full gc pass. A full gc pass ignores freshobj array, so it doesn't matter that its use was discontinued. --- ChangeLog | 17 +++++++++++++++++ gc.c | 8 +++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index edfef9ac..2f1e3b68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2014-10-18 Kaz Kylheku + + Deal with situation when GC is disabled and the freshobj array runs out + of room. This could happen when parsing a really large TXR program, + since gc is disabled during parsing. Currently it asserts, which + is not acceptable. + + * gc.c (make_obj): If after gc, the freshobj array has not been + emptied (obviously because gc is disabled), do not assert. + Rather, set the full_gc flag to request a full garbage collection + when gc is re-enabled. Furthermore, only place newly allocated objects + into freshobj if full_gc has not been set. Thus, if we exhaust the + freshobj array while gc is off, the full_gc flag is set, and we + discontinue use of that array. When gc is re-enabled, we will do a full + gc pass. A full gc pass ignores freshobj array, so it doesn't matter + that its use was discontinued. + 2014-10-18 Kaz Kylheku * match.c (mf_all): Drop data_lineno parameter. Initialize diff --git a/gc.c b/gc.c index 850605c5..d3dd1f3c 100644 --- a/gc.c +++ b/gc.c @@ -165,7 +165,8 @@ val make_obj(void) malloc_delta >= opt_gc_delta) { gc(); - assert (freshobj_idx < FRESHOBJ_VEC_SIZE); + if (freshobj_idx >= FRESHOBJ_VEC_SIZE) + full_gc = 1; prev_malloc_bytes = malloc_bytes; } #else @@ -189,7 +190,8 @@ val make_obj(void) #endif #if CONFIG_GEN_GC ret->t.gen = 0; - freshobj[freshobj_idx++] = ret; + if (!full_gc) + freshobj[freshobj_idx++] = ret; #endif gc_bytes += sizeof (obj_t); return ret; @@ -208,7 +210,7 @@ val make_obj(void) } } - return 0; + abort(); } static void finalize(val obj) -- cgit v1.2.3