Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7f062965e945c0a7118392143155c12223d2747c
https://github.com/WebKit/WebKit/commit/7f062965e945c0a7118392143155c12223d2747c
Author: Sosuke Suzuki <[email protected]>
Date: 2026-05-17 (Sun, 17 May 2026)
Changed paths:
A JSTests/modules/import-defer-dynamic-evaluation.js
A JSTests/modules/import-defer-dynamic-rejects.js
A JSTests/modules/import-defer-dynamic-syntax.js
A JSTests/modules/import-defer-dynamic-tla.js
A JSTests/modules/import-defer-dynamic.js
M JSTests/test262/config.yaml
M Source/JavaScriptCore/API/JSAPIGlobalObject.h
M Source/JavaScriptCore/API/JSAPIGlobalObject.mm
M Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
M Source/JavaScriptCore/jsc.cpp
M Source/JavaScriptCore/parser/ASTBuilder.h
M Source/JavaScriptCore/parser/NodeConstructors.h
M Source/JavaScriptCore/parser/Nodes.h
M Source/JavaScriptCore/parser/Parser.cpp
M Source/JavaScriptCore/parser/SyntaxChecker.h
M Source/JavaScriptCore/runtime/Completion.cpp
M Source/JavaScriptCore/runtime/Completion.h
M Source/JavaScriptCore/runtime/GlobalObjectMethodTable.h
M Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
M Source/JavaScriptCore/runtime/JSMicrotask.cpp
M Source/JavaScriptCore/runtime/JSModuleLoader.cpp
M Source/JavaScriptCore/runtime/JSModuleLoader.h
M Source/JavaScriptCore/runtime/Microtask.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
M Source/WebCore/bindings/js/JSDOMGlobalObject.cpp
M Source/WebCore/bindings/js/JSDOMGlobalObject.h
M Source/WebCore/bindings/js/ScriptModuleLoader.cpp
M Source/WebCore/bindings/js/ScriptModuleLoader.h
Log Message:
-----------
[JSC] Implement dynamic `import.defer()` semantics
https://bugs.webkit.org/show_bug.cgi?id=314794
Reviewed by Keith Miller.
This implements the dynamic `import.defer(specifier)` form of the Deferred
Module Evaluation proposal[1], following up on r299443 (313827) which added
the static `import defer * as ns` form.
Per ContinueDynamicImport[2], when the import phase is `defer`, the module
graph is loaded and linked exactly as for `import()`, but the deferred root is
not executed. Instead, GatherAsynchronousTransitiveDependencies() collects the
post-order list of unexecuted top-level-await modules in the graph; each is
evaluated, and the import.defer() promise resolves to the deferred module
namespace once all of those evaluation promises settle. If the gather returns
nothing (no async transitive deps), the deferred namespace is returned without
scheduling any evaluation.
Two new internal microtasks implement the deferred-phase pipeline.
DynamicImportDeferLoadSettled performs link, gathers async transitive
dependencies, and evaluates them. DynamicImportDeferDependencySettled is a
SafePerformPromiseAll-equivalent AND-join, reusing
JSPromiseCombinatorsGlobalContext as the counter cell. Per spec the join must
not look up `then` on the dep promises, which the test262 fixture
promise-prototype-then-not-called.js verifies.
The feature remains gated behind `--useImportDefer`.
[1] https://tc39.es/proposal-defer-import-eval/
[2] https://tc39.es/proposal-defer-import-eval/#sec-ContinueDynamicImport
Tests: JSTests/modules/import-defer-dynamic-evaluation.js
JSTests/modules/import-defer-dynamic-rejects.js
JSTests/modules/import-defer-dynamic-syntax.js
JSTests/modules/import-defer-dynamic-tla.js
JSTests/modules/import-defer-dynamic.js
* JSTests/modules/import-defer-dynamic-evaluation.js: Added.
* JSTests/modules/import-defer-dynamic-rejects.js: Added.
(catch):
* JSTests/modules/import-defer-dynamic-syntax.js: Added.
(try.await.import.defer.toString):
(catch):
* JSTests/modules/import-defer-dynamic-tla.js: Added.
* JSTests/modules/import-defer-dynamic.js: Added.
* JSTests/test262/config.yaml:
* Source/JavaScriptCore/API/JSAPIGlobalObject.h:
* Source/JavaScriptCore/API/JSAPIGlobalObject.mm:
(JSC::JSAPIGlobalObject::moduleLoaderImportModule):
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::ImportNode::emitBytecode):
* Source/JavaScriptCore/jsc.cpp:
(GlobalObject::moduleLoaderImportModule):
* Source/JavaScriptCore/parser/ASTBuilder.h:
(JSC::ASTBuilder::createImportExpr):
* Source/JavaScriptCore/parser/NodeConstructors.h:
(JSC::ImportNode::ImportNode):
* Source/JavaScriptCore/parser/Nodes.h:
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseMemberExpression):
* Source/JavaScriptCore/parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createImportExpr):
* Source/JavaScriptCore/runtime/Completion.cpp:
(JSC::importModule):
* Source/JavaScriptCore/runtime/Completion.h:
* Source/JavaScriptCore/runtime/GlobalObjectMethodTable.h:
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSMicrotask.cpp:
(JSC::moduleLoadTopSettled):
(JSC::resolveDeferredImportNamespace):
(JSC::dynamicImportLoadSettled):
(JSC::dynamicImportDeferDependencySettled):
(JSC::runInternalMicrotask):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::JSModuleLoader::loadModule):
(JSC::JSModuleLoader::requestImportModule):
(JSC::JSModuleLoader::importModule):
(JSC::JSModuleLoader::finishLoadingImportedModule):
(JSC::JSModuleLoader::continueDynamicImport):
* Source/JavaScriptCore/runtime/JSModuleLoader.h:
* Source/JavaScriptCore/runtime/Microtask.h:
* Source/JavaScriptCore/runtime/ModuleLoaderPayload.cpp:
(JSC::ModuleLoaderPayload::ModuleLoaderPayload):
(JSC::ModuleLoaderPayload::create):
* Source/JavaScriptCore/runtime/ModuleLoaderPayload.h:
* Source/JavaScriptCore/runtime/ModuleLoadingContext.cpp:
(JSC::ModuleLoadingContext::ModuleLoadingContext):
(JSC::ModuleLoadingContext::create):
* Source/JavaScriptCore/runtime/ModuleLoadingContext.h:
* Source/WebCore/bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::moduleLoaderImportModule):
* Source/WebCore/bindings/js/JSDOMGlobalObject.h:
* Source/WebCore/bindings/js/ScriptModuleLoader.cpp:
(WebCore::ScriptModuleLoader::importModule):
* Source/WebCore/bindings/js/ScriptModuleLoader.h:
Canonical link: https://commits.webkit.org/313376@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications