You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add Node-style primordials to runtime builtins
The runtime's builtins install globals and leave closures behind that keep
running for the lifetime of the app: event dispatch, the Promise proxy traps,
console's smart-stringify, __extends. Those closures reached for intrinsics
(Array.prototype.slice, JSON.stringify, Object.create, ...) through the live
globals, so app code replacing one could break or observe runtime internals.
primordials.js captures the intrinsics the other builtins need into a frozen,
null-prototype namespace and BuiltinLoader passes it to every builtin as a
second fixed parameter next to `binding`. It is built lazily on the first
RunBuiltin of an isolate — during runtime init, before user code — and cached
in Caches, so workers snapshot their own realm and late-compiling builtins
still see pristine intrinsics.
Instance methods are uncurried Node-style, `uncurryThis(fn)` being
Function.prototype.bind.bind(Function.prototype.call): ArrayPrototypeSlice(list, 1)
rather than list.slice(1). Benchmarked under jitless (which is how the runtime
always runs on device) uncurried calls cost +5-12% per op over a raw method
call but beat the captured-and-.call() alternative, so they are used uniformly.
ESLint gains no-restricted-properties for the captured statics and
no-restricted-globals for the captured constructors, each pointing at the
replacement; uncurried instance-method use stays a review rule since the
receiver cannot be matched.
0 commit comments