comptime VM: VM-native type_info REFLECTION — whole metatype surface HANDLED (P3.4 step 8)
Ported type_info($T) into the VM (callBuiltinVm .type_info arm -> new
buildTypeInfo), the inverse of step 7's define: reflect a type INTO a TypeInfo
VALUE built in flat memory (VM-native mirror of legacy reflectTypeInfo).
- Decodes the source type into a tag + members (tagged-union/struct field &
enum variant -> {name, ty}, payloadless variant -> void; tuple -> bare
positional Types), then lays the nested value out bottom-up using layouts
derived from the TypeInfo RESULT type (ins.ty, now threaded into
callBuiltinVm): element array -> {ptr,len} slice -> info struct
(EnumInfo/StructInfo/TupleInfo) -> TypeInfo {tag, payload} tagged union
(reusing step 7's tagged-union write).
- Variant/field names materialize via makeStringValue, extracted from text_of.
- Same backing_type guard as step 7 (bail rather than mis-read the tag).
The ENTIRE metatype surface now runs HANDLED on the VM with ZERO fallback:
0614-0624 + 0632 (0616 field_type folds at lower time). The
define(declare, type_info(T)) round-trips (0619/0622/0623) mint byte-identical
copies on the VM; VM output byte-matches legacy for all. 697/0 both gates + all
unit tests. Remaining VM fallbacks in the comptime corpus are now genuinely
non-metatype emit-time side effects (print/global_addr/compiler_call/inline-asm).
This commit is contained in:
@@ -26,23 +26,22 @@ with ONE welded mechanism. Branch: `reify` (off `master`). Update after every st
|
||||
> breaks cross-compilation — host vs target layout — and loses the sandbox. A
|
||||
> flat-memory VM keeps both while getting native bytes + speed.)
|
||||
>
|
||||
> **Next action (2026-06-18) — VM-native metatype CONSTRUCTION landed (step 7, uncommitted).** The
|
||||
> metatype `declare`/`define` builtins + tagged-union `enum_init`-with-payload now run NATIVELY on
|
||||
> the VM (new `.call_builtin` exec arm → `callBuiltinVm`/`defineFromInfo`, reading the `TypeInfo`
|
||||
> value from FLAT MEMORY; faithful port of legacy `defineEnum`/`Struct`/`Tuple`). So the metatype
|
||||
> CONSTRUCTION examples run **fully HANDLED** on the VM (no `call_builtin` fallback): `0614`/`0620`/
|
||||
> `0621`/`0624`/`0632`; `0622`/`0623` define-HANDLED then fall back at the still-unported `type_info`.
|
||||
> Both `enum_init`/`define` bail loudly on a `backing_type` tagged union (wrong layout) rather than
|
||||
> silent-clobber. **697/0 BOTH gates + all unit tests** (added: tagged-union `enum_init` payload).
|
||||
> NOT yet committed. **THE NEXT STEP: port `type_info`** (reflect a type → build the `TypeInfo`
|
||||
> value in flat memory, the inverse of `define` — reuses tagged-union `enum_init`) so `0619`/`0622`/
|
||||
> `0623` go fully HANDLED; then drive the SX_COMPTIME_FLAT_TRACE fallback list toward
|
||||
> genuinely-non-comptime cases. Earlier landed: dedicated `Type` builtin TypeId (`6844fb9`/`94f60c5`/
|
||||
> `554871b`); WRITE side declare_type/register_type/pointer_to VM-native (`66005af`); real
|
||||
> lowering-time Context for allocating type-fns (`eb68d9e`). What's LEFT toward the end-state ONE
|
||||
> evaluator: (1) finish porting the comptime corpus onto the VM (type_info next); (2) THEN flip the
|
||||
> VM to default + delete `interp.zig` (with user go-ahead); (3) re-express `define`/`make_enum` as
|
||||
> sx over the compiler-API once legacy is gone (allocation works only on the sole VM evaluator).
|
||||
> **Next action (2026-06-18) — the WHOLE metatype surface is VM-native (steps 7+8, committed through
|
||||
> `d0ebc55`; step 8 uncommitted).** `declare`/`define`/`type_info` + tagged-union `enum_init` all run
|
||||
> NATIVELY on the VM (`.call_builtin` exec arm → `callBuiltinVm`; `defineFromInfo` decodes a
|
||||
> `TypeInfo` from flat memory, `buildTypeInfo` reflects one INTO flat memory — faithful ports of
|
||||
> legacy `defineEnum`/`Struct`/`Tuple`/`reflectTypeInfo`). The ENTIRE metatype range `0614`–`0624` +
|
||||
> `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:** drive the remaining VM fallbacks (now ALL genuinely-non-metatype emit-time side
|
||||
> effects — `print`/`out` 0613, `global_addr` 0600, `compiler_call` #compiler hooks 0602/0603,
|
||||
> inline-asm global 1654) to empty (port or confirm each is legitimately non-comptime), THEN — with
|
||||
> explicit user go-ahead — flip the VM to default + delete `interp.zig` (the end-state ONE evaluator),
|
||||
> and re-express `define`/`make_enum` as sx over the compiler-API (allocation works on the sole VM).
|
||||
> Earlier landed: dedicated `Type` builtin TypeId (`6844fb9`/`94f60c5`/`554871b`); WRITE side
|
||||
> declare_type/register_type/pointer_to VM-native (`66005af`); real lowering-time Context (`eb68d9e`);
|
||||
> metatype construction declare/define/enum_init (`d0ebc55`).
|
||||
>
|
||||
> Done so far in Phase 3:
|
||||
> - **READ side (7 readers, dual-path):** `find_type`/`type_kind`/`type_field_count`/
|
||||
@@ -348,6 +347,24 @@ 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 8 (VM plan) — VM-native `type_info` REFLECTION → the whole metatype surface is HANDLED (2026-06-18).**
|
||||
Ported `type_info($T)` into the VM (`callBuiltinVm` `.type_info` arm → new `buildTypeInfo`), the
|
||||
inverse of step 7's `define`: reflect a type INTO a `TypeInfo` VALUE built in FLAT MEMORY (the
|
||||
VM-native mirror of legacy `reflectTypeInfo`). Decodes the source type into a tag + members
|
||||
(tagged-union/struct field & enum variant → `{ name, ty }`, a payloadless variant → `void`;
|
||||
tuple → bare positional `Type`s), then lays out the nested value bottom-up using layouts derived
|
||||
from the `TypeInfo` RESULT type (`ins.ty`, now threaded into `callBuiltinVm`): element array →
|
||||
`{ptr,len}` slice → info struct (`EnumInfo`/`StructInfo`/`TupleInfo`) → `TypeInfo { tag, payload }`
|
||||
tagged union (reusing step 7's tagged-union write). Variant/field names materialize via a
|
||||
`makeStringValue` helper extracted from `text_of`. Same `backing_type` guard as step 7. **Result:
|
||||
the ENTIRE metatype surface runs HANDLED on the VM with ZERO fallback** — `0614`–`0624` + `0632`
|
||||
(0616 `field_type` folds at lower time, no comptime eval); the `define(declare, type_info(T))`
|
||||
round-trips (`0619`/`0622`/`0623`) mint byte-identical copies on the VM. VM output byte-matches
|
||||
legacy for all. **697/0 BOTH gates + all unit tests.** On `reify`. **Remaining VM fallbacks in the
|
||||
comptime corpus are now genuinely-non-metatype** emit-time side effects: `print`/`out` (0613),
|
||||
`global_addr` (0600), `compiler_call` #compiler hooks (0602/0603), and the inline-asm global
|
||||
(1654). **Next:** port those (or confirm each is a legitimately-non-comptime case) to drive the
|
||||
fallback list to empty, then — with user go-ahead — flip the VM to default + delete `interp.zig`.
|
||||
- **Phase 3 P3.4 step 7 (VM plan) — VM-native metatype CONSTRUCTION: `declare`/`define` + tagged-union `enum_init` (2026-06-18).**
|
||||
Ported the metatype type-CONSTRUCTION builtins into the VM so the construction examples run
|
||||
HANDLED end-to-end (no `call_builtin` fallback). Three pieces: (1) **tagged-union `enum_init`
|
||||
|
||||
Reference in New Issue
Block a user