summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-12-31 06:45:48 -0800
committerKaz Kylheku <kaz@kylheku.com>2020-12-31 06:45:48 -0800
commitf729bf27dc68a6d7553a6bbcd2de67d12ae22a2b (patch)
tree8f1a8579937b0fc86a0838cca4be9d842ebda96a
parentd8b3cead17df6d9b86168621e4bbe0d970274c97 (diff)
downloadtxr-f729bf27dc68a6d7553a6bbcd2de67d12ae22a2b.tar.gz
txr-f729bf27dc68a6d7553a6bbcd2de67d12ae22a2b.tar.bz2
txr-f729bf27dc68a6d7553a6bbcd2de67d12ae22a2b.zip
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!
-rw-r--r--gc.c4
1 files 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;