Files
ziran/tests/spec
waozi 31d291f337 Keep native records and arrays in place
Records spent all its time copying: every member update copied the whole
2048-byte array word by word, extracts copied each 32-byte record out and
loop edges copied the array again. The native backend now plans aggregate
storage the way zx2wasm does, in a new cmd/compiler_machine_aggregate.zi:

- Aggregate values whose lifetimes never overlap share one frame object, so
  an insert whose source dies there writes only its member, and loop-carried
  and branch-joined values reuse their arguments' object with no edge copy.
- On x86-64 an extract read only by extracts in its block is a view: its
  members are read and changed in place through one address register
  (StackAddress, then FieldAddress or ElementAddress), shared with a
  dominating view of the same storage and member. A changed view put back
  where it came from emits nothing. AggregateExtract/AggregateInsert take
  that register as their aggregate operand.
- Dynamic indices carry the shared facts' proven bound and skip their check;
  others are checked once per address.
- Copies and zeroing of 64 bytes or more run a 16-byte movups loop with a new
  indexed x86 operand instead of unrolled 8-byte pairs.

Per the owner, speed comes first and only correctness guardrails stay: no
new verifier obligations; the remaining checks are unproven index bounds,
interference before sharing a slot, and the view write/read windows. The
allocator's aggregate cycle temporaries now have the aggregate's own size,
which 8-byte record swaps needed once coalescing made such cycles common.

tests/spec/zx_lowered_aggregates.zi joins the ZX parity suite: the Records
kernel (68788), a whole-array snapshot after insert, a two-array swap cycle,
in-place branch updates, a record parameter changed in place, loop-carried
and edge-carried records, a small-record swap at a join and scalar stores at
runtime indices, matched against C, the interpreter, native and Wasm.

On Omega (receipts in bench/results/*records-before/after.json) Records goes
from 1951 to 32 us natively and 1858 to 29 us on the zx engine (C 8.7 us,
Wasm 17.0 us); its image shrinks from 69,760 to 12,416 bytes and Sieve's
from 94,336 to 8,320. make check (276/276) and make check-bootstrap pass.
2026-11-15 19:40:16 -03:00
..
2026-10-31 02:46:00 -03:00