Skip to content

Commit 9fadb87

Browse files
committed
[JSC] Make Microtask dispatcher tail-call
https://bugs.webkit.org/show_bug.cgi?id=329282 rdar://191227869 Reviewed by Marcus Plutowski. 322691@main improved doxbee-promise. But after PGO profile is updated, it becomes net regression. The reason is complicated: it accelerates async function path in microtask dispatcher, and PGO sees some threshold and it extracts some hot code from the large switch statement. This duplicate the code and increasing the register pressure, plus it makes function's stack frame larger, and we end up attaching stack-check due to that, and this makes all microtasks slower. This patch changes the way of dispatching microtasks. We define all microtask's handler as a static NEVER_INLINE function, and we dispatch them from the switch statement. This will be compiled to jump table with tail-call. We also attach MUST_TAIL annotation to ensure this becomes tail-call. This avoids the above stack frame problem, and keeping dispatching extremely efficient (literally just a jump via tail-call). * Source/JavaScriptCore/runtime/JSMicrotask.cpp: (JSC::runPromiseRaceResolveJob): (JSC::runPromiseAllResolveJob): (JSC::runPromiseAllSettledResolveJob): (JSC::runPromiseAnyResolveJob): (JSC::runAsyncGeneratorYieldAwaited): (JSC::runAsyncGeneratorBodyCallNormal): (JSC::runAsyncGeneratorBodyCallReturn): (JSC::runAsyncGeneratorAwaitReturn): (JSC::runPromiseFinallyReactionJob): (JSC::runAsyncModuleExecutionDone): (JSC::runModuleRegistryFetchSettled): (JSC::runModuleRegistryModuleSettled): (JSC::runModuleGraphLoadingError): (JSC::runModuleLoadStep): (JSC::runModuleLoadTopSettled): (JSC::runModuleLoadTopRejected): (JSC::runModuleLoadSpecifierTransform): (JSC::runModuleLoadCombinedLoadSettled): (JSC::runModuleLoadCombinedStateSettled): (JSC::runModuleLoadLinkEvaluateSettled): (JSC::runModuleLoadReturnRecord): (JSC::runModuleLoadStoreError): (JSC::dynamicImportLoadSettled): (JSC::runDynamicImportDeferDependencySettled): (JSC::runDynamicImportEvaluateSettled): (JSC::runImportModuleNamespace): (JSC::runPromiseResolveWithoutHandlerJob): (JSC::runWebAssemblyCompileStreaming): (JSC::runWebAssemblyInstantiateStreaming): (JSC::runAsyncGeneratorDriverResume): (JSC::runNone): (JSC::runOpaque): (JSC::runPromiseResolveThenableJobFast): (JSC::runPromiseResolveThenableJobWithInternalMicrotaskFast): (JSC::runPromiseResolveThenableJob): (JSC::runPromiseResolveThenableJobWithInternalMicrotask): (JSC::runPromiseFulfillWithoutHandlerJob): (JSC::runPromiseReactionJob): (JSC::runInvokeFunctionJob): (JSC::runAsyncFunctionResume): (JSC::runAsyncFromSyncIteratorContinue): (JSC::runAsyncFromSyncIteratorDone): (JSC::runPromiseFinallyAwaitJob): (JSC::runAsyncModuleExecutionResume): (JSC::runModuleLoadReturnModuleKey): (JSC::runDynamicImportLoadSettled): (JSC::runDynamicImportDeferLoadSettled): (JSC::runInternalMicrotask): (JSC::promiseRaceResolveJob): Deleted. (JSC::promiseAllResolveJob): Deleted. (JSC::promiseAllSettledResolveJob): Deleted. (JSC::promiseAnyResolveJob): Deleted. (JSC::asyncGeneratorYieldAwaited): Deleted. (JSC::asyncGeneratorBodyCallNormal): Deleted. (JSC::asyncGeneratorBodyCallReturn): Deleted. (JSC::asyncGeneratorAwaitReturnContinuation): Deleted. (JSC::promiseFinallyReactionJob): Deleted. (JSC::asyncModuleExecutionDone): Deleted. (JSC::moduleRegistryFetchSettled): Deleted. (JSC::moduleRegistryModuleSettled): Deleted. (JSC::moduleGraphLoadingError): Deleted. (JSC::moduleLoadStep): Deleted. (JSC::moduleLoadTopSettled): Deleted. (JSC::moduleLoadTopRejected): Deleted. (JSC::moduleLoadSpecifierTransform): Deleted. (JSC::moduleLoadCombinedLoadSettled): Deleted. (JSC::moduleLoadCombinedStateSettled): Deleted. (JSC::moduleLoadLinkEvaluateSettled): Deleted. (JSC::moduleLoadReturnRecord): Deleted. (JSC::moduleLoadStoreError): Deleted. (JSC::dynamicImportDeferDependencySettled): Deleted. (JSC::dynamicImportEvaluateSettled): Deleted. (JSC::importModuleNamespace): Deleted. (JSC::promiseResolveWithoutHandlerJob): Deleted. (JSC::webAssemblyCompileStreaming): Deleted. (JSC::webAssemblyInstantiateStreaming): Deleted. (JSC::asyncGeneratorDriverResume): Deleted. * Source/JavaScriptCore/runtime/Microtask.h: Canonical link: https://commits.webkit.org/325160@main
1 parent 4bbc344 commit 9fadb87

2 files changed

Lines changed: 456 additions & 511 deletions

File tree

0 commit comments

Comments
 (0)