ERR/E3.0 (slice 3b): comptime trace resolution

#run failures now print the same `func at file:line:col` trace as
runtime, resolved in-process via the interpreter's IR/source tables.

- Read-side context-split op `.trace_resolve` (mirror of .trace_frame),
  lowered from a name-recognized `__trace_resolve_frame(u64) -> Frame`.
- emit_llvm: inttoptr the operand to *Frame + load (the value
  .trace_frame stamped in).
- interp: unpack (func_id << 32 | span.start); resolve func/file from
  module.functions and line/col via SourceLoc.compute over a new
  source_map (setSourceMap wired at every production interp site).
- trace.sx: frame_at -> u64; to_string routes each frame through
  __trace_resolve_frame, so one source works in both machines.

Compiled path behavior unchanged (243/244/247 identical; it now loads
via the op). New examples/253-comptime-trace.sx exercises the comptime
path. Gates: zig build, zig build test, run_examples.sh -> 291 passed.
This commit is contained in:
agra
2026-06-01 15:33:50 +03:00
parent 11f6377d9c
commit b5241243e6
11 changed files with 120 additions and 5 deletions

View File

@@ -284,7 +284,7 @@ traces and DWARF can never disagree:
compiler so the JIT resolves `sx_trace_*` via `dlsym`; auto-injected as a
`#source` for AOT when `needs_trace_runtime` is set.
**Formatter (run time) compiled ✅ (3a), comptime ⏳ (3b)** — `trace.sx` `to_string()` loops
**Formatter (run time) ✅ (compiled 3a, comptime 3b)** — `trace.sx` `to_string()` loops
`sx_trace_len()` / `sx_trace_frame_at(i)` and resolves each `u64` through
a **read-side context-split primitive** (the mirror of the push op):
@@ -434,7 +434,7 @@ a Mach-O debug map, never register JIT DWARF.
| IR instructions carry source spans | ✅ done — E3.0 slice 1 (`b44a5d0`) |
| DWARF emission (compile unit / subprogram / line table) | ✅ done — E3.0 slice 2 (`c32d694`) |
| Niladic trace-push op + interned `Frame` table (runtime) | ✅ done — E3.3 slice 3a (`1b6cbc1`) |
| Comptime resolver (`func_id, ir_offset` → location) | ⏳ planned — slice 3b |
| Comptime resolver (`func_id, ir_offset` → location) | ✅ done — slice 3b |
| Source snippet + `^` caret | ⏳ planned — slice 3c |
| `--emit-obj` / `--debug` artifact plumbing | ⏳ planned — slice 3d |
| Stepping verification ladder (macOS → sim → device) | ⏳ planned — slice 3e (capstone) |