ReviewOS

zig-utils/zig-js

VM: quicken numeric sparse-array stores

#1050
Closed chris opened this 9 days ago ·
9 days ago

Parent: #498 Related: #1049, #1048, #493

Measured problem

The executed #1049 VM witness confirms a valid distant Array assignment such as values[1000000] = 7 uses no indexed store shortcut. Sparse array indices live as named own data properties after dense growth declines them, but repeated updates still format/coerce the Number key and run the full prototype/receiver [[Set]] algorithm even when the exact own descriptor is already writable data.

The same conservative has_indexed_property guard also rejects updates to present dense elements whenever an unrelated sparse named index exists.

Scope

  • Add a synchronized exact-own-data replacement primitive that never creates a property or bypasses an accessor/non-writable descriptor.
  • Use it for primitive-Number updates to existing sparse Array data properties with bounded stack key storage.
  • Let present dense own elements remain quick when an unrelated sparse named index exists.
  • Preserve holes, inherited setters/non-writable data, accessors, Proxies/revocation, invalid keys, Array length behavior, restrictions, GC barriers, and no-GIL synchronization.
  • Keep sparse property creation/growth generic; no source/workload recognition or property-result cache.
  • Update the source-derived quickening inventory and generated architecture page.

Acceptance

  • The pre-change zero-hit sparse store witness records positive hits with identical Node results.
  • Existing sparse data, dense-with-unrelated-sparse data, holes, inherited setters, accessors, non-writable data, Proxy stores, invalid keys, and strict failures are pinned.
  • Restriction ownership plus focused normal and unsuppressed TSan tests pass.
  • Quickening inventory, benchmark-validator, docs-manifest, and offline-link gates pass.
  • Sparse property creation and prototype-observable misses remain explicitly generic.
9 days ago

Implemented in dcdeab4.

Repeated primitive Number stores now replace existing writable sparse Array data properties under one coherent property-lock snapshot with the GC barrier intact. Present dense elements also stay quick when unrelated sparse data exists. Creation, holes, inherited setters, accessors, non-writable descriptors, Proxies, invalid keys, and strict failures retain ordinary [[Set]].

Validation:

  • pre-change sparse-store witness: zero hits; after: positive hits
  • full edge matrix agrees with Node in isolated and shared modes
  • focused normal and unsuppressed TSan tests: 3/3 each, including foreign restriction ownership
  • quickening inventory: 17 guarded, 5 unsupported
  • benchmark harness self-tests: 19/19
  • docs: 51 pages, exact manifest, 378 valid offline links

The test262 corpus is absent from this checkout, so no conformance flip count is claimed.

Sign in to comment on this issue.