diff options
| author | LLLL Colonq <llll@colonq> | 2026-09-02 21:13:24 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-09-02 21:13:24 -0400 |
| commit | c01f847b68a7fcd48eb0f3d456aa993a6f69ea8d (patch) | |
| tree | 9da9636f6f390950f052c14b64f833ac1819d5cc /pit/src/runtime | |
| parent | a107593b6b362fb68e409c9d7b79427776d137d7 (diff) | |
Diffstat (limited to 'pit/src/runtime')
| -rw-r--r-- | pit/src/runtime/eval.c | 5 | ||||
| -rw-r--r-- | pit/src/runtime/gc.c | 1 | ||||
| -rw-r--r-- | pit/src/runtime/symtab.c | 7 | ||||
| -rw-r--r-- | pit/src/runtime/value/cell.c | 2 |
4 files changed, 14 insertions, 1 deletions
diff --git a/pit/src/runtime/eval.c b/pit/src/runtime/eval.c index b0b53b6..a2b9e79 100644 --- a/pit/src/runtime/eval.c +++ b/pit/src/runtime/eval.c @@ -180,8 +180,11 @@ bool pit_vm_run_one(pit_runtime *rt) { pit_value pit_vm_eval(pit_runtime *rt, pit_value v) { i64 start = rt->callstack->next; vm_push_code(rt, v); + i64 gc = 0; while (pit_vm_run_one(rt) && rt->callstack->next > start) { - if (rt->expr_stack->next == 0 && rt->compilation_stack->next == 0) { + gc += 1; + if (gc > 100 && rt->expr_stack->next == 0 && rt->compilation_stack->next == 0) { + gc = 0; pit_gc(rt); /* TODO hack to avoid running GC during macroexpansion */ } } diff --git a/pit/src/runtime/gc.c b/pit/src/runtime/gc.c index e96e36b..119861a 100644 --- a/pit/src/runtime/gc.c +++ b/pit/src/runtime/gc.c @@ -29,6 +29,7 @@ static pit_value gc_copy_value(pit_runtime *rt, pit_value 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; diff --git a/pit/src/runtime/symtab.c b/pit/src/runtime/symtab.c index ca4ecf2..5684074 100644 --- a/pit/src/runtime/symtab.c +++ b/pit/src/runtime/symtab.c @@ -104,8 +104,12 @@ void pit_symtab_symbol_mark_special_form(pit_runtime *rt, pit_value sym) { if (!ent) { pit_error(rt, "bad symbol"); return; } ent->is_special_form = true; } +#include <stdio.h> void pit_symtab_bind(pit_runtime *rt, pit_value sym, pit_value cell) { /* although we cannot set frozen symbols, we can still bind them temporarily - no need to check */ + fprintf(stderr, "binding "); pit_dump_to_file(rt, stderr, sym, false); + fprintf(stderr, " to "); pit_dump_to_file(rt, stderr, cell, false); + fprintf(stderr, "\n"); pit_symtab_entry *ent = pit_symtab_lookup(rt, sym); if (!ent) { pit_error(rt, "bad symbol"); return; } if (pit_vec_push(pit_value)(rt->saved_bindings, ent->value) < 0) pit_error(rt, "binding stack overflow"); @@ -115,6 +119,9 @@ pit_value pit_symtab_unbind(pit_runtime *rt, pit_value sym) { pit_symtab_entry *ent = pit_symtab_lookup(rt, sym); if (!ent) { pit_error(rt, "bad symbol"); return PIT_NIL; } pit_value old = ent->value; + fprintf(stderr, "unbinding "); pit_dump_to_file(rt, stderr, sym, false); + fprintf(stderr, " (was "); pit_dump_to_file(rt, stderr, old, false); + fprintf(stderr, ")\n"); if (pit_vec_pop(pit_value)(rt->saved_bindings, &ent->value) < 0) pit_error(rt, "binding stack underflow"); return old; } diff --git a/pit/src/runtime/value/cell.c b/pit/src/runtime/value/cell.c index 34b9226..2a99ce2 100644 --- a/pit/src/runtime/value/cell.c +++ b/pit/src/runtime/value/cell.c @@ -11,11 +11,13 @@ pit_value pit_value_cell_new(pit_runtime *rt, pit_value v) { h->in.cell = v; return ret; } +#include <stdio.h> pit_value pit_value_cell_get(pit_runtime *rt, pit_value cell, pit_value sym) { if (pit_value_sort(cell) != PIT_VALUE_SORT_REF) { char buf[256]; i64 end = pit_dump(rt, buf, sizeof(buf) - 1, sym, false); buf[end] = 0; + fprintf(stderr, "attempted to get unbound variable/function: %s\n", buf); pit_error(rt, "attempted to get unbound variable/function: %s", buf); return PIT_NIL; } |
