ReviewOS

zig-utils/zig-js

Private ABI: compare StringData semantically across representations

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

Parents: #495, #473 Related: #672, #693

Problem

Private JSC__JSString__eql compares Value.asStr physical bytes, and private deep equality repeats that comparison for boxed String primitives. Jest-compatible string-containing and string-matching predicates also use raw byte substring search. A canonical/static cell and a physical flat-Latin-1 cell can therefore compare unequal or produce representation-dependent substring results despite containing the same JavaScript StringData.

Scope

  • Route private JSString equality and boxed String deep equality through the engine semantic string comparator.
  • Route string-containing and string-string matching through representation-aware UTF-16 code-unit search.
  • Preserve object recursion, asymmetric inversion, regex matching, pending-exception publication, handle/context affinity, and ABI symbols/layouts.
  • Keep same-cell and same-representation fast paths allocation-free; propagate conversion/search OOM through existing private pending-exception state.

No-workaround rules

  • No global canonicalization, pointer-identity equality, lossy repair, ASCII restriction, retry, suppression, ABI fork, or byte-search approximation.
  • No stacks, queues, jobs, Promise modes/reactions, Worker lifecycle, or Map/Set iterator changes.

Acceptance

  • Canonical, static, and physical flat-Latin-1 cells compare by exact StringData through JSString eql and boxed deep equality.
  • String-containing and string-string matching follow UTF-16 code-unit semantics across representations.
  • Same-representation fast paths remain allocation-free and flat conversion OOM is explicit.
  • Focused Debug, forced-flat, ReleaseSafe, TSan, private ABI fixtures/audits, and full units pass; applicable Test262 accounting is exact.
8 days ago

Landed in 459af38b. Private JSString and boxed String equality now use semantic comparison, while string-containing and string-string matching use bounded UTF-16 code-unit search. Focused Debug, forced-flat, ReleaseSafe, and TSan witnesses passed; the existing deep/Jest controls passed in Debug and TSan; Home/Bun private audits passed; Home runtime fixture linked and exercised 392/392 symbols; full units passed 1,793 with 1 intentional skip, 0 failures, and 0 leaks. Test262 has 0 applicable private-ABI cases, so flips 0.

Sign in to comment on this issue.