summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-10-18 20:12:23 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-10-18 20:12:23 -0700
commit88e7e54b5b415c7ab4e6fedd3e3e519d8bf3a68b (patch)
tree4ebcdb7b7981ec6f47caedb36881323ba4de210f
parent415f36f296efa0b286e6f55013e7ca554232a0c9 (diff)
downloadtxr-88e7e54b5b415c7ab4e6fedd3e3e519d8bf3a68b.tar.gz
txr-88e7e54b5b415c7ab4e6fedd3e3e519d8bf3a68b.tar.bz2
txr-88e7e54b5b415c7ab4e6fedd3e3e519d8bf3a68b.zip
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.
-rw-r--r--ChangeLog17
-rw-r--r--gc.c8
2 files changed, 22 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index edfef9ac..2f1e3b68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2014-10-18 Kaz Kylheku <kaz@kylheku.com>
+ 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 <kaz@kylheku.com>
+
* match.c (mf_all): Drop data_lineno parameter. Initialize
the corresponding member based on whether or not data is nil.
(do_match_line, mf_from_ml, match_filter, match_fun, extract):
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)