From ee8cc90a8c4b3138b462dd5271f003d14e103918 Mon Sep 17 00:00:00 2001 From: zinc Date: Wed, 14 Oct 2026 09:44:24 +0000 Subject: todo: compiler file split, cross-reference report, local records, x86-64 jit --- TODO.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TODO.md b/TODO.md index 9da5a0f..db93fcb 100644 --- a/TODO.md +++ b/TODO.md @@ -160,6 +160,9 @@ the final full suite stays at the very end whatever its size. - [ ] verify both compilers against `docs/SPEC.md` with a fresh agent: one test program per rule, run on both, every deviation reported and triaged. - [ ] a `make parity` runner that compiles the zc0-compatible programs (and the genome sources) with zc0 and with the self-hosted compiler, runs both images and compares output, so the two front ends can't disagree silently again (the `&&`/`||` precedence bug). - [x] c typedefs: `typedef T name;` declares a type alias, including pointer, array and function types, usable everywhere a type is, shown in hovers. +- [ ] split `src/compiler/compiler.zc` into files by phase (lexer, types, expressions, statements, analyzer, declarations, check mode, image), listed in order in one place; the concatenation must reproduce the old file exactly so every image stays byte-identical. update every consumer: the makefile, tool scripts, the language server's embedded copy, tests, docs. +- [ ] a cross-reference report: for every global of the compiler, the functions that write it and the ones that only read it, built from the language server's references so scoping is exact, runnable as a script and in ci so a new writer of core state shows up in review. +- [ ] group the compiler's parallel per-local arrays (`lname`, `ltype`, `lstate`, `lhome`, `lown`, ...) into one record per local with accessor functions, so a branch snapshot is one block copy and each field's invariant is written once next to the record. then do the same for symbols and types. the genome must keep reaching its fixpoint, and the analyzer's behavior must not change (all rejection suites and the program checks identical). - [ ] continue removing `unchecked` from the remaining runtime boundaries by teaching the analyzer the missing ownership and drop contracts; document any irreducible low-level escapes. the compiler, standard library and lsp no longer disable checking for their functions. status, from a trial that was reverted: with `unchecked` removed, `copy_w` and `fill_w` pass the analyzer once their gate stores go through `syscall(SYS_COPY, ...)`, `dgrow` once `w[-2] = it` becomes `own(w, it)`, `dpush` once `own(x, h[2])` comes before the store, and `dnew` as is. but the checked versions changed run-time behavior: 7 of the 87 program checks in `tests/test.sh` failed (closure cells, the proved-loop bounds check) and `tests/programs/share.zc` hung with a checked `cons`. so checked code in these functions inserts cleanup the runtime can't afford, and each one needs its contract taught to the analyzer, not just a rewrite that compiles. `free`, `recycle`, `recycle_leaf` and `gc` are the allocator and collector that the analyzer's own cleanup calls, so they stay unchecked and need to be documented as the irreducible escapes. `src/lib/actor.zc` has about 20 more. - [ ] document the public standard-library apis with concise descriptions of behavior, parameters, ownership and return values where applicable; update reference and learning entries, add executable examples and record implemented changes in history; keep prose lowercase and verify docs appear in hovers. - [ ] revise diagnostics, comments and learning/reference prose using professional compiler documentation guidance, preserving lowercase and adding message regressions. @@ -167,6 +170,7 @@ the final full suite stays at the very end whatever its size. - [ ] test blocks: `test "name" { ... }` with `expect(cond)`, compiled only by `zy --test file.zc`, which runs each block and prints one line per test with the position of the first failed `expect`; skipped at parse time otherwise. built as a library through `run.syntax` and `run.statement_hook`, like actors. - [ ] bounds checking on by default for indexing heap pointers (checked against the block header's payload size) and typed arrays (`T[n]`, `T[?]`), stopping with the index, the length and the source line. a keyword `unbounded`, used like `unchecked` (function, block, or top-level for the rest of the unit), turns it off. `o3` implies `unbounded`, so o3 code never pays for bounds checks. constant indexes into fixed arrays are checked at compile time and emit nothing. - [ ] after the compiler namespace and fuzzing work, add more general functionality to the standard library. +- [ ] a hand-written x86-64 jit, ported from the arm64 one: phase 1 translates ordinary blocks (shared translation table, coverage and invalidation; x86 emitter and instruction selection), validated program by program against the interpreter, and becomes the default x86-64 linux core when it matches everywhere. phase 2 compiles o3 regions and inlines enhancements like the arm64 backend does. - [ ] struct destructors: a struct may declare `fn drop()`, which the compiler calls wherever it frees an owned value of that type (scope end, reassignment, `rt.free`), before the memory is released. use it for file descriptors in `std.Host` and processes in `actor.zc`. decide and document what happens when an owner with a `drop` passes into unchecked code. - [ ] runtime source positions: a line table per function (code offset to source position) stored in the image, behind a `lines on;` switch like `docs on;`. faults, failed bounds checks and a new `rt.trace()` print `file:line in function` for every frame on the interpreter, microcore and javascript vm; the jit and llvm backends map native addresses back to vm code. - [ ] borrow returns tied to an argument, with syntax that stays out of the way: a function can return a pointer into one of its parameters (`find`, `skip_space`, `first`), the caller's analyzer treats the result as a borrow of whatever was passed, and freeing or moving that argument while the result is live is an error. the callee is checked to return only borrows of that parameter. prefer inference from the body over annotation; when a spelling is needed, keep it to the parameter's name. -- cgit v1.2.3