Skip to content

[JSC] Rewrite module loader#57827

Open
heimskr wants to merge 1 commit intoWebKit:mainfrom
heimskr:eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await
Open

[JSC] Rewrite module loader#57827
heimskr wants to merge 1 commit intoWebKit:mainfrom
heimskr:eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await

Conversation

@heimskr
Copy link
Contributor

@heimskr heimskr commented Feb 4, 2026

36e0098

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

Reviewed by NOBODY (OOPS!).

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.

Added a test (JSTests/modules/sync-from-async.js) that used to cause an
assertion failure in debug builds of jsc.

* JSTests/modules/sync-from-async.js: Added.
* JSTests/modules/sync-from-async/a.js: Added.
* JSTests/modules/sync-from-async/b.js: Added.
(shouldThrow):
* 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:
* 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/Sources.txt:
* 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::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::loadedModules):
(JSC::AbstractModuleRecord::loadedModules const):
(JSC::AbstractModuleRecord::asyncParentModules const):
(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::runInternalMicrotask):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::jsValueToSpecifier):
(JSC::isFetchError):
(JSC::JSModuleLoader::duplicateTypeError):
(JSC::JSModuleLoader::duplicateError):
(JSC::maybeDuplicateFetchError):
(JSC::JSModuleLoader::ModuleFailure::ModuleFailure):
(JSC::JSModuleLoader::ModuleFailure::isEvaluationError const):
(JSC::JSModuleLoader::ModuleFailure::operator bool const):
(JSC::getErrorInfo):
(JSC::attachErrorInfo):
(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::moduleRequestsEqual):
(JSC::JSModuleLoader::getImportedModule):
(JSC::JSModuleLoader::maybeGetImportedModule):
(JSC::JSModuleLoader::hostLoadImportedModule):
(JSC::JSModuleLoader::innerModuleLoading):
(JSC::JSModuleLoader::finishLoadingImportedModule):
(JSC::JSModuleLoader::continueModuleLoading):
(JSC::JSModuleLoader::continueDynamicImport):
(JSC::JSModuleLoader::loadRequestedModules):
(JSC::JSModuleLoader::ensureRegistered):
(JSC::JSModuleLoader::getRegisteredMayBeNull):
(JSC::JSModuleLoader::ModuleMapEntry::getRecord const):
(JSC::JSModuleLoader::ModuleMapEntry::isRecord const):
(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):
* 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/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:

36e0098

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ❌ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 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
✅ 🛠 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
Copy link

@Jarred-Sumner Jarred-Sumner left a comment

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

RETURN_IF_EXCEPTION(scope, void());

// Because `this` keeps `fetchPromise` alive (and, by extension, onFetchFulfilled), it's okay for the fulfillment function to capture `this`.
JSValue onFetchFulfilled = JSNativeStdFunction::create(vm, globalObject, 1, { }, [this](JSGlobalObject* globalObject, CallFrame* callFrame) {

Choose a reason for hiding this comment

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

Can we avoid the JSNativeStdFunction here similarly to everywhere else?


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

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

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
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);

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
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
Copy link
Contributor Author

heimskr commented Feb 4, 2026

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
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
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
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
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
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
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
@webkit-ews-buildbot
Copy link
Collaborator

macOS Safer C++ Build #83580 (9de40ff)

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

Comment on lines +97 to +98
auto values = thisObject->m_dependencies.values();
visitor.append(values.begin(), values.end());
Copy link
Member

Choose a reason for hiding this comment

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

You need to protect this hashtable access with a lock since this visitChildren is concurrently running. (See cellLock() for example).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do I need to lock it before accessing it elsewhere too, or just here?

Copy link
Member

Choose a reason for hiding this comment

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

Ultimately, when we need to take a lock is,

  1. When the main thread is modifying the table
  2. When accessing it from the concurrent thread

But I think it is fine that we just guard it in every case. It is not performance critical part :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume this applies also to Vectors of WriteBarriers, right?

// Based on the Source Text Module Record
// http://www.ecma-international.org/ecma-262/6.0/#sec-source-text-module-records
class AbstractModuleRecord : public JSInternalFieldObjectImpl<2> {
class AbstractModuleRecord : public JSInternalFieldObjectImpl<3> {
Copy link
Member

Choose a reason for hiding this comment

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

We are using JSInternalFieldObjectImpl because this was accessed from JS code (so internal field was useful to use it). But now ModuleLoader.js is removed. This means we can just put these flags directly in AbstractModuleRecord and we no longer need to have JSInternalFieldObjectImpl. Probably we can just inherit JSCell.

Copy link
Contributor Author

@heimskr heimskr Mar 3, 2026

Choose a reason for hiding this comment

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

Do you have advice on how I should change this part of BytecodeGenerator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@heimskr heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 9de40ff to dcd54eb Compare March 3, 2026 19:59
@heimskr heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from dcd54eb to 5fa61cb Compare March 3, 2026 21:17
@heimskr heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 5fa61cb to d433f74 Compare March 3, 2026 23:44
@heimskr heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from d433f74 to 959a007 Compare March 3, 2026 23:59
@webkit-ews-buildbot
Copy link
Collaborator

macOS Safer C++ Build #83777 (5fa61cb)

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

@webkit-ews-buildbot
Copy link
Collaborator

iOS Safer C++ Build #2067 (5fa61cb)

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

@webkit-ews-buildbot
Copy link
Collaborator

macOS Safer C++ Build #83824 (959a007)

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

@webkit-ews-buildbot
Copy link
Collaborator

iOS Safer C++ Build #2114 (959a007)

❌ Found 2 failing files with 3 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 959a007 to 4a2a374 Compare March 4, 2026 17:51
@webkit-ews-buildbot
Copy link
Collaborator

macOS Safer C++ Build #83956 (4a2a374)

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

@webkit-ews-buildbot
Copy link
Collaborator

iOS Safer C++ Build #2246 (4a2a374)

❌ Found 2 failing files with 3 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 4a2a374 to 431d87a Compare March 5, 2026 22:17
@heimskr heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from 431d87a to ebde759 Compare March 6, 2026 00:39
@webkit-ews-buildbot
Copy link
Collaborator

macOS Safer C++ Build #84309 (ebde759)

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

@webkit-ews-buildbot
Copy link
Collaborator

iOS Safer C++ Build #2574 (ebde759)

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

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

Reviewed by NOBODY (OOPS!).

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.

Added a test (JSTests/modules/sync-from-async.js) that used to cause an
assertion failure in debug builds of jsc.

* JSTests/modules/sync-from-async.js: Added.
* JSTests/modules/sync-from-async/a.js: Added.
* JSTests/modules/sync-from-async/b.js: Added.
(shouldThrow):
* 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:
* 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/Sources.txt:
* 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::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::loadedModules):
(JSC::AbstractModuleRecord::loadedModules const):
(JSC::AbstractModuleRecord::asyncParentModules const):
(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::runInternalMicrotask):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::jsValueToSpecifier):
(JSC::isFetchError):
(JSC::JSModuleLoader::duplicateTypeError):
(JSC::JSModuleLoader::duplicateError):
(JSC::maybeDuplicateFetchError):
(JSC::JSModuleLoader::ModuleFailure::ModuleFailure):
(JSC::JSModuleLoader::ModuleFailure::isEvaluationError const):
(JSC::JSModuleLoader::ModuleFailure::operator bool const):
(JSC::getErrorInfo):
(JSC::attachErrorInfo):
(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::moduleRequestsEqual):
(JSC::JSModuleLoader::getImportedModule):
(JSC::JSModuleLoader::maybeGetImportedModule):
(JSC::JSModuleLoader::hostLoadImportedModule):
(JSC::JSModuleLoader::innerModuleLoading):
(JSC::JSModuleLoader::finishLoadingImportedModule):
(JSC::JSModuleLoader::continueModuleLoading):
(JSC::JSModuleLoader::continueDynamicImport):
(JSC::JSModuleLoader::loadRequestedModules):
(JSC::JSModuleLoader::ensureRegistered):
(JSC::JSModuleLoader::getRegisteredMayBeNull):
(JSC::JSModuleLoader::ModuleMapEntry::getRecord const):
(JSC::JSModuleLoader::ModuleMapEntry::isRecord const):
(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):
* 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/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:
@heimskr heimskr force-pushed the eng/JSC-ReferenceError-when-multiple-modules-are-simultaneously-importing-a-module-containing-a-top-level-await branch from ebde759 to 36e0098 Compare March 6, 2026 20:24
@webkit-ews-buildbot
Copy link
Collaborator

macOS Safer C++ Build #84508 (36e0098)

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

@webkit-ews-buildbot
Copy link
Collaborator

iOS Safer C++ Build #2747 (36e0098)

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

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

Labels

merging-blocked Applied to prevent a change from being merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants