ReviewOS

zig-utils/zig-js

VM: quicken canonical string array indices

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

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

Measured problem

An executed VM witness confirms canonical primitive String indices such as "0" produce correct Array and mapped-arguments reads/stores while all four relevant quick-path counters remain unchanged. These keys are already property keys, so they have no observable ToPropertyKey hook, yet they still enter full generic indexed dispatch.

Scope

  • Recognize canonical primitive String array indices alongside primitive Number indices for guarded Array and arguments-object read/store paths.
  • Preserve mapped arguments aliasing, dense/holey/sparse Array behavior, descriptors, accessors, Proxies/revocation, restrictions, and no-GIL synchronization.
  • Reject non-canonical forms such as "01", "-0", fractions, negatives, and 4294967295 from Array-index shortcuts.
  • Keep Symbol and object key coercion generic and one-shot.
  • Keep TypedArray canonical-numeric-string semantics separate; "-0", out-of-bounds, detachment, and numeric-string rules differ from ordinary Arrays.
  • Update the source-derived quickening inventory and generated architecture page.

Acceptance

  • The pre-change zero-hit witness records positive Array and arguments read/store hits with identical Node results.
  • Dense, holey, sparse, mapped/unmapped arguments, descriptors, accessors, Proxy, canonical/non-canonical strings, Symbol, and object keys are pinned.
  • TypedArray string-key counters remain unchanged and Integer-Indexed semantics remain exact.
  • Focused normal and unsuppressed TSan tests pass.
  • Quickening inventory, benchmark-validator, docs-manifest, and offline-link gates pass.
9 days ago

Implemented and pushed in 7046af6.

Canonical primitive String array indices now use the guarded fast paths for dense, holey, and sparse Arrays and for mapped and unmapped arguments objects. The implementation keeps the loop-plan arithmetic path Number-only and leaves TypedArray keys on the separate Integer-Indexed path.

Measured evidence:

  • The pre-change witness recorded zero Array/arguments quick hits; the completed matrix records positive hits for canonical String reads and stores with identical Node results in isolated and shared modes.
  • Non-canonical strings (01, -0, fractions, and 4294967295), Symbol keys, object coercion, Proxy traps, inherited holes, and accessors remain generic.
  • TypedArray "0" remains generic here and does not increment the Number-key TypedArray counter.
  • Focused VM test: 2/2 normal and 2/2 under unsuppressed TSan.
  • Quickening inventory: 17 guarded families and 5 unsupported families.
  • Aggregate benchmark-comparison validators: 19/19.
  • Documentation: 51 pages generated and all 378 offline links valid.

The test262 corpus is unavailable in this checkout, so no conformance-flip claim is made.

Sign in to comment on this issue.