aboutsummaryrefslogtreecommitdiff
path: root/docs/history/07-zygote/notes.md
blob: a4f108901b521fa73828dcb837dcdeb7a7c7a4a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
# the zygote

the code/ folder next to this file is the zygote exactly as it was packed in stage 8 and 9: the asm genome (gen.s, aslib.s), the arm64-only core, the repl and the .s examples. these are the notes as they were written in the transcript.

## message 7

> can you make it a zygote approach?
> a minimal core loads first, reads and compiles the program (either wholly or partially, for speed) and replaces it with itself. so it's like a jvm but self-contained and on the same level as itself, where the assembler can itself be modified in-memory to assemble different code. for this we need to ditch llvm

**summary:** the current design, described above. the native core only does jit and glue. it loads the genome (boot loader + assembler, both vm code) at 48000. the boot loader reads source until eof or a backtick, assembles it at 0 and jumps there. compilation is lazy per block, straight from live memory, with superblocks through `z`, fused constant targets, and dispatch chained through a table. invalidation uses the coverage byte map plus a store hook, so self-modified code gets retranslated instead of interpreted. the resident assembler sits at fixed addresses, and `repl.s` rewrites its mnemonic table so `p` means out, then assembles and runs input chunks in a loop, overwriting the same address each time. verified under qemu on linux arm64, including the self-hosted assembler running on the zygote. about 4x faster than the golfed interpreter.