feat(pbs): add mutable lists and stable snapshot cursors
Implement SDK list<T> and Cursor<T> with trusted compiler bindings and generic storage publication across IR and PBX. Pin the runtime provider and include specs, conformance coverage, installed examples, and DSC-0090 lessons.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Typed common Registry and PBX v0
|
||||
|
||||
Status: normative. Owner: `compiler/general`. Runtime contract reference:
|
||||
`runtime` revision `f7d7c167531bb662a1af9d73fc326bb476bf8aa7`,
|
||||
`runtime` revision `d9b9eeb171d2861ec660d4cf5703b0795eac49a9`,
|
||||
`docs/specs/runtime/02c-program-registry-and-pbx-v0.md` and
|
||||
`docs/vm-arch/ISA_CORE.md` in that repository.
|
||||
|
||||
@@ -186,3 +186,61 @@ Synthetic common IR additionally exercises linking, lowering, optimization and
|
||||
emission without PBS. Frontend migration and integrated release readiness are
|
||||
tracked separately in AGD75; passing common conformance does not claim complete
|
||||
PBS lowering or complete Studio/runtime integration.
|
||||
|
||||
|
||||
## Generic logical guards and atomic storage publication
|
||||
|
||||
The core includes the following generic operations, with u16 opcodes and
|
||||
little-endian u32 immediates. They introduce no new Registry category, syscall,
|
||||
source-language collection or ambient transaction. Operand order below is bottom
|
||||
to top; all integer operands are Int64.
|
||||
|
||||
| Opcode | Immediate | Stack operands consumed |
|
||||
| --- | --- | --- |
|
||||
| INDEX_GUARD `0xA7` | none | index, exclusive limit |
|
||||
| ARRAY_CHECK_LENGTH `0xA8` | Array TypeId | length |
|
||||
| ARRAY_COPY `0xA9` | Array TypeId | source, sourceStart, target, targetStart, count |
|
||||
| STORAGE_PUBLISH `0xAA` | Array TypeId, Struct TypeId, first field, second field | source, sourceStart, target, targetStart, count, fillStart, fillCount, element group, owner, first field group, second field group |
|
||||
|
||||
All operations return no values. INDEX_GUARD accepts exactly
|
||||
`0 <= index < limit`, otherwise TRAP_OOB. It does not use physical storage length.
|
||||
ARRAY_CHECK_LENGTH accepts zero through u32::MAX without allocating. Negative
|
||||
lengths produce TRAP_OOB; values above u32::MAX produce the same resource
|
||||
SizeOverflow failure as ARRAY_NEW. This check does not reserve future allocation.
|
||||
|
||||
ARRAY_COPY and STORAGE_PUBLISH require exact Array receiver identities and complete
|
||||
stored groups. Every range must have nonnegative start/count and fit its physical
|
||||
array; an empty range may start at length. Invalid ranges produce TRAP_OOB, never
|
||||
clamping or truncation. Copy reads the pre-attempt source sequence, including for
|
||||
overlapping source/target ranges. Presence tags, immutable boxes, native owners and
|
||||
object identities are preserved without payload unpacking or repacking.
|
||||
|
||||
STORAGE_PUBLISH first copies the selected source range, then fills the selected
|
||||
target range with the supplied element group, then writes the two selected fields
|
||||
on the supplied Struct owner. Fields must be distinct valid indices on that Struct;
|
||||
their types and widths come from the immutable Registry. Source code/producer owns
|
||||
selection of every range, value, owner and field. The VM implements these generic
|
||||
ordered effects and does not select collection algorithms.
|
||||
|
||||
Loading validates all immediate identities/categories/fields even in unreachable
|
||||
code. Verification requires complete typed operands. ARRAY_COPY consumes five
|
||||
slots; STORAGE_PUBLISH consumes `8 + elementWidth + firstWidth + secondWidth`.
|
||||
INDEX_GUARD consumes two slots and ARRAY_CHECK_LENGTH consumes one.
|
||||
|
||||
Execution validates all receivers, lengths/ranges, supplied groups and source
|
||||
groups, and reserves the complete charged copy scratch before writing. Validation,
|
||||
quota or host allocation refusal leaves all input operands and destinations
|
||||
unchanged, including both fields and native owners. Scratch uses TemporaryBytes,
|
||||
is refunded on success/refusal and does not relax any resource ceiling. Existing
|
||||
operands remain roots during preparation. There is no GC, callback, scheduler or
|
||||
other interleaving inside this single instruction. Commit uses already validated
|
||||
complete groups, performs no fallible allocation and consumes operands only after
|
||||
all selected effects have been published. No prepared token escapes the attempt.
|
||||
|
||||
Base cycle costs are 2 for either guard, 4 for ARRAY_COPY and 6 for STORAGE_PUBLISH.
|
||||
Copy adds `2 * count * elementWidth`; publication additionally adds
|
||||
`fillCount * elementWidth + firstWidth + secondWidth`. Work arithmetic is checked
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user