feat(vm)!: implement typed callables and single-context execution
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Add structural Fn signatures, typed capture environments, indirect calls and Trait dispatch while preserving logical parameter and result groups, ownership and budgets. Remove guest coroutine execution and legacy loading. Activate bounded sealed PBX v1 with mandatory capture metadata, preserve frame continuations and root return results, and migrate producers and shipped cartridges. Publish coordinated specs, handoffs and the completed runtime lesson. Validation: 880 workspace tests passed, 9 existing tests ignored; both cartridges completed six production-host frames.
This commit is contained in:
@@ -3,30 +3,22 @@
|
||||
This document describes the Registry v1 producer and consumer interfaces. The normative contract
|
||||
is [Program Registry and PBX v1](../specs/runtime/02c-program-registry-and-pbx-v1.md).
|
||||
The rationale and published mechanisms are explained in [Registry Boundaries and Owned Values](../../discussion/lessons/DSC-0058-program-registry-type-and-function-metadata/LSN-0059-registry-boundaries-and-owned-values.md).
|
||||
The completed callable and production integration is explained in [Typed Callables and Frame-Owned Continuations](../../discussion/lessons/DSC-0052-vm-closures-captures-and-dynamic-calls/LSN-0061-typed-callables-and-frame-owned-continuations.md).
|
||||
|
||||
## Publication state
|
||||
|
||||
The bounded writer/owned decoder, sealed `ValidatedProgramImage::load`, shared
|
||||
session factory, typed direct-call/return boundaries, Dynamic/reference execution,
|
||||
fixed input catalogue, typed collection operations and string accounting have executable tests. The production
|
||||
`initialize` transition, removal of old unchecked entry points, all producer
|
||||
migration and both regenerated runtime examples remain pending. Existing closure
|
||||
receivers need a typed callable contract; none of the four accepted Registry
|
||||
categories may be used as a provisional closure type.
|
||||
The production `initialize` path uses bounded `ValidatedProgramImage::load` and
|
||||
`VirtualMachine::from_image`. The v0 decoder, slot-only verifier, scheduler and
|
||||
unchecked executable constructors have been removed. Internal test producers,
|
||||
Dummy Boy and Stress emit sealed v1 with typed Fn metadata and mandatory captures.
|
||||
The runtime retains existing constant/string ownership, collections, Dynamic and
|
||||
reference boundaries. The separate render frame scheduler remains active.
|
||||
|
||||
### Pending production integration
|
||||
|
||||
| Component | Pending implementation and validation |
|
||||
| --- | --- |
|
||||
| Loader and image | Switch production initialize to the sealed strict v1 factory; retire old decoder and unchecked entry points while preserving typed callable behavior. |
|
||||
| Constant ownership | Complete image/constant provenance on migrated production entry points using the delivered ledgers and native retention domains. |
|
||||
| Verification | Route production loads through bounded Registry verification; remove the old verifier while adding typed callable checks. |
|
||||
| Diagnostics | Audit structured load/runtime/native diagnostics through the final active loader and hosts. |
|
||||
| Producers and examples | Migrate producers/fixtures, regenerate dummy-boy and stress-console PBX files, and execute both through the active runtime. These generators are ordinary programs sharing the production consumer being migrated. |
|
||||
| Conformance | Add migrated producer/example/callable evidence to this handoff and the existing conformance matrix. |
|
||||
| Publication | Audit final coordinated publication, legacy removal, traceability and migrated workspace/examples. |
|
||||
|
||||
This integration reuses the delivered Registry foundation and [typed collection producer interface](collection-producer-handoff.md). New strings/bytes/save APIs, coordinated stress and representative-game headroom each require their own technical contract or validation workload.
|
||||
Fn values, frame-owned capture environments, typed indirect calls and receiver-first
|
||||
trait dispatch use [the function-value contract](../specs/runtime/02b-vm-function-values-and-closures.md).
|
||||
FRAME_SYNC resumes next PC; successful root RET permits recurring entry preparation.
|
||||
New strings/bytes/save APIs, long-run stress and representative-game headroom require
|
||||
separate technical contracts and workloads.
|
||||
|
||||
The external Studio handoff targets are the build-pipeline
|
||||
`backend/bytecode/BytecodeModule.java` and `backend/irvm/IRVMIntrinsicRegistry.java`,
|
||||
@@ -40,7 +32,7 @@ repository publishes requirements and oracles; those modules have not been edite
|
||||
Emit PBX version 1 only. The header is 32 bytes: magic at 0, u16 version at 4,
|
||||
little-endian flag 0 at 6, reserved zero at 7, section count at 8 and twenty zero
|
||||
bytes at 12. Directory entries are file-relative u32 kind/offset/length triples.
|
||||
Mandatory kinds are 0, 1, 2, 4, 5, 6 and 7; debug kind 3 is optional. Keep empty
|
||||
Mandatory kinds are 0, 1, 2, 4, 5, 6, 7 and 8; debug kind 3 is optional. Keep empty
|
||||
mandatory tables with count zero. Never skip unknown sections or retain a legacy
|
||||
fallback. Use the canonical chapter's field order and UTF-8 rules, not Rust layouts.
|
||||
|
||||
@@ -66,18 +58,19 @@ unknown declarations, invalid indices and unused declarations are rejected.
|
||||
## Independent binary oracles
|
||||
|
||||
The manually specified minimal executable in
|
||||
`crates/console/prometeu-bytecode/tests/registry_v1.rs::minimal_bytes` is 173 bytes.
|
||||
Its directory begins at 32; seven entries end at 116:
|
||||
`crates/console/prometeu-bytecode/tests/registry_v1.rs::minimal_bytes` is 193 bytes.
|
||||
Its directory begins at 32; eight entries end at 128:
|
||||
|
||||
| Kind | Offset | Length | Payload |
|
||||
| --- | ---: | ---: | --- |
|
||||
| constants | 116 | 4 | count 0 |
|
||||
| functions | 120 | 29 | one unnamed zero-parameter/result function, offset 0, length 2, locals/max 0 |
|
||||
| code | 149 | 2 | `01 00` (HALT) |
|
||||
| exports | 151 | 4 | count 0 |
|
||||
| syscalls | 155 | 4 | count 0 |
|
||||
| types | 159 | 10 | one unnamed Bool import, BuiltinId `0x0013` |
|
||||
| implementations | 169 | 4 | count 0 |
|
||||
| constants | 128 | 4 | count 0 |
|
||||
| functions | 132 | 29 | one unnamed zero-parameter/result function, offset 0, length 2, locals/max 0 |
|
||||
| code | 161 | 2 | `01 00` (HALT) |
|
||||
| exports | 163 | 4 | count 0 |
|
||||
| syscalls | 167 | 4 | count 0 |
|
||||
| types | 171 | 10 | one unnamed Bool import, BuiltinId `0x0013` |
|
||||
| implementations | 181 | 4 | count 0 |
|
||||
| captures | 185 | 8 | function count 1; empty environment |
|
||||
|
||||
The independent multi-slot fixture in the same suite declares `fn(vec2)->vec2`
|
||||
with TypeId 0, no serialized widths, no extra locals and max 2. Its fourteen code
|
||||
@@ -128,11 +121,11 @@ human wording or manufacture runtime PCs for rejected loads.
|
||||
| Consumer | Accepted handoff | Status / remaining ownership |
|
||||
| --- | --- | --- |
|
||||
| Studio/PBS | PBX schema, signatures/names, effect-order and binary oracles, nine imports, all input IDs and diagnostics | External implementation and source-language tests pending; no external edits claimed |
|
||||
| Collections | Typed aligned layouts/defaults, exact storage groups, reference/native maps and checked adapters | Internal containers are tested; guest collection operations/costs/GC integration require a complete operation contract |
|
||||
| Callables | Function/implementation tables and direct-call contracts; exact trait views | Callable/capture/dispatch/coroutine semantics and coordinated producer migration remain pending |
|
||||
| Collections | Typed aligned layouts/defaults, exact storage groups, reference/native maps and checked adapters | Typed collection operations, costs, complete-group storage and GC execute through the active sealed loader |
|
||||
| Callables | Function/implementation tables and direct-call contracts; exact trait views | Fn, typed captures, CALL_CLOSURE/GET_CAPTURE/CALL_TRAIT and single-context production migration are implemented |
|
||||
| Strings/bytes/save | Arc strings, image/session Weak ledgers, bounded native writers and explicit import/export provenance | Existing string paths are integrated; new operations and their operation-specific evidence remain pending |
|
||||
| Resource stability | Product ceilings, generational handles, fallible capacity reservations and structured faults | Focused ownership/quota rollback is core evidence; coordinated long-run/cross-host stress requires separate workloads |
|
||||
| Reference game | Runtime contract, example migration requirement and technical measurements | Game workload/headroom/readiness requires representative-game evidence, not unit test counts |
|
||||
| Reference game | Runtime contract, migrated example images and focused technical measurements | Game workload/headroom/readiness requires representative-game evidence, not unit test counts |
|
||||
|
||||
Image constant allocations are shared between sessions without a session-content
|
||||
charge. New/imported runtime allocations belong to their session; equal text does
|
||||
@@ -141,3 +134,26 @@ Arc. `ValueSnapshot` keeps domain owners alive while tooling retains values and
|
||||
serializes only the ordinary value list. Cross-session import copies external
|
||||
content into the destination domain. Stored String slots remain `Option<Arc<str>>`;
|
||||
native ownership is not a guest GC reference or an input hardware carrier.
|
||||
|
||||
## Callable producer obligations
|
||||
|
||||
Emit Fn tag 4 with ordered logical parameter AND result TypeIds; parameter names do
|
||||
not change identity. Emit one descriptor per signature. Array/Fn structural cycles
|
||||
must terminate at nominal Struct/Trait anchors. Function bodies carry no hidden arg0.
|
||||
Captures section 8 contains a u32 function count and, for every FunctionId in order,
|
||||
a u32 capture count followed by ordered TypeIds; emit explicit empty lists too.
|
||||
Mutable bindings lower to shared private typed Struct cells; immutable captures
|
||||
copy their complete values. CALL/host preparation cannot enter capturing bodies.
|
||||
|
||||
MAKE_CLOSURE 0x52 carries FunctionId/FnTypeId (10 bytes), CALL_CLOSURE 0x53 carries
|
||||
expected FnTypeId (6), GET_CAPTURE 0x57 carries environment-group index (6), and
|
||||
CALL_TRAIT 0x58 carries TraitTypeId/method index (10). Costs are 8+C, 6, 2+W and 6.
|
||||
Trait views follow explicit arguments; the target receives its concrete receiver
|
||||
first. Typed Fn can be stored in Struct/Array/Dynamic but cannot implement Trait.
|
||||
SPAWN/YIELD/SLEEP 0x54–0x56 reject anywhere in code. Old captures=/argc= assembler
|
||||
forms reject. Neither callbacks nor captures introduce a scheduling phase.
|
||||
|
||||
External compiler acceptance requires these exact bytes and signatures, Fn
|
||||
pass/return/storage, shared cells, named-argument evaluation order, nested sync
|
||||
continuation and structured failure tests. The runtime's binary/behavioral oracles
|
||||
are available; no external implementation is claimed.
|
||||
|
||||
Reference in New Issue
Block a user