Index: third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp |
diff --git a/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp b/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp |
index baceb7eedd23f10e52a9ea52e7ffd19e0cf300e0..b4400f988a3a5b7feee76b8800aa953144895064 100644 |
--- a/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp |
+++ b/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.cpp |
@@ -451,6 +451,14 @@ ModuleTreeLinker::UninstantiatedInclusiveDescendants() { |
// or null). |
DCHECK(current); |
+ // [nospec, optimization] |
+ // We can safely skip recursing into the descendants if the module graph |
+ // node status is "instantiated". The sub-graph is guaranteed to be all |
+ // "instantiated", thus never would end up in the "uninstantiated set". |
+ if (current->InstantiationState() == |
+ ModuleInstantiationState::kInstantiated) |
+ continue; |
+ |
// Step 4.3. If inclusive descendants and stack both do not contain current, |
// then: |
if (inclusive_descendants.Contains(current)) |