diff options
Diffstat (limited to 'pit/src/runtime/gc.c')
| -rw-r--r-- | pit/src/runtime/gc.c | 12 |
1 files changed, 8 insertions, 4 deletions
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 <lcq/pit/arena.h> #include <lcq/pit/runtime/gc.h> 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 <stdio.h> + 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); + } } |
