diff --git a/current/CHECKPOINT-COMPILER-API.md b/current/CHECKPOINT-COMPILER-API.md index ee820f26..bb02c4dd 100644 --- a/current/CHECKPOINT-COMPILER-API.md +++ b/current/CHECKPOINT-COMPILER-API.md @@ -34,14 +34,34 @@ with ONE welded mechanism. Branch: `reify` (off `master`). Update after every st > `0632` runs **HANDLED with ZERO fallback** (incl. the `define(declare, type_info(T))` round-trips > `0619`/`0622`/`0623`); VM output byte-matches legacy. `enum_init`/`define`/`type_info` bail loudly > on a `backing_type` tagged union rather than silent-clobber. **697/0 BOTH gates + all unit tests.** -> **THE NEXT STEP — Phase 4 (legacy-interp retirement) is now PLANNED in `PLAN-COMPILER-VM.md`.** -> Audited the 5 roles the legacy interp still serves (A comptime folds · B `#insert` · C post-link -> bundler · D `#compiler` hooks · E bail diagnostics). **User decision (2026-06-18): UNIFY** — the VM -> gains a host-FFI escape + real-pointer translation and runs the post-link bundler too; `interp.zig` -> fully deleted (true ONE evaluator). Dependency-ordered sub-phases: **4A** finish comptime ops -> (box_any/unbox_any · out/print · global_addr · trace) → **4B** VM-native diagnostics → **4C** -> `#insert` → **4D** host FFI + `#compiler` hooks → **4E** bundler (+ dedicated bundle tests, no -> corpus guard) → **4F** flip default + delete `interp.zig`/`Value` + re-express `define`/`make_enum`. +> **THE NEXT STEP — Phase 4D.3 (`compiler_call` / #compiler hooks on the VM).** Phase 4 (legacy-interp +> retirement) is PLANNED in `PLAN-COMPILER-VM.md`; **user decision: UNIFY** (the VM runs the post-link +> bundler too, `interp.zig` fully deleted). DONE this arc (all green): **4A.1** box_any/unbox_any + +> `.any` as a 16-byte aggregate (`1526d19`); **4D.0** comptime memory → an ARENA, `Addr` = real host +> pointer, no buffer/cap/move (`625ba0f`); **4D.1** general host-FFI escape — `Vm.callHostExtern` +> dlsym + host_ffi, any extern, args/returns pass untouched since Addr IS a host pointer (`e7a8708`, +> example 0636 `toupper`); **4D.2** slice/string args → NUL-term `char*` + float-arg/return guards +> (`6a7f690`, example 0637 `strlen([:0]u8)`). **699/0 BOTH gates.** +> +> **4D.3 findings (for a fast restart):** the corpus drivers are `0602`/`0603` — their `#run +> configure()` calls BuildOptions hooks (`build_options`, `BuildOptions.set_post_link_callback`) → +> the `.compiler_call` op → currently bails on the VM. The hook ABI is `Value`-based: +> `HookFn = fn(interp: *const Interpreter, args: []const Value, bc: *BuildConfig, alloc) HookError!Value` +> (`compiler_hooks.zig:103`); the registry is `Registry` (built by `registerDefaults`), reached on the +> interp as `self.hooks` + `self.build_config` (`interp.zig:204`/`:201`, set by emit_llvm/core before +> the eval). Plan for 4D.3 (transitional Value shim — rewrite the ABI to flat memory only in 4F): +> (1) thread `*BuildConfig` (+ the hook `Registry`) into the `Vm` and through `tryEval` from the +> emit-time sites (mirror how `interp_inst.build_config` is set at `emit_llvm.zig:860`/`:106x`); +> (2) add a `.compiler_call` exec arm: resolve the hook by name, `regToValue` each flat arg → `Value`, +> call the hook, `valueToReg` the result. **Open question:** the hooks take `*const Interpreter` — +> audit whether any DEREFERENCE it for the arg kinds in play (`.string`/`.func_ref`/`.int` decode via +> `asString`/`asFuncRef`, which for a `regToValue`-built Value don't need the interp). If some hook +> needs a real interp, the pragmatic transitional route is to pass the `interp_inst` already created +> at the emit-time site into `tryEval`. Then `0602`/`0603` should run HANDLED. Dependency-ordered +> remainder: **4A leftovers** (out/print [double-output-on-fallback caveat], global_addr, trace, +> switch_br for the Any-tag type-switch in 0114/0520–0524/1035) · **4B** VM diagnostics · **4C** +> `#insert` · **4E** bundler (+ dedicated bundle tests) · **4F** flip default + delete +> `interp.zig`/`Value` + flat-memory `HookFn` + re-express `define`/`make_enum`. > Starting at **4A.1 (box_any/unbox_any)**. See `PLAN-COMPILER-VM.md` → Phase 4 for the full plan + > top risks (flat-pointer escape on buffer realloc; bundler test coverage). > Earlier landed: dedicated `Type` builtin TypeId (`6844fb9`/`94f60c5`/`554871b`); WRITE side