diff options
Diffstat (limited to 'TODO.md')
| -rw-r--r-- | TODO.md | 240 |
1 files changed, 210 insertions, 30 deletions
@@ -3,7 +3,7 @@ - [x] add mandatory documentation for every built-in type. - [x] use `/* ... */` comments as documentation, including comments for individual variables and arguments on the same line. - [x] run focused tests between changes and avoid repeating the full suite. -- [x] check every core source file through the lsp document protocol with its expected source dependencies; reproduce and fix editor diagnostics, including those in `src/compiler/compiler.zc`. +- [x] check every core source file through the lsp document protocol with its expected source dependencies; reproduce and fix editor diagnostics, including those in the compiler (`src/compiler/parts`, checked as one document). - [x] rename current i/o and string helpers consistently, including `puts` → `put_s`, `putn` → `put_n`, and `scat` → `cat_s`; update compiler references, examples, tests, and documentation. - [x] review passing a temporary owned return to an output function; preserve the restriction if it is needed for lifetime safety, otherwise fix it with regression coverage. - [x] draft `docs/BORROW.md` with a concrete plan for a less intrusive borrow checker and lifetime analyzer. @@ -141,37 +141,217 @@ - [x] bring documentation, examples, learn entries, history notes and test fixtures in line with the include and namespace format and the other language changes made alongside it: qualify runtime built-ins as `rt.put_s`, `rt.put_n`, `rt.put_c`, `rt.eof` and `rt.get_c`, require the explicit `include` each module needs, and remove the remaining bare builtin names so every shipped sample, every documented snippet and every expected-output fixture compiles and runs against the current compiler. the learn guide and `README.md` snippets are checked by the suite, so they are the gate, but the prose and the non-exercised samples are not. - [x] add accept, reject and regression coverage for the actor and icon libraries once each is finished: for actors, syntax activation through the include-time extension, spawn/recv/send across input and output types, multiple instances of one actor, parallel execution, implicit `this`, and confirmation that no actor code is reachable from the compiler or anything it reads by default; for icon, find/replace over real syntax, undeclaring names, changing types, adding and rewriting blocks, evaluating parts of an expression, and stepping execution while reading locals and globals, including the failure cases for each. +## handoff: where things stand + +this section is written so work can resume from the repository alone. the +branch is `ccr-0054c02e-dfdvnd`; everything listed as done below is committed +and pushed there. + +### how the work is organized +- start with `ONBOARD.md` (reading order and exact commands), then + `docs/SPEC.md` (the language reference), then this file. +- the compiler is twelve files listed in order in `src/compiler/parts`; their + concatenation is the old `compiler.zc`. the genome sources (runtime, core, + compiler parts, language server) must stay inside zc0's subset: zc0 has no + structs, enums or `?:` yet (in progress, see below); `u`, `m`, `d` are + ordinary names; parenthesize mixed `&&`/`||`; global arrays as `word[64] x;`. +- focused checks, never the whole suite until the last item: + `make` (ends with `fixpoint: N words`), `bash tests/runerr.sh build/bin/zy + tests/errors` (and `typeerrors`, `langerrors`), `python3 + tests/drivers/learn.py build/bin/zy`, `python3 tests/drivers/icon_test.py + build/bin/zy`, `python3 tests/drivers/actor_test.py build/bin/zy`, + `ZC_TEST_TIMEOUT_SCALE=4 node tests/drivers/lsp_test.js build/bin/zclsp`, + `ZC_TEST_TIMEOUT_SCALE=4 node tests/drivers/hint_fixes_test.js + build/bin/zclsp`, `make parity` (zc0 against the self-hosted compiler; by + design differences live in `tests/parity.known`). on x86-64 linux `zy` and + the language server now run on the x86-64 jit (o3 regions still interpreted); + `ZC_TEST_TIMEOUT_SCALE` stretches the deadlines on slower hosts. + `bash tests/drivers/jit_x64_test.sh build/bin/zyi build/bin/zy` compares the + jit with the interpreter (`make build/bin/zyi`) on every program. +- work was done by delegating each item to a separate agent in its own git + worktree (outside the repo, under `/workspace/tinyvm-wt/`) and merging its branch. + every brief started with "read ONBOARD.md first" plus the sections relevant + to the job, stated the invariants (fixpoint, byte-identical images where a + change should not alter output, zc0 subset), the focused checks, and asked + for a report of files changed, tests run and open questions. +- prose everywhere is lowercase with plain punctuation; `//` line comments, + `/* */` only between code; a comment above a declaration is its hover text. + +### vision and direction + +the coordinator's view of where zc stands and where it should go, recorded so +the reasoning behind the open items survives the session. + +- what zc gets right: the compiler lives in memory next to the program, so + `eval`, parse words, immediate functions and library-defined syntax (actors + with no actor code in the compiler) fall out of the architecture: forth's + strength with c's syntax. the ownership analyzer infers most of what other + languages make you annotate (it already infers that `skip(s)` returns a + borrow of `s`). unchecked code falls back to a conservative collector instead + of undefined behavior. the language server is the real compiler in check + mode, so diagnostics cannot drift from compilation. one image runs on the + interpreter, microcore, javascript, wasm, arm64 jit and llvm. +- what holds it back: trust and visibility. until `docs/SPEC.md` there was no + spec, and the two implementations disagreed (`&&`/`||`) without anyone + noticing. run-time failures carry no position and a wild read can exit 0. + "checked" is not purely static: turning the checker on inserts cleanup that + can change behavior (the reverted `unchecked` trial hung `share.zc`). + friction: the toolchain's own sources must stay in zc0's subset; word-per- + character strings cost eight times the memory of `bstr` and split every api + in two (`put_s` and `put_bs`); the compiler's state is global parallel + arrays; on x86 the language server was interpreted (about 18 s to check the + compiler) until the x86-64 jit landed. +- priorities, in order: things that turn wrong behavior into a located, + reproducible failure come first, because everything else (fuzzing, a proving + scaffold, outside users) depends on them: runtime line tables, bounds + checking, and the spec with its parity runner and conformance suite. then the + language features that make zc pleasant (`defer`, destructors, variadics and + `std.print`, test blocks, borrow returns for declarations). then speed (the + x86-64 jit). +- bootstrap philosophy: zc0 is an independent implementation in c that never + retires (like go 1.4, unlike rust's downloaded stage 0 or ocaml's and zig's + committed binaries), so the system builds from source with only a c compiler + and no committed blob. its value is being small, so it grows only where a + feature is cheap and produces no code of its own (tags, recasts, byte + strings, maybe enums and `?:`), never structs. the parity runner is a small + form of wheeler's diverse double-compiling: the two front ends check each + other. +- managing the compiler's global state: (1) a cross-reference report of + writers and readers per global, checked in ci; (2) group each family of + parallel arrays in one place with its invariants written once, and route + snapshot and restore through one pair of functions; (3) the split into phase + files (done). do not try to make the state non-global: the single-pass design + is fast because of it; the goal is visible ownership of state, not removal. +- debugging, beyond line tables and bounds checks: every effect a program has + goes through one syscall gate, so record and replay is cheap here (log each + gate result, replay a run exactly, then add tracing or watchpoints at will). + once line tables exist, a debug adapter for vscode (breakpoints, stepping, + locals) on top of the interpreter is the next step. +- a proving scaffold (the owner asked for an opinion): yes, but check before + prove. a written semantics comes first (the spec, then a small executable + reference evaluator). grow it out of the analyzer that already exists rather + than beside it. order: stack-effect checking for every function and `asm` + block (the commonest invisible bug on a stack machine); declared side + effects at module boundaries (globals touched, syscalls or not) checked + against the effect masks the compiler already computes; `requires`/`ensures` + contracts compiled to run-time checks under a switch, with the easy ones + discharged statically from the value facts. keep the trusted base small and + outside the self-compiling loop (a prover inside the genome can approve its + own mistakes, as the fixpoint approved the precedence bug); prefer + translation validation of each compile over proving the compiler whole. +- native code: the hand-written jit exists for arm64 and (phase 1, no o3 + regions or inlined enhancements yet) x86-64 linux; the llvm backend + (`-DZYLLVM`) is the portable native tier but the default build leaves it + out. cheap win: build the llvm core by default whenever `llvm-config` is + found. the x86-64 port of the hand-written jit is worth it for compile + latency (microseconds per block against milliseconds for llvm), which + matters for short programs and the language server. + +### feature decisions (owner's requirements, settled) +- bounds checking is on by default; `unbounded` (used like `unchecked`: + function prefix, block, top-level statement) turns it off; `o3` implies + `unbounded`. +- `defer` runs at the end of the current block on every exit path, like the c + defer proposal, plus ownership awareness; destructors (`fn drop()`) exist as + well. +- borrow returns: inferred from the body wherever possible; any spelling for + declarations must stay unobtrusive (proposed: `borrows s` after the + parameter list). +- `string` is a built-in alias of `char*` (done); c typedefs (done). +- variadics: count and per-argument types available, several packs per + function when element types differ (`void f(...int a, ...char b)`), a mixed + `...any` pack, and `...*any` for comma-free calls; `std.print` is a global, + javascript-like print built on it. +- struct-level untyped constants (done), typo suggestions for members (done). +- every new agent brief starts with "read ONBOARD.md first". + +### done in this session (all merged) +- build from source with c23 `#embed`, everything generated under `build/`, + `ONBOARD.md`, the embed declaration (`embed "f" as [type] name;`). +- language: untyped `const` (local, top level, inside structs), c precedence + for `&&`/`||` (the self-hosted compiler had them swapped), `typedef` and the + built-in `string` alias, struct constants (`std.Text.MAX`). +- editor: quick fixes for hints (rename to `_`, make const, `<<`, stack + buffer), missing-import fixes for every module (rt, core, run, loaded files, + and std, icon and libraries listed in `src/lib/modules.txt`, scanned from + source, including static groups like `std.Text.itoa`), typo fixes for + functions, module exports, fields and static members. +- zc0: packed byte strings, `u`/`m`/`d` as names, local `embed`, and the asm + enhancement bug parity found. +- tooling: `make parity` (`src/tools/parity.sh`), the compiler split into + phase files, `docs/SPEC.md`, standard-library api docs and + `examples/std_tour.zc`, temporary notes removed, `PROPOSALS.md`. + +### in flight when this was written (not on the branch; re-brief if missing) +these were running as agents in worktrees. if their branches were not merged +before the session ended, the work is lost and each item below must be started +again from its description in the open list. a zip of the repository with every +worktree is uploaded to the owner after each update. +- spec verification: the first agent was stopped by a session interruption + and its partial `tests/conformance/` was not merged; start it again from + "verify both compilers". +- runtime line tables and backtraces, see "runtime source positions". +- bounds checking with `unbounded`, see "bounds checking". +- the cross-reference report, see "a cross-reference report". +- four small fixes: std member hovers, `capture.end`, bare sibling static calls, `void main` in run-only images. +- the `defer` statement, see "`defer` statement". + +### decisions +- no structs in zc0 (owner's call): zc0 stays the small trusted root of the + bootstrap. so the compiler keeps its parallel arrays; the records refactor + becomes grouping and documenting them (see that item). enums and `?:` in zc0 + stay optional and low priority. +- agents: sonnet 5.5 for the jobs; do not cancel running agents. + ## open, easiest first -every item still to do, including the ones added after the list above. sorted -by how hard each is to implement, so the large language features come last. -the final full suite stays at the very end whatever its size. +sorted by how hard each is to implement; the final full suite stays last. +items with an architecture note carry the design worked out so far, enough to +brief someone without re-reading the code. -- [x] remove temporary markdown files: decide on `TASKLIST.md` (a record of an earlier session's requests), `docs/BOOTSTRAP-OWNERSHIP.md` (its problem is resolved) and `docs/design/handoff.md`, keeping anything still referenced from `README.md` or `ONBOARD.md`. -- [x] verify every command in `ONBOARD.md` from a clean checkout and fix the ones that drifted. (`make check` is left to the final suite run below.) -- [x] add `string` as a built-in alias of `char*`, in types, hovers and completions. -- [x] untyped constants inside structs: `struct Text { const MAX = 24; }`, reached as `std.Text.MAX`, with the same rules as a local or top-level `const k = 5;`. -- [ ] typo suggestions for field and method names: `p.lenght` and `std.Text.itao` suggest the closest member, with the language server's change-to quick fix. -- [ ] hover on standard-library members (`std.Text.itoa`, `std.array_contains`, a group name) returns nothing in the language server, though completion shows the same documentation; a struct static function in the document itself does show its hover. find where `do_hover` resolves qualified library members and fix it, with a hover check. -- [ ] `std.capture.end` writes its terminator at `rt.outbuf[rt.outn]`; when more than 256 characters were captured, `outn` equals the capacity and the 0 lands one word past the buffer. check and fix, with a regression program. -- [ ] a bare call to a sibling static function inside a struct's method (`lim()` for a static `lim`) reports `lim is used but never defined`; resolve it like the bare struct constants now are. -- [ ] packed byte strings and `u`/`m`/`d` in zc0: match the self-hosted compiler's `bstr` support, and treat `u`, `m`, `d` as ordinary names (a recast is the letter directly followed by `*`; tags are accepted and ignored), keeping zc0's genome image byte-identical. -- [ ] write `docs/SPEC.md`, the language specification, from the self-hosted compiler as the reference, with the zc0 subset marked and every disagreement between prose and code listed. -- [ ] 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. -- [ ] 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. -- [ ] `defer` statement: `defer expr;` or `defer { ... }` runs when the enclosing block ends, on every exit path (fall-through, `return`, `break`, `continue`), in reverse order of declaration, with the values its expressions name at the time the block ends. follows the c defer proposal (n3199 style) with ownership awareness: a deferred call that consumes an owner counts as its transfer, so the analyzer neither frees it twice nor reports it leaked. -- [ ] 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. -- [ ] 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. -- [ ] variadic arguments and `std.print`. variadics know their count, keep each argument's type, allow several packs per function when their element types differ (`void test(...int a, ...char b)`), and allow a mixed pack of any types (`...any args`). `...*any args` makes the call comma-free: `std.print("x = " name ", and they are " age " years old.\n");`. `std.print` is a global, javascript-like print that takes any number of arguments and formats each by its type (numbers, floats, strings, byte strings, pointers). -- [ ] continue fuzzing the compiler, analyzer, runtime, standard library, lsp, build tools and generated artifacts, including analyzer properties, memory-limit edges, compiler image mutation and long-running lsp memory use; fix discovered bugs and performance regressions. current coverage includes malformed parser inputs, source immutability across runtime compilation, allocation/gc leak deltas, configured-memory growth, and available native, microcore, javascript and webassembly execution hosts. +- [ ] (in flight) hover on standard-library members (`std.Text.itoa`, `std.array_contains`, a group name) returns nothing in the language server, though completion shows the same documentation; a struct static function in the document itself does show its hover. find where `do_hover` resolves qualified library members and fix it, with a hover check. +- [ ] (in flight) `std.capture.end` writes its terminator at `rt.outbuf[rt.outn]`; when more than 256 characters were captured, `outn` equals the capacity and the 0 lands one word past the buffer. check and fix, with a regression program. +- [ ] (in flight) a bare call to a sibling static function inside a struct's method (`lim()` for a static `lim`) reports `lim is used but never defined`; resolve it like the bare struct constants now are (`mstruct` in the declarations part). +- [ ] (in flight) a run-only image accepts `void main()` from zc0 but the self-hosted compiler rejects it against `run.zc`'s `int main();` prototype; make the two agree. +- [ ] remaining zc0 gaps: string literals over 4095 bytes, `embed` of an array type inside a function, `x as T` with more than a single name (`x as int*`), zc0 silently accepting `.u` on a parameter, and integer literals (`010` is 8 in zc0, 10 in the compiler; zc0 saturates on overflow). `docs/history/43-stdlib/notes.md` still says zc0 reserves u/m/d: add a pointer forward rather than rewriting history. +- [ ] (in flight) verify both compilers against `docs/SPEC.md` with a fresh agent that did not write it: expectations derived from the spec text before running anything, one program per rule under `tests/conformance/<section>/`, a runner `tests/conformance/run.sh`, each failure classified as self-hosted bug, zc0 bug, or spec error, and appendix b confirmed item by item. then add the runner to `tests/test.sh`. +- [ ] fix the implementation bugs listed in `docs/SPEC.md` appendix b, once confirmed: `memdebug scrub;` rejected; enum members can't reference earlier members; a plain function redefinition silently shadows the first; a prototype after the definition hides it; `?:` with one int and one float branch gives garbage; `bool` not normalised; float global initializers rejected; a global initializer naming another global uses its address; `include std;` inside a function body; syntax-error recovery hiding later errors; unterminated `/*` and string literals; `x as int * y`; prototypes needing parameter names; `len(char*)` with typecheck off; duplicate `case` labels; local `const` in constant expressions; constant expressions without precedence (`1+2*3` is 9). fix the prose items the appendix lists too. +- [ ] (in flight) a cross-reference report: for every global of the compiler, the functions that write it and the ones that only read it. build it from the language server's references (`textDocument/references` on `build/bin/zclsp`, so scoping is exact) and classify each reference as a write when an assignment operator, `++` or `--` follows it. output under `build/xref/`; a committed baseline and a `--check` mode that fails when a new writer of a global appears, so it can run in ci. +- [ ] optional, low priority: plain enums and `?:` in zc0 (both are small and produce ordinary code), so parity covers more programs. no structs in zc0 (decided). +- [ ] group the compiler's parallel per-local arrays (`lname`, `ltype`, `lstate`, `lhome`, `lown`, `lslot`, `ltag`, `lpos`, `lnsz`, `lleaf`, ...) without structs: declare each family together in one place, with one comment block stating each array's meaning and invariant (for example when `lhome` is meaningful), route snapshot and restore of the family through one pair of functions, and use the cross-reference report to confirm nothing else writes them. then symbols and types the same way. fixpoint and analyzer behavior unchanged. +- [ ] continue removing `unchecked` from the runtime. a reverted trial showed: `copy_w`/`fill_w` pass the analyzer when their gate stores go through `syscall(SYS_COPY, ...)`, `dgrow` with `own(w, it)` instead of `w[-2] = it`, `dpush` with `own` before the store, `dnew` as is; but the checked versions changed behavior (7 program checks failed, `tests/programs/share.zc` hung with a checked `cons`), so checked code inserts cleanup these functions can't afford. each needs its contract taught to the analyzer. `free`, `recycle`, `recycle_leaf`, `gc` are the allocator and collector the analyzer's own cleanup calls: document them as the irreducible escapes. `src/lib/actor.zc` has about 20 more. +- [ ] revise diagnostics, comments and learning/reference prose using professional compiler documentation guidance, preserving lowercase and adding message regressions. touches messages everywhere, so do it when few other compiler changes are in flight. +- [ ] (in flight) `defer` statement: `defer expr;` or `defer { ... }` runs when the enclosing block ends, on every exit path, in reverse order, evaluating its expressions when it runs (like the c defer proposal), with ownership awareness: a deferred call that consumes an owner is that owner's transfer. architecture: grab the deferred statement's tokens at the `defer` (like `grab()` in the statements part) and keep a stack of [block depth, token list]. replay a list with `src_push(1, q, 0, 0); next(); stmt(); src_pop();`. block ends go through `block_close` (call it there before `exit_vars`, for entries at the current depth, newest first); `kw_return` evaluates its value first, then must replay every entry of the function (depth >= 1) before `exit_vars(1, 0)`; `kw_break` and `kw_continue` replay entries deeper than the loop's depth (`f[2] + 1`) before their `exit_vars`. after an early exit `live = 0`, so the analyzer state changed by the replay is discarded. closures keep their own base index. reject `return`, `break`, `continue` inside a deferred statement. defer must also work in unchecked code (`exit_vars` returns early there, so replay independently of `fchk`). +- [ ] 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. build it as a library through `run.syntax` and `run.statement_hook`, like `src/lib/actor.zc`. +- [ ] (in flight) bounds checking on by default, `unbounded` to turn it off (function prefix, block, top-level `unbounded;`, mirroring `unchecked`), implied by `o3`. architecture: indexing is compiled in the postfix `[` handling of the expressions part; growable arrays already check (`dat`, `range_jz`, the `outside` enhancement, `proven()` removing checks a loop test already did). fixed arrays `T[n]` with a variable index get the same inline check against the constant `n`. pointers get a runtime call (for example `rt.bchk(p, i)`) that checks only when `p` is the start of a live heap block (header check word `p ^ MAGIC`, `paylen`), skipping constant index 0 and sizes the analyzer knows (`lnsz`). reports go through `oob`. the runtime, core, compiler parts, server, `run.zc` and `build.zc` start with `unbounded;`, which zc0 accepts and ignores (genome bytes unchanged). keep std, icon and actor checked unless a function touches raw memory on purpose. measure interpreter time before and after. +- [ ] after the fuzzing work, add more general functionality to the standard library. +- [ ] struct destructors: a struct may declare `fn drop()`, called wherever the compiler frees an owned value of that type, before the memory is released. architecture: the compiler frees owned locals in `freevar` (analyzer part), called from `exit_vars`, reassignment and explicit `rt.free`/`rt.recycle` calls (`s_free`, `s_recycle` handling in the call code); when the local's static type is a pointer to a struct with a `Name.drop` method, emit a call to it first. objects freed by the collector or inside unchecked code do not run `drop`: document that. first users: file descriptors in `std.Host`, processes in `actor.zc`. +- [ ] (in flight) runtime source positions. architecture: at each statement start (`stmt()`) record (code address `here`, line); per function a permanent data block [entry, end, name, file, count, pairs...] linked into a runtime list (`rt.line_blocks`), or appended to run-only images by `build_image` like the symbol blob. `lines on;`/`lines off;` like `docs on;`; on for user programs, off for the genome unless the growth is small. a new syscall op returns the return-stack pointer (the return stack is in vm memory, 0x1A4100..0x1B40FF, growing up); implement it in `src/core/core.c`, `src/micro/micro.c`, `src/js/tinyvm.ts` and the wasm port. `rt.trace()` walks the return stack, printing ` at file:line in function` for words inside a known function range. the runtime's fatal reports (`oob`, bad heap pointer, double free, out of memory, frame overflow) print the trace after their unchanged first line. check mode skips all of it. +- [ ] borrow returns tied to an argument. inference already works for a callee defined before the call: `char* skip(char* s) { ...; return s + i; }` makes `let r = skip(t); rt.free(t); r[0]` an error. the gap: when the call comes before the callee's definition, nothing is reported and the program reads freed memory. extend the deferred effect requirements (`effect_require`, `effect_finish` at unit end) so a forward-called function whose return turns out to alias a parameter produces the same error. for bodyless declarations, externs and function types, add an unobtrusive spelling, for example a `borrows s` clause after the parameter list (`char* skip(char* s) borrows s;`), checked against the body when one exists. +- [ ] variadic arguments and `std.print`. design: a pack is passed as one hidden argument, a caller-built read-only growable-array handle (`fixed T[?]` view: [len, cap, items, element size] in the caller's frame, so `len(a)` and `a[i]` work unchanged and nothing is allocated). `...int a` is a typed pack; several packs per function when their element types differ (`void f(...int a, ...char b)`): each extra argument goes to the pack whose element type matches its static type, an ambiguous match is an error, packs come after the fixed parameters. `...any args` packs each value with a kind code (int, float, char, string, bstr, pointer, ...) and its type record: `any` is a small built-in record { kind, value, type }. `...*any args` makes the call comma-free: after the fixed arguments, the parser reads unary expressions until `)`, commas optional, so `std.print("x = " name ", age " age "\n");` works and binary expressions must be parenthesized. `std.print(...*any args)` prints each argument by its kind (`put_n`, the float printer, `put_s`, `put_bs`, a character for `char`, hex for pointers). +- [ ] x86-64 jit phase 2: compile o3 regions to x86-64 (port `rcompile` and the region register allocation; regions now run on the region interpreter and are 2 to 4 times slower than their plain versions on this jit) and inline enhancements (lower the optimized micro-ops to x86 registers as the arm64 path does, instead of calling `xrun`). validate with `tests/drivers/jit_x64_test.sh` and `tests/bench/bench.sh`, which now has an x86-64 jit column. add the driver to `tests/test.sh` on x86-64 linux. +- [ ] build the llvm core by default when `llvm-config` is available (the makefile falls back to the interpreter otherwise), so x86 hosts get a native tier and the language server stops being interpreted; keep `ZYNOLLVM=1` and `-DZYINTERP` as the opt-outs. +- [ ] stack-effect checking: every function and `asm` block declares or is inferred to have a fixed data-stack effect, and the compiler reports a block whose paths leave the stack unbalanced. the first step of a proving scaffold. +- [ ] declared side effects at module boundaries (globals touched, syscalls or not), checked against the effect masks the compiler already computes. +- [ ] `requires`/`ensures` contracts on functions, compiled to run-time checks under a switch, with the cases the value facts settle (constants, simple ranges) checked statically. +- [ ] record and replay: a core option that logs every syscall gate result to a file and replays a run from the log exactly, for reproducing failures and adding tracing after the fact. +- [ ] a debug adapter for vscode (breakpoints, stepping, locals) on the interpreter, built on the line tables. +- [ ] reduce the cost of word-per-character strings: measure, then decide between making `bstr` the default string, unifying the two apis behind one name, or both. +- [ ] continue fuzzing the compiler, analyzer, runtime, standard library, lsp, build tools and generated artifacts, including analyzer properties, memory-limit edges, compiler image mutation and long-running lsp memory use; feed generated programs to `make parity` for differential fuzzing between zc0 and the self-hosted compiler; fix discovered bugs. - [ ] keep improving the borrow checker: fewer annotations in ordinary code, clearer messages naming both the owner and the conflicting use, and new fixtures for each rule that changes. -- [ ] run the full suite once everything above is done, fix what it finds, and only then tick this item. +- [ ] run the full suite once everything above is done (`make test JOBS=4`; `make check` is the quick one), fix what it finds, and only then tick this item. + +## done in the sorted list +- [x] a hand-written x86-64 jit, phase 1 (`ZYJIT_X64` in `src/core/core.c`, default on x86-64 linux; `-DZYINTERP` and `make build/bin/zyi` give the interpreter). r12 memory, r13 data stack, r14 return stack, r15 table, rbx state; stack slots addressed with a virtual offset so r13 moves only at calls and exits; shares the table, coverage map, store hook and invalidation with the arm64 jit. enhancements are called through `xrun`, o3 regions run on the region interpreter (`ZYNOO3=1` runs their vm code through the jit instead). 179 of 179 programs agree with the interpreter (`tests/drivers/jit_x64_test.sh`), the self-compile is byte-identical and about 7x faster (1.5 s against 11 s), and the rejection, learn, icon, actor, lsp and hint suites pass on it. +- [x] remove temporary markdown files (`TASKLIST.md`, `docs/design/handoff.md` deleted; `BOOTSTRAP-OWNERSHIP.md` moved to `docs/history/`). +- [x] verify every command in `ONBOARD.md` from a clean checkout and fix the ones that drifted. +- [x] add `string` as a built-in alias of `char*`. +- [x] untyped constants inside structs, reached as `Text.MAX` and `std.Text.MAX`. +- [x] typo suggestions for field and member names, with the change-to quick fix. +- [x] packed byte strings and `u`/`m`/`d` in zc0, byte-identical genome. +- [x] `docs/SPEC.md`, with the zc0 subset (appendix a) and disagreements and bugs (appendix b). +- [x] `make parity`: zc0 against the self-hosted compiler on every program zc0 accepts. +- [x] c typedefs. +- [x] the compiler split into phase files listed in `src/compiler/parts`. +- [x] standard-library api documentation, `examples/std_tour.zc`. |
