Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
70591cb
jsc: expose Node.js-style primordials as link-time constants
robobun Jul 25, 2026
795d638
build: point WEBKIT_VERSION at preview release for oven-sh/WebKit#341
robobun Jul 25, 2026
c244774
shorten primordials comments
robobun Jul 25, 2026
e56d298
test(primordials): gate tamper via env, keep harness on captured buil…
robobun Jul 25, 2026
1a9e9d4
ci: retrigger
robobun Jul 25, 2026
e3f28fe
test(primordials): poison getter-backed primordials and assert tamper…
robobun Jul 25, 2026
8ea828c
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 25, 2026
e4b4873
primordials: audit binding, generated typedefs, exhaustive tamper tests
dylan-conway Jul 25, 2026
f22c668
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 25, 2026
5173759
bump WebKit preview pin to d0f433e1
dylan-conway Jul 25, 2026
f5a9397
primordials: oxlint-disable in generated .d.ts, tamper canary in exha…
robobun Jul 25, 2026
b8e0b84
primordials: address review nits in internal-for-testing + tamper suite
robobun Jul 25, 2026
8af6966
test(primordials): wire worker exit handler so a crash surfaces immed…
robobun Jul 25, 2026
d7c3488
test(primordials): capture Reflect.set in prelude; reportAndExit in p…
robobun Jul 25, 2026
9abbbf9
Full Node.js primordials parity, generated
dylan-conway Jul 26, 2026
f7db891
bump WebKit preview pin to 39d7bcfd
dylan-conway Jul 26, 2026
cee3704
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 26, 2026
f08a7ea
primordials: address review feedback
dylan-conway Jul 26, 2026
46ae65d
primordials: keep Node's explicit Safe* constructors
dylan-conway Jul 26, 2026
e3a4639
Merge remote-tracking branch 'origin/main' into farm/caec3ad2/primord…
robobun Aug 3, 2026
2b93ac8
build: restore webkitTestFFIPath export dropped in merge
robobun Aug 3, 2026
22d75df
bump WebKit preview pin to 01de5fd4
robobun Aug 3, 2026
c6a0d3d
Merge remote-tracking branch 'origin/main' into farm/caec3ad2/primord…
robobun Aug 3, 2026
f153789
primordials: fix CI lint + Float16Array inspect crash; regenerate
dylan-conway Aug 3, 2026
75292f8
bump WebKit preview pin to 291ee11e
dylan-conway Aug 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/build/deps/webkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* for local mode. Override via `--webkit-version=<hash>` to test a branch.
* From https://github.com/oven-sh/WebKit releases.
*/
export const WEBKIT_VERSION = "e6e37cda216c0292ae68c30c84a9dc8601d0fba5";
export const WEBKIT_VERSION = "autobuild-preview-pr-341-291ee11e";

/**
* WebKit (JavaScriptCore) — the JS engine.
Expand Down
202 changes: 202 additions & 0 deletions src/codegen/generate-primordials-probe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
// Probe half of src/codegen/generate-primordials.ts. Runs inside a pristine target
// bun binary and reports, for every member Node's primordials construction would
// produce from this engine's intrinsics, where the pristine value comes from.
// Output: JSON { entries: [...], missing: [...] } on stdout.
//
// This mirrors lib/internal/per_context/primordials.js's enumeration exactly; only
// what is recorded differs (provenance instead of values).
Comment thread
dylan-conway marked this conversation as resolved.

const varargsMethods = [
"ArrayOf",
"ArrayPrototypePush",
"ArrayPrototypeUnshift",
"MathHypot",
"MathMax",
"MathMin",
"StringFromCharCode",
"StringFromCodePoint",
"StringPrototypeConcat",
"TypedArrayOf",
];

const entries = [];
const missing = [];

function keyDescription(key) {
// Well-known symbols are named by their identifier ("iterator", "toStringTag").
return typeof key === "symbol" ? key.description.replace(/^Symbol\./, "") : key;
}

// Same renaming Node applies: symbol keys become SymbolX, string keys get their
// first character upper-cased.
Comment thread
dylan-conway marked this conversation as resolved.
function getNewKey(key) {
return typeof key === "symbol"
? `Symbol${key.description[7].toUpperCase()}${key.description.slice(8)}`
: `${key[0].toUpperCase()}${key.slice(1)}`;
}

function record(entry) {
entries.push(entry);
}

function copyOwnProperties(object, holder, prefix, mode) {
if (object === undefined || object === null) {
missing.push(holder);
return;
}
for (const key of Reflect.ownKeys(object)) {
const newKey = getNewKey(key);
const desc = Reflect.getOwnPropertyDescriptor(object, key);
const symbolKey = typeof key === "symbol";
// Original attributes, so a descriptor can be rebuilt pristinely by the generator.
const attributes = { enumerable: desc.enumerable, configurable: desc.configurable, writable: desc.writable };
if ("get" in desc) {
record({
name: `${prefix}Get${newKey}`,
holder,
key: keyDescription(key),
symbolKey,
kind: "Getter",
attributes,
});
if (desc.set)
record({
name: `${prefix}Set${newKey}`,
holder,
key: keyDescription(key),
symbolKey,
kind: "Setter",
attributes,
});
continue;
}
const name = `${prefix}${newKey}`;
const value = desc.value;
const type = value === null ? "null" : typeof value;
if (type === "function") {
// mode: "uncurried" (prototype methods), "static", or "bound" (receiver-bound statics).
record({ name, holder, key: keyDescription(key), symbolKey, kind: "Method", call: mode, attributes });
} else if (type === "object" || type === "symbol") {
record({ name, holder, key: keyDescription(key), symbolKey, kind: "Value", valueType: type, attributes });
} else {
// Spec constants (constructor length/name, Math/Number constants, BYTES_PER_ELEMENT,
// Symbol.toStringTag strings): inlined as literals rather than read at runtime.
Comment thread
dylan-conway marked this conversation as resolved.
const literal = type === "string" ? JSON.stringify(value) : String(value);
record({ name, holder, key: keyDescription(key), symbolKey, kind: "Literal", literal, attributes });
}
if (varargsMethods.includes(name)) record({ name: `${name}Apply`, kind: "ApplyVariant", base: name });
}
}

const G = globalThis;

// Configurable value properties of the global object.
record({ name: "Proxy", kind: "HolderSelf", holder: "ProxyObject" });
// The `globalThis` user code observes is the global's own globalThis property
// (an accessor to the global-this object), not the global object itself.
Comment thread
dylan-conway marked this conversation as resolved.
record({
name: "globalThis",
holder: "GlobalObject",
key: "globalThis",
symbolKey: false,
kind: "Value",
valueType: "object",
});
for (const name of ["decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "eval", "unescape"])
record({ name, holder: "GlobalObject", key: name, symbolKey: false, kind: "Method", call: "static" });

// Namespace objects.
for (const name of ["Atomics", "JSON", "Math", "Reflect"]) copyOwnProperties(G[name], `${name}Object`, name, "static");
copyOwnProperties(G.Proxy, "ProxyObject", "Proxy", "static");

// Intrinsic constructors: the constructor itself, its own properties, and its prototype's.
for (const name of [
"AggregateError",
"Array",
"ArrayBuffer",
"BigInt",
"BigInt64Array",
"BigUint64Array",
"Boolean",
"DataView",
"Date",
"Error",
"EvalError",
"FinalizationRegistry",
"Float16Array",
"Float32Array",
"Float64Array",
Comment thread
claude[bot] marked this conversation as resolved.
"Function",
"Int16Array",
"Int32Array",
Comment thread
claude[bot] marked this conversation as resolved.
"Int8Array",
"Iterator",
"Map",
"Number",
"Object",
"RangeError",
"ReferenceError",
"RegExp",
"Set",
"String",
"Symbol",
"SyntaxError",
"TypeError",
"URIError",
"Uint16Array",
"Uint32Array",
"Uint8Array",
"Uint8ClampedArray",
"WeakMap",
"WeakRef",
"WeakSet",
]) {
record({ name, kind: "HolderSelf", holder: `${name}Constructor` });
copyOwnProperties(G[name], `${name}Constructor`, name, "static");
copyOwnProperties(G[name]?.prototype, `${name}Prototype`, `${name}Prototype`, "uncurried");
}

// Constructors whose statics need the constructor as receiver (Promise.all etc.).
for (const name of ["Promise"]) {
record({ name, kind: "HolderSelf", holder: `${name}Constructor` });
copyOwnProperties(G[name], `${name}Constructor`, name, "bound");
copyOwnProperties(G[name].prototype, `${name}Prototype`, `${name}Prototype`, "uncurried");
}

// %TypedArray%: not on the global object; statics need a concrete constructor receiver.
{
const TypedArray = Reflect.getPrototypeOf(Uint8Array);
record({ name: "TypedArray", kind: "HolderSelf", holder: "TypedArrayConstructor" });
copyOwnProperties(TypedArray, "TypedArrayConstructor", "TypedArray", "uncurried");
copyOwnProperties(TypedArray.prototype, "TypedArrayPrototype", "TypedArrayPrototype", "uncurried");
}

// Abstract prototypes with no exposed constructor.
for (const [name, object] of [
["ArrayIteratorPrototype", Reflect.getPrototypeOf([][Symbol.iterator]())],
["AsyncFunctionPrototype", Reflect.getPrototypeOf(async function () {})],
["AsyncGeneratorFunctionPrototype", Reflect.getPrototypeOf(async function* () {})],
["AsyncIteratorPrototype", Reflect.getPrototypeOf(Reflect.getPrototypeOf(async function* () {}).prototype)],
["GeneratorFunctionPrototype", Reflect.getPrototypeOf(function* () {})],
["IteratorHelperPrototype", Reflect.getPrototypeOf([].values().drop(0))],
["MapIteratorPrototype", Reflect.getPrototypeOf(new Map()[Symbol.iterator]())],
["RegExpStringIteratorPrototype", Reflect.getPrototypeOf(RegExp.prototype[Symbol.matchAll].call(/a/g, "a"))],
["SetIteratorPrototype", Reflect.getPrototypeOf(new Set()[Symbol.iterator]())],
["StringIteratorPrototype", Reflect.getPrototypeOf(""[Symbol.iterator]())],
[
"WrapForValidIteratorPrototype",
Reflect.getPrototypeOf(
Iterator.from({
next() {
return { done: true };
},
}),
),
],
]) {
record({ name, kind: "HolderSelf", holder: name });
copyOwnProperties(object, name, name, "uncurried");
}

// Bun.write is native: the probe must not depend on the module it generates.
await Bun.write(Bun.stdout, JSON.stringify({ entries, missing }));
Loading
Loading