session-2026-09-25.md 2.4 KB

Session save — 2026-09-25: self-hosting runtime

Started from "the whole compiler source set compiles under V3 and links" (v3-selfcompile-image) and pushed the runtime much further.

Landed

Tag What
v3-selfcompile-image nested modules (ListHandler); HALT; Strings.Delete/Append; 1-char literal to VAR ARRAY OF CHAR; nested anonymous-array bound-clobber fix; sessBuf 4 MiB + manual flush; strNams/strTexts 4096
v3-inline-array-fields record array fields are inline (standard M2 layout), not pointers: SymTab layout, QbeGen data/access/copy, InitHeap in place, SymTab ALLOCATE→NEW
v3-nul-strings NUL-terminated CHAR arrays (terminator slot at index = count, index = count readable); stdlib Strings and the C shim are NUL-based; m2arg keeps capacity
af392e1 scanner Reset: NEW(buf[i]) (BufBlock needs a descriptor header)
v3-deref-var-actual ^ yields the pointee address: sfx := TRUE, so a VAR actual p^/a[i]^ passes the pointee address (was AddrOf(base))

Main suite 111/111 throughout.

Self-compiled compiler status

It now:

  1. runs (no startup crash — the heap/inline-array fix),
  2. opens its input via the self-hosted FileIO + shim,
  3. starts parsing — and crashes in the scanner's Reset.

Fixed: VAR actual of a dereferenced pointer (v3-deref-var-actual)

For a VAR actual that is a dereferenced pointer (b[0]^), V3 passed AddrOf(b) instead of the pointee address. Design's ^ handler now always sets sfx := TRUE (q holds the pointee address), so Fact's VAR-actual note is q itself. Repro Fill(b[0]^) now works; the scanner's FileIO.ReadBytes(src, buf[i]^, read) is correct.

Current crash

The self-compiled compiler now parses the scanner/parser and reaches the source's TYPE block, then segfaults in SymTab.OpaqueBase (TypeItem ← TypeBlock ← DeclSeq ← ProgModule), dereferencing a bad symbol node (mov 0x49(%rax),…). Next runtime bug to chase.

Remaining after that

  • Re-run the self-compiled compiler on a file; iterate on further runtime bugs.
  • Cross-stage FileIO selection and bootstrap/fixpoint.sh (Stage1 gm2 → Stage2 V3 → Stage3 V3, byte-identical .ssa), with the stage-aware CR flag (-m for gm2, no -m for V3).

Note

compiler/toto.mod is the user's uncommitted edit (left alone).