Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c71210975aaf236bf29b61320c1a77a49882f2d2
https://github.com/WebKit/WebKit/commit/c71210975aaf236bf29b61320c1a77a49882f2d2
Author: Sosuke Suzuki <[email protected]>
Date: 2026-05-14 (Thu, 14 May 2026)
Changed paths:
M Source/JavaScriptCore/runtime/JSPromise.cpp
M Source/JavaScriptCore/runtime/JSPromise.h
M Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp
Log Message:
-----------
[JSC] Avoid creating both first resolving functions when only one is needed
in `Promise.all` / `Promise.any`
https://bugs.webkit.org/show_bug.cgi?id=314813
Reviewed by Yusuke Suzuki.
Promise.all's slow path (custom thenables that go through `then`) lazily
creates a
shared onRejected via createFirstResolvingFunctions(), but discards the resolve
function it returns. Likewise, Promise.any's slow path only needs the resolve
function and discards the reject function.
The two "first resolving" functions are independent: unlike
createResolvingFunctions(),
they don't cross-reference each other via
JSFunctionWithFields::Field::ResolvingOther.
The "already resolved" state is tracked by isFirstResolvingFunctionCalledFlag
on the
JSPromise itself. So creating just one of them is safe.
Split createFirstResolvingFunctions() into createFirstResolveFunction() and
createFirstRejectFunction(), and have Promise.all / Promise.any call only the
one
they need, saving one JSFunctionWithFields allocation per slow-path entry.
Promise.race and newPromiseCapability still need both, so they continue to use
the
combined helper, which now delegates to the singular ones.
* Source/JavaScriptCore/runtime/JSPromise.cpp:
(JSC::JSPromise::createFirstResolveFunction):
(JSC::JSPromise::createFirstRejectFunction):
* Source/JavaScriptCore/runtime/JSPromise.h:
* Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
Canonical link: https://commits.webkit.org/313287@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications