interp: copy aggregate value trees without native recursion
This commit is contained in:
1 parent
b1b9b4cf03
commit
afc40f8502
6 files changed
+367
-7
No files matched your search
@@ -476,3 +476,5 @@ The [audit-report increment](air-type-depth-audit.md#audit-report-traversal) fix
|
||||
The [executed runtime audit](runtime-value-depth-audit.md) confirms that a verified one-byte value with 32,768 length-one nested arrays aborts inside zeroValue under `aji run --fuel 8`, rather than producing a run record. The instruction has not exhausted fuel. Iterative runtime traversal must preserve initialization, value shape, allocator/root lifetimes, collection safety and instruction accounting; adding a depth trap/acceptance limit needs a normative decision. At that baseline, recursive copying, value sizing, collection and serialization were additional audit candidates with unverified failure paths; the increment below records subsequent executed failures. Compiler type repairs in Q-059 do not resolve Q-060.
|
||||
|
||||
The [zero-materialization increment](runtime-value-depth-audit.md#zero-materialization-repair) removes recursion from zeroValue while preserving payload shape/order, whole-local publication and instruction accounting. Deep unit tests cover 32,768 anonymous/nominal levels and pending siblings; the original run now returns normally. Follow-up probes independently verify native-stack failures in deepCopy/copyAll on local.load and Copier.value/items with collection before every instruction. Those are remaining Q-060 work, not a new acceptance limit; value sizing and output serialization remain audit candidates.
|
||||
|
||||
The [storage/value-copy increment](runtime-value-depth-audit.md#storagevalue-copy-repair) removes recursion from deepCopy/copyAll while retaining per-occurrence payload independence, aggregate identities, shallow handles and failure publication rules. The previous 32,768-level local.load run now returns normally. An added local.store forces ordinary-threshold collection and independently confirms the remaining Copier.value/items native-stack failure, without collect-every-step instrumentation. Sharing-preserving collection/result copying, accounted-value queries and output serialization remain open; no accepted-depth or trap limit is introduced.
|
||||
@@ -39,3 +39,13 @@ The original 32,768-level input now returns `{"status":"returned","value":null}`
|
||||
- Adding `%v = local.load %a` immediately after zeroing aborts without JSON inside deepCopy/copyAll (4,998 frames each), under the same fuel 8. Storage-to-SSA copying still requires its own iterative traversal.
|
||||
|
||||
Both probes retain the ordinary native stack limit and disable only child core capture, with no wall-clock termination. Evidence comes from the runner exit status and Zig's symbolized stderr, not a saved core dump. Q-060 stays open for copying, sharing-preserving collection/result copying, accounted-value queries and output serialization.
|
||||
|
||||
## Storage/value-copy repair
|
||||
|
||||
DeepCopy now visits aggregate/array payloads in the original preorder using explicit pending-sibling continuations. CopyAll keeps its root-list order and invokes that traversal for each root. Every occurrence gets a fresh payload, even when the input reuses one payload more than once. Aggregate declaration/variant identity and scalar bits/types are preserved; owner, mutex, graph and other identity leaves remain shallow, just as before. This is distinct from the collector, which must preserve sharing. Temporary traversal storage is released before the next instruction safe point; allocation failure does not publish a partial local.store value.
|
||||
|
||||
The invariant is unchanged storage/SSA value independence, alongside unchanged ownership identity and explicit loan rules. Spec 07a's local.store/local.load/load/store rules and spec 08's type/initialization/borrow checks are unchanged. The mixed Copy-record/enum/array AIR/source pair copies into and out of local storage, changes one repeated row without affecting the other, restores from a snapshot, and checks that a later store does not mutate the snapshot. Existing read_uninitialized and copy_overlapping AIR cases remain rejected with E1010/E2101; there is no new rejection or diagnostic code. Aji authority/effects, deterministic instruction/fuel counts, accepted syntax/types and runtime traps remain unchanged. No new limit or bundle text is introduced.
|
||||
|
||||
Unit tests copy 32,768 alternating array/aggregate levels with pending siblings, empty payloads, variant identities and signed integer bits. They mutate one of two complete copies, independently test reused source payloads within one value, preserve explicit owner/mutex/graph identities, and force a mid-copy payload allocation failure while retaining complete old local storage. A verified deep programme pins exact fuel 0–4 boundaries: local.load still consumes one instruction. Forty-two mixed-type old/new runs have identical records.
|
||||
|
||||
The previously crashing 32,768-level zero/local.load/ret programme now returns normally under fuel 8 at the ordinary collection threshold. Adding local.store back to the same local forces an ordinary threshold collection and aborts without JSON in Copier.value/items (4,997/4,998 symbolized frames, zero deepCopy frames). This confirms the next failure without collection instrumentation. The collector/result copier, accounted-value queries and output serialization remain Q-060 work.
|
||||
@@ -410,3 +410,9 @@ Old/new comparison of 1,410 pre-existing source files preserves every diagnostic
|
||||
The [Q-060 zero-materialization increment](../design/runtime-value-depth-audit.md#zero-materialization-repair) fills zeroable values iteratively, retaining field/element order, declaration identities, independent payloads, whole-local publication, allocator errors and fuel/scheduling. Unit cases cover 32,768 array/nominal levels with pending siblings and an allocation failure; a mixed AIR/source run pair checks initialization and subsequent writes. The original fuel-8 probe now returns normally and forty shallow mixed-type old/new records are identical. Follow-up probes independently confirm recursive local-load copying and sharing-preserving collection failures. Q-060 and Phase 6 remain open; no normative/bundle/feature/code change or new depth limit. No fresh Claude review was available.
|
||||
|
||||
Validation: all units/format checks, test-extended and 1,785/1,785 conformance cases pass; both new mixed-type cases also pass with collection before every instruction. A verified 32,768-level unit probe pins exact fuel 0–3 boundaries and instruction counts. Source/AIR semantics and bundle size are unchanged; the separate deep collector/copy failures are retained in Q-060.
|
||||
|
||||
## P6-1 runtime storage/value copying (2026-10-09)
|
||||
|
||||
The [Q-060 storage/value-copy increment](../design/runtime-value-depth-audit.md#storagevalue-copy-repair) replaces recursive aggregate/array copying with pending-sibling continuations. Every source payload occurrence remains independently copied; scalar/variant/declaration facts, identity handles, allocator errors and instruction/fuel counts remain unchanged. Deep unit cases cover 32,768 alternating levels, siblings/empty fields, duplicate payloads, identity leaves and failed local.store publication. A mixed Copy-record/enum/array AIR/source pair and 42 exact old/new run comparisons cover observable copying. The prior deep local.load probe now returns, while an added local.store independently reaches the remaining collector failure under its ordinary threshold. Units/format checks, test-extended and all 1,787 conformance cases pass. No normative/bundle/feature/code change or new depth limit; Q-060 and Phase 6 remain open. No fresh Claude review was available.
|
||||
|
||||
Both new copy cases also pass with collection before every instruction; their shallow sharing-preserving GC behavior is covered separately from the retained deep collector failure.
|
||||
Reference in new issue
Block a user