diff options
| author | LLLL Colonq <llll@colonq> | 2026-09-01 20:59:47 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-09-01 20:59:47 -0400 |
| commit | a107593b6b362fb68e409c9d7b79427776d137d7 (patch) | |
| tree | e12f7ac95177432abb477273fb5f11122bafb38a /pit/src/runtime/gc.c | |
| parent | ff7407c146b8129c2f1cc7ebe3b5771ad2f5dfdd (diff) | |
Diffstat (limited to 'pit/src/runtime/gc.c')
| -rw-r--r-- | pit/src/runtime/gc.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pit/src/runtime/gc.c b/pit/src/runtime/gc.c index 1cc6547..e96e36b 100644 --- a/pit/src/runtime/gc.c +++ b/pit/src/runtime/gc.c @@ -27,7 +27,9 @@ static pit_value gc_copy_value(pit_runtime *rt, pit_value v) { return v; } } +// #include <stdio.h> void pit_gc(pit_runtime *rt) { + // fprintf(stderr, "running gc: heap size is %ld\n", rt->heap->next); rt->frozen_values = 0; rt->frozen_symtab = 0; pit_arena *fromspace = rt->heap; @@ -60,6 +62,11 @@ void pit_gc(pit_runtime *rt) { pit_value *v = pit_vec_get(pit_value)(rt->saved_bindings, i); if (v != NULL) *v = gc_copy_value(rt, *v); /* TODO warn on failure here? */ } + /* the evaluation stack is reachable */ + for (i64 i = 0; i < rt->result_stack->next; ++i) { + pit_value *v = pit_vec_get(pit_value)(rt->result_stack, i); + if (v != NULL) *v = gc_copy_value(rt, *v); /* TODO warn on failure here? */ + } /* recursively populate all reachable values from that initial set */ for (i64 scan = 0; scan < tospace->next; ++scan) { pit_value_heavy *h = pit_arena_get(tospace, scan); @@ -106,4 +113,5 @@ void pit_gc(pit_runtime *rt) { rt->annotations = tospace_ann; rt->annotations_backbuffer = fromspace_ann; pit_hashtable_reset(pit_ref, pit_annotation)(rt->annotations_backbuffer); + // fprintf(stderr, "done! heap size is %ld\n", rt->heap->next); } |
