Repository navigation
Closed
Description
Parent: #140
Tracked by: #134, #163, #164
Symbols (URL cluster sub-slice 3 — origin length)
| Symbol | Home (packages/runtime/src/jsc/URL.zig @ 7ed99c02) |
Bun C++ (upstream/src/jsc/bindings/BunString.cpp) |
|---|---|---|
URL__originLength |
:167 — extern fn URL__originLength(latin1_slice: [*]const u8, len: usize) u32; (declared, un-wrapped: originFromSlice is omitted pending strings.firstNonASCII) |
:569 — WTF::String from the latin-1 slice, WTF::URL, invalid → 0, else url.pathStart() |
Both pinned profiles declare the identical zig-side signature (latin1_slice: [*]const u8, len: usize) u32 (the C++ size_t return narrows to u32).
Last standalone URL-cluster symbol; after this slice only the DOMURL object-creation group (BunString__toURL/toJSDOMURL + WebCore__DOMURL__cast_/href_/pathname_/fileSystemPath) remains in the cluster.
Acceptance criteria
- Parse the latin-1 slice through the allocator-first
urlParsewith no base; empty/invalid (scheme-less) input returns 0, matching Bun's validity guard. -
pathStartis computed from the parsed parts so it exactly mirrorsurlSerialize's prefix emission:scheme:plus, when a host component is present,//+ userinfo (user[:pw]@, emitted only when non-empty) + host + (:portwhen set), plus the/.sentinel for a non-opaque path that begins with//. This is the byte offset where the path begins in the canonical serialization — i.e.url.origin.lengthfor tuple origins, and the scheme/authority prefix length otherwise. - The latin-1 slice is widened to WTF-8 before parsing (WTF 8-bit string semantics); non-ASCII bytes follow the parser's existing rules. A null slice returns 0 (zig-js sentinel where Bun dereferences unconditionally).
- Compiled runtime fixture covers: http with userinfo+port, default-port elision,
file:(empty authority present), opaque-path (mailto:), the//-led non-opaque sentinel case, invalid input → 0, null → 0; results cross-checked againstnew URL(...).origin.lengthwhere the JS getter exists (http/https) and against the serialized prefix elsewhere. Fixture symbol count 313 → 314. - Home inventory
311/431, Bun inventory304/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 parser machinery: reuse
urlParse+ the parts layout; the prefix-length arithmetic must not duplicate serialization logic beyond reading the same component fields. - Context-free: no realm, no exception channel — pure bytes in, length out.
Metadata
Metadata
Assignees
Labels
No labels
Activity
feat(abi): expose the URL origin-length boundary (#312)
docs(abi): publish URL origin-length evidence (#312)
chrisbbreuer commentedon Jul 19, 2026
Evidence — landed on main as runtime
a95eb6fd+ docsa44593a7.Implementation:
URL__originLengthinsrc/c_api.zigwidens the latin-1 slice to WTF-8 (privateLatin1ToWTF8, WTF 8-bit string semantics), parses with no base through the allocator-firsturlParse, and returns thepathStartoffset computed from the parsed parts so it mirrorsurlSerialize's prefix emission exactly —scheme:plus, with a host present,//+ non-empty userinfo (user[:pw]@) + host + (:portwhen set), plus the/.sentinel for a non-opaque//-led path. Empty/invalid input and a null slice return 0. Context-free: no realm, no exception channel.Validation:
http://user:pw@example.com:8080→ 31, default-port elision → 18,file:empty-authority → 7, opaquemailto:→ 7), JS-derived paritypathStart === href.length - pathname.lengthfor the non-special hierarchical (foo://host:9/p) and/.-sentinel (foo:////p) cases,origin.lengthgetter parity for https, and invalid/empty/null → 0.bun-private-abi-audit: implemented-private 304/421 (pending 117).c-api-audit: 320 private profile exports, 117/117 public complete.bcf9b0fd(isolated from unrelated uncommitted wasm work in the shared checkout): baseline 1152 passed / 3 failed vs candidate 1152 passed / 3 failed — identical failure sets (the three known pre-existing: gc slab size, wasm.decode malformed, wasm.validate GC canonical recursive type identity). Zero new failures.Inventories refreshed: Home 311/431 implemented (120 pending), Bun 304/421 (117 pending). Docs boundary evidence published in
docs/abi/README.md. Only the DOMURL object-creation group remains in the URL cluster.