ReviewOS

zig-utils/zig-js

VM: quicken present reads from holey arrays

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

Parent: #498 Related: #1045, #1046, #1047, #493

Measured problem

The VM's primitive-Number get_index shortcut handles packed dense Arrays, but in isolated execution it rejects the entire object as soon as any hole map exists. An executed pre-change witness using [1, , 3] reads the two present elements correctly while the indexed quick-path counter remains unchanged at zero. Both reads therefore allocate/coerce the numeric key and re-enter generic [[Get]] even though the requested own elements are present and have no indexed accessor.

Scope

  • Keep primitive numeric reads of present own dense elements quick when unrelated holes exist.
  • Retain generic [[Get]] for the hole itself so inherited indexed properties remain observable.
  • Preserve exact indexed accessors, Proxy/revocation, invalid numeric keys, restrictions, and no-GIL element synchronization.
  • Use the existing hole-aware element accessor; do not add a layout recognizer or duplicate property semantics.
  • Update the source-derived quickening inventory and generated architecture page.

Acceptance

  • The pre-change zero-hit witness records positive quick-path hits with identical Node results.
  • Present elements, the hole, inherited values, indexed accessors, numeric -0, and invalid numeric keys are pinned.
  • Focused normal and unsuppressed TSan tests pass.
  • Quickening inventory, benchmark-validator, docs-manifest, and offline-link gates pass.
  • Sparse named indices and prototype-observable misses remain explicitly generic.
8 days ago

Implemented in 3d1de16.

Primitive Number reads now keep present dense elements on the VM quick path when unrelated holes exist. The hole itself, inherited indexed values, indexed accessors, sparse named indices, negative/fractional keys, and other observable cases retain ordinary [[Get]].

Validation:

  • pre-change isolated witness: zero hits; after: positive hits
  • full edge matrix agrees with Node in isolated and shared modes
  • focused normal and unsuppressed TSan tests: 2/2 each
  • neighboring packed/TypedArray reads: 4/4
  • 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.