Skip to content

perf: make the sandboxed preload Buffer global lazy - #54034

Closed
trop[bot] wants to merge 1 commit into
45-x-yfrom
trop/45-x-y-bp-perf-make-the-sandboxed-preload-buffer-global-lazy-1789682868793
Closed

trop[bot] wants to merge 1 commit into
45-x-yfrom
trop/45-x-y-bp-perf-make-the-sandboxed-preload-buffer-global-lazy-1789682868793

Conversation

@trop

@trop trop Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Backport of #53855

See that PR for details.

Notes: Reduced sandboxed renderer startup work for preload scripts that do not use Buffer.

With context isolation the preload realm's global is private to preloads, so
Buffer is defined there as a property that loads the polyfill on first use
instead of evaluating it for every frame before any preload runs. Without
context isolation it stays a preload-scoped parameter as before.

The persisted preload code cache is now also keyed on that wrapper shape,
because V8's cached-data check does not notice a changed parameter list.

Also drops the `Buffer` hidden value set on the sandboxed global; its native
consumer was removed in #34794.

With the wrapper shape now depending on where the bundle runs, the renderer
decides it from the actual script context (main world vs isolated world)
rather than the contextIsolation preference, and names the parameter list in
the compiled source so a persisted code cache produced for one shape is
rejected rather than run against the other.

Co-authored-by: Sam Attard <[email protected]>
@trop
trop Bot requested a review from MarshallOfSound September 17, 2026 22:08
@trop trop Bot mentioned this pull request Sep 17, 2026
6 tasks done
@trop trop Bot added 45-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Sep 17, 2026
@trop
trop Bot deleted the trop/45-x-y-bp-perf-make-the-sandboxed-preload-buffer-global-lazy-1789682868793 branch September 17, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

45-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant