ReviewOS

zig-utils/zig-js

ABI: implement exact private record construction

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

Goal

Implement the exact pinned Home/Bun private-JSC record/object construction boundary for:

  • JSC__JSValue__putRecord
  • JSC__JSValue__fromEntries

This is a child of #134, #140, #163, and #164.

Required semantics

JSC__JSValue__putRecord

  • Decode the target in the selected VM and reject invalid/foreign targets deterministically.
  • Decode the key and every value from all supported ZigString encodings without observable JavaScript coercion.
  • Preserve the pinned cardinality rule: zero values creates an empty array, one value creates a scalar string, and multiple values create an ordered string array.
  • Define a direct own data property with writable, enumerable, and configurable attributes, bypassing inherited setters.
  • Replace an existing own property with the exact constructed value.
  • Publish abrupt completion, allocation failure, and pre-existing pending exceptions through the shared first-wins exception boundary.

JSC__JSValue__fromEntries

  • Construct an ordinary selected-realm object with Object.prototype, including the zero-entry case.
  • Decode keys and values from all supported ZigString encodings without invoking JavaScript.
  • Preserve insertion order, duplicate-key last-value behavior, and ECMAScript integer-index enumeration ordering.
  • Match the pinned clone=false and clone=true ownership/lifetime behavior.
  • Handle null pointers, count/capacity overflow, and allocation failure without partial observable results.
  • Publish failures through the shared first-wins exception boundary.

Completion evidence

  • Add focused behavioral tests for both exports, including Latin-1/UTF-8/UTF-16 strings, duplicates, numeric keys, inherited setters, cardinalities, realm/VM rejection, pending exceptions, and allocation cleanup.
  • Add both symbols to the pinned Home/Bun inventories and the linkable private-value fixture.
  • Keep public/private export classification at zero unclassified symbols.
  • Run the focused test first, then one batched Home/Bun/public ABI audit.
  • Update the README and compatibility documentation with exact counts and evidence.
  • Close this issue only after the implementation and documentation commits are on origin/main.
9 days ago

Completed on origin/main in implementation commit 8b564d0 and documentation commit eee6386. Focused record-construction coverage passed 3/3 with zero leaks. The batched gates pass at Home 214/431 (217 pending), Bun 208/421 (213 pending), 213/213 linked runtime symbols, 117/117 public declarations, 19 extensions, and 218 classified private/support exports. The committed JSC comparison remains 36a617b because this ABI-only slice does not change benchmark execution paths.

Sign in to comment on this issue.