summaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-04-05 10:09:29 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-04-05 10:09:29 -0700
commit2615b13d4fa8ff0e882a5f616eeb9236d570bdcd (patch)
tree139da4d66dd0b3de219e88bd0e483804c2a8350e /gc.c
parent050fe79a752814cf63ae9f40620febbb86cae1ce (diff)
downloadtxr-2615b13d4fa8ff0e882a5f616eeb9236d570bdcd.tar.gz
txr-2615b13d4fa8ff0e882a5f616eeb9236d570bdcd.tar.bz2
txr-2615b13d4fa8ff0e882a5f616eeb9236d570bdcd.zip
* gc.c (mark_obj, sweep_one, gc_is_reachable): Check for gen > 0 rather
than gen == 0. This allows gen == -1 objects to be considered the same as gen == 0, and traversed. (gc_set, gc_mutated): When a gen 0 object is added to the checkobj array, set its generation to -1. This prevents duplicates in the checkobj array. Also, it fixes a bug: an vector marked as mutated was not being traversed due to being in generation 1.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index d2bc39e9..546be894 100644
--- a/gc.c
+++ b/gc.c
@@ -260,7 +260,7 @@ tail_call:
t = obj->t.type;
#if CONFIG_GEN_GC
- if (!full_gc && obj->t.gen != 0)
+ if (!full_gc && obj->t.gen > 0)
return;
#endif
@@ -433,7 +433,7 @@ static int sweep_one(obj_t *block)
#endif
#if CONFIG_GEN_GC
- if (!full_gc && block->t.gen != 0)
+ if (!full_gc && block->t.gen > 0)
abort();
#endif
@@ -602,7 +602,7 @@ int gc_is_reachable(val obj)
return 1;
#if CONFIG_GEN_GC
- if (!full_gc && obj->t.gen != 0)
+ if (!full_gc && obj->t.gen > 0)
return 1;
#endif
@@ -618,6 +618,7 @@ val gc_set(val *ptr, val obj)
if (in_malloc_range((mem_t *) ptr) && is_ptr(obj) && obj->t.gen == 0) {
if (checkobj_idx >= CHECKOBJ_VEC_SIZE)
gc();
+ obj->t.gen = -1;
checkobj[checkobj_idx++] = obj;
}
*ptr = obj;
@@ -628,6 +629,7 @@ val gc_mutated(val obj)
{
if (checkobj_idx >= CHECKOBJ_VEC_SIZE)
gc();
+ obj->t.gen = -1;
return checkobj[checkobj_idx++] = obj;
}