summaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-09 07:56:25 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-09 07:56:25 -0700
commitdfd1680302962c29521770c512e8ed1ddfb640b1 (patch)
tree661e13301a83a486c39e3af2d09725aae65cab32 /gc.c
parent91d4184615878babd7c8c3675418c5421b5e663c (diff)
downloadtxr-dfd1680302962c29521770c512e8ed1ddfb640b1.tar.gz
txr-dfd1680302962c29521770c512e8ed1ddfb640b1.tar.bz2
txr-dfd1680302962c29521770c512e8ed1ddfb640b1.zip
Small optimization in finalization.
* gc.c (prepare_finals): In the second pass, only mark objects that were identified in the first pass as unreachable. Reachable ones don't require a redundant call to mark_obj. Also, objects identified as unreachable can be moved to gen 0. This is something like what the mark_makefresh hack was trying to do. It only does anything in a full GC pass, because in an incremental pass, anything identified as unreachable is necessarily gen 0. It can help prevent some objects that are revived by finalization from sliding back to gen 1 and hanging around.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index 9125f070..af91bba7 100644
--- a/gc.c
+++ b/gc.c
@@ -623,7 +623,12 @@ static void prepare_finals(void)
f->reachable = is_reachable(f->obj);
for (f = final_list; f; f = f->next) {
- mark_obj(f->obj);
+ if (!f->reachable) {
+#if CONFIG_GEN_GC
+ f->obj->t.gen = 0;
+#endif
+ mark_obj(f->obj);
+ }
mark_obj(f->fun);
}
}