Skip to content

[JSC] Rewrite module loader - #57827

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
heimskr:eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await
Apr 14, 2026
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
heimskr:eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await

Conversation

@heimskr

@heimskr heimskr commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

4a63810

[JSC] Rewrite module loader
https://bugs.webkit.org/show_bug.cgi?id=242740
rdar://97370038

Reviewed by Yusuke Suzuki and Sosuke Suzuki.

The current module loader has long-standing bugs. This includes assertion failures
when run on valid ES modules, incorrect ordering of module evaluation and quirks with
top-level await. This PR removes the current amalgam of C++ and JS and replaces
it with a pure-C++ rewrite that follows the modern ECMAScript spec instead of
the old WHATWG Loader proposal.

JSTests/modules/sync-from-async.js used to cause an assertion failure in debug builds of jsc before this PR.
JSTests/modules/concurrent-imports.js ensures that module loading progresses in the correct order.
JSTests/modules/bare-resolution-failure.js ensures that resolution failures are cached properly.

* JSTests/modules/bare-resolution-failure.js: Added.
(catch):
* JSTests/modules/bare-resolution-failure/a/x.js: Added.
* JSTests/modules/bare-resolution-failure/b/y.js: Added.
* JSTests/modules/concurrent-imports.js: Added.
(async loadDynamicModule):
* JSTests/modules/concurrent-imports/module.js: Added.
(export.someFunction):
* JSTests/modules/sync-from-async.js: Added.
* JSTests/modules/sync-from-async/a.js: Added.
* JSTests/modules/sync-from-async/b.js: Added.
(shouldThrow):
* JSTests/modules/tla-cycle.js: Added.
(catch):
* JSTests/modules/tla-cycle/a.js: Added.
* JSTests/modules/tla-cycle/b.js: Added.
* JSTests/modules/tla-cycle/c.js: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/dynamic-imports-script-error-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-1-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-4-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/top-level-await/sibling-imports-not-blocked.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/top-level-await/sibling-imports-not-blocked.any.worker-expected.txt:
* LayoutTests/ipc/coreipc.js: Fixed "const char" being resolved to "char" instead of "uint8_t".
(export.resolveAlias):
(isPrimitiveType): Fixed typo.
(isPrimtiveType): Deleted.
* Source/JavaScriptCore/API/JSAPIGlobalObject.h:
* Source/JavaScriptCore/API/JSAPIGlobalObject.mm:
(JSC::JSAPIGlobalObject::moduleLoaderResolve):
(JSC::JSAPIGlobalObject::moduleLoaderImportModule):
(JSC::JSAPIGlobalObject::moduleLoaderFetch):
(JSC::JSAPIGlobalObject::loadAndEvaluateJSScriptModule):
* Source/JavaScriptCore/API/JSContext.mm:
(-[JSContext dependencyIdentifiersForModuleJSScript:]):
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/DerivedSources-input.xcfilelist:
* Source/JavaScriptCore/DerivedSources.make:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Scripts/generate-unified-sources.sh:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/UnifiedSources-output.xcfilelist:
* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/builtins/ModuleLoader.js: Removed.
* Source/JavaScriptCore/heap/Heap.cpp:
* Source/JavaScriptCore/heap/Heap.h:
* Source/JavaScriptCore/jsc.cpp:
(GlobalObject::moduleLoaderImportModule):
(GlobalObject::moduleLoaderResolve):
(GlobalObject::moduleLoaderFetch):
(runWithOptions):
* Source/JavaScriptCore/parser/ModuleAnalyzer.cpp:
(JSC::ModuleAnalyzer::analyze):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseInner):
* Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp:
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::AsyncEvaluationOrder):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::order const):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::order):
(JSC::AbstractModuleRecord::AbstractModuleRecord):
(JSC::AbstractModuleRecord::finishCreation):
(JSC::AbstractModuleRecord::visitChildrenImpl):
(JSC::AbstractModuleRecord::ModuleRequest::type const):
(JSC::AbstractModuleRecord::LoadedModuleRequest::LoadedModuleRequest):
(JSC::AbstractModuleRecord::ModuleRequest::operator== const):
(JSC::AbstractModuleRecord::appendRequestedModule):
(JSC::AbstractModuleRecord::hostResolveImportedModule):
(JSC::AbstractModuleRecord::getModuleNamespace):
(JSC::AbstractModuleRecord::asyncCapability const):
(JSC::AbstractModuleRecord::asyncCapability):
(JSC::AbstractModuleRecord::link):
(JSC::AbstractModuleRecord::evaluate):
(JSC::AbstractModuleRecord::evaluateModuleSync):
(JSC::checkSafeToRecurse):
(JSC::AbstractModuleRecord::innerModuleEvaluation):
(JSC::AbstractModuleRecord::innerModuleLinking):
(JSC::AbstractModuleRecord::moduleType const):
(JSC::AbstractModuleRecord::cycleRoot):
(JSC::AbstractModuleRecord::topLevelCapability):
(JSC::AbstractModuleRecord::hasTLA):
(JSC::AbstractModuleRecord::appendAsyncParentModule):
* Source/JavaScriptCore/runtime/AbstractModuleRecord.h:
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::isDone const):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::isUnset const):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::hasOrder const):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::setDone):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::done):
(JSC::AbstractModuleRecord::cycleRoot const):
(JSC::AbstractModuleRecord::asyncEvaluationOrder const):
(JSC::AbstractModuleRecord::pendingAsyncDependencies const):
(JSC::AbstractModuleRecord::hasTLA const):
(JSC::AbstractModuleRecord::topLevelCapability const):
(JSC::AbstractModuleRecord::asyncEvaluationOrder):
(JSC::AbstractModuleRecord::pendingAsyncDependencies):
* Source/JavaScriptCore/runtime/Completion.cpp:
(JSC::createEntrypointModuleKey):
(JSC::rejectPromise):
(JSC::loadAndEvaluateModule):
(JSC::getSourceType):
(JSC::loadModule):
(JSC::linkAndEvaluateModule):
(JSC::importModule):
(JSC::createSymbolForEntrypointModule): Deleted.
* Source/JavaScriptCore/runtime/Completion.h:
* Source/JavaScriptCore/runtime/CyclicModuleRecord.cpp: Added.
(JSC::CyclicModuleRecord::CyclicModuleRecord):
(JSC::CyclicModuleRecord::finishCreation):
(JSC::CyclicModuleRecord::visitChildrenImpl):
(JSC::CyclicModuleRecord::initializeEnvironment):
(JSC::CyclicModuleRecord::link):
(JSC::CyclicModuleRecord::evaluate):
(JSC::CyclicModuleRecord::execute):
(JSC::CyclicModuleRecord::executeAsync):
(JSC::gatherAvailableAncestors):
(JSC::CyclicModuleRecord::asyncExecutionRejected):
(JSC::CyclicModuleRecord::asyncExecutionFulfilled):
* Source/JavaScriptCore/runtime/CyclicModuleRecord.h: Copied from Source/JavaScriptCore/runtime/JSModuleRecord.h.
(JSC::CyclicModuleRecord::subspaceFor):
(JSC::CyclicModuleRecord::status const):
(JSC::CyclicModuleRecord::evaluationError const):
(JSC::CyclicModuleRecord::dfsAncestorIndex const):
(JSC::CyclicModuleRecord::status):
(JSC::CyclicModuleRecord::evaluationError):
(JSC::CyclicModuleRecord::dfsAncestorIndex):
* Source/JavaScriptCore/runtime/GlobalObjectMethodTable.h:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSMicrotask.cpp:
(JSC::asyncModuleExecutionDone):
(JSC::asyncModuleExecutionResume):
(JSC::moduleRegistryFetchSettled):
(JSC::moduleRegistryModuleSettled):
(JSC::moduleGraphLoadingError):
(JSC::moduleLoadStep):
(JSC::moduleLoadTopSettled):
(JSC::moduleLoadTopRejected):
(JSC::moduleLoadSpecifierTransform):
(JSC::moduleLoadCombinedLoadSettled):
(JSC::moduleLoadCombinedStateSettled):
(JSC::moduleLoadLinkEvaluateSettled):
(JSC::moduleLoadReturnRecord):
(JSC::moduleLoadStoreError):
(JSC::dynamicImportLoadSettled):
(JSC::dynamicImportEvaluateSettled):
(JSC::importModuleNamespace):
(JSC::runInternalMicrotask):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::jsValueToSpecifier):
(JSC::JSModuleLoader::isFetchError):
(JSC::JSModuleLoader::duplicateTypeError):
(JSC::JSModuleLoader::duplicateError):
(JSC::JSModuleLoader::maybeDuplicateFetchError):
(JSC::JSModuleLoader::ModuleFailure::ModuleFailure):
(JSC::JSModuleLoader::ModuleFailure::isEvaluationError const):
(JSC::JSModuleLoader::ModuleFailure::operator bool const):
(JSC::JSModuleLoader::getErrorInfo):
(JSC::JSModuleLoader::attachErrorInfo):
(JSC::JSModuleLoader::JSModuleLoader):
(JSC::JSModuleLoader::destroy):
(JSC::JSModuleLoader::finishCreation):
(JSC::JSModuleLoader::visitChildrenImpl):
(JSC::JSModuleLoader::dependencyKeysIfEvaluated):
(JSC::JSModuleLoader::provideFetch):
(JSC::getFetchType):
(JSC::JSModuleLoader::loadModule):
(JSC::JSModuleLoader::linkAndEvaluateModule):
(JSC::JSModuleLoader::requestImportModule):
(JSC::JSModuleLoader::importModule):
(JSC::JSModuleLoader::resolve):
(JSC::JSModuleLoader::fetch):
(JSC::JSModuleLoader::getImportedModule):
(JSC::JSModuleLoader::maybeGetImportedModule):
(JSC::JSModuleLoader::hostLoadImportedModule):
(JSC::checkSafeToRecurse):
(JSC::JSModuleLoader::innerModuleLoading):
(JSC::JSModuleLoader::finishLoadingImportedModule):
(JSC::JSModuleLoader::continueModuleLoading):
(JSC::JSModuleLoader::continueDynamicImport):
(JSC::JSModuleLoader::loadRequestedModules):
(JSC::JSModuleLoader::ensureRegistered):
(JSC::JSModuleLoader::getRegisteredMayBeNull):
(JSC::JSModuleLoader::addResolutionFailure):
(JSC::JSModuleLoader::ModuleReferrer::getScript const):
(JSC::JSModuleLoader::ModuleReferrer::getModule const):
(JSC::JSModuleLoader::ModuleReferrer::getRealm const):
(JSC::JSModuleLoader::ModuleReferrer::isScript const):
(JSC::JSModuleLoader::ModuleReferrer::isModule const):
(JSC::JSModuleLoader::ModuleReferrer::isRealm const):
(JSC::JSModuleLoader::ModuleReferrer::toJSValue const):
(JSC::JSModuleLoader::makeModule):
(JSC::JSModuleLoader::loadAndEvaluateModule): Deleted.
(JSC::JSC_DEFINE_HOST_FUNCTION): Deleted.
(JSC::stringFromScriptFetchParametersType): Deleted.
* Source/JavaScriptCore/runtime/JSModuleLoader.h:
* Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h:
(JSC::JSModuleLoader::createStructure):
* Source/JavaScriptCore/runtime/JSModuleRecord.cpp:
(JSC::JSModuleRecord::evaluate):
(JSC::JSModuleRecord::execute):
(JSC::JSModuleRecord::getOrMakeExecutable):
(JSC::JSModuleRecord::createStructure): Deleted.
(JSC::JSModuleRecord::link):
(JSC::JSModuleRecord::instantiateDeclarations): Deleted.
* Source/JavaScriptCore/runtime/JSModuleRecord.h:
* Source/JavaScriptCore/runtime/JSModuleRecordInlines.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::JSModuleRecord::createStructure):
* Source/JavaScriptCore/runtime/JSPromise.h:
* Source/JavaScriptCore/runtime/JSType.cpp:
(WTF::printInternal):
* Source/JavaScriptCore/runtime/JSType.h:
* Source/JavaScriptCore/runtime/Microtask.h:
* Source/JavaScriptCore/runtime/ModuleGraphLoadingState.cpp: Added.
(JSC::ModuleGraphLoadingState::ModuleGraphLoadingState):
(JSC::ModuleGraphLoadingState::destroy):
(JSC::ModuleGraphLoadingState::finishCreation):
(JSC::ModuleGraphLoadingState::visitChildrenImpl):
(JSC::ModuleGraphLoadingState::create):
(JSC::ModuleGraphLoadingState::promise const):
(JSC::ModuleGraphLoadingState::pendingModulesCount const):
(JSC::ModuleGraphLoadingState::isLoading const):
(JSC::ModuleGraphLoadingState::scriptFetcher const):
(JSC::ModuleGraphLoadingState::pendingModulesCount):
(JSC::ModuleGraphLoadingState::isLoading):
(JSC::ModuleGraphLoadingState::scriptFetcher):
(JSC::ModuleGraphLoadingState::appendVisited):
(JSC::ModuleGraphLoadingState::containsVisited const):
* Source/JavaScriptCore/runtime/ModuleGraphLoadingState.h: Copied from Source/JavaScriptCore/runtime/JSModuleRecord.h.
* Source/JavaScriptCore/runtime/ModuleGraphLoadingStateInlines.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::ModuleGraphLoadingState::createStructure):
* Source/JavaScriptCore/runtime/ModuleLoaderPayload.cpp: Added.
(JSC::ModuleLoaderPayload::ModuleLoaderPayload):
(JSC::ModuleLoaderPayload::destroy):
(JSC::ModuleLoaderPayload::finishCreation):
(JSC::ModuleLoaderPayload::visitChildrenImpl):
(JSC::ModuleLoaderPayload::create):
(JSC::ModuleLoaderPayload::getState const):
(JSC::ModuleLoaderPayload::getPromise const):
(JSC::ModuleLoaderPayload::isState const):
(JSC::ModuleLoaderPayload::isPromise const):
(JSC::ModuleLoaderPayload::underlyingPromise const):
(JSC::ModuleLoaderPayload::fulfillment const):
(JSC::ModuleLoaderPayload::fulfillment):
(JSC::ModuleLoaderPayload::decrementRemaining):
* Source/JavaScriptCore/runtime/ModuleLoaderPayload.h: Copied from Source/JavaScriptCore/API/JSAPIGlobalObject.h.
* Source/JavaScriptCore/runtime/ModuleLoaderPayloadInlines.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::ModuleLoaderPayload::createStructure):
* Source/JavaScriptCore/runtime/ModuleLoadingContext.cpp: Added.
(JSC::ModuleLoadingContext::ModuleLoadingContext):
(JSC::ModuleLoadingContext::destroy):
(JSC::ModuleLoadingContext::create):
(JSC::ModuleLoadingContext::referrer const):
(JSC::ModuleLoadingContext::visitChildrenImpl):
* Source/JavaScriptCore/runtime/ModuleLoadingContext.h: Added.
* Source/JavaScriptCore/runtime/ModuleLoadingContextInlines.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::ModuleLoadingContext::createStructure):
* Source/JavaScriptCore/runtime/ModuleMap.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::ModuleMapHash::hash):
(JSC::ModuleMapHash::equal):
(JSC::ResolutionMapHash::hash):
(JSC::ResolutionMapHash::equal):
* Source/JavaScriptCore/runtime/ModuleRegistryEntry.cpp: Added.
(JSC::ModuleRegistryEntry::ModuleRegistryEntry):
(JSC::ModuleRegistryEntry::destroy):
(JSC::ModuleRegistryEntry::finishCreation):
(JSC::ModuleRegistryEntry::visitChildrenImpl):
(JSC::ModuleRegistryEntry::create):
(JSC::ModuleRegistryEntry::key const):
(JSC::ModuleRegistryEntry::moduleType const):
(JSC::ModuleRegistryEntry::record const):
(JSC::ModuleRegistryEntry::ensureFetchPromise):
(JSC::ModuleRegistryEntry::ensureModulePromise):
(JSC::ModuleRegistryEntry::loadPromise const):
(JSC::ModuleRegistryEntry::error const):
(JSC::ModuleRegistryEntry::fetchError const):
(JSC::ModuleRegistryEntry::instantiationError const):
(JSC::ModuleRegistryEntry::evaluationError const):
(JSC::ModuleRegistryEntry::status const):
(JSC::ModuleRegistryEntry::record):
(JSC::ModuleRegistryEntry::loadPromise):
(JSC::ModuleRegistryEntry::fetchError):
(JSC::ModuleRegistryEntry::instantiationError):
(JSC::ModuleRegistryEntry::evaluationError):
(JSC::ModuleRegistryEntry::status):
(JSC::ModuleRegistryEntry::provideFetch):
(JSC::ModuleRegistryEntry::fetchComplete):
* Source/JavaScriptCore/runtime/ModuleRegistryEntry.h: Copied from Source/JavaScriptCore/runtime/JSModuleRecord.h.
* Source/JavaScriptCore/runtime/ModuleRegistryEntryInlines.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::ModuleRegistryEntry::createStructure):
* Source/JavaScriptCore/runtime/PinballCompletion.cpp:
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::visitAggregateImpl):
* Source/JavaScriptCore/runtime/VM.h:
(JSC::VM::incrementModuleAsyncEvaluationCount):
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::link):
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.h:
* Source/WebCore/bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::moduleLoaderResolve):
(WebCore::JSDOMGlobalObject::moduleLoaderFetch):
(WebCore::JSDOMGlobalObject::moduleLoaderImportModule):
* Source/WebCore/bindings/js/JSDOMGlobalObject.h:
* Source/WebCore/bindings/js/JSExecState.h:
(WebCore::JSExecState::loadModule):
(WebCore::JSExecState::linkAndEvaluateModule):
* Source/WebCore/bindings/js/ScriptController.cpp:
(WebCore::ScriptController::linkAndEvaluateModuleScriptInWorld):
(WebCore::ScriptController::linkAndEvaluateModuleScript):
(WebCore::ScriptController::setupModuleScriptHandlers):
* Source/WebCore/bindings/js/ScriptController.h:
* Source/WebCore/bindings/js/ScriptModuleLoader.cpp:
(WebCore::parseURLLikeModuleSpecifier):
(WebCore::ScriptModuleLoader::resolve):
(WebCore::ScriptModuleLoader::fetch):
(WebCore::rejectPromise):
(WebCore::ScriptModuleLoader::importModule):
(WebCore::ScriptModuleLoader::notifyFinished):
* Source/WebCore/bindings/js/ScriptModuleLoader.h:
* Source/WebCore/workers/WorkerOrWorkletScriptController.cpp:
(WebCore::WorkerOrWorkletScriptController::linkAndEvaluateModule):
(WebCore::WorkerOrWorkletScriptController::loadAndEvaluateModule):
* Tools/TestWebKitAPI/Resources/cocoa/coreipc.js:
(resolveAlias):
(isPrimitiveType):
(isPrimtiveType): Deleted.
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionContext.mm:
(TestWebKitAPI::TEST(WKWebExtensionContext, TopLevelThrowInModuleBackground)):
(TestWebKitAPI::TEST(WKWebExtensionContext, TopLevelThrowInPopup)):

Canonical link: https://commits.webkit.org/311236@main

00d4f4c

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe   🛠 win ⏳ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim loading 🛠 mac-AS-debug ✅ 🧪 wpe-wk2   🧪 win-tests ⏳ 🛠 mac-apple
✅ 🧪 webkitperl   🧪 ios-wk2   🧪 api-mac ✅ 🧪 api-wpe ⏳ 🛠 vision-apple
  🧪 ios-wk2-wpt   🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🛠 🧪 jsc   🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-debug-arm64   🛠 ios-safer-cpp   🧪 mac-wk2   🧪 gtk-wk2
✅ 🛠 vision   🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress   🛠 playstation
✅ 🧪 vision-wk2   🧪 mac-intel-wk2   🛠 jsc-armv7
✅ 🛠 tv ✅ 🛠 mac-safer-cpp   🧪 jsc-armv7-tests
✅ 🛠 tv-sim
  🛠 watch
✅ 🛠 watch-sim

@heimskr
heimskr requested review from a team and cdumez as code owners February 4, 2026 01:57

@Jarred-Sumner Jarred-Sumner left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very exciting! Some comments but note I am not a WebKit reviewer so you have no obligation to address them


const Vector<AbstractModuleRecord::ModuleRequest>& requests = record->requestedModules();

JSArray* array = constructEmptyArray(globalObject, nullptr, requests.size());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can use MarkedArgumentBuffer dependencyKeys; and append to that one-at-a-time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the advantage?

RETURN_IF_EXCEPTION(scope, nullptr);
}

RELEASE_AND_RETURN(scope, array);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RELEASE_AND_RETURN(scope, array);
RELEASE_AND_RETURN(scope, constructArray(vm, globalObject, dependencyKeys));

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 4, 2026
@webkit-ews-buildbot

Copy link
Copy Markdown
Collaborator

Safer C++ Build #78075 (027dc02)

❌ Found 2 failing files with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@heimskr
heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 027dc02 to c6ed35a Compare February 4, 2026 18:29
@heimskr

heimskr commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

I've written a fuzzer to produce convoluted dependency graphs to test the module loader rewrite. So far, every test I've run has produced identical output when run with this PR vs. when run with NodeJS, whereas running the tests with JSC prior to this PR will produce incorrect output and (in debug builds) the occasional assertion failure.

@heimskr
heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from c6ed35a to cef57c9 Compare February 4, 2026 20:57
@webkit-ews-buildbot

Copy link
Copy Markdown
Collaborator

Safer C++ Build #78208 (c6ed35a)

❌ Found 2 failing files with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@webkit-ews-buildbot

Copy link
Copy Markdown
Collaborator

Safer C++ Build #78249 (cef57c9)

❌ Found 2 failing files with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@heimskr
heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from cef57c9 to fc59918 Compare February 5, 2026 01:00
@webkit-ews-buildbot

Copy link
Copy Markdown
Collaborator

Safer C++ Build #78320 (fc59918)

❌ Found 2 failing files with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@heimskr
heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from fc59918 to baf444b Compare February 5, 2026 19:34
@webkit-ews-buildbot

Copy link
Copy Markdown
Collaborator

Safer C++ Build #78542 (baf444b)

❌ Found 2 failing files with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@heimskr
heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from baf444b to 77b5a41 Compare February 6, 2026 01:28
@webkit-ews-buildbot

Copy link
Copy Markdown
Collaborator

Safer C++ Build #78626 (77b5a41)

❌ Found 2 failing files with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@heimskr
heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 77b5a41 to 73a3f6d Compare February 6, 2026 20:35
@webkit-ews-buildbot

Copy link
Copy Markdown
Collaborator

Safer C++ Build #78788 (73a3f6d)

❌ Found 2 failing files with 2 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@heimskr
heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 73a3f6d to 3607817 Compare February 7, 2026 06:24
@heimskr
heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 3607817 to a12f172 Compare February 7, 2026 08:52
@heimskr

heimskr commented Apr 1, 2026

Copy link
Copy Markdown
Contributor Author

One more tiny regression

Fixed. I added your test too.

@sosukesuzuki sosukesuzuki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found more two assertion failures...

Case 1

// a.js (entry, run with: jsc -m a.js)
import("./b.js");
drainMicrotasks();
export const a = 1;

// b.js
import "./a.js";
export const b = 2;
ASSERTION FAILED: module->status() == Status::Unlinked
Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp(1128) innerModuleLinking

Case 2

// a.js (entry, run with: jsc -m a.js)
import "./b.js";
export const a = 1;

// b.js
import "./a.js";
import("./b.js");
drainMicrotasks();
export const b = 2;
ASSERTION FAILED: status() == Status::Unlinked || ... || Status::Evaluated
Source/JavaScriptCore/runtime/CyclicModuleRecord.cpp(334) link

@sosukesuzuki sosukesuzuki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if assertion failure I commented is fixed, r=me

@heimskr

heimskr commented Apr 2, 2026

Copy link
Copy Markdown
Contributor Author

if assertion failure I commented is fixed, r=me

I have a fix currently (see the most recent commit) for the assertion failures, but it's a linear scan during dynamic imports so I'm concerned about its performance impact, especially because this occurs only if microtasks are explicitly drained while a microtask is already being processed. This strikes me as something that wouldn't ever occur on the web, given that (if I'm not mistaken) there's no way for user JS to explicitly drain the microtask queue. (I.e., there's no equivalent of jsc shell's drainMicrotasks function.) Reentrant microtask draining is (again, if I'm not mistaken) redundant at best and dangerous at worst, so I'm not sure it's worth taking a performance hit to accommodate it. I'm currently running some performance tests, but chances are I will revert the fix.

https://bugs.webkit.org/show_bug.cgi?id=242740
rdar://97370038

Reviewed by Yusuke Suzuki and Sosuke Suzuki.

The current module loader has long-standing bugs. This includes assertion failures
when run on valid ES modules, incorrect ordering of module evaluation and quirks with
top-level await. This PR removes the current amalgam of C++ and JS and replaces
it with a pure-C++ rewrite that follows the modern ECMAScript spec instead of
the old WHATWG Loader proposal.

JSTests/modules/sync-from-async.js used to cause an assertion failure in debug builds of jsc before this PR.
JSTests/modules/concurrent-imports.js ensures that module loading progresses in the correct order.
JSTests/modules/bare-resolution-failure.js ensures that resolution failures are cached properly.

* JSTests/modules/bare-resolution-failure.js: Added.
(catch):
* JSTests/modules/bare-resolution-failure/a/x.js: Added.
* JSTests/modules/bare-resolution-failure/b/y.js: Added.
* JSTests/modules/concurrent-imports.js: Added.
(async loadDynamicModule):
* JSTests/modules/concurrent-imports/module.js: Added.
(export.someFunction):
* JSTests/modules/sync-from-async.js: Added.
* JSTests/modules/sync-from-async/a.js: Added.
* JSTests/modules/sync-from-async/b.js: Added.
(shouldThrow):
* JSTests/modules/tla-cycle.js: Added.
(catch):
* JSTests/modules/tla-cycle/a.js: Added.
* JSTests/modules/tla-cycle/b.js: Added.
* JSTests/modules/tla-cycle/c.js: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/choice-of-error-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/dynamic-imports-script-error-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-1-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-2-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-3-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-4-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/top-level-await/sibling-imports-not-blocked.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/top-level-await/sibling-imports-not-blocked.any.worker-expected.txt:
* LayoutTests/ipc/coreipc.js: Fixed "const char" being resolved to "char" instead of "uint8_t".
(export.resolveAlias):
(isPrimitiveType): Fixed typo.
(isPrimtiveType): Deleted.
* Source/JavaScriptCore/API/JSAPIGlobalObject.h:
* Source/JavaScriptCore/API/JSAPIGlobalObject.mm:
(JSC::JSAPIGlobalObject::moduleLoaderResolve):
(JSC::JSAPIGlobalObject::moduleLoaderImportModule):
(JSC::JSAPIGlobalObject::moduleLoaderFetch):
(JSC::JSAPIGlobalObject::loadAndEvaluateJSScriptModule):
* Source/JavaScriptCore/API/JSContext.mm:
(-[JSContext dependencyIdentifiersForModuleJSScript:]):
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/DerivedSources-input.xcfilelist:
* Source/JavaScriptCore/DerivedSources.make:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Scripts/generate-unified-sources.sh:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/UnifiedSources-output.xcfilelist:
* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/builtins/ModuleLoader.js: Removed.
* Source/JavaScriptCore/heap/Heap.cpp:
* Source/JavaScriptCore/heap/Heap.h:
* Source/JavaScriptCore/jsc.cpp:
(GlobalObject::moduleLoaderImportModule):
(GlobalObject::moduleLoaderResolve):
(GlobalObject::moduleLoaderFetch):
(runWithOptions):
* Source/JavaScriptCore/parser/ModuleAnalyzer.cpp:
(JSC::ModuleAnalyzer::analyze):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseInner):
* Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp:
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::AsyncEvaluationOrder):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::order const):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::order):
(JSC::AbstractModuleRecord::AbstractModuleRecord):
(JSC::AbstractModuleRecord::finishCreation):
(JSC::AbstractModuleRecord::visitChildrenImpl):
(JSC::AbstractModuleRecord::ModuleRequest::type const):
(JSC::AbstractModuleRecord::LoadedModuleRequest::LoadedModuleRequest):
(JSC::AbstractModuleRecord::ModuleRequest::operator== const):
(JSC::AbstractModuleRecord::appendRequestedModule):
(JSC::AbstractModuleRecord::hostResolveImportedModule):
(JSC::AbstractModuleRecord::getModuleNamespace):
(JSC::AbstractModuleRecord::asyncCapability const):
(JSC::AbstractModuleRecord::asyncCapability):
(JSC::AbstractModuleRecord::link):
(JSC::AbstractModuleRecord::evaluate):
(JSC::AbstractModuleRecord::evaluateModuleSync):
(JSC::checkSafeToRecurse):
(JSC::AbstractModuleRecord::innerModuleEvaluation):
(JSC::AbstractModuleRecord::innerModuleLinking):
(JSC::AbstractModuleRecord::moduleType const):
(JSC::AbstractModuleRecord::cycleRoot):
(JSC::AbstractModuleRecord::topLevelCapability):
(JSC::AbstractModuleRecord::hasTLA):
(JSC::AbstractModuleRecord::appendAsyncParentModule):
* Source/JavaScriptCore/runtime/AbstractModuleRecord.h:
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::isDone const):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::isUnset const):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::hasOrder const):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::setDone):
(JSC::AbstractModuleRecord::AsyncEvaluationOrder::done):
(JSC::AbstractModuleRecord::cycleRoot const):
(JSC::AbstractModuleRecord::asyncEvaluationOrder const):
(JSC::AbstractModuleRecord::pendingAsyncDependencies const):
(JSC::AbstractModuleRecord::hasTLA const):
(JSC::AbstractModuleRecord::topLevelCapability const):
(JSC::AbstractModuleRecord::asyncEvaluationOrder):
(JSC::AbstractModuleRecord::pendingAsyncDependencies):
* Source/JavaScriptCore/runtime/Completion.cpp:
(JSC::createEntrypointModuleKey):
(JSC::rejectPromise):
(JSC::loadAndEvaluateModule):
(JSC::getSourceType):
(JSC::loadModule):
(JSC::linkAndEvaluateModule):
(JSC::importModule):
(JSC::createSymbolForEntrypointModule): Deleted.
* Source/JavaScriptCore/runtime/Completion.h:
* Source/JavaScriptCore/runtime/CyclicModuleRecord.cpp: Added.
(JSC::CyclicModuleRecord::CyclicModuleRecord):
(JSC::CyclicModuleRecord::finishCreation):
(JSC::CyclicModuleRecord::visitChildrenImpl):
(JSC::CyclicModuleRecord::initializeEnvironment):
(JSC::CyclicModuleRecord::link):
(JSC::CyclicModuleRecord::evaluate):
(JSC::CyclicModuleRecord::execute):
(JSC::CyclicModuleRecord::executeAsync):
(JSC::gatherAvailableAncestors):
(JSC::CyclicModuleRecord::asyncExecutionRejected):
(JSC::CyclicModuleRecord::asyncExecutionFulfilled):
* Source/JavaScriptCore/runtime/CyclicModuleRecord.h: Copied from Source/JavaScriptCore/runtime/JSModuleRecord.h.
(JSC::CyclicModuleRecord::subspaceFor):
(JSC::CyclicModuleRecord::status const):
(JSC::CyclicModuleRecord::evaluationError const):
(JSC::CyclicModuleRecord::dfsAncestorIndex const):
(JSC::CyclicModuleRecord::status):
(JSC::CyclicModuleRecord::evaluationError):
(JSC::CyclicModuleRecord::dfsAncestorIndex):
* Source/JavaScriptCore/runtime/GlobalObjectMethodTable.h:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSMicrotask.cpp:
(JSC::asyncModuleExecutionDone):
(JSC::asyncModuleExecutionResume):
(JSC::moduleRegistryFetchSettled):
(JSC::moduleRegistryModuleSettled):
(JSC::moduleGraphLoadingError):
(JSC::moduleLoadStep):
(JSC::moduleLoadTopSettled):
(JSC::moduleLoadTopRejected):
(JSC::moduleLoadSpecifierTransform):
(JSC::moduleLoadCombinedLoadSettled):
(JSC::moduleLoadCombinedStateSettled):
(JSC::moduleLoadLinkEvaluateSettled):
(JSC::moduleLoadReturnRecord):
(JSC::moduleLoadStoreError):
(JSC::dynamicImportLoadSettled):
(JSC::dynamicImportEvaluateSettled):
(JSC::importModuleNamespace):
(JSC::runInternalMicrotask):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::jsValueToSpecifier):
(JSC::JSModuleLoader::isFetchError):
(JSC::JSModuleLoader::duplicateTypeError):
(JSC::JSModuleLoader::duplicateError):
(JSC::JSModuleLoader::maybeDuplicateFetchError):
(JSC::JSModuleLoader::ModuleFailure::ModuleFailure):
(JSC::JSModuleLoader::ModuleFailure::isEvaluationError const):
(JSC::JSModuleLoader::ModuleFailure::operator bool const):
(JSC::JSModuleLoader::getErrorInfo):
(JSC::JSModuleLoader::attachErrorInfo):
(JSC::JSModuleLoader::JSModuleLoader):
(JSC::JSModuleLoader::destroy):
(JSC::JSModuleLoader::finishCreation):
(JSC::JSModuleLoader::visitChildrenImpl):
(JSC::JSModuleLoader::dependencyKeysIfEvaluated):
(JSC::JSModuleLoader::provideFetch):
(JSC::getFetchType):
(JSC::JSModuleLoader::loadModule):
(JSC::JSModuleLoader::linkAndEvaluateModule):
(JSC::JSModuleLoader::requestImportModule):
(JSC::JSModuleLoader::importModule):
(JSC::JSModuleLoader::resolve):
(JSC::JSModuleLoader::fetch):
(JSC::JSModuleLoader::getImportedModule):
(JSC::JSModuleLoader::maybeGetImportedModule):
(JSC::JSModuleLoader::hostLoadImportedModule):
(JSC::checkSafeToRecurse):
(JSC::JSModuleLoader::innerModuleLoading):
(JSC::JSModuleLoader::finishLoadingImportedModule):
(JSC::JSModuleLoader::continueModuleLoading):
(JSC::JSModuleLoader::continueDynamicImport):
(JSC::JSModuleLoader::loadRequestedModules):
(JSC::JSModuleLoader::ensureRegistered):
(JSC::JSModuleLoader::getRegisteredMayBeNull):
(JSC::JSModuleLoader::addResolutionFailure):
(JSC::JSModuleLoader::ModuleReferrer::getScript const):
(JSC::JSModuleLoader::ModuleReferrer::getModule const):
(JSC::JSModuleLoader::ModuleReferrer::getRealm const):
(JSC::JSModuleLoader::ModuleReferrer::isScript const):
(JSC::JSModuleLoader::ModuleReferrer::isModule const):
(JSC::JSModuleLoader::ModuleReferrer::isRealm const):
(JSC::JSModuleLoader::ModuleReferrer::toJSValue const):
(JSC::JSModuleLoader::makeModule):
(JSC::JSModuleLoader::loadAndEvaluateModule): Deleted.
(JSC::JSC_DEFINE_HOST_FUNCTION): Deleted.
(JSC::stringFromScriptFetchParametersType): Deleted.
* Source/JavaScriptCore/runtime/JSModuleLoader.h:
* Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h:
(JSC::JSModuleLoader::createStructure):
* Source/JavaScriptCore/runtime/JSModuleRecord.cpp:
(JSC::JSModuleRecord::evaluate):
(JSC::JSModuleRecord::execute):
(JSC::JSModuleRecord::getOrMakeExecutable):
(JSC::JSModuleRecord::createStructure): Deleted.
(JSC::JSModuleRecord::link):
(JSC::JSModuleRecord::instantiateDeclarations): Deleted.
* Source/JavaScriptCore/runtime/JSModuleRecord.h:
* Source/JavaScriptCore/runtime/JSModuleRecordInlines.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::JSModuleRecord::createStructure):
* Source/JavaScriptCore/runtime/JSPromise.h:
* Source/JavaScriptCore/runtime/JSType.cpp:
(WTF::printInternal):
* Source/JavaScriptCore/runtime/JSType.h:
* Source/JavaScriptCore/runtime/Microtask.h:
* Source/JavaScriptCore/runtime/ModuleGraphLoadingState.cpp: Added.
(JSC::ModuleGraphLoadingState::ModuleGraphLoadingState):
(JSC::ModuleGraphLoadingState::destroy):
(JSC::ModuleGraphLoadingState::finishCreation):
(JSC::ModuleGraphLoadingState::visitChildrenImpl):
(JSC::ModuleGraphLoadingState::create):
(JSC::ModuleGraphLoadingState::promise const):
(JSC::ModuleGraphLoadingState::pendingModulesCount const):
(JSC::ModuleGraphLoadingState::isLoading const):
(JSC::ModuleGraphLoadingState::scriptFetcher const):
(JSC::ModuleGraphLoadingState::pendingModulesCount):
(JSC::ModuleGraphLoadingState::isLoading):
(JSC::ModuleGraphLoadingState::scriptFetcher):
(JSC::ModuleGraphLoadingState::appendVisited):
(JSC::ModuleGraphLoadingState::containsVisited const):
* Source/JavaScriptCore/runtime/ModuleGraphLoadingState.h: Copied from Source/JavaScriptCore/runtime/JSModuleRecord.h.
* Source/JavaScriptCore/runtime/ModuleGraphLoadingStateInlines.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::ModuleGraphLoadingState::createStructure):
* Source/JavaScriptCore/runtime/ModuleLoaderPayload.cpp: Added.
(JSC::ModuleLoaderPayload::ModuleLoaderPayload):
(JSC::ModuleLoaderPayload::destroy):
(JSC::ModuleLoaderPayload::finishCreation):
(JSC::ModuleLoaderPayload::visitChildrenImpl):
(JSC::ModuleLoaderPayload::create):
(JSC::ModuleLoaderPayload::getState const):
(JSC::ModuleLoaderPayload::getPromise const):
(JSC::ModuleLoaderPayload::isState const):
(JSC::ModuleLoaderPayload::isPromise const):
(JSC::ModuleLoaderPayload::underlyingPromise const):
(JSC::ModuleLoaderPayload::fulfillment const):
(JSC::ModuleLoaderPayload::fulfillment):
(JSC::ModuleLoaderPayload::decrementRemaining):
* Source/JavaScriptCore/runtime/ModuleLoaderPayload.h: Copied from Source/JavaScriptCore/API/JSAPIGlobalObject.h.
* Source/JavaScriptCore/runtime/ModuleLoaderPayloadInlines.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::ModuleLoaderPayload::createStructure):
* Source/JavaScriptCore/runtime/ModuleLoadingContext.cpp: Added.
(JSC::ModuleLoadingContext::ModuleLoadingContext):
(JSC::ModuleLoadingContext::destroy):
(JSC::ModuleLoadingContext::create):
(JSC::ModuleLoadingContext::referrer const):
(JSC::ModuleLoadingContext::visitChildrenImpl):
* Source/JavaScriptCore/runtime/ModuleLoadingContext.h: Added.
* Source/JavaScriptCore/runtime/ModuleLoadingContextInlines.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::ModuleLoadingContext::createStructure):
* Source/JavaScriptCore/runtime/ModuleMap.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::ModuleMapHash::hash):
(JSC::ModuleMapHash::equal):
(JSC::ResolutionMapHash::hash):
(JSC::ResolutionMapHash::equal):
* Source/JavaScriptCore/runtime/ModuleRegistryEntry.cpp: Added.
(JSC::ModuleRegistryEntry::ModuleRegistryEntry):
(JSC::ModuleRegistryEntry::destroy):
(JSC::ModuleRegistryEntry::finishCreation):
(JSC::ModuleRegistryEntry::visitChildrenImpl):
(JSC::ModuleRegistryEntry::create):
(JSC::ModuleRegistryEntry::key const):
(JSC::ModuleRegistryEntry::moduleType const):
(JSC::ModuleRegistryEntry::record const):
(JSC::ModuleRegistryEntry::ensureFetchPromise):
(JSC::ModuleRegistryEntry::ensureModulePromise):
(JSC::ModuleRegistryEntry::loadPromise const):
(JSC::ModuleRegistryEntry::error const):
(JSC::ModuleRegistryEntry::fetchError const):
(JSC::ModuleRegistryEntry::instantiationError const):
(JSC::ModuleRegistryEntry::evaluationError const):
(JSC::ModuleRegistryEntry::status const):
(JSC::ModuleRegistryEntry::record):
(JSC::ModuleRegistryEntry::loadPromise):
(JSC::ModuleRegistryEntry::fetchError):
(JSC::ModuleRegistryEntry::instantiationError):
(JSC::ModuleRegistryEntry::evaluationError):
(JSC::ModuleRegistryEntry::status):
(JSC::ModuleRegistryEntry::provideFetch):
(JSC::ModuleRegistryEntry::fetchComplete):
* Source/JavaScriptCore/runtime/ModuleRegistryEntry.h: Copied from Source/JavaScriptCore/runtime/JSModuleRecord.h.
* Source/JavaScriptCore/runtime/ModuleRegistryEntryInlines.h: Copied from Source/JavaScriptCore/runtime/JSModuleLoaderInlines.h.
(JSC::ModuleRegistryEntry::createStructure):
* Source/JavaScriptCore/runtime/PinballCompletion.cpp:
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::visitAggregateImpl):
* Source/JavaScriptCore/runtime/VM.h:
(JSC::VM::incrementModuleAsyncEvaluationCount):
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::link):
* Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.h:
* Source/WebCore/bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::moduleLoaderResolve):
(WebCore::JSDOMGlobalObject::moduleLoaderFetch):
(WebCore::JSDOMGlobalObject::moduleLoaderImportModule):
* Source/WebCore/bindings/js/JSDOMGlobalObject.h:
* Source/WebCore/bindings/js/JSExecState.h:
(WebCore::JSExecState::loadModule):
(WebCore::JSExecState::linkAndEvaluateModule):
* Source/WebCore/bindings/js/ScriptController.cpp:
(WebCore::ScriptController::linkAndEvaluateModuleScriptInWorld):
(WebCore::ScriptController::linkAndEvaluateModuleScript):
(WebCore::ScriptController::setupModuleScriptHandlers):
* Source/WebCore/bindings/js/ScriptController.h:
* Source/WebCore/bindings/js/ScriptModuleLoader.cpp:
(WebCore::parseURLLikeModuleSpecifier):
(WebCore::ScriptModuleLoader::resolve):
(WebCore::ScriptModuleLoader::fetch):
(WebCore::rejectPromise):
(WebCore::ScriptModuleLoader::importModule):
(WebCore::ScriptModuleLoader::notifyFinished):
* Source/WebCore/bindings/js/ScriptModuleLoader.h:
* Source/WebCore/workers/WorkerOrWorkletScriptController.cpp:
(WebCore::WorkerOrWorkletScriptController::linkAndEvaluateModule):
(WebCore::WorkerOrWorkletScriptController::loadAndEvaluateModule):
* Tools/TestWebKitAPI/Resources/cocoa/coreipc.js:
(resolveAlias):
(isPrimitiveType):
(isPrimtiveType): Deleted.
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionContext.mm:
(TestWebKitAPI::TEST(WKWebExtensionContext, TopLevelThrowInModuleBackground)):
(TestWebKitAPI::TEST(WKWebExtensionContext, TopLevelThrowInPopup)):

Canonical link: https://commits.webkit.org/311236@main
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 311236@main (4a63810): https://commits.webkit.org/311236@main

Reviewed commits have been landed. Closing PR #57827 and removing active labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants