diff options
| author | 2026-10-12 08:46:23 +0330 | |
|---|---|---|
| committer | 2026-10-12 08:46:23 +0330 | |
| commit | ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch) | |
| tree | 70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /src/runtime/run.zc | |
a
Diffstat (limited to 'src/runtime/run.zc')
| -rw-r--r-- | src/runtime/run.zc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/runtime/run.zc b/src/runtime/run.zc new file mode 100644 index 0000000..60193a7 --- /dev/null +++ b/src/runtime/run.zc @@ -0,0 +1,27 @@ +// run-only image: the runtime, a collector root set, and start. there is no +// resident compiler and none of its tables. put this between rt.zc and a +// program that defines main, and compile with zc0 (the program has to stay in +// the stage-0 subset: no types, no quote, no parse words). +// +// cat build/run/rt.zc src/runtime/run.zc examples/hello.zc | ./zc0 >build/run/genome.h + +// the program's entry point, written by the program (see start). +int main(); + +// the collector's roots: the code and globals, the program's frames and the +// operand stack. the collector marks from these before it frees anything. +int gc_roots() { + markrange(0, CODE_END); + markrange(GORG, GORG[6]); + gc_frames(); + markrange(dsp(), data_top); + return 0; +} + +// the first code a run-only image executes: it sets up the heap, runs main and halts. +int start() { + heap_init(); + main(); + halt(); + return 0; +} |
