ReviewOS

zig-utils/zig-js

VM: quicken numeric sparse-array reads

#1049
Closed chris opened this 8 days ago ·
8 days ago

Parent: #498 Related: #1048, #493

Measured problem

A valid distant Array index such as 1000000 exceeds the dense-growth window and is represented as an ordinary named own property while still extending Array length. An executed VM witness confirms values[1000000] = 7; values[1000000] returns 7 but leaves the indexed quick-read counter unchanged. The primitive Number key therefore still enters generic ToPropertyKey and full [[Get]] despite the receiver already publishing an indexed-own flag and the value being a direct own data descriptor.

Scope

  • Add a guarded primitive-Number read path for valid sparse Array indices represented as named own data properties.
  • Format the known integer key into bounded stack storage and use the coherent named-descriptor snapshot.
  • Preserve holes, inherited indexed values, indexed accessors, Proxies/revocation, invalid numeric keys, restrictions, and no-GIL property synchronization.
  • Keep sparse writes 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 witness records positive sparse-read hits with identical Node results.
  • Own sparse data, unrelated dense data, inherited values, accessors, Proxy reads, and invalid numeric keys are pinned.
  • Restriction ownership plus focused normal and unsuppressed TSan tests pass.
  • Quickening inventory, benchmark-validator, docs-manifest, and offline-link gates pass.
  • Sparse stores and prototype-observable misses remain explicitly generic.
8 days ago

Implemented in 552fec1.

Primitive Number reads now resolve direct sparse Array data properties through the atomic indexed-own publication flag and one coherent named-descriptor snapshot. The known integer key uses bounded stack storage. Prototype misses, accessors, Proxies, invalid numeric keys, and sparse stores remain generic.

Validation:

  • pre-change sparse 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.