Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index ba62de6298abb5cf8d65923e2889ec7358e3c6ee..b8fbbcfa2c31dea9d7fc002d6dcc7389d096ee65 100644 |
--- a/src/compiler.cc |
+++ b/src/compiler.cc |
@@ -1345,12 +1345,22 @@ |
} |
} |
-bool ContainsAsmModule(Handle<Script> script) { |
- WeakFixedArray::Iterator iter(script->shared_function_infos()); |
- DisallowHeapAllocation no_gc; |
- |
- while (SharedFunctionInfo* info = iter.Next<SharedFunctionInfo>()) { |
- if (info->HasAsmWasmData()) return true; |
+bool ContainsAsmModule(const Scope* scope, Zone* zone) { |
+ DCHECK_NOT_NULL(scope); |
+ DCHECK_NOT_NULL(zone); |
+ ZoneQueue<const Scope*> worklist(zone); |
+ // We assume scopes form a tree, so no need to check for cycles |
+ worklist.push(scope); |
+ while (!worklist.empty()) { |
+ const Scope* s = worklist.front(); |
+ worklist.pop(); |
+ if (s->IsAsmModule()) { |
+ return true; |
+ } |
+ for (const Scope* child = s->inner_scope(); child != nullptr; |
+ child = child->sibling()) { |
+ worklist.push(child); |
+ } |
} |
return false; |
} |
@@ -1497,7 +1507,7 @@ |
compilation_cache->PutScript(source, context, language_mode, result); |
if (FLAG_serialize_toplevel && |
compile_options == ScriptCompiler::kProduceCodeCache && |
- !ContainsAsmModule(script)) { |
+ !ContainsAsmModule(info.scope(), &zone)) { |
HistogramTimerScope histogram_timer( |
isolate->counters()->compile_serialize()); |
RuntimeCallTimerScope runtimeTimer(isolate, |