comptime VM: wire the VM at the lowering-time site + measure (P3.4)

Route runComptimeTypeFunc (the type-fn fold — the third comptime call site)
through comptime_vm.tryEval behind -Dcomptime-flat/SX_COMPTIME_FLAT with legacy
fallback, mirroring the two emit-time folds. Extract the shared post-check
(checkComptimeTypeResult — the declared-but-never-defined zero-field guard) so the
VM and legacy paths share it.

Measurement (SX_COMPTIME_FLAT_TRACE): every metatype/compiler-API type-fn bails
CLEANLY at "no __sx_default_context global to materialize the implicit context" —
at lowering time the default-context global doesn't exist yet (it's built at emit
time), so the VM bails at context materialization, before running the body (no
partial mint, no crash -> legacy mints). The hardening holds: no crashes across
the corpus on the lowering-time VM path.

So the first lowering-time blocker is the implicit context, not Type modeling.
Both gates 697/0. Near-pure fallback today — permanent scaffolding that lights up
as the default-context handling + Type modeling + VM-native write side land.
This commit is contained in:
agra
2026-06-18 11:55:59 +03:00
parent 34734d415b
commit 9d041b5136
2 changed files with 55 additions and 5 deletions

View File

@@ -325,6 +325,22 @@ when reached (sentinels or accessor fns; see the design doc Risks).
`List` growth; orthogonal, see `current/CHECKPOINT-METATYPE.md`.)
## Log
- **Phase 3 P3.4 (VM plan) — wire the VM at the LOWERING-time site + measure (2026-06-18).**
Routed `runComptimeTypeFunc` (the type-fn fold — the THIRD comptime call site) through
`comptime_vm.tryEval` behind `-Dcomptime-flat`/`SX_COMPTIME_FLAT` with legacy fallback,
mirroring the two emit-time folds. Extracted the shared post-check (`checkComptimeTypeResult`
— the declared-but-never-defined zero-field guard) so both paths use it. **Measurement
(SX_COMPTIME_FLAT_TRACE):** every metatype/compiler-API type-fn currently bails CLEANLY
with `no __sx_default_context global to materialize the implicit context` — at lowering
time the default-context global doesn't exist yet (it's built at emit time), so the VM bails
at context materialization, BEFORE running the body (no partial mint, no crash → legacy
mints). The hardening holds: **no crashes** across the corpus on the VM lowering-time path.
Both gates **697/0**. **So the FIRST lowering-time blocker is the implicit context, not
`Type` modeling** — the VM needs a way to materialize/skip the default context at lowering
time (most type-fns get an implicit ctx for potential `List`-growth alloc; many don't use
it). Next: materialize a lowering-time default context for the VM (or pass a null ctx +
bail only if the allocator is actually used), THEN model `Type` values + the VM-native write
side. This is near-pure fallback today — permanent scaffolding that lights up as those land.
- **Phase 3 P3.4-prep (VM plan) — harden the VM against malformed lowering-time IR (2026-06-18).**
Prerequisite for wiring the VM at the LOWERING-time comptime site (`runComptimeTypeFunc`),
where IR can be malformed (an unresolved name lowers to a dangling / `Ref.none` operand —