interp: calculate runtime value sizes without recursion
This commit is contained in:
1 parent
f92817b127
commit
6353ab5f5d
6 files changed
+276
-5
No files matched your search
@@ -21,7 +21,7 @@ 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.
|
||||
|
||||
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, collection, value sizing and output serialization. Q-060 remains open for the latter two failures.
|
||||
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, collection, value sizing and output serialization. Q-060 remains open for output serialization; the earlier increments record the failures that led to each repair.
|
||||
|
||||
## Zero-materialization repair
|
||||
|
||||
@@ -66,3 +66,15 @@ Two follow-up failures are independently verified on the same ordinary native st
|
||||
- Allocating an owner for the same loaded array using own.new with fuel 16 and an eight-byte heap grant aborts with exit -6, no JSON and 10,001 valueBytes frames. The value's accounted size is one byte. This confirms native recursion in runtime value sizing after zeroing, loading and collection now complete.
|
||||
|
||||
Q-060 remains open for valueBytes and output serialization. No normative or agent-bundle text changes in this increment.
|
||||
|
||||
## Runtime value-size repair
|
||||
|
||||
ValueBytes now iterates the first-element chain of fixed value arrays, composing their positive lengths into a checked factor. Scalar, capability, graph-reference, built-in enum and nominal leaf accounting remains unchanged; named types still delegate to the existing module size query. A zero-sized leaf yields zero even if the length factor overflows, matching the original inner-to-outer checked multiplication. A nonzero leaf with an overflowing factor still yields null. ArrayBytes continues to query the element before multiplying by the dynamic count, so a zero count cannot mask an overflowing element. The traversal uses constant state and allocates no temporary or payload storage.
|
||||
|
||||
The invariant is equality with spec 08 §7.1's static accounted size, including nominal maximum enum payloads, zero-sized records and overflow. The existing heap/region/graph charge, failure, release and sixteen-byte graph-header rules remain unchanged (spec 03 §18–§24); authority is still explicit. Fixed value arrays have positive lengths (spec 07 §8.8), and runtime-sized backing arrays are not allocatable SSA values (spec 03 §19.2). No verifier acceptance rule changes. The existing overflowing_array_chain AIR/source rejection pair still reports E5101. The new nested_allocation_quota AIR/source run pair returns 42: twelve-byte nested content fits exactly, a second live allocation fails budget_exceeded, zero-sized content still fits, and freeing restores authority for a repeated allocation. No new code, trap, effect, feature, semantic flag, accepted-depth limit or bundle text is introduced. Fuel, instruction count, collection safe points, ownership transfer and deterministic outcomes are unchanged.
|
||||
|
||||
Unit tests compare scalar/nominal/built-in/capability/iref leaves under mixed array lengths against static accounting, preserving inactive enum payload maxima. Query-only inputs cover 32,768 wrappers, overflowing factors with zero/nonzero leaves and zero dynamic counts; shared payloads compactly represent these queries without claiming verified exponential constructions. A verified 32,768-level own.new programme pins exact fuel 0–6 boundaries under ordinary and per-instruction collection. A one-byte grant takes success, a zero-byte grant takes the error edge, and both executions terminate with the original instruction counts. The formerly crashing CLI probe now returns null with grants one and eight; grant zero retains its explicit failure trap. The successful deep run and both new conformance examples pass with collection before every instruction.
|
||||
|
||||
Validation: unit/format checks, test-extended and all 1,789 ordinary conformance cases pass. Ten old/new quota records for the new AIR/source pair are identical. Another 426 generated runs independently compute expected charges for scalar/record/enum contents, mixed fixed arrays, individual/repeated/zero-count owners and island/arc headers; every boundary outcome matches that oracle and the old interpreter's record. These are generated runtime robustness inputs, not model-evaluation or held-out tasks. The earlier full per-instruction collector conformance run remains additional validation in progress.
|
||||
|
||||
Q-060 remains open for output serialization at the fixed std.json.Stringify nesting stack and the still-recursive writeValue traversal. Q-059's uncached nominal query audit is separate; this repair does not claim to close it.
|
||||
Reference in new issue
Block a user