comptime VM: lowering-time default context (P3.4 step 1)
materializeDefaultContext now falls back to a zeroed Context (found by name) when the __sx_default_context global is absent — i.e. at lowering time, where the global isn't emitted yet. A type-fn that never touches the allocator runs past context setup; one that allocates reads a null alloc_fn (zeroed) and call_indirect on the null func-ref bails to legacy (a real lowering-time context with the CAllocator thunk func-refs is a follow-up). Measurement (SX_COMPTIME_FLAT_TRACE): the bail moved deeper — make_enum now bails at const_type (the Type-literal op, unported); register_type type-fns bail at the welded write call. No table mutation before either bail (write fns bail before minting), so parity holds: both gates 697/0, no crashes. Next: model the const_type op + the Type-return bridge + the VM-native write side, which together let a type-fn run end-to-end on the VM.
This commit is contained in:
@@ -325,6 +325,21 @@ when reached (sentinels or accessor fns; see the design doc Risks).
|
||||
`List` growth; orthogonal, see `current/CHECKPOINT-METATYPE.md`.)
|
||||
|
||||
## Log
|
||||
- **Phase 3 P3.4 step 1 (VM plan) — lowering-time default context; first blocker cleared (2026-06-18).**
|
||||
`materializeDefaultContext` now falls back to a ZEROED `Context` (found by name) when the
|
||||
`__sx_default_context` global is absent — i.e. at LOWERING time, where the global isn't
|
||||
emitted yet. A type-fn that never touches the allocator now runs past context setup; one
|
||||
that allocates reads a null `alloc_fn` (zeroed) → `call_indirect` on the null func-ref
|
||||
bails → legacy fallback (a REAL lowering-time context with the CAllocator thunk func-refs,
|
||||
so allocating type-fns also run on the VM, is a follow-up). **Measurement: the bail moved
|
||||
deeper** — metatype `make_enum` now bails at `const_type` (the `Type`-literal op, unported);
|
||||
`register_type` type-fns bail at the welded write call (declare_type/register_type aren't in
|
||||
`callCompilerFn`). No table mutation happens before either bail (the write fns bail before
|
||||
minting), so parity holds: both gates **697/0**, no crashes. **Next blockers (the "model
|
||||
Type" chunk):** (a) the `const_type` op → a word = `TypeId.index()`; (b) the Type-return
|
||||
bridge (`regToValue` for a `Type`/`.any` word → `.type_tag`); (c) the VM-native write side
|
||||
(declare_type/register_type/pointer_to in `callCompilerFn`) + a real lowering-time context.
|
||||
Only once those land does a type-fn actually run end-to-end on the VM (a HANDLED case).
|
||||
- **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,
|
||||
|
||||
Reference in New Issue
Block a user