ReviewOS

zig-utils/zig-js

ABI: create callable JSFunctions from Zig host functions

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

Goal

Implement the pinned Home/Bun private-JSC JSFunction__createFromZig boundary with the exact BunString, JSHostFn, CallFrame, visibility, intrinsic, arity, and optional constructor contracts.

Parent tracking: #134, #140, #163, #164.

Required behavior

  • Decode the by-value 24-byte BunString name without retaining borrowed input.
  • Create a callable function in the requested realm with stable name and length.
  • Invoke the supplied JSHostFn through the pinned JSC64 CallFrame register layout (callee, argument count including this, receiver/new.target, arguments).
  • Translate returned EncodedJSValue values and pending exceptions exactly at the VM boundary.
  • Support an explicit constructor callback and the upstream default host-constructor path.
  • Validate null/foreign/invalid values, pending-exception preservation, sibling realms, and GC rooting.
  • Promote both pinned inventories and consumer evidence, then update README/docs.

Evidence gate

  • Home private ABI audit: 249/431 implemented, 182 pending, zero unclassified.
  • Bun private ABI audit: 243/421 implemented, 178 pending, zero unclassified.
  • Compiled Home consumer fixture: 248/248, including call, construct, sibling-realm, GC, and failure paths.
  • Targeted test-home-private-abi and test-c-api gates pass.
  • Benchmark artifact remains 36a617b3; this ABI-only slice does not alter the benchmark workload.

Implementation: d2a653b. Documentation: 515f058.

9 days ago

Completed on main.

  • Implementation: d2a653b3
  • Documentation/evidence: 515f0583
  • Home: 249/431 implemented, 182 pending, zero unclassified
  • Bun core: 243/421 implemented, 178 pending, zero unclassified
  • Compiled consumer: 248/248
  • Targeted test-home-private-abi and test-c-api gates pass
  • Benchmark artifact remains 36a617b3 because the measured workload is unchanged

Sign in to comment on this issue.