interp: materialize zero values with explicit continuations

This commit is contained in:
dev committed 2026-10-09 21:38:59 +03:00
1 parent 9549a3dec6
commit b1b9b4cf03
6 files changed
+354 -19

No files matched your search

+18 -1
View File
@@ -21,4 +21,21 @@ Every array length is one. The accounted value/frame size is one byte, and `aji
This confirms native recursion in zeroValue on a verified input. An iterative fix must retain zero initialization, value shape, heap/root lifetimes, allocation failure handling, collection safety and instruction/fuel accounting. A new accepted-depth limit or trap would require a normative decision; none is added by compiler-side repairs.
Source inspection also finds recursion in deepCopy/copyAll and valueBytes. Those failure paths are **unverified**: no deep-value input reached them in this probe. Runtime marking and output serialization also need inspection before claiming complete bounded native-stack behavior. Q-060 remains open.
At the initial baseline, deepCopy/copyAll, valueBytes and collection/serialization were inspection candidates only: the zero-materialization failure prevented probing them. The executed results below supersede that status for copying and collection. valueBytes and output serialization still need depth probes before claiming complete bounded native-stack behavior. Q-060 remains open.
## Zero-materialization repair
The implementation now fills zeroable arrays and named structs in the original preorder, using explicit continuations only for pending siblings. Single-child edges need no continuation. Result payloads remain in the execution heap; temporary traversal metadata uses a separate host arena and is released before the next instruction safe point. A partially built value is not published to the local cell if an allocation fails.
The preserved invariant is complete initialization without aliasing independent array/struct payloads. Spec 07a's local.zero verifier rule (zeroable type, no live borrow) and spec 08 §13's whole-local initialization remain unchanged. All leaves have the same integer type/zero bits or false boolean, and aggregate declaration/variant identities and field/element order are unchanged. No runtime rule, Aji allocation authority, opcode, effect, feature, diagnostic code, trap, accepted-depth limit or fuel/scheduler event is introduced. Existing enum/capability zero rejects remain E1001 in AIR and E7006/zero_not_zeroable in source; the public zero_enum/capability_not_zeroable cases and their source analogues remain rejection examples.
Unit tests traverse 32,768 single-element arrays and a 32,768-declaration chain with heterogeneous pending siblings, empty-record leaves and three-byte arrays. A constrained payload allocator fails after allocating the root and proves that the old local value survives the failed instruction. The new zero_structure_siblings AIR/source pair checks complete mixed zeroing followed by a write and unchanged independent fields. Forty generated shallow mixed-type runs produce byte-identical old/new records.
An additional verified deep-program unit test pins fuel 0/1/2 as exact limit records and fuel 3 as successful completion, with matching instruction counts at the ordinary collection threshold.
The original 32,768-level input now returns `{"status":"returned","value":null}` under fuel 8 at the ordinary collection threshold. This is not a claim that all deep runtime paths work. Two follow-up probes are independently confirmed:
- With collection before every instruction, the same program aborts without JSON inside Copier.value/items (4,997/4,998 symbolized frames). Its ordinary run succeeds, isolating the collector's recursive payload copy from zero construction.
- 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.