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.
|
||||
|
||||
Reference in New Issue
Block a user