ReviewOS

zig-utils/zig-js

ABI: implement copied, atomic, and rope string construction

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

Parent

Scope

Implement the exact shared private string-construction boundary against pinned Home and Bun revisions:

  • ZigString__toValueGC: copy every tagged Latin-1, UTF-8, and UTF-16 representation into a selected-VM JavaScript string.
  • ZigString__to16BitValue: match the pinned raw UTF-8-to-WTF string conversion contract.
  • ZigString__toAtomicValue: canonicalize equal strings to one VM-owned atomic string cell without leaking identity across VMs.
  • JSC__JSValue__createRopeString: perform ordered ToString conversion and concatenate exact UTF-16 code-unit sequences while publishing abrupt completion through the shared VM exception slot.

External-string callback/finalization exports and borrowed toZigString views are separate ownership families and are out of scope.

Acceptance

  • Every tagged input encoding covers empty, Latin-1, astral, and lone-surrogate cases.
  • Copying is proven by mutating source storage after construction.
  • Atomic strings converge within one VM and remain isolated across VMs.
  • Rope conversion covers primitive/object coercion order, same-VM siblings, foreign values, and first-exception preservation.
  • Focused runtime, both inventories, README/docs, and parent trackers are current.

Completion evidence

Implemented on main in 2bd1a7c6; README and ABI documentation published in 77bb23fa.

  • ZigString__toValueGC copies empty, Latin-1, UTF-8, UTF-16, astral, and lone-surrogate input; mutation-after-copy is covered.
  • ZigString__to16BitValue implements raw UTF-8 conversion and rejects invalid input through the VM exception slot.
  • ZigString__toAtomicValue uses one VM-owned intern table shared by sibling realms and isolated from foreign VMs.
  • JSC__JSValue__createRopeString performs left-then-right ToString, exact surrogate-pair concatenation, same-VM sibling acceptance, foreign-VM rejection, abrupt completion, and first-exception preservation.
  • zig build test-home-private-abi -Doptimize=Debug passes 93/93 symbols.
  • Home audit: 95/431 implemented, 336 pending. Bun core audit: 88/421 implemented, 333 pending.
9 days ago

Completed on main in 2bd1a7c with documentation in 77bb23f. Focused runtime: 93/93; Home: 95/431; Bun core: 88/421.

Sign in to comment on this issue.