comptime VM: dedicated Type builtin TypeId (8B), distinct from .any — foundation (dead)

Add TypeId.type_value (slot 19) + matching TypeInfo.type_value variant: an
8-byte type handle, distinct from the 16-byte boxed .any. All types.zig layout
handlers wired (size/align 8, display "Type", hash/eql); toLLVMTypeInfo -> i64.

Reserve builtin headroom: first_user 19 -> 100 (slots 20-99 padded with the
unresolved tripwire) so future builtins don't renumber user TypeIds / churn
sx ir snapshots. 22 IR snapshots regenerated (pure renumber to 100-base).

type_resolver still returns .any for "Type" — nothing produces .type_value
yet, so no behavior change. 697/0 both gates.
This commit is contained in:
agra
2026-06-18 13:03:21 +03:00
parent 7d59b5eeb6
commit 6844fb90e7
25 changed files with 39319 additions and 37485 deletions

View File

@@ -335,6 +335,23 @@ 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 2 (VM plan) — dedicated `Type` builtin TypeId: FOUNDATION landed (dead/additive) (2026-06-18).**
Added `TypeId.type_value` (slot 19) + a matching `TypeInfo.type_value` variant + the builtins
init entry — an **8-byte type handle distinct from the 16-byte boxed `.any`** (THE WALL). All
`types.zig` layout handlers wired: `sizeOf`/`typeSizeBytes` → 8, `typeAlignBytes` → 8,
`typeName` → "Type", `hashTypeInfo`/`typeInfoEql` no-payload arms. Only ONE exhaustive switch
needed a new arm (`backend/llvm/types.zig` `toLLVMTypeInfo` → `cached_i64`); every other
`switch(TypeInfo)` site has an `else` (audited when the resolver flips). **`first_user` 19 → 100**
(per the user): slots 2099 are RESERVED builtin headroom (infos padded with the `unresolved`
tripwire), so future builtins don't renumber user TypeIds / churn `sx ir` snapshots. Cost:
~80 default entries in each binary's per-type reflection arrays (user opted in). **Still dead:**
`type_resolver.zig:64` STILL returns `.any` for "Type" — nothing produces `.type_value` yet, so
NO behavior change. Regenerated 22 IR snapshots (pure TypeId renumber to 100-base; `git diff
--name-only` confirmed ONLY `.ir` files + the 2 source files changed — no stdout/stderr/exit).
**697/0 both gates** (OFF and `-Dcomptime-flat`). **Next:** flip `type_resolver:64` →
`.type_value`, then migrate the `.any` refs that mean "a Type value" (const_type result /
reflection returns / metatype `Type` params / `.type_tag` checks) — leave the real boxed-Any
refs — file-by-file with a build after each.
- **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