Skip to content

Upgrade WebKit to fc9f2fa7272fec64905df6a9c78e15d7912f14ca - #28371

Merged
Jarred-Sumner merged 17 commits into
mainfrom
claude/webkit-upgrade-de176b3
Mar 22, 2026
Merged

Jarred-Sumner merged 17 commits into
mainfrom
claude/webkit-upgrade-de176b3

Conversation

@sosukesuzuki

@sosukesuzuki sosukesuzuki commented Mar 21, 2026 •

Copy link
Copy Markdown
Member

WebKit Upgrade Changes

Summary

Upgraded from WebKit commit a30d85f to 57cc442 (1650 commits total, 301 touching JSC/WTF/bmalloc).

Key Changes Affecting Bun

Microtask & Promise (⚠️ Breaking API Changes)

The MicrotaskQueue implementation moved entirely from WebCore into JSC. This changes several APIs Bun overrides/calls:

  • GlobalObjectMethodTable::queueMicrotaskToEventLoop hook removed — microtasks are now enqueued directly into a per-JSGlobalObject Ref<MicrotaskQueue> m_microtaskQueue.
  • JSGlobalObject::queueMicrotask signature changed — now takes VM& as first parameter:
    • void queueMicrotask(VM&, QueuedTask&&)
    • void queueMicrotask(VM&, InternalMicrotask, uint8_t, JSValue, JSValue, JSValue)
  • New JSGlobalObject::setMicrotaskQueue(Ref<MicrotaskQueue>&&) — hosts set a custom queue instead of implementing a method-table hook. Queue has scheduleToRunIfNeeded virtual.
  • New MicrotaskCall — a CachedCall-like fast-path for microtask invocation that caches FunctionExecutable*/CodeBlock*. callMicrotask now takes this parameter internally.
  • JSC::runMicrotask no longer exported — draining is done inside JSC via MicrotaskQueue::performMicrotaskCheckpoint.
  • New CrossTaskToken — VM now holds RefPtr<CrossTaskToken> carried between tasks (base class for WebCore's UserGestureToken).
  • Promise.resolve spec fix — subclass constructor no longer returns base Promise (cross-realm constructor check).
  • Micro-optimized triggerPromiseReactions, JSPromise C++ code, and MicrotaskQueue drain path.
  • New PerformPromiseThen DFG/FTL node.

Relevant commits: 113e989f0ab0, fa403f3bda25, 3692b888d679, cef91b6c3f11, 6309e93f8193, b6d94e4de12f, c1df92d228fc, 7a597ba1b58e, 40f8432a95e2

GlobalObjectMethodTable Changes

  • queueMicrotaskToEventLoop removed (see above).
  • compileStreaming / instantiateStreaming signature changed — now take std::optional<WebAssemblyCompileOptions>&&. Wrapped in #if ENABLE(WEBASSEMBLY) with void* placeholders when disabled.
  • JSGlobalObject::addStaticGlobals signature changed — now takes std::span<GlobalPropertyInfo> instead of (GlobalPropertyInfo*, int).

Header / Include Changes

  • MarkedVector broken out of ArgList.h into its own header (f7c81e42deb4).
  • JSPIContext moved out of VM.h (fcf736d4f9e9).
  • LIFETIME_BOUND annotations added to many getters in JSC and WTF (75c21debe092, 418eb5cfca82, 7d6d7706aac8).
  • WTF StringHasher streaming interface removed (756399f1473c).
  • RegisterSetBuilder merged into RegisterSet (b23dfb2b0212).
  • StructureStubInfo renamed to PropertyInlineCache (ffb03436fd34).

Parser & Language Features

  • Explicit Resource Management — using (4ca75592d165) and await using (92e52221d299) syntax implemented, plus several follow-up bytecode/spec fixes (6c959cf9637e, 57a48c393902, 138963318c87, 064f2d4d90ab, 9a3b8c612a49).
  • Lexer: integer fast path (dc352eb56d2c), fast '0' lexing (46eeb62ea27a).
  • Parser: improved VariableEnvironment map perf (577296de6a91), ScopeRef retired (c1a4f50e71dc), RestParameterNode direct binding (e89865c7f8c3).
  • Bytecode: emitBytecodeInConditionContext for ConditionalNode (ee963cf3db75), removed redundant to_string in single-expr template literals (c89babbf6441).

JIT / Optimization

  • Quick tier-up — quick DFG/FTL tier-up for proven-stable functions (9af814208502), recovery after reinstall (f92b82d07c51), threshold tuning (87d8e03a1a4b), jettison-during-finalization fix (66f509e2dccd), premature jettison fix (90a5bb45b586).
  • Property IC — StructureStubInfo → PropertyInlineCache rename, split into subclasses (d042d9b75315), combined Handler+Data IC (365ecfc0a511), megamorphic GetById handles String (65d02142320f).
  • RegExp IC — new RegExp#lastIndex IC (d2c63be26cd6).
  • Greedy register allocator coalescing rewrite (f8b9ab1a0bfa).
  • Air stack allocation worst-case improvement (c03651a49eb9).
  • FTL CompareStrictEq(Untyped) bit-trick fast path (089c67d2ead9).
  • ArrayIsArray intrinsic for Array.isArray (b7c903516b25).
  • Double Mod optimization in DFG/FTL (899d00c4aa72).
  • Better HeapBigIntUse speculation (38c024bb251e).
  • Fast C++ → JS calls on x64 (32de67469bf0).
  • s_maxTransitionLength bumped 64 → 128 (f6414a9cee54).

Runtime / GC

  • GC: distinguish UAF crashes from general memory corruption (80d2d35df693), Heap::writeBarrier GC-validation (682cd16441c4).
  • JSNativeStdFunction can safely capture (8ed6b76ec394).
  • Cloned SymbolTable cached per JSGlobalObject (5980a4242cc7).
  • ArrayBuffer: page-based zero-fill for large zero-clear (bee72f6e2750).
  • JSBigInt: shrink size (d2f75e3929bb), tighten hot path (22fb65b6b34b), cached remainder (559de0581a46), multiply uses result buffer (e4e7aafcdfd8).
  • Better rope resolution ordering heuristics (313be2bb1cf5).
  • String#includes uses tryFindOneChar (dbe0b0a08f9a).
  • containsHole uses WTF::find64 for double arrays (26af206baebb).
  • OrderedHashTableHelper storage mutation uses DeferTerminationForAWhile (f45f20af9c44).
  • Intl: std::unique_ptr for ICU resources, fixes UEnumeration leak (1566af375f80).

WebAssembly

  • WebAssembly.compileStreaming / .instantiateStreaming accept compileOptions (4f51c89e3c77, e075761ea48f).
  • address field added to memory descriptor (c7a099ccc935).
  • Memory64 bounds checking fixes in BBQ (653249798501, d8a913bd3feb).
  • SIMD: shuffle reduction (8eb745ff86d0), B3 SIMD shuffle optimization (99bafdf6e24a, 72cb0c48cb44), x64 SIMD optimizations (8528edac562f), ARM64 simple shl/ushr/sshr (b349f3567217), more SIMD lowering (dbf8cb7e3ecc).
  • BBQ: csel/fcsel for select (6708616ef5ef).
  • OMG: write-barrier aligned to FTL (8b75d8f65733), tail-call scratch clobber (4572dd488e4e), F32 float storage (a73d24da9011).
  • Element entry count limited to 10M per spec (3e5413522e4c).
  • Polymorphic inlining of indirect calls gets Rare annotation (9d8c6b94fcc4).

RegExp / YARR

  • Named vs numbered backreferences distinguished (12ef604ef990).
  • Multiple backtracking/capture-clearing JIT fixes (0bebf49082ee, fbd2a11004f4, 2fb117dc7dcd).
  • String#replace surrogate-advancement fix for non-unicode regexps (13f7de0a8f94).
  • DFG strength reduction lastIndex clobber fix (a3789656ce60).
  • RegExpMatchFastGlobal must-generate to prevent FTL DCE (e8f0cb20dfb0).

Bug Fixes (Spec / Correctness)

  • TypedArray#sort when comparator accesses .buffer (b9c004b3c5be).
  • Array#includes(undefined, fromIndex) hole handling (b2cf11dd2959).
  • Array#flat depth-0 / DerivedArray bailout (58336b9e2fcd).
  • Array.p.concat checks all indexed accessors (131349b225e3).
  • Array.prototype.copyWithin return value (685247318fa2).
  • Set methods throw on non-object iterator next() result (4d96716c8dc8).
  • RegExp#@@matchAll lastIndex clamping (8cfdd1d58057).
  • Temporal.PlainDate.from SIGSEGV fix (ce0c3918570d).
  • AsyncDisposableStack#disposeAsync stack overflow fix (9a3b8c612a49).
  • Don't set attributes on private fields when sealing/freezing (672cdd38781c).
  • DFG: preserve ToNumber side-effect for Math.pow(x) (dfddac02cb48), iterator_next/open Phantom emission (d9b3841d9b3f), ShadowChicken cannot-exit (9d596abdce46), PhantomNewArrayWithButterfly exception handling (0dbabc018f3f), MapIterationEntryKey result type (3f6f7836068a), MultiGetByOffsetMethod double conversion (f2c5bf80637a).
  • FTL BigInt comparison fixes (dc46995eb9ed).
  • LLInt arity fix against sp (2a07f263519f).
  • B3 ReduceStrength Int52→Int32 unsound optimization (1c537b0aea64).

libpas / bmalloc

  • libpas: retag-on-scavenge + soft-mode enabled (bdbe48f72fba), page-based zeroing threshold 64MB→1MB (b245c6393674), unconditional tag-on-alloc (b754353fb35e), bitfit heaps used quickly (dee9781145cf), PAS_ASSERT unified (7b43a563bdda), futex lock on PlayStation (15957d955111).
  • bmalloc: BASSERT rerouted to libpas asserts when available (736a08b1bbf5).

WTF

  • Deque made branchless (f3b792ece3b9).
  • HashTable: removeIf early-return when null (519967f72252), skip destructor for trivially-destructible (93262de2b325), batch count updates in weak cleanup (69aae74416c4), weak-pointer lookup hardening (2ace7bf41640).
  • SIMD pair search (cf507455abeb).
  • String from null ASCIILiteral → null String (30479f7ed01f).
  • CheckedPtr/CheckedRef constructible from WeakPtr/WeakRef (687172c1a2f2).
  • C++20 IntegralOrEnum concept (0090c1577f59).

CI Status

Known pre-existing failures (not caused by this PR)

Linux bundler_compile.test.ts timeouts — These are caused by PR #26923 (ELF section for standalone binaries), which was merged to main on Mar 19. That PR:

  1. Changed describe("bundler", ...) → describe.concurrent("bundler", ...) in bundler_compile.test.ts
  2. Changed the Linux inject path from a simple append (~2KB write) to reading the entire executable into memory, modifying the ELF, and rewriting everything (~120MB I/O per compile)

With 20 concurrent compile tests each doing ~1.5GB of I/O (copy + read + write of a ~500MB profile binary), Linux CI machines exhaust resources. The ELF PR's own CI (build #40193) shows identical failures on all Linux x64 targets.

Fixed in this PR by reverting the describe.concurrent back to sequential describe.

Fixed in this PR

  • Windows bundler_defer.test.ts — Made the FinalizationRegistry test more robust by using a bounded gc+sleep loop instead of a single Bun.gc(true) + await.

darwin webview.test.ts / webview-chrome.test.ts timeouts — Pre-existing from PR #28185 (merged Mar 20). That PR's own CI (build #40403) shows identical darwin failures. The click(selector) tests rely on requestAnimationFrame which doesn't fire on CI macOS's (0,0) alpha=0 window (CVDisplayLink throttling). Not caused by this WebKit upgrade.

@robobun

robobun commented Mar 21, 2026 •

Copy link
Copy Markdown
Collaborator
Updated 5:31 AM PT - Mar 22nd, 2026

❌ @sosukesuzuki, your commit cabf10d has 2 failures in Build #40995 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 28371

That installs a local version of the PR into your bun-28371 executable, so you can run:

bun-28371 --bun

@coderabbitai

coderabbitai Bot commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Updated default WebKit commit; removed event-loop queue helpers from several global method tables; migrated many GC visitor hooks to GC-thread variants; added explicit VM argument to numerous promise resolve calls; adjusted WebAssembly streaming APIs, generated static-global emission, wasm memory clone behavior, tests, and an allowlist.

Changes

Cohort / File(s) Summary
WebKit configuration
cmake/tools/SetupWebKit.cmake, scripts/build/deps/webkit.ts
Updated fallback/default WEBKIT_VERSION from b55703a58c8e57ac3479b9ba5cd434386a298965 → fc9f2fa7272fec64905df6a9c78e15d7912f14ca.
Event-loop hook removals
src/bake/BakeGlobalObject.cpp, src/bun.js/bindings/NodeVM.cpp, src/bun.js/bindings/ZigGlobalObject.cpp
Removed queueMicrotaskToEventLoop / queueTaskToEventLoop local helpers from global object method tables and related initialization.
Promise resolves: pass VM
src/bun.js/bindings/.../BunAnalyzeTranspiledModule.cpp, .../JSSecrets.cpp, .../ModuleLoader.cpp, .../NodeTimerObject.cpp, .../bindings.cpp, .../webcore/JSDOMPromiseDeferred.cpp, .../webcore/JSWorker.cpp, .../webview/JSWebView.cpp, src/bun.js/bindings/BunGCOutputConstraint.cpp
Replaced promise->resolve(globalObject, ...) with promise->resolve(globalObject, vm, ...) (or equivalent) at multiple call sites to pass the active VM.
GC visitor renames (to GC-thread)
src/bun.js/bindings/webcore/..., src/bun.js/bindings/sqlite/JSSQLStatement.cpp, src/bun.js/bindings/JSMockFunction.cpp, src/bun.js/bindings/JSBundlerPlugin.cpp
Renamed template hook visitAdditionalChildren(Visitor&) → visitAdditionalChildrenInGCThread(Visitor&); updated call sites and macros from DEFINE_VISIT_ADDITIONAL_CHILDREN → DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD across many classes.
ZigGlobalObject — WASM streaming & statics
src/bun.js/bindings/ZigGlobalObject.cpp, src/bun.js/bindings/ZigGlobalObject.h, src/codegen/bundle-functions.ts
Adjusted compileStreaming/instantiateStreaming signatures to accept std::optional<JSC::WebAssemblyCompileOptions>&&; created streaming compiler with std::nullopt; switched to addStaticGlobals(staticGlobals) overload.
Wasm memory cloning
src/bun.js/bindings/webcore/SerializedScriptValue.cpp
Pass addressType from created JSWebAssemblyMemory into Wasm::Memory::create(...) / createZeroSized(...) during clone deserialization.
Codegen: visitor and statics
src/codegen/generate-classes.ts
Generator now emits visitAdditionalChildrenInGCThread and DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD, updates call sites, and uses addStaticGlobals(staticGlobals) overload.
Misc — tests & allowlist
test/js/bun/s3/s3-fd-validation.test.ts, scripts/verify-baseline-static/allowlist-x64-windows.txt, test/bundler/expectBundled.ts
Reordered named imports in a test; added two MSVC-STL vectorized-algorithm symbols to x64-windows allowlist; updated spawn usage to await using with a 60_000ms timeout in a test helper.

Suggested reviewers

  • cirospaciari
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: upgrading WebKit to a specific commit hash. It is concise, specific, and directly reflects the primary objective of the changeset.
Description check ✅ Passed The PR description is comprehensive and detailed, covering the WebKit upgrade with specific commit hashes, API changes, and affected subsystems.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/bun.js/bindings/JSBundlerPlugin.cpp (1)

161-216: ⚠️ Potential issue | 🔴 Critical

Add the missing DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSBundlerPlugin) macro.

This file renames the helper function and updates call sites but omits the macro registration present in all other migrated bindings. Without it, the visitAdditionalChildrenInGCThread hook may not be properly wired into JSC's garbage collection system.

🔧 Suggested fix
 DEFINE_VISIT_CHILDREN(JSBundlerPlugin);
+DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSBundlerPlugin);
 
 template<typename Visitor>
 void JSBundlerPlugin::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/bun.js/bindings/JSBundlerPlugin.cpp` around lines 161 - 216, The file
defines JSBundlerPlugin::visitAdditionalChildrenInGCThread but forgot to
register it with the JSC GC macros; add the macro invocation
DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSBundlerPlugin) alongside the
existing DEFINE_VISIT_CHILDREN(JSBundlerPlugin) and
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSBundlerPlugin) so the
visitAdditionalChildrenInGCThread hook is properly wired into JSC's garbage
collector for the JSBundlerPlugin class.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmake/tools/SetupWebKit.cmake`:
- Around line 8-10: The change sets WEBKIT_VERSION to a commit SHA that has no
matching release tag in oven-sh/WebKit, which will break downloading prebuilt
artifacts; revert or remove the hardcoded default in SetupWebKit.cmake (the
set(WEBKIT_VERSION de176b300e6545e3dbb2049e38ef1e22d943b3e0) line) and instead
leave WEBKIT_VERSION unset or set it to a known-good release tag, then verify
the release tag named autobuild-<sha> exists in the oven-sh/WebKit repository
(or that prebuilt artifacts are published) before reintroducing this specific
value. Ensure references to WEBKIT_VERSION in the rest of the script continue to
work when it is unset and update any documentation or CI that relies on a
default.

In `@src/bun.js/bindings/ZigGlobalObject.cpp`:
- Line 3432: The compileStreaming and instantiateStreaming functions currently
accept an unnamed std::optional<JSC::WebAssemblyCompileOptions>&& but never
forward it to handleResponseOnStreamingAction, causing StreamingCompiler::create
to be called with std::nullopt; fix this by naming the parameter (e.g.,
compileOptions) in compileStreaming/instantiateStreaming, thread that
compileOptions through to handleResponseOnStreamingAction, and ensure
handleResponseOnStreamingAction forwards the optional to
StreamingCompiler::create (replace the std::nullopt argument at the
StreamingCompiler::create call with the forwarded compileOptions) so callers'
WebAssemblyCompileOptions are respected.

---

Outside diff comments:
In `@src/bun.js/bindings/JSBundlerPlugin.cpp`:
- Around line 161-216: The file defines
JSBundlerPlugin::visitAdditionalChildrenInGCThread but forgot to register it
with the JSC GC macros; add the macro invocation
DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSBundlerPlugin) alongside the
existing DEFINE_VISIT_CHILDREN(JSBundlerPlugin) and
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSBundlerPlugin) so the
visitAdditionalChildrenInGCThread hook is properly wired into JSC's garbage
collector for the JSBundlerPlugin class.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9fa81b51-48ed-4514-92b7-2bd7a9f0e94e

📥 Commits

Reviewing files that changed from the base of the PR and between db2156e and 28319ea.

📒 Files selected for processing (48)
  • cmake/tools/SetupWebKit.cmake
  • src/bake/BakeGlobalObject.cpp
  • src/bun.js/bindings/BunAnalyzeTranspiledModule.cpp
  • src/bun.js/bindings/BunGCOutputConstraint.cpp
  • src/bun.js/bindings/JSBundlerPlugin.cpp
  • src/bun.js/bindings/JSMockFunction.cpp
  • src/bun.js/bindings/JSSecrets.cpp
  • src/bun.js/bindings/ModuleLoader.cpp
  • src/bun.js/bindings/NodeTimerObject.cpp
  • src/bun.js/bindings/NodeVM.cpp
  • src/bun.js/bindings/ZigGlobalObject.cpp
  • src/bun.js/bindings/ZigGlobalObject.h
  • src/bun.js/bindings/bindings.cpp
  • src/bun.js/bindings/sqlite/JSSQLStatement.cpp
  • src/bun.js/bindings/webcore/CustomEventCustom.cpp
  • src/bun.js/bindings/webcore/JSAbortSignal.cpp
  • src/bun.js/bindings/webcore/JSAbortSignal.h
  • src/bun.js/bindings/webcore/JSAbortSignalCustom.cpp
  • src/bun.js/bindings/webcore/JSCustomEvent.cpp
  • src/bun.js/bindings/webcore/JSCustomEvent.h
  • src/bun.js/bindings/webcore/JSDOMPromiseDeferred.cpp
  • src/bun.js/bindings/webcore/JSErrorEvent.cpp
  • src/bun.js/bindings/webcore/JSErrorEvent.h
  • src/bun.js/bindings/webcore/JSErrorEventCustom.cpp
  • src/bun.js/bindings/webcore/JSEventEmitter.cpp
  • src/bun.js/bindings/webcore/JSEventEmitter.h
  • src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp
  • src/bun.js/bindings/webcore/JSEventTarget.cpp
  • src/bun.js/bindings/webcore/JSEventTarget.h
  • src/bun.js/bindings/webcore/JSEventTargetCustom.cpp
  • src/bun.js/bindings/webcore/JSMessageChannel.cpp
  • src/bun.js/bindings/webcore/JSMessageChannel.h
  • src/bun.js/bindings/webcore/JSMessageChannelCustom.cpp
  • src/bun.js/bindings/webcore/JSMessageEvent.cpp
  • src/bun.js/bindings/webcore/JSMessageEvent.h
  • src/bun.js/bindings/webcore/JSMessageEventCustom.cpp
  • src/bun.js/bindings/webcore/JSMessagePort.cpp
  • src/bun.js/bindings/webcore/JSMessagePort.h
  • src/bun.js/bindings/webcore/JSMessagePortCustom.cpp
  • src/bun.js/bindings/webcore/JSPerformanceObserver.cpp
  • src/bun.js/bindings/webcore/JSPerformanceObserver.h
  • src/bun.js/bindings/webcore/JSPerformanceObserverCustom.cpp
  • src/bun.js/bindings/webcore/JSWorker.cpp
  • src/bun.js/bindings/webcore/SerializedScriptValue.cpp
  • src/bun.js/webview/JSWebView.cpp
  • src/codegen/bundle-functions.ts
  • src/codegen/generate-classes.ts
  • test/js/bun/s3/s3-fd-validation.test.ts
💤 Files with no reviewable changes (2)
  • src/bun.js/bindings/NodeVM.cpp
  • src/bake/BakeGlobalObject.cpp

Comment thread src/bun.js/bindings/ZigGlobalObject.cpp Resolved

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This large WebKit upgrade touching 47 files with breaking API changes across core JSC integration points warrants a human review.

Extended reasoning...

Overview

This PR upgrades WebKit from commit b55703a to de176b3 (1650 upstream commits), modifying 47 files across cmake, codegen templates, and C++ bindings throughout src/bun.js/bindings/ and src/bake/.

Security Risks

No direct security vulnerabilities introduced. The WebKit upgrade brings GC hardening (writeBarrier validation, UAF crash distinguishing, weak-pointer lookup hardening) which may reduce attack surface.

Level of Scrutiny

High scrutiny appropriate. Changes span critical subsystems:

  • Promise resolution: every promise->resolve() updated to add vm parameter (15+ call sites)
  • Microtask queue: removal of queueMicrotaskToEventLoop hook is an architectural change affecting how Bun integrates with JSCs microtask scheduling
  • GC visitors: mechanical rename of visitAdditionalChildren to visitAdditionalChildrenInGCThread across many DOM-binding objects
  • WebAssembly: Memory::create and streaming compiler signatures changed

Other Factors

Bug hunting found no issues. CI build triggered. Changes follow established WebKit upgrade patterns and appear mechanically correct. However, the scope (47 files) plus the microtask scheduling architectural change justify human validation before merge.

@sosukesuzuki sosukesuzuki changed the title Upgrade WebKit to de176b300e6545e3dbb2049e38ef1e22d943b3e0 Upgrade WebKit to fc9f2fa7272fec64905df6a9c78e15d7912f14ca Mar 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmake/tools/SetupWebKit.cmake`:
- Around line 8-10: The WEBKIT_VERSION variable was bumped to
fc9f2fa7272fec64905df6a9c78e15d7912f14ca but the corresponding release tag
autobuild-fc9f2fa7272fec64905df6a9c78e15d7912f14ca is not published yet; revert
the WEBKIT_VERSION change in SetupWebKit.cmake (restore the prior commit hash)
or gate this change until the prebuilts are published by removing the new hash
from the set(WEBKIT_VERSION ...) assignment and/or adding a pre-check that
validates the existence of the release tag before attempting to download
prebuilts (use the WEBKIT_VERSION symbol and the expected
autobuild-<WEBKIT_VERSION> tag name in the check).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ed440143-3290-47f4-bd73-3df0198e2cde

📥 Commits

Reviewing files that changed from the base of the PR and between 28319ea and 14276e7.

📒 Files selected for processing (1)
  • cmake/tools/SetupWebKit.cmake

Comment on lines 8 to 10
if(NOT WEBKIT_VERSION)
set(WEBKIT_VERSION b55703a58c8e57ac3479b9ba5cd434386a298965)
set(WEBKIT_VERSION fc9f2fa7272fec64905df6a9c78e15d7912f14ca)
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

TAG="autobuild-fc9f2fa7272fec64905df6a9c78e15d7912f14ca"
REPO="oven-sh/WebKit"

echo "== Checking if release tag ${TAG} exists =="
if gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then
  echo "OK: Release tag exists"
else
  echo "FAIL: Release tag ${TAG} not found in ${REPO}"
  exit 1
fi

echo
echo "== Listing release assets =="
gh release view "$TAG" --repo "$REPO" --json assets --jq '.assets[].name' | sort

echo
echo "== Checking for expected platform artifacts =="
expected_assets=(
  "bun-webkit-linux-amd64-lto.tar.gz"
  "bun-webkit-linux-arm64-lto.tar.gz"
  "bun-webkit-macos-amd64-lto.tar.gz"
  "bun-webkit-macos-arm64-lto.tar.gz"
  "bun-webkit-windows-amd64-lto.tar.gz"
)

ASSETS_JSON="$(gh release view "$TAG" --repo "$REPO" --json assets)"
missing=0
for name in "${expected_assets[@]}"; do
  if echo "$ASSETS_JSON" | jq -e --arg n "$name" '.assets[] | select(.name == $n)' >/dev/null; then
    echo "OK   $name"
  else
    echo "MISS $name"
    missing=1
  fi
done

if [[ "$missing" -ne 0 ]]; then
  echo
  echo "WARN: Some expected artifacts may be missing"
fi

Repository: oven-sh/bun

Length of output: 239


Do not merge until the WebKit release is published.

The WEBKIT_VERSION is updated to fc9f2fa7272fec64905df6a9c78e15d7912f14ca, but the corresponding release tag autobuild-fc9f2fa7272fec64905df6a9c78e15d7912f14ca does not exist in oven-sh/WebKit. The build will fail when attempting to download prebuilt artifacts. The WebKit prebuilts must be built and published to the release page before this change can merge.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmake/tools/SetupWebKit.cmake` around lines 8 - 10, The WEBKIT_VERSION
variable was bumped to fc9f2fa7272fec64905df6a9c78e15d7912f14ca but the
corresponding release tag autobuild-fc9f2fa7272fec64905df6a9c78e15d7912f14ca is
not published yet; revert the WEBKIT_VERSION change in SetupWebKit.cmake
(restore the prior commit hash) or gate this change until the prebuilts are
published by removing the new hash from the set(WEBKIT_VERSION ...) assignment
and/or adding a pre-check that validates the existence of the release tag before
attempting to download prebuilts (use the WEBKIT_VERSION symbol and the expected
autobuild-<WEBKIT_VERSION> tag name in the check).

Comment thread src/bun.js/bindings/ZigGlobalObject.cpp Resolved
sosukesuzuki and others added 6 commits March 21, 2026 21:37
JSBigInt.cpp now uses std::min({initializer_list}) which pulls in
MSVC STL's __std_minmax implementation with AVX/AVX-512 instructions.
These are runtime-gated by __isa_available.
This ensures spawned subprocesses are killed when they hang,
preventing zombie processes from starving concurrent tests.
WebKit's CRASH() macro now uses WTFBreakpointTrap() on Linux release
builds (int3 on x64, brk on arm64), which raises SIGTRAP instead of
the previous SIGSEGV at 0xbbadbeef from WTFCrash(). Without a SIGTRAP
handler, a failed RELEASE_ASSERT would cause undefined behavior as
execution falls through to __builtin_unreachable() after the trap
signal is handled without re-raising.
The bytecode compile tests hang consistently on Linux CI. These changes
add a granular diagnostic test that separately exercises each phase
(plain build, bytecode only, compile only, both, run compiled) so we
can see exactly which step hangs. Also adds signalCode reporting when
build/run subprocesses are killed by timeout.
Comment thread src/crash_handler.zig Resolved
The SIGTRAP handler addition broke child_process.test.ts which expects
SIGTRAP signal to be reported as-is. The crash handler was catching it
and converting the exit to SIGILL. Since default SIGTRAP disposition
is terminate (not ignore), WebKit RELEASE_ASSERT failures would still
terminate the process correctly without Bun's handler.

The prefix variable in expectBundled.ts was out of scope in the build
signalCode check, preventing us from seeing the subprocess output.

Added 10 concurrent compile tests to the diagnostic - if these hang
but the sequential ones pass, the issue is concurrency-related.
The Linux bundler_compile.test.ts hang is a pre-existing issue from
PR #26923 (ELF section for standalone binaries), not from the WebKit
upgrade. That PR added describe.concurrent to bundler_compile.test.ts
and changed the Linux inject path from a simple append to reading and
rewriting the entire executable. With 20 concurrent compiles of a
~500MB profile binary, this causes resource exhaustion. The ELF PR's
own CI (build #40193) shows the same failures.
The test was hanging on Windows waiting for FinalizationRegistry
callbacks that never fired after a single Bun.gc(true). GC doesn't
guarantee immediate finalization, especially across event loop ticks.
Replace the single await with a bounded loop that repeatedly invokes
GC and yields to the event loop, giving DeferredWorkTimer callbacks
a chance to run.
PR #26923 changed this to describe.concurrent and also changed the
Linux ELF inject path from a simple append to reading + rewriting the
entire executable. With profile builds at ~500MB, running 20 concurrent
compiles exhausts CI resources. Sequential execution avoids this
resource contention. The ELF PR's own CI (build #40193) shows identical
timeouts on all Linux x64 targets.
Comment on lines 273 to 282
if (opts->error.type == Secrets::ErrorType::NotFound) {
if (opts->op == SecretsJobOptions::GET) {
// For GET operations, NotFound resolves with null
RELEASE_AND_RETURN(scope, promise->resolve(global, jsNull()));
RELEASE_AND_RETURN(scope, promise->resolve(global, vm, jsNull()));
} else if (opts->op == SecretsJobOptions::DELETE_OP) {
// For DELETE_OP operations, NotFound means we return false
RELEASE_AND_RETURN(scope, promise->resolve(global, jsBoolean(false)));
RELEASE_AND_RETURN(scope, promise->resolve(global, vm, jsBoolean(false)));
}
}
JSValue error = opts->error.toJS(vm, global);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟣 Pre-existing bug: Bun.secrets.delete(service, name) fails silently when called with two positional string arguments because case DELETE_OP: falls through to case SET: which requires 3 positional args instead of 2. This is a pre-existing issue unrelated to this PR's WebKit upgrade changes.

Extended reasoning...

What the bug is

In SecretsJobOptions::fromJS() (JSSecrets.cpp), the case DELETE_OP: label has no body and falls through to case SET:. The shared positional-argument path inside that combined block checks args.size() > 2, requiring three string arguments (service, name, value). But DELETE_OP only needs two arguments (service + name) — there is no value to delete. So any call like Bun.secrets.delete("myService", "myKey") with two positional strings skips the fast path entirely and falls into fromOptionsObject(), which throws "Expected options to be an object" because the second argument is a string, not an options object.

The specific code path

0 ""

0 ""

0 ""

1 "/usr/include/stdc-predef.h" 1 3 4

0 "" 2

1 ""

By contrast, case GET: correctly uses args.size() > 1 in its own branch, requiring only 2 string args.

Why existing code does not prevent it

The fall-through is intentional for the options-object form (both SET and DELETE can accept {service, name, value} / {service, name} objects), but the positional-argument guard was written with only SET in mind (which genuinely needs 3 args: service, name, value). Nobody added a separate positional check for DELETE_OP that needs only 2.

Impact

Any caller using the convenient Bun.secrets.delete('service', 'name') positional form receives a runtime error instead of a successful deletion. The options-object form Bun.secrets.delete({ service: 'x', name: 'y' }) works correctly. This is a silent behavioral regression for users who follow the documented positional API.

Step-by-step proof

  1. User calls: await Bun.secrets.delete('com.example', 'API_KEY')
  2. JS glue marshals this as callWithThisValueAndArguments -> fromJS(globalObject, args) where args = ['com.example', 'API_KEY'], args.size() == 2, op == DELETE_OP
  3. Switch hits case DELETE_OP: — no body — falls to case SET:
  4. Guard args.size() > 2 -> 2 > 2 -> false — positional path skipped
  5. fromOptionsObject() is called; it looks at args.at(0) expecting an object, finds a string -> throws "Expected options to be an object"
  6. Promise rejects with that error instead of deleting the secret

How to fix it

Give DELETE_OP its own case block before SET:, mirroring the GET: pattern but checking args.size() > 1:

0 ""

0 ""

0 ""

1 "/usr/include/stdc-predef.h" 1 3 4

0 "" 2

1 ""

Pre-existing classification

This PR's only change to JSSecrets.cpp is updating promise->resolve(global, value) to promise->resolve(global, vm, value) to match the new WebKit JSPromise API. The argument-parsing logic in fromJS() was not touched by this PR.

After reverting to sequential describe, the test passes 39 tests in
3 minutes on ASAN before hitting the file-level timeout. With 54 total
compile tests each needing ~4.6s sequentially on ASAN (due to the ELF
inject path reading + rewriting the entire ~800MB binary), the total
needed is ~250s which exceeds the default 3-minute testTimeout but
fits within the 5-minute integrationTimeout.
…pe read

- Forward WebAssemblyCompileOptions through compileStreaming/instantiateStreaming
  to StreamingCompiler::create instead of dropping it. The new JSC API accepts
  compile options (e.g. JS string builtins) and we were silently ignoring them.

- Replace result->memory().addressType() with explicit Wasm::AddressType::I32
  in SerializedScriptValue WasmMemoryTag deserialization. The call was reading
  from an uninitialized stub before result->adopt() is called. Memory64 isn't
  serialized in WasmMemoryTag anyway, so I32 is the only correct value.
  (Upstream WebKit has the same latent bug.)

- Add missing DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSBundlerPlugin)
  for consistency with other classes (was pre-existing, but harmless to add).

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addressType and WebAssemblyCompileOptions bugs raised in earlier inline comments were fixed in cabf10d — LGTM.

Extended reasoning...

Overview

This PR upgrades WebKit from b55703a to fc9f2fa (1650 upstream commits, 301 touching JSC/WTF/bmalloc), adapting Bun's bindings to API changes in the new JSC. Changed files span 54 files across C++ bindings, codegen, and tests. The code changes are largely mechanical: method renames (visitAdditionalChildren → visitAdditionalChildrenInGCThread), macro renames, adding a vm parameter to JSPromise::resolve, forwarding a new WebAssemblyCompileOptions&& parameter, removing the now-deleted queueMicrotaskToEventLoop hook, and switching addStaticGlobals to the new std::span overload.

Security Risks

No security-sensitive changes are present. The promise/GC/Wasm API changes are adapting to upstream JSC behavior, not introducing new attack surface. The SerializedScriptValue.cpp fix explicitly documents the Memory64 limitation rather than silently passing wrong data.

Level of Scrutiny

Although the PR is large in scope, the changes are faithful mechanical adaptations to upstream API breakage — the kind that accumulate across a WebKit bump. Two substantive bugs were found and fixed by cabf10d: (1) WebAssemblyCompileOptions being unnamed/unforwarded, and (2) result->memory().addressType() being called on an uninitialized stub before result->adopt(). Both are now correctly resolved. The remaining flagged items (JSSQLStatement missing macro, JSSecrets DELETE_OP fallthrough) are pre-existing bugs not introduced by this PR.

Other Factors

CI failures mentioned in the robobun comment (v8-heap-snapshot.test.ts illegal instruction on Windows aarch64, bake/dev/stress.test.ts on Windows 2019 x64) appear to be pre-existing issues unrelated to this WebKit upgrade, consistent with the PR description noting known pre-existing failures. The test improvements (sequential bundler describe, robust FinalizationRegistry loop, await using spawn with timeout) are defensive and appropriate.

Comment on lines 2789 to 2795
DEFINE_VISIT_CHILDREN(JSSQLStatement);

template<typename Visitor>
void JSSQLStatement::visitAdditionalChildren(Visitor& visitor)
void JSSQLStatement::visitAdditionalChildrenInGCThread(Visitor& visitor)
{
JSSQLStatement* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟣 JSSQLStatement.cpp is missing the DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSSQLStatement) macro — this is a pre-existing omission (the old code also lacked DEFINE_VISIT_ADDITIONAL_CHILDREN(JSSQLStatement)), perpetuated by this PR which renamed the method without adding the newly-required macro. To fix, add DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSSQLStatement); on the line after DEFINE_VISIT_CHILDREN(JSSQLStatement), consistent with every other class implementing this method.

Extended reasoning...

This PR renames visitAdditionalChildren to visitAdditionalChildrenInGCThread across all affected files. For every class implementing this method — GlobalObject, JSBundlerPlugin, JSMockFunction, and all the webcore classes — the corresponding DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(ClassName) macro is either added (new classes) or updated (existing classes). JSSQLStatement is the sole exception: the diff shows no removal of an old DEFINE_VISIT_ADDITIONAL_CHILDREN(JSSQLStatement) macro, which means the class never had the old macro either, and consequently the new one was never added. This is confirmed by running grep for DEFINE_VISIT_ADDITIONAL_CHILDREN in JSSQLStatement.cpp, which returns zero matches.

By contrast, JSMockFunction shows -DEFINE_VISIT_ADDITIONAL_CHILDREN(JSMockFunction) / +DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSMockFunction) in the diff, and GlobalObject similarly shows the old macro being renamed to the new one. JSSQLStatement fell through both the old and new macro registrations. The omission predates this PR, making this a pre-existing issue that the PR perpetuated when it touched the file.

The DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD macro registers the visitAdditionalChildrenInGCThread function so that GC worker threads can invoke it during concurrent/incremental GC cycles. Without the macro, the GC framework has no registered hook for JSSQLStatement's additional marking from worker threads. The method itself marks _structure, _prototype, and userPrototype fields.

The practical risk from this omission is partially mitigated: JSSQLStatement's visitChildrenImpl already visits the same three fields (_structure, _prototype, userPrototype) directly, so the main-thread GC marking path remains correct. However, the missing registration removes the GC infrastructure the WebKit upgrade specifically introduced, and as JSC grows more reliant on concurrent worker-thread marking, the absent hook could become a real correctness hazard.

Step-by-step proof: (1) In the PR diff, search for DEFINE_VISIT_ADDITIONAL_CHILDREN changes in JSSQLStatement.cpp — there are none. (2) Search JSBundlerPlugin.cpp diff — shows +DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSBundlerPlugin) was added. (3) Search JSMockFunction.cpp diff — shows the macro was renamed from old to new. (4) JSSQLStatement had neither the old macro before the PR nor the new macro after. The one-line fix is: add DEFINE_VISIT_ADDITIONAL_CHILDREN_IN_GC_THREAD(JSSQLStatement); immediately after DEFINE_VISIT_CHILDREN(JSSQLStatement); at line 2789.

@Jarred-Sumner
Jarred-Sumner merged commit 7336160 into main Mar 22, 2026
59 of 64 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the claude/webkit-upgrade-de176b3 branch March 22, 2026 07:10
robobun added a commit that referenced this pull request Apr 22, 2026
The underlying JSC bug — GetDisposeMethod wrapped [Symbol.asyncDispose]
in a closure that discarded the returned promise — was fixed upstream
in WebKit and picked up in Bun 1.3.12 via the bump to fc9f2fa7 (#28371).
This adds a regression test so a future WebKit update can't silently
reintroduce the behavior.

Covers use(), adopt(), and defer(); asserts LIFO ordering, that each
disposer is fully awaited before the next begins, and that disposeAsync()
does not resolve until all resources have finished disposing.
structwafel pushed a commit to structwafel/bun that referenced this pull request Apr 25, 2026
Jarred-Sumner pushed a commit that referenced this pull request May 4, 2026
The underlying JSC bug — GetDisposeMethod wrapped [Symbol.asyncDispose]
in a closure that discarded the returned promise — was fixed upstream
in WebKit and picked up in Bun 1.3.12 via the bump to fc9f2fa7 (#28371).
This adds a regression test so a future WebKit update can't silently
reintroduce the behavior.

Covers use(), adopt(), and defer(); asserts LIFO ordering, that each
disposer is fully awaited before the next begins, and that disposeAsync()
does not resolve until all resources have finished disposing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants