From dfd1680302962c29521770c512e8ed1ddfb640b1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 9 Sep 2015 07:56:25 -0700 Subject: 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. --- gc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); } } -- cgit v1.2.3