diff options
Diffstat (limited to 'pit/src')
| -rw-r--r-- | pit/src/main.c | 2 | ||||
| -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 |
5 files changed, 15 insertions, 2 deletions
diff --git a/pit/src/main.c b/pit/src/main.c index 74c2f03..157ad87 100644 --- a/pit/src/main.c +++ b/pit/src/main.c @@ -8,7 +8,7 @@ #include <lcq/pit/library.h> int main(int argc, char **argv) { - i64 sz = 4 * 1024 * 1024; + i64 sz = 256 * 1024 * 1024; u8 *buf = malloc((size_t) sz); pit_runtime *rt = pit_runtime_new(buf, sz); pit_install_library_essential(rt); 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; } |
