feat(vm): add typed array and struct guest operations
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Add seven Registry-backed collection opcodes with bounded verification, complete value groups, transactional publication and exact attempt costs. Publish ISA, memory and cycle contracts, producer handoff and the completed lesson. Validate with 925 workspace tests, optimized collection suites and all eight coverage domain gates. Make headless fixture directory names unique for parallel tests.
This commit is contained in:
@@ -131,3 +131,26 @@ The PVM is:
|
||||
## Program Registry v1 integration
|
||||
|
||||
[Program Registry and PBX v1](02c-program-registry-and-pbx-v1.md) defines typed immediate domains, opcodes 0x0090–0x0096, complete multi-slot groups and conservative type-flow verification. Unknown facts require runtime validation and do not alone reject an otherwise valid join. Opcode bytes remain u16; TypeId immediates are u32 little-endian.
|
||||
|
||||
|
||||
## Typed Collection Instructions
|
||||
|
||||
These instructions require a validated Program Registry. Opcodes are u16 little-endian; TypeId and field immediates are u32 little-endian. T is the receiver descriptor, F its declared field type, E its Array element type. Stack order below is bottom to top; groups retain Registry component order.
|
||||
|
||||
| Instruction | Code | Immediate | Bytes | Stack effect | Full attempt cycles |
|
||||
| --- | --- | --- | ---: | --- | --- |
|
||||
| STRUCT_NEW T | 0x00A0 | T | 6 | [] → ref<T> | 8 + sum(w(fields)) |
|
||||
| STRUCT_GET type=T, field=f | 0x00A1 | T, f | 10 | ref<T> → slots(F) | 3 + w(F) |
|
||||
| STRUCT_SET type=T, field=f | 0x00A2 | T, f | 10 | ref<T>, slots(F) → [] | 4 + w(F) |
|
||||
| ARRAY_NEW T | 0x00A3 | T | 6 | length:Int64 → ref<T> | 8 + N*w(E), valid N; otherwise 8 |
|
||||
| ARRAY_LEN T | 0x00A4 | T | 6 | ref<T> → length:Int64 | 3 |
|
||||
| ARRAY_GET T | 0x00A5 | T | 6 | ref<T>, index:Int64 → slots(E) | 3 + w(E) |
|
||||
| ARRAY_SET T | 0x00A6 | T | 6 | ref<T>, index:Int64, slots(E) → [] | 4 + w(E) |
|
||||
|
||||
w is the resolved execution-slot width: scalar, String, color and concrete references use one; vec2, Trait and Dynamic use two; pixel uses three. Reference width never traverses referenced instances. The Struct construction sum is cached during bounded Registry resolution, with no PBX schema change. `OpCode::cycles()` supplies only the base component for these instructions.
|
||||
|
||||
STRUCT operations require a Struct descriptor; ARRAY operations require an Array descriptor, never its element TypeId or BuiltinId. Fields are immediate owner-local indices in declaration order. Every operation may trap; none branches, terminates or constitutes a safepoint. All instructions, including unreachable ones, undergo bounded structural verification and exact Registry height analysis. Finite type/group facts converge before proven conflicts are rejected. Unknown facts retain runtime checking; locals have no permanent type.
|
||||
|
||||
After charging the attempt, incomplete temporary operands trap with STACK_UNDERFLOW. Instance operations check receiver carrier, absence, liveness/generation, category, Registry and exact TypeId first; array access then checks exact Int64 index and bounds; SET checks the complete value group last. There is no numeric, Trait or Dynamic coercion. Negative lengths or indices and indices at/above length trap with OOB (0x03); wrong carriers/types/groups trap with TYPE (0x04); absent receivers with NULL_REFERENCE (0x0E); invalid/dead/stale handles with INVALID_HANDLE (0x0F). Positive lengths above u32, checked size/cost overflow, resource quotas and recoverable allocation failures trap with RESOURCE_LIMIT (0x10), preserving resource reason/requested/limit. Static invalid TypeIds/categories/fields produce LOAD_INVALID_REFERENCE; proven stack/type conflicts produce LOAD_INVALID_CODE. Runtime TrapInfo preserves the attempted PC, opcode and available source span.
|
||||
|
||||
Publication and ownership follow [typed collection memory](03-memory-stack-heap-and-allocation.md); charging follows [time and cycles](01-time-model-and-cycles.md). See the [producer handoff](../../vm-arch/collection-producer-handoff.md) for independent byte oracles and construction examples. Production consumers must enter through the validated PBX v1 image boundary described in [Program Registry](02c-program-registry-and-pbx-v1.md).
|
||||
|
||||
Reference in New Issue
Block a user