From f729bf27dc68a6d7553a6bbcd2de67d12ae22a2b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 31 Dec 2020 06:45:48 -0800 Subject: gc: fix unnecessary full gc request in finalization. * gc.c (call_finalizers_impl): Objects are only added to freshobj if they are in the zero generation. We should skip that entire block of code if the object isn't in that generation. Not only is it wasteful to execute that code for the mature generation, but the logic falsely sets the full_gc flag whenever processing a non-gen-0 object! --- gc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index 05cf55dc..493da5f0 100644 --- a/gc.c +++ b/gc.c @@ -787,7 +787,7 @@ static val call_finalizers_impl(val ctx, val obj = found->obj; funcall1(found->fun, obj); #if CONFIG_GEN_GC - if (inprogress) { + if (inprogress && obj->t.gen == 0) { for (dup = 0, i = freshobj_idx_start; i < freshobj_idx; i++) { if (freshobj[i] == obj) { dup = 1; @@ -796,7 +796,7 @@ static val call_finalizers_impl(val ctx, } if (!dup) { - if (freshobj_idx < FRESHOBJ_VEC_SIZE && obj->t.gen == 0) { + if (freshobj_idx < FRESHOBJ_VEC_SIZE) { freshobj[freshobj_idx++] = obj; } else { full_gc = 1; -- cgit v1.2.3