aboutsummaryrefslogtreecommitdiff
path: root/docs/history/25-genmap/notes.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/history/25-genmap/notes.md')
-rw-r--r--docs/history/25-genmap/notes.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/history/25-genmap/notes.md b/docs/history/25-genmap/notes.md
new file mode 100644
index 0000000..65e322e
--- /dev/null
+++ b/docs/history/25-genmap/notes.md
@@ -0,0 +1,28 @@
+# 25 — one memory-size layout
+
+the sizes lived in four places that had to be kept in step by hand: the numbers in `memmap.h`, the `// @map-rt` block in `src/rt.zc`, the `// @map-cc` block in `src/compiler.zc`, and two functions in `tools/genmap.c` (`place_small`, `place_run`). there were no extra checked-in copies of the runtime. the history snapshots stay as they were. `src/run.zc` is the run-only boot stub, not a second map, and it stayed.
+
+`tools/genmap.c` is now one packer. a `Spec` says whether this is a compiler or a run-only image, and the sizes that actually differ: heap low and heap length, a type region, a pad before the frame-pointer word, the genome reservation, and the frame, return, mark and data stacks. compiler tables (hash, pool, symbols, locals, forward refs, snapshots, quotes, source stack, operator sequences, contexts, loop stack) have a tight default and a historical one. `layout` places the regions from the bottom. `--words` pins MW and gives whatever is left to the data stack. without it, MW is the packed size rounded up to a multiple of 4096, which is what the arm64 `cmp xn, #MW` encoding needs.
+
+## presets
+
+`--preset small` and `--preset run` are the two maps from stage 22. `--preset default` is the historical 1,048,576-word machine. that one is not the tight compiler stretched to 1m words. the type area still overlaps the top of the heap (`ZFP == HEAP_HI`, and `R_TY = ZFP - 16384` stays in the source), the tables stay large (string pool 40704 words, 4096 symbols, snapshot and quote buffers 8192), and the gaps between the genome and the frame stack stay where they were. packing those sizes reproduces the old addresses: heap `0x40000..0xA0000`, tables `0xA0100..0xBFF00`, `GORG 0xC0000`, frame `0xE0000..0xF0000`, data `0xFC000..0xFFFF0`.
+
+the checked-in sources are still that default, so `cat src/rt.zc src/compiler.zc | zc0` is the same compile as before. `genmap --preset default --check` reads `memmap.h` and the two const blocks and exits non-zero if a number disagrees. the small copy still rewrites, in the copy only, `ZFP - 16384` to `ZFP - 8192`, the snapshot cap 8000 to 1000, and both quote caps 2700 to 300. `lfa` is still the string `ld 655360` in `src/rt.zc`. the copy gets `ld` of that build's `ZFP`.
+
+## the same bytes another way
+
+the flag form of the two old profiles was diffed against `--preset`. same `memmap.h`, `rt.zc`, `compiler.zc` and `map.txt`:
+
+```
+genmap --mode compiler --name small --heap-lo 8192 --heap 20480 --types 8192 \
+ --genome 90000 --frame 2048 --return 512 --mark 512 --data 3072 \
+ --snap-cap 1000 --quote-cap 300 -o build/small
+genmap --mode run --words 32768 -o build/run
+```
+
+`genmap small DIR` and `genmap run DIR` still work. `test.sh` and `baremetal/run.sh` call the new flags. a bigger heap for `primes.zc` is `genmap --preset small --heap 65536`, and MW follows.
+
+what did not change: the 1m genome, the 172032-word compiler, the 32768-word run-only image. a `--mode compiler --words 1048576` without the default preset is a different machine (tight tables, type region of its own, packed from the bottom). it is not a substitute for `--preset default`.
+
+`test.sh` after this stage: 295 passed, 0 failed. the three new checks are the default `--check` and the two flag-form diffs. the fixpoint stayed 91158 words.