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 | |
| parent | a107593b6b362fb68e409c9d7b79427776d137d7 (diff) | |
Diffstat (limited to 'pit')
| -rw-r--r-- | pit/Makefile | 2 | ||||
| -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 |
6 files changed, 16 insertions, 3 deletions
diff --git a/pit/Makefile b/pit/Makefile index 0a9da88..2d71a7c 100644 --- a/pit/Makefile +++ b/pit/Makefile @@ -3,7 +3,7 @@ EXE ?= pit CC ?= gcc AR ?= ar override CPPFLAGS += -MMD -MP -override CFLAGS += -fPIC --std=c99 -g -Ideps/ -Isrc/ -Iinclude/ -Wall -Wextra -Wpedantic -Wconversion -Wformat-security -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wnull-dereference -Wfloat-equal -Wundef -Wpointer-arith -Wbad-function-cast -Wlogical-op -Wmissing-braces -Wcast-align -Wstrict-overflow=5 -fwrapv # -ftrapv +override CFLAGS += -O2 -fPIC --std=c99 -g -Ideps/ -Isrc/ -Iinclude/ -Wall -Wextra -Wpedantic -Wconversion -Wformat-security -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wnull-dereference -Wfloat-equal -Wundef -Wpointer-arith -Wbad-function-cast -Wlogical-op -Wmissing-braces -Wcast-align -Wstrict-overflow=5 -fwrapv # -ftrapv override LDFLAGS += -g -static BUILD = build_$(CC) 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; } |
