Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 78682e818cf83e6c8a17c7082beeeaa3f0777e10
https://github.com/WebKit/WebKit/commit/78682e818cf83e6c8a17c7082beeeaa3f0777e10
Author: Sosuke Suzuki <[email protected]>
Date: 2026-04-26 (Sun, 26 Apr 2026)
Changed paths:
M Source/JavaScriptCore/heap/Heap.h
M Source/JavaScriptCore/runtime/Completion.cpp
M Source/JavaScriptCore/runtime/JSMicrotask.cpp
M Source/JavaScriptCore/runtime/JSModuleLoader.cpp
M Source/JavaScriptCore/runtime/JSModuleLoader.h
M Source/JavaScriptCore/runtime/ModuleGraphLoadingState.cpp
M Source/JavaScriptCore/runtime/ModuleGraphLoadingState.h
M Source/JavaScriptCore/runtime/ModuleLoaderPayload.cpp
M Source/JavaScriptCore/runtime/ModuleLoaderPayload.h
M Source/JavaScriptCore/runtime/ModuleLoadingContext.cpp
M Source/JavaScriptCore/runtime/ModuleLoadingContext.h
Log Message:
-----------
[JSC] Avoid per-edge ModuleLoaderPayload allocation in graph loading
https://bugs.webkit.org/show_bug.cgi?id=313330
Reviewed by Yusuke Suzuki.
Every dependency edge in graph loading allocated a fresh
ModuleLoaderPayload cell to wrap the ModuleGraphLoadingState before
passing it to HostLoadImportedModule. The spec just passes the same
`state` for every edge [1]; the wrapper existed only so the spec's
`payload ∈ { GraphLoadingState, PromiseCapability }` sum [2] could be
encoded as a single C++ type.
Pass the payload as opaque JSCell* instead. finishLoadingImportedModule
dispatches with one dynamicDowncast on ModuleGraphLoadingState. The
graph-load path now passes the state directly; only top-level dynamic
import() still allocates a ModuleLoaderPayload (the PromiseCapability).
ModuleLoaderPayload is simplified: holds JSPromise* only,
DoesNotNeedDestruction, IsoSubspace moves to cellHeapCellType. The
combined-promise AND-join slots are mirrored onto ModuleGraphLoadingState
so it can serve as the third microtask argument too.
The host hook boundary is unchanged.
In a local microbenchmark loading 500 entry modules with 100 shared
leaves each (50,000 dependency edges), peak RSS dropped from 64.95 MB to
62.49 MB (-3.8%). End-to-end time was unchanged within noise; the savings
are footprint, not throughput. JSTests/microbenchmarks does not currently
include any module-loader benchmarks.
[1]: https://tc39.es/ecma262/#sec-InnerModuleLoading
[2]: https://tc39.es/ecma262/#sec-HostLoadImportedModule
* Source/JavaScriptCore/heap/Heap.h:
* Source/JavaScriptCore/runtime/Completion.cpp:
(JSC::loadAndEvaluateModule):
* Source/JavaScriptCore/runtime/JSMicrotask.cpp:
(JSC::moduleLoadTopSettled):
(JSC::moduleLoadCombinedLoadSettled):
(JSC::moduleLoadCombinedStateSettled):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::JSModuleLoader::hostLoadImportedModule):
(JSC::JSModuleLoader::loadModule):
(JSC::JSModuleLoader::innerModuleLoading):
(JSC::JSModuleLoader::finishLoadingImportedModule):
* Source/JavaScriptCore/runtime/JSModuleLoader.h:
(JSC::isModuleLoaderHostDefinedPayload):
* Source/JavaScriptCore/runtime/ModuleGraphLoadingState.cpp:
(JSC::ModuleGraphLoadingState::visitChildrenImpl):
* Source/JavaScriptCore/runtime/ModuleGraphLoadingState.h:
* Source/JavaScriptCore/runtime/ModuleLoaderPayload.cpp:
(JSC::ModuleLoaderPayload::ModuleLoaderPayload):
(JSC::ModuleLoaderPayload::visitChildrenImpl):
(JSC::ModuleLoaderPayload::destroy): Deleted.
(JSC::ModuleLoaderPayload::getState const): Deleted.
(JSC::ModuleLoaderPayload::getPromise const): Deleted.
(JSC::ModuleLoaderPayload::isState const): Deleted.
(JSC::ModuleLoaderPayload::isPromise const): Deleted.
(JSC::ModuleLoaderPayload::underlyingPromise const): Deleted.
(JSC::ModuleLoaderPayload::fulfillment const): Deleted.
(JSC::ModuleLoaderPayload::fulfillment): Deleted.
(JSC::ModuleLoaderPayload::decrementRemaining): Deleted.
* Source/JavaScriptCore/runtime/ModuleLoaderPayload.h:
* Source/JavaScriptCore/runtime/ModuleLoadingContext.cpp:
(JSC::ModuleLoadingContext::ModuleLoadingContext):
(JSC::ModuleLoadingContext::create):
* Source/JavaScriptCore/runtime/ModuleLoadingContext.h:
Canonical link: https://commits.webkit.org/312041@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications