From 71bfa9094a4a25f762d681bb07f79f92a95dbb87 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Sun, 6 Sep 2026 17:40:51 -0400 Subject: pit: Fix evaluator bug --- pit/src/runtime/gc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'pit/src/runtime/gc.c') diff --git a/pit/src/runtime/gc.c b/pit/src/runtime/gc.c index 119861a..7fd42fa 100644 --- a/pit/src/runtime/gc.c +++ b/pit/src/runtime/gc.c @@ -1,3 +1,4 @@ +#include #include static i64 gc_copy(pit_runtime *rt, pit_value_heavy *h) { @@ -27,10 +28,8 @@ static pit_value gc_copy_value(pit_runtime *rt, pit_value v) { return v; } } -// #include + void pit_gc(pit_runtime *rt) { - return; - // 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; @@ -114,5 +113,10 @@ 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); +} + +void pit_gc_if_necessary(pit_runtime *rt) { + if (pit_arena_byte_idx(rt->heap, rt->heap->next * 5) > rt->heap->back * 4) { + pit_gc(rt); + } } -- cgit v1.3.1