ReviewOS

zig-utils/zig-js

ABI: convert BunString values and arrays into native JS cells

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

Parent

Scope

Build on #195's pinned BunString/WTFStringImpl layout to implement the non-URL conversion family:

  • BunString__toJS;
  • BunString__transferToJS;
  • BunString__toJSWithLength;
  • BunString__createArray.

URL-producing variants remain a separate DOMURL slice.

Acceptance

  • All four imports are implemented for both pinned profiles.
  • Transfer consumes exactly one owned reference and marks non-empty input Dead only after success.
  • Length truncation is by UTF-16 code unit, not UTF-8 byte.
  • Array conversion validates/converts atomically and preserves order.
  • Focused fixture, both audits, README, ABI docs, and parent issues are current.

Evidence

Implemented in 835ac339; documentation published in fd7298b7.

  • zig build test-home-private-abi -Doptimize=Debug: 84/84 combined symbols linked and runtime matrix passed.
  • zig build home-private-abi-audit bun-private-abi-audit: Home 86/431 implemented (345 pending); Bun 79/421 implemented (342 pending).
  • Coverage includes Empty/Dead, 8/16-bit WTFStringImpl, Latin-1/UTF-8/UTF-16 ZigString, astral and lone-surrogate text, UTF-16-unit prefixes that split a surrogate pair, non-mutating conversion, success-only transfer invalidation, owned ref release, zero-length/null and ordered array construction, selected-realm Array prototypes, failure atomicity, and first-exception preservation.
9 days ago

Completed and pushed directly to main in two chunks:

  • 835ac339 — four BunString conversion exports, exact representation/ownership logic, inventories, and 84/84 runtime fixture.
  • fd7298b7 — README and ABI/integration/API evidence.

Focused runtime and both pinned audits pass. Current status: Home 86/431 implemented (345 pending); Bun 79/421 implemented (342 pending). Parent issues #134, #140, #163, and #164 are updated.

Sign in to comment on this issue.