feat(vm): publish typed fields across multiple structs atomically
Add schema-driven FIELDS_PUBLISH without collection-specific runtime behavior. Validate every nullable destination and complete field group before allocation-free publication, with neutral ownership, malformed-input and quota coverage.
This commit is contained in:
@@ -219,3 +219,37 @@ before mutation. A refused preparation still charges the attempted work. Neither
|
||||
operation is a safepoint. Consumers must prepare any potentially failing return
|
||||
carrier and all call operands before publication; a series of ordinary stores is
|
||||
not a substitute for whole-operation safety.
|
||||
|
||||
|
||||
## Atomic publication of multiple Struct instances
|
||||
|
||||
FIELDS_PUBLISH (`0xAB`) has one little-endian u32 schema TypeId immediate. The
|
||||
schema MUST be a Registry Struct whose ordered field types are all Struct types.
|
||||
Names are descriptive only. The schema is declarative metadata; no request object,
|
||||
new Registry category or preparation token is allocated or exposed.
|
||||
|
||||
For each schema entry, the operand stack supplies one nullable destination
|
||||
reference followed by every destination field's complete typed value group, in
|
||||
field declaration order. The stack effect is the sum, over entries, of one plus
|
||||
the destination instance's initialization-slot count; no results are produced.
|
||||
Null skips that destination, but every supplied field group is still validated.
|
||||
Non-null destinations require exact concrete Struct identity and a live reference
|
||||
of the current session/generation. Array, Trait, Fn and builtin schema entries are
|
||||
invalid, including in unreachable instructions. The full schema and exact stack
|
||||
height/groups are checked under normal Registry admission/work limits.
|
||||
|
||||
Validate all destinations and value groups before any shared write or operand
|
||||
consumption. The original operands remain roots throughout preparation. Then write
|
||||
all fields in schema order, without allocation, fallible validation, callbacks,
|
||||
GC or scheduler interleaving, and consume the entire input. Input values are
|
||||
captured before publication; repeated destinations use ordered last-write
|
||||
semantics. Complete multi-slot/native/reference groups retain identity and normal
|
||||
ownership. A failed attempt preserves every destination and the operand stack.
|
||||
|
||||
The operation allocates no publication scratch or guest object. Operand/frame and
|
||||
source value preparation remain normally charged and may fail before publication.
|
||||
Base cost is 6 cycles. After the stack-height check, precharge one cycle per schema
|
||||
entry and one per destination field execution slot for the complete declared
|
||||
attempt, including skipped destinations. Quotas are unchanged.
|
||||
This is a generic typed storage mechanism; collection algorithms and node topology
|
||||
remain source-owned, with no collection-specific VM instruction or syscall.
|
||||
|
||||
@@ -202,3 +202,12 @@ The [Program Registry contract](../specs/runtime/02c-program-registry-and-pbx-v0
|
||||
## VM-owned random core
|
||||
|
||||
See the [random contract](../specs/runtime/02e-vm-owned-random-core.md) for Random BuiltinId 0x0016, ObjectKind tag 9, intrinsics 0x4000–0x4003, atomic state mutation, bounded 4+8*N costs and rejection-limit trap 0x00000015. Random is managed by the VM heap and existing GC, without host entropy or PBX changes.
|
||||
|
||||
|
||||
## Atomic publication of multiple Struct instances
|
||||
|
||||
FIELDS_PUBLISH (0xAB) atomically publishes complete typed fields to multiple
|
||||
source-selected Struct destinations. Its schema is an ordinary Registry Struct;
|
||||
no new category, request object, syscall or safepoint is introduced. Exact nullable
|
||||
destination rules, stack effects, validation, costs and commit semantics are in the
|
||||
[canonical instruction contract](../specs/runtime/02-vm-instruction-set.md#atomic-publication-of-multiple-struct-instances).
|
||||
|
||||
@@ -198,3 +198,12 @@ STORAGE_PUBLISH (0xAA) provide generic logical validation, complete stored-group
|
||||
transfer and prepared atomic publication. Their encoding, typed operands, exact
|
||||
faults, overlap semantics, costs and preflight/commit guarantees are defined by
|
||||
the [canonical instruction contract](../specs/runtime/02-vm-instruction-set.md#logical-guards-and-atomic-storage-publication). No new Registry category, syscall, collection algorithm or safepoint is introduced.
|
||||
|
||||
|
||||
## Atomic publication of multiple Struct instances
|
||||
|
||||
FIELDS_PUBLISH (0xAB) atomically publishes complete typed fields to multiple
|
||||
source-selected Struct destinations. Its schema is an ordinary Registry Struct;
|
||||
no new category, request object, syscall or safepoint is introduced. Exact nullable
|
||||
destination rules, stack effects, validation, costs and commit semantics are in the
|
||||
[canonical instruction contract](../specs/runtime/02-vm-instruction-set.md#atomic-publication-of-multiple-struct-instances).
|
||||
|
||||
Reference in New Issue
Block a user