diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-01-01 03:00:51 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-01-01 03:00:51 -0800 |
commit | 14d97b54e72ff2f0f6b13bc70418a3eaff7865e4 (patch) | |
tree | 3b4681dd74971a5aa30d410e27422258a4fda698 /gc.c | |
parent | 3edc515f91586cb5bb7bc666fb9222c67eabfdb2 (diff) | |
download | txr-14d97b54e72ff2f0f6b13bc70418a3eaff7865e4.tar.gz txr-14d97b54e72ff2f0f6b13bc70418a3eaff7865e4.tar.bz2 txr-14d97b54e72ff2f0f6b13bc70418a3eaff7865e4.zip |
gc: streamlining finalization-related code.
* gc.c (prepare_finals): Do not move unreachable objects with
finalizers into generation 0 here.
(call_finalizers_impl): Don't test the object for being in
generation 0; that may not be true since we don't ensure that
in prepare_finals now. Instead check he reachable flag of he
finalization entry; that tells us that we are dealing with an
object that had been found unreachable. When we re-introduce
it into freshobj, we set its generation to zero. Also, don't
bother with this freshobj logic if the full_gc flag has
been set. That now includes not bothering to set object
generations to zero.
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -745,9 +745,6 @@ NOINLINE static void prepare_finals(void) for (f = final_list; f; f = f->next) { if (!f->reachable) { -#if CONFIG_GEN_GC - f->obj->t.gen = 0; -#endif mark_obj(f->obj); } mark_obj(f->fun); @@ -789,8 +786,11 @@ static val call_finalizers_impl(val ctx, val obj = found->obj; funcall1(found->fun, obj); #if CONFIG_GEN_GC - if (--obj->t.fincount == 0 && inprogress && obj->t.gen == 0) { + if (--obj->t.fincount == 0 && inprogress && + !full_gc && !found->reachable) + { if (freshobj_idx < FRESHOBJ_VEC_SIZE) { + obj->t.gen = 0; freshobj[freshobj_idx++] = obj; } else { full_gc = 1; |