Parent: #140 Tracked by: #134, #163, #164
Symbols (URL cluster sub-slice 4 — DOMURL object boundary, final URL-cluster slice)
| Symbol | Home (packages/runtime/src/... @ 7ed99c02) | Bun C++ (upstream/src/jsc/bindings/...) |
|---|---|---|
BunString__toJSDOMURL | jsc/bun_string_jsc.zig:9 — (globalObject, in: *String) JSValue | BunString.cpp:580 — DOMURL::create(str, String()) + toJSNewlyCreated; RETURN_IF_EXCEPTION → {} |
BunString__toURL | jsc/ZigString.zig:148 — (this: *const ZigString, *JSGlobalObject) JSValue (string-first arg order) | not vendored in the upstream C++ subset; semantics pinned to the same DOMURL::create(url, "") path as toJSDOMURL with a ZigString input |
WebCore__DOMURL__cast_ | jsc/DOMURL.zig:26 — (JSValue, *VM) ?*DOMURL | bindings.cpp:2132 — WebCoreCast<JSDOMURL, DOMURL> |
WebCore__DOMURL__href_ | jsc/DOMURL.zig:40 — (*DOMURL, out: *ZigString) void (Home-only) | bindings.cpp:2137 — domURL->href().string() as ZigString |
WebCore__DOMURL__pathname_ | jsc/DOMURL.zig:71 — (*DOMURL, out: *ZigString) void (Home-only) | bindings.cpp:2142 — domURL->href().path() as ZigString |
WebCore__DOMURL__fileSystemPath | jsc/DOMURL.zig:53 — (*DOMURL, error_code: *c_int) String | bindings.cpp:2149 — error 1 non-empty host, error 2 %2f in path, error 3 not file:; else url.fileSystemPath() (decoded path) |
Key semantics pinned from the vendored sources:
DOMURL::create(url, base)returnsExceptionOr<Ref<DOMURL>>(webcore/DOMURL.h:45): invalid input raises a TypeError thattoJSNewlyCreatedpropagates through the throw scope — sotoJSDOMURL/toURLpublish the exception and return.emptyon invalid input; they do not create empty-href objects.- The created object IS the realm's URL-interface object (
instanceof URLtrue): URL prototype, the hidden URL component slots, and the livesearchParamssnapshot — identical in shape tonew URL(str)minus thenew-target check. - The
VM*incast_is the VM identity zig-js already publishes fromJSC__JSGlobalObject__vm/bunVM(the context group). Cast is VM-scoped: any same-VM realm's URL object qualifies; foreign-VM values, non-URL objects, and primitives return null. The returnedDOMURL*borrows the live JS object (Bun returns the wrapper-owned impl pointer) — valid while the caller's value keeps it alive; no allocation, no ownership transfer. href_/pathname_return borrowed ZigString views that must outlive the call without a free hook: views are interned in a process-global latin1/UTF-16 store (mirroring the existing group-levelzig_string_views), latin1 for 8-bit content, UTF-16 otherwise.fileSystemPathis context-free:file:scheme required (else error 3 Dead), non-empty host → error 1 Dead, case-insensitive%2fin the serialized path → error 2 Dead, else the percent-decoded path as an owned BunString. A nullDOMURL*yields error 2 Dead (zig-js sentinel where Bun dereferences unconditionally).
Acceptance criteria
- Engine: one allocator-first
urlCreateDomUrlObjecthelper next to the URL constructor (proto from the realm'sURL.prototype, hidden component slots, livesearchParamssnapshot, TypeError on invalid input);urlLoadmadepub. Zero behavior change to the JSURLconstructor. BunString__toJSDOMURL/BunString__toURLdecode their BunString/ZigString input with the established same-VM preamble, build the object, and return its encoded handle; invalid input publishes the TypeError and returns.empty.WebCore__DOMURL__cast_validates the VM handle (alignment + group self-consistency), decodes with VM affinity, applies the URL-slot predicate, and returns the borrowing pointer.href_/pathname_/fileSystemPathaccept the borrowing pointer with alignment + slot revalidation;href_/pathname_zero the out-param on null/stale input;fileSystemPathwrites error codes only on failure (success leaves the caller'sc_intuntouched, matching Bun).- Compiled runtime fixture 314 → 320: object creation parity (
instanceof URL, href/searchParams vsnew URL), invalid-input exception publication for both creators, cast acceptance of native-created ANDnew URL-constructed objects, cast rejection (non-URL object, primitive, foreign VM, null VM), href_/pathname_ round-trips, fileSystemPath success + all three error codes, null tolerance throughout. - Home inventory
317/431, Bun inventory308/421;bun-private-abi-audit+c-api-auditgreen; fullzig build testzero new failures (worktree baseline-vs-candidate against the same pinned base).
Design constraints
- No new object model: the DOMURL object is the existing URL-builtin object shape;
cast_is a predicate, not a conversion. - The process-global ZigString view store reuses the exact latin1/UTF-16 conversion of the group-level store (shared helper), guarded by a mutex since it is not thread-affine.
fileSystemPathperforms no GC allocation (private allocator only), so the borrowed object needs no active realm during the call.