Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7598b7e88cc0f0ba8736fd178da57e71618ed6d4
https://github.com/WebKit/WebKit/commit/7598b7e88cc0f0ba8736fd178da57e71618ed6d4
Author: Yusuke Suzuki <[email protected]>
Date: 2025-10-06 (Mon, 06 Oct 2025)
Changed paths:
R JSTests/stress/never-inlined-functions.js
M JSTests/stress/promise-withResolvers.js
M JSTests/stress/sampling-profiler-microtasks.js
M LayoutTests/inspector/console/message-stack-trace-expected.txt
M LayoutTests/js/dom/promise-rejection-might-stack-overflow-expected.txt
M LayoutTests/js/dom/promise-rejection-might-stack-overflow.html
M Source/JavaScriptCore/CMakeLists.txt
M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
M Source/JavaScriptCore/Sources.txt
M Source/JavaScriptCore/builtins/AsyncDisposableStackPrototype.js
M Source/JavaScriptCore/builtins/AsyncGeneratorPrototype.js
M Source/JavaScriptCore/builtins/AsyncIteratorPrototype.js
M Source/JavaScriptCore/builtins/BuiltinNames.h
M Source/JavaScriptCore/builtins/DisposableStackPrototype.js
M Source/JavaScriptCore/builtins/ModuleLoader.js
M Source/JavaScriptCore/builtins/PromiseConstructor.js
M Source/JavaScriptCore/builtins/PromiseOperations.js
M Source/JavaScriptCore/builtins/PromisePrototype.js
M Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp
M Source/JavaScriptCore/bytecode/LinkTimeConstant.h
M Source/JavaScriptCore/debugger/Debugger.h
M Source/JavaScriptCore/debugger/ScriptProfilingScope.h
M Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
M Source/JavaScriptCore/heap/Heap.cpp
M Source/JavaScriptCore/heap/Heap.h
M Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp
M Source/JavaScriptCore/interpreter/CachedCall.cpp
M Source/JavaScriptCore/interpreter/Interpreter.cpp
M Source/JavaScriptCore/interpreter/Interpreter.h
M Source/JavaScriptCore/interpreter/ProtoCallFrame.h
M Source/JavaScriptCore/interpreter/ProtoCallFrameInlines.h
M Source/JavaScriptCore/interpreter/VMEntryRecord.h
M Source/JavaScriptCore/llint/LowLevelInterpreter.asm
M Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
M Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
M Source/JavaScriptCore/runtime/CallData.cpp
M Source/JavaScriptCore/runtime/CallData.h
M Source/JavaScriptCore/runtime/CommonIdentifiers.h
M Source/JavaScriptCore/runtime/Intrinsic.h
M Source/JavaScriptCore/runtime/JSCast.h
A Source/JavaScriptCore/runtime/JSFunctionWithFields.cpp
A Source/JavaScriptCore/runtime/JSFunctionWithFields.h
M Source/JavaScriptCore/runtime/JSGlobalObject.cpp
M Source/JavaScriptCore/runtime/JSGlobalObject.h
M Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
M Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h
M Source/JavaScriptCore/runtime/JSGlobalObjectInlines.h
M Source/JavaScriptCore/runtime/JSInternalPromise.cpp
M Source/JavaScriptCore/runtime/JSMicrotask.cpp
M Source/JavaScriptCore/runtime/JSMicrotask.h
M Source/JavaScriptCore/runtime/JSPromise.cpp
M Source/JavaScriptCore/runtime/JSPromise.h
M Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp
M Source/JavaScriptCore/runtime/JSPromisePrototype.cpp
M Source/JavaScriptCore/runtime/JSPromisePrototype.h
M Source/JavaScriptCore/runtime/JSPromiseReaction.cpp
M Source/JavaScriptCore/runtime/JSPromiseReaction.h
M Source/JavaScriptCore/runtime/Microtask.h
M Source/JavaScriptCore/runtime/MicrotaskQueue.h
M Source/JavaScriptCore/runtime/MicrotaskQueueInlines.h
M Source/JavaScriptCore/runtime/VM.cpp
M Source/JavaScriptCore/runtime/VM.h
M Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp
M Source/WebCore/SaferCPPExpectations/ForwardDeclCheckerExpectations
M Source/WebCore/bindings/js/JSDOMAsyncIterator.h
M Source/WebCore/bindings/js/JSDOMPromise.cpp
M Source/WebCore/bindings/js/JSDOMPromiseDeferred.h
M Source/WebCore/bindings/js/JSDOMWindowBase.cpp
M Source/WebCore/dom/Microtasks.cpp
M Source/WebCore/dom/RejectedPromiseTracker.cpp
M Source/WebCore/dom/ScriptExecutionContext.cpp
M Source/WebCore/dom/UserGestureIndicator.cpp
M Source/WebCore/dom/UserGestureIndicator.h
M Source/WebCore/inspector/InspectorFrontendAPIDispatcher.cpp
Log Message:
-----------
[JSC] Move most of Promise operations to C++
https://bugs.webkit.org/show_bug.cgi?id=300130
rdar://problem/161914098
Reviewed by Yijia Huang.
This patch is the second step of optimizing our microtasks.
1. We move most of Promise operations to C++. The remaining ones will be
moved as well, and only handful of them intentionally remains in JS
because of callback calls etc.
2. We introduce JSFunctionWithFields to handle various promise resolve
reject function creations efficiently. This has 2 slots for random
data, and we leverage this to efficiently create resolve / reject
functions in C++.
3. Microtask operations are defined via InternalMicrotask, and run fully
in C++. We use integer to indicate this ID, and we invoke corresponding
operations in C++. We will increase this coverage, and eventually we will
stop accepting arbitrary JS functions for microtask. Some remaining
ones (like, self.queueMicrotask) will be handled via InternalMicrotask
which invokes JS function.
4. Many promise functions, including Promise.prototype.then is now fully
written in C++ for performance and strong integration into the rest
of microtask mechanism.
5. VMEntryRecord is extended to keep JSCell* context field. This is set
when we invoke a microtask, and unwinding can detect and expand a bit
additional information via that. We replace async stack trace
mechanism with this.
* JSTests/stress/never-inlined-functions.js: Removed.
* JSTests/stress/promise-withResolvers.js:
(shouldBe):
* JSTests/stress/sampling-profiler-microtasks.js:
(platformSupportsSamplingProfiler.testResults):
* LayoutTests/inspector/console/message-stack-trace-expected.txt:
* LayoutTests/js/dom/promise-rejection-might-stack-overflow-expected.txt:
* LayoutTests/js/dom/promise-rejection-might-stack-overflow.html:
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/builtins/AsyncDisposableStackPrototype.js:
(disposeAsync):
* Source/JavaScriptCore/builtins/AsyncGeneratorPrototype.js:
(linkTimeConstant.awaitValue): Deleted.
* Source/JavaScriptCore/builtins/AsyncIteratorPrototype.js:
(linkTimeConstant.promiseReturnUndefinedOnFulfilled):
(overriddenName.string_appeared_here.asyncDispose):
* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/builtins/DisposableStackPrototype.js:
(linkTimeConstant.getAsyncDisposableMethod):
* Source/JavaScriptCore/builtins/ModuleLoader.js:
(linkTimeConstant.fulfillFetch):
* Source/JavaScriptCore/builtins/PromiseConstructor.js:
(withResolvers): Deleted.
* Source/JavaScriptCore/builtins/PromiseOperations.js:
(linkTimeConstant.promiseEmptyOnRejected):
(linkTimeConstant.newHandledRejectedPromise): Deleted.
(linkTimeConstant.triggerPromiseReactions): Deleted.
(linkTimeConstant.resolvePromise): Deleted.
(linkTimeConstant.rejectPromise): Deleted.
(linkTimeConstant.fulfillPromise): Deleted.
(linkTimeConstant.resolvePromiseWithFirstResolvingFunctionCallCheck): Deleted.
(linkTimeConstant.fulfillPromiseWithFirstResolvingFunctionCallCheck): Deleted.
(linkTimeConstant.rejectPromiseWithFirstResolvingFunctionCallCheck): Deleted.
(linkTimeConstant.createResolvingFunctions): Deleted.
(linkTimeConstant.neverInline.promiseReactionJobWithoutPromise): Deleted.
(linkTimeConstant.resolveWithoutPromise): Deleted.
(linkTimeConstant.rejectWithoutPromise): Deleted.
(linkTimeConstant.fulfillWithoutPromise): Deleted.
(linkTimeConstant.resolveWithoutPromiseForAsyncAwait):
(linkTimeConstant.createResolvingFunctionsWithoutPromise): Deleted.
(linkTimeConstant.neverInline.promiseReactionJob):
(linkTimeConstant.promiseResolveThenableJobFast): Deleted.
(linkTimeConstant.promiseResolveThenableJobWithoutPromiseFast): Deleted.
(linkTimeConstant.promiseResolveThenableJob):
(linkTimeConstant.promiseResolveThenableJobWithDerivedPromise): Deleted.
(linkTimeConstant.alwaysInline.performPromiseThen): Deleted.
* Source/JavaScriptCore/builtins/PromisePrototype.js:
(then): Deleted.
* Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* Source/JavaScriptCore/bytecode/LinkTimeConstant.h:
* Source/JavaScriptCore/debugger/Debugger.h:
* Source/JavaScriptCore/debugger/ScriptProfilingScope.h:
* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsicCall):
* Source/JavaScriptCore/heap/Heap.cpp:
* Source/JavaScriptCore/heap/Heap.h:
* Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::isPromiseRejectedWithNativeGetterTypeError):
(Inspector::JSInjectedScriptHost::getInternalProperties):
* Source/JavaScriptCore/interpreter/CachedCall.cpp:
(JSC::CachedCall::CachedCall):
* Source/JavaScriptCore/interpreter/Interpreter.cpp:
(JSC::Interpreter::getAsyncStackTrace):
(JSC::Interpreter::getStackTrace):
(JSC::Interpreter::notifyDebuggerOfExceptionToBeThrown):
(JSC::Interpreter::executeProgram):
(JSC::Interpreter::executeBoundCall):
(JSC::Interpreter::executeCallImpl):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::executeEval):
(JSC::Interpreter::executeModuleProgram):
* Source/JavaScriptCore/interpreter/Interpreter.h:
* Source/JavaScriptCore/interpreter/ProtoCallFrame.h:
* Source/JavaScriptCore/interpreter/ProtoCallFrameInlines.h:
(JSC::ProtoCallFrame::init):
* Source/JavaScriptCore/interpreter/VMEntryRecord.h:
* Source/JavaScriptCore/llint/LowLevelInterpreter.asm:
* Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm:
* Source/JavaScriptCore/llint/LowLevelInterpreter64.asm:
* Source/JavaScriptCore/runtime/CallData.cpp:
(JSC::call):
(JSC::callMicrotask):
* Source/JavaScriptCore/runtime/CallData.h:
* Source/JavaScriptCore/runtime/CommonIdentifiers.h:
* Source/JavaScriptCore/runtime/Intrinsic.h:
* Source/JavaScriptCore/runtime/JSCast.h:
* Source/JavaScriptCore/runtime/JSFunctionWithFields.cpp: Added.
(JSC::JSFunctionWithFields::JSFunctionWithFields):
(JSC::JSFunctionWithFields::create):
(JSC::JSFunctionWithFields::visitChildrenImpl):
(JSC::JSFunctionWithFields::createStructure):
* Source/JavaScriptCore/runtime/JSFunctionWithFields.h: Copied from
Source/JavaScriptCore/runtime/JSPromisePrototype.h.
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildrenImpl):
(JSC::JSGlobalObject::installSaneChainWatchpoints):
(JSC::JSGlobalObject::tryInstallTypedArraySpeciesWatchpoint):
(JSC::JSGlobalObject::queueMicrotask):
(JSC::JSGlobalObject::installArraySpeciesWatchpoint): Deleted.
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::promiseThenWatchpointSet):
(JSC::JSGlobalObject::promiseSpeciesWatchpointSet):
(JSC::JSGlobalObject::promisePrototypeChainIsSaneWatchpointSet):
(JSC::JSGlobalObject::promiseSpeciesGetterSetter const):
(JSC::JSGlobalObject::promiseResolveFunction const):
(JSC::JSGlobalObject::internalPromisePrototype const):
(JSC::JSGlobalObject::functionWithFieldsStructure const):
(JSC::JSGlobalObject::promiseCapabilityObjectStructure const):
(JSC::JSGlobalObject::promiseReactionJobFunction const): Deleted.
(JSC::JSGlobalObject::promiseReactionJobWithoutPromiseFunction const): Deleted.
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h:
* Source/JavaScriptCore/runtime/JSGlobalObjectInlines.h:
(JSC::JSGlobalObject::asyncGeneratorYieldOnRejectedFunction const):
(JSC::JSGlobalObject::promiseEmptyOnFulfilledFunction const):
(JSC::JSGlobalObject::promiseEmptyOnRejectedFunction const):
(JSC::JSGlobalObject::newPromiseCapabilityFunction const): Deleted.
(JSC::JSGlobalObject::resolvePromiseFunction const): Deleted.
(JSC::JSGlobalObject::rejectPromiseFunction const): Deleted.
(JSC::JSGlobalObject::performPromiseThenFunction const): Deleted.
* Source/JavaScriptCore/runtime/JSInternalPromise.cpp:
(JSC::JSInternalPromise::then):
* Source/JavaScriptCore/runtime/JSMicrotask.cpp:
(JSC::dynamicCastToCell):
(JSC::promiseResolveThenableJobFastSlow):
(JSC::promiseResolveThenableJobWithoutPromiseFastSlow):
(JSC::promiseResolveThenableJob):
(JSC::runInternalMirotask):
(JSC::runJSMicrotask):
* Source/JavaScriptCore/runtime/JSMicrotask.h:
* Source/JavaScriptCore/runtime/JSPromise.cpp:
(JSC::JSPromise::createNewPromiseCapability):
(JSC::JSPromise::createPromiseCapability):
(JSC::JSPromise::createDeferredData):
(JSC::JSPromise::rejectedPromise):
(JSC::JSPromise::resolve):
(JSC::JSPromise::reject):
(JSC::JSPromise::fulfill):
(JSC::JSPromise::performPromiseThenExported):
(JSC::JSPromise::rejectAsHandled):
(JSC::JSPromise::performPromiseThen):
(JSC::JSPromise::rejectPromise):
(JSC::JSPromise::fulfillPromise):
(JSC::JSPromise::resolvePromise):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSPromise::triggerPromiseReactions):
(JSC::JSPromise::resolveWithoutPromiseForAsyncAwait):
(JSC::JSPromise::resolveWithoutPromise):
(JSC::JSPromise::rejectWithoutPromise):
(JSC::JSPromise::fulfillWithoutPromise):
(JSC::JSPromise::isThenFastAndNonObservable):
(JSC::promiseSpeciesConstructor):
(JSC::createPromiseCapabilityObjectStructure):
(JSC::JSPromise::then):
(JSC::JSPromise::status const): Deleted.
(JSC::JSPromise::result const): Deleted.
(JSC::JSPromise::flags const): Deleted.
(JSC::JSPromise::isHandled const): Deleted.
(JSC::JSPromise::convertCapabilityToDeferredData): Deleted.
(JSC::callFunction): Deleted.
(JSC::JSPromise::markAsHandled): Deleted.
* Source/JavaScriptCore/runtime/JSPromise.h:
(JSC::JSPromise::status const):
(JSC::JSPromise::isHandled const):
(JSC::JSPromise::result const):
(JSC::JSPromise::reactionsOrResult const):
(JSC::JSPromise::setReactionsOrResult):
(JSC::JSPromise::markAsHandled):
(JSC::JSPromise::flags const):
* Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp:
(JSC::JSPromiseConstructor::finishCreation):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSPromisePrototype.cpp:
(JSC::promiseSpeciesWatchpointIsValid):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSPromisePrototype.h:
* Source/JavaScriptCore/runtime/JSPromiseReaction.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION): Deleted.
* Source/JavaScriptCore/runtime/JSPromiseReaction.h:
* Source/JavaScriptCore/runtime/Microtask.h:
* Source/JavaScriptCore/runtime/MicrotaskQueue.h:
(JSC::QueuedTask::arguments const):
* Source/JavaScriptCore/runtime/MicrotaskQueueInlines.h:
(JSC::MicrotaskQueue::performMicrotaskCheckpoint):
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::callPromiseRejectionCallback):
(JSC::VM::didExhaustMicrotaskQueue):
(JSC::VM::promiseResolvingFunctionResolveExecutableSlow):
(JSC::VM::promiseResolvingFunctionRejectExecutableSlow):
(JSC::VM::promiseFirstResolvingFunctionResolveExecutableSlow):
(JSC::VM::promiseFirstResolvingFunctionRejectExecutableSlow):
(JSC::VM::promiseResolvingFunctionResolveWithoutPromiseExecutableSlow):
(JSC::VM::promiseResolvingFunctionRejectWithoutPromiseExecutableSlow):
(JSC::VM::promiseCapabilityExecutorExecutableSlow):
(JSC::VM::visitAggregateImpl):
* Source/JavaScriptCore/runtime/VM.h:
(JSC::VM::promiseResolvingFunctionResolveExecutable):
(JSC::VM::promiseResolvingFunctionRejectExecutable):
(JSC::VM::promiseFirstResolvingFunctionResolveExecutable):
(JSC::VM::promiseFirstResolvingFunctionRejectExecutable):
(JSC::VM::promiseResolvingFunctionResolveWithoutPromiseExecutable):
(JSC::VM::promiseResolvingFunctionRejectWithoutPromiseExecutable):
(JSC::VM::promiseCapabilityExecutorExecutable):
* Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/WebCore/SaferCPPExpectations/ForwardDeclCheckerExpectations:
* Source/WebCore/bindings/js/JSDOMAsyncIterator.h:
(WebCore::IteratorTraits>::next):
(WebCore::IteratorTraits>::runNextSteps):
* Source/WebCore/bindings/js/JSDOMPromise.cpp:
(WebCore::DOMPromise::result const):
(WebCore::DOMPromise::status const):
(WebCore::DOMPromise::markAsHandled):
* Source/WebCore/bindings/js/JSDOMPromiseDeferred.h:
(WebCore::DeferredPromise::markAsHandled const):
* Source/WebCore/bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::queueMicrotaskToEventLoop):
* Source/WebCore/dom/Microtasks.cpp:
(WebCore::MicrotaskQueue::runJSMicrotask):
(WebCore::MicrotaskQueue::performMicrotaskCheckpoint):
* Source/WebCore/dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::promiseRejected):
(WebCore::RejectedPromiseTracker::reportUnhandledRejections):
(WebCore::RejectedPromiseTracker::reportRejectionHandled):
* Source/WebCore/dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
* Source/WebCore/dom/UserGestureIndicator.cpp:
(WebCore::UserGestureIndicator::currentUserGestureForMainThread):
* Source/WebCore/dom/UserGestureIndicator.h:
* Source/WebCore/inspector/InspectorFrontendAPIDispatcher.cpp:
(WebCore::InspectorFrontendAPIDispatcher::evaluateOrQueueExpression):
Canonical link: https://commits.webkit.org/301095@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes