comptime VM: box_any/unbox_any + .any as a 16-byte flat-memory aggregate (Phase 4A.1)
Ported the Any-boxing conversion pair:
- box_any: alloc the 16-byte { type_tag@0, value@8 } box, tag = source TypeId
index (matches the legacy comptime interp; runtime anyTag also normalizes
arbitrary-width ints). Value slot holds a word source's scalar bytes (via
writeField(source_type) so f32 round-trips) or an aggregate source's
flat-memory ADDR (the runtime pointer-in-value-slot shape).
- unbox_any: read the value slot back (word -> readField; aggregate -> the
stored ADDR).
Required promoting .any to a first-class flat-memory aggregate (was
kindOf -> .unsupported): kindOf(.any) = .aggregate (16B, by-address) and
fieldOffset special-cases .any to the {@0, @8} layout (shared with
string/slice). Without the latter a struct_get on an Any panicked
(union field 'struct' while 'any' is active) -- caught + fixed, no crash.
Updated two unit tests that used unbox_any as the "unported op" example ->
compiler_call; added a box->unbox round-trip test. 697/0 both gates + all
unit tests. The 6 box_any examples no longer bail at box_any (output matches
legacy) but fall back further at switch_br/type_name/out (later 4A steps).
This commit is contained in:
@@ -352,6 +352,21 @@ when reached (sentinels or accessor fns; see the design doc Risks).
|
||||
`List` growth; orthogonal, see `current/CHECKPOINT-METATYPE.md`.)
|
||||
|
||||
## Log
|
||||
- **Phase 4A.1 (VM plan) — `box_any`/`unbox_any` on the VM + `.any` as a 16-byte aggregate (2026-06-18).**
|
||||
Ported the Any-boxing conversion pair: `box_any` allocates the 16-byte `{ type_tag@0, value@8 }`
|
||||
box (tag = source TypeId index, matching the legacy comptime interp), writing a word source's
|
||||
scalar via `writeField(source_type)` (so f32 round-trips) or an aggregate source's flat-memory
|
||||
ADDR (the runtime pointer-in-value-slot shape); `unbox_any` reads the value slot back (word →
|
||||
`readField`, aggregate → the stored ADDR). **Required making `.any` a first-class flat-memory
|
||||
aggregate** (it was `kindOf → .unsupported`): `kindOf(.any) = .aggregate` (16B, by-address) +
|
||||
`fieldOffset` special-cases `.any` to the `{@0, @8}` layout (shared with string/slice) — without
|
||||
the latter, a `struct_get` on an Any panicked (`union field 'struct' while 'any' is active`),
|
||||
caught + fixed (no crash; "never crash" upheld). Updated two unit tests that used `unbox_any` as
|
||||
the "unported op" example → now `compiler_call`; added a box→unbox round-trip test. **697/0 BOTH
|
||||
gates + all unit tests.** On `reify`. The 6 box_any examples (0114/0520–0524/1035) no longer bail
|
||||
at box_any and produce VM output byte-matching legacy, but are not YET fully HANDLED — they now
|
||||
fall back further at `switch_br` (comptime Any-tag type-switch), `type_name`, and `out`/print
|
||||
(4A.2+/later steps). **Next (4A.2):** comptime `out`/print (VM output buffer + flush).
|
||||
- **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
|
||||
|
||||
Reference in New Issue
Block a user