Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 53d4af93f61e8fdecf708c2be7186d85c9653826
https://github.com/WebKit/WebKit/commit/53d4af93f61e8fdecf708c2be7186d85c9653826
Author: Sosuke Suzuki <[email protected]>
Date: 2026-10-05 (Mon, 05 Oct 2026)
Changed paths:
M Source/JavaScriptCore/runtime/JSMicrotask.cpp
M Source/JavaScriptCore/runtime/JSMicrotask.h
M Source/JavaScriptCore/runtime/JSPromise.cpp
M Source/JavaScriptCore/runtime/MicrotaskQueue.cpp
M Source/JavaScriptCore/runtime/MicrotaskQueueInlines.h
Log Message:
-----------
[JSC] `MicrotaskQueue` should not copy `QueuedTask` through the stack when
queing and running microtask
https://bugs.webkit.org/show_bug.cgi?id=326306
Reviewed by Yusuke Suzuki.
JSGlobalObject::queueMicrotask built a temporary QueuedTask on the stack
with four 8-byte stores and moved it into the deque with two 16-byte loads,
which defeats store-to-load forwarding. The temporary had to live on the
stack because its address was also passed to queueMicrotaskSlow.
This patch builds a separate QueuedTask for the slow path, so that the
compiler can write the one for the fast path directly into the deque's
slot.
The slot is then written with 8-byte stores, so a task that runs soon
after it was queued has to be read with 8-byte loads too.
runInternalMicrotask now takes the three arguments by value instead of a
span, so that MicrotaskQueue::drainImpl does not have to copy the task to
the stack. The helpers for module loading and dynamic import still take a
span, so an array is built only at those call sites.
On x86-64 (clang 21), perf stat shows that ld_blocks.store_forward goes
from 2.0 to 0.0 per microtask in microbenchmarks.
* Source/JavaScriptCore/runtime/JSMicrotask.cpp:
(JSC::runInternalMicrotask):
* Source/JavaScriptCore/runtime/JSMicrotask.h:
* Source/JavaScriptCore/runtime/JSPromise.cpp:
(JSC::JSPromise::resolveWithInternalMicrotaskForAsyncAwait):
* Source/JavaScriptCore/runtime/MicrotaskQueue.cpp:
(JSC::runMicrotask):
(JSC::runMicrotaskWithDebugger):
(JSC::MicrotaskQueue::drainImpl):
* Source/JavaScriptCore/runtime/MicrotaskQueueInlines.h:
(JSC::MicrotaskQueue::enqueue):
(JSC::JSGlobalObject::queueMicrotask):
Canonical link: https://commits.webkit.org/322691@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications