Parent: #140 Tracked by: #134, #164
Symbol
| Symbol | Bun (upstream/src/jsc/JSObject.zig) | Bun C++ (upstream/src/jsc/bindings/bindings.cpp) |
|---|---|---|
JSC__JSObject__create | JSObject.zig:11 — extern fn JSC__JSObject__create(global_object: *JSGlobalObject, length: usize, ctx: *anyopaque, initializer: InitializeCallback) JSValue; | bindings.cpp:2477 |
Bun-only symbol (not declared by the pinned Home profile). The C++ definition creates an empty object with the realm Object.prototype and inline capacity clamped to JSFinalObject::maxInlineCapacity, then synchronously invokes the consumer initializer as initializer(ctx, object, globalObject) — Bun's struct-marshalling path (createFromStructWithPrototype, JSObject.zig:135) uses it to populate POJOs field by field. InitializeCallback = *const fn (ctx: *anyopaque, obj: *JSObject, global: *JSGlobalObject) callconv(.c) void (JSObject.zig:123).
Acceptance criteria
- Export creates a fresh empty object with the selected realm's
Object.prototype(same observable shape asJSC__JSValue__createEmptyObject), then invokes the initializer exactly once, synchronously, before returning. - The initializer receives the exact
ctxpass-through, the stable canonical cell handle (the same address the returned EncodedJSValue exposes at the private cell boundary — zig-js encodes objects as their canonical box address), and the sameJSGlobalObjecthandle the export received. length/capacity is documented as a performance-only hint: JSC clamps it tomaxInlineCapacity; zig-js shapes grow on demand, so there is no observable difference for any value, including capacity larger than JSC's clamp.- Null-tolerant per zig-js private-ABI convention: null global returns
.emptywithout invoking the initializer; null initializer still creates and returns the object. - Compiled runtime fixture covers: initializer invocation count/order, ctx/global pass-through identity, cell-handle identity with the returned value,
Object.prototypeidentity with a peer empty object, null-initializer creation, null-global tolerance. Fixture symbol count 290 → 291. - Bun inventory
281/421implemented (Home unchanged: symbol is Bun-only);bun-private-abi-audit+c-api-auditgreen; fullzig build testzero new failures (worktree baseline-vs-candidate against the same pinned base).