ReviewOS

zig-utils/zig-js

VM: quicken canonical TypedArray String keys

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

Parent: #498 Related: #1045, #1046, #1051

The executed VM witness new Uint8Array([1,2]); values["1"] = 8; values["0"] + values["1"] returns Node's 9 but leaves both TypedArray read and store hit counters unchanged. Canonical primitive String keys still enter generic dispatch even though they need no observable ToPropertyKey operation.

Scope: admit primitive String keys recognized by the existing CanonicalNumericIndexString operation into the direct Integer-Indexed read/store helpers. Keep String "-0" invalid while Number negative zero denotes index zero. Retain post-RHS-coercion buffer revalidation, BigInt conversion, detachment/resize, and restriction ownership. Non-canonical String, object/Symbol, and Proxy cases keep their complete semantics.

Acceptance:

  • The zero-hit witness records read and store hits in isolated/shared modes.
  • String -0, invalid canonical indices, Number -0, non-canonical strings, RHS coercion, BigInt, resize/detach, and restrictions are pinned against Node.
  • Focused normal/unsuppressed TSan tests and before/after TypedArray Get/Set corpus checks pass.
  • The source-derived quickening inventory and generated docs gates pass.

Shared canonical-key prerequisite completed in #1058.

9 days ago

Implemented in 22305c8, following the shared canonical-key correctness fix #1058 / 9eb494e.

VM TypedArray indexed reads/stores now admit primitive String keys through CanonicalNumericIndexString. Number negative zero maps to index zero; String -0 remains invalid. RHS coercion still precedes buffer/index revalidation, including invalid canonical keys and buffer resize/grow/detach. Noncanonical, rounded decimal, object, Symbol, and Proxy keys preserve ordinary/observable semantics.

Measured evidence:

  • The executed before witness recorded zero String-key read/store hits; the completed isolated/shared witness records positive hits.
  • Node-confirmed effect matrices pin coercion counts, BigInt errors, resize/grow/detach, shared-buffer growth, rounded ordinary names, and generic key/Proxy behavior.
  • TypedArray tests pass 9/9 normally and 9/9 under unsuppressed TSan, including four actual no-GIL workers and restriction ownership.
  • The neighboring Array/arguments canonical String test passes 2/2.
  • Pinned Test262 TypedArray internals: 240 pass before and after, zero failures, zero flips; saved outputs are byte-identical. Its tree/VM witness reports 240 agreements and zero divergences on both sides.
  • Inventory: 17 guarded families, 5 unsupported families, 42 counters. Documentation renders 51 pages and links resolve in all 378 checked files.

Sign in to comment on this issue.