Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index 1972fd10b6e64463cf5ddb872bbad5b451efa231..d979662fe351cd575e9d7fac60392d6680b4a566 100644 |
--- a/src/compiler.cc |
+++ b/src/compiler.cc |
@@ -434,6 +434,17 @@ CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job) { |
return status; |
} |
+void SetSharedFunctionFlagsFromLiteral(FunctionLiteral* literal, |
+ Handle<SharedFunctionInfo> shared_info) { |
+ shared_info->set_ast_node_count(literal->ast_node_count()); |
+ if (literal->dont_optimize_reason() != kNoReason) { |
+ shared_info->DisableOptimization(literal->dont_optimize_reason()); |
+ } |
+ if (literal->flags() & AstProperties::kMustUseIgnitionTurbo) { |
+ shared_info->set_must_use_ignition_turbo(true); |
+ } |
+} |
+ |
bool Renumber(ParseInfo* parse_info, |
Compiler::EagerInnerFunctionLiterals* eager_literals) { |
RuntimeCallTimerScope runtimeTimer(parse_info->isolate(), |
@@ -443,16 +454,9 @@ bool Renumber(ParseInfo* parse_info, |
parse_info->zone(), parse_info->literal(), eager_literals)) { |
return false; |
} |
- Handle<SharedFunctionInfo> shared_info = parse_info->shared_info(); |
- if (!shared_info.is_null()) { |
- FunctionLiteral* lit = parse_info->literal(); |
- shared_info->set_ast_node_count(lit->ast_node_count()); |
- if (lit->dont_optimize_reason() != kNoReason) { |
- shared_info->DisableOptimization(lit->dont_optimize_reason()); |
- } |
- if (lit->flags() & AstProperties::kMustUseIgnitionTurbo) { |
- shared_info->set_must_use_ignition_turbo(true); |
- } |
+ if (!parse_info->shared_info().is_null()) { |
+ SetSharedFunctionFlagsFromLiteral(parse_info->literal(), |
+ parse_info->shared_info()); |
} |
return true; |
} |
@@ -481,7 +485,7 @@ bool GenerateUnoptimizedCode(CompilationInfo* info) { |
return true; |
} |
-bool CompileUnoptimizedInnerFunctionsRecursively( |
+bool CompileUnoptimizedInnerFunctions( |
ThreadedList<ThreadedListZoneEntry<FunctionLiteral*>>* literals, |
CompilationInfo* outer_info) { |
Isolate* isolate = outer_info->isolate(); |
@@ -491,21 +495,13 @@ bool CompileUnoptimizedInnerFunctionsRecursively( |
for (auto it : *literals) { |
FunctionLiteral* literal = it->value(); |
+ Handle<SharedFunctionInfo> shared = |
+ Compiler::GetSharedFunctionInfo(literal, script, outer_info); |
+ if (shared->is_compiled()) continue; |
- // Find any previously allocated shared function info for the given literal. |
- Handle<SharedFunctionInfo> shared; |
- MaybeHandle<SharedFunctionInfo> maybe_existing = |
- script->FindSharedFunctionInfo(isolate, literal); |
- if (maybe_existing.ToHandle(&shared)) { |
- DCHECK(!shared->is_toplevel()); |
- // If we found an existing shared function info with compiled code, |
- // we are done. |
- if (shared->is_compiled()) continue; |
- } else { |
- shared = |
- isolate->factory()->NewSharedFunctionInfoForLiteral(literal, script); |
- shared->set_is_toplevel(false); |
- } |
+ // The {literal} has already been numbered because AstNumbering decends into |
+ // eagerly compiled function literals. |
+ SetSharedFunctionFlagsFromLiteral(literal, shared); |
ParseInfo parse_info(script); |
parse_info.set_literal(literal); |
@@ -520,11 +516,7 @@ bool CompileUnoptimizedInnerFunctionsRecursively( |
if (outer_info->will_serialize()) info.PrepareForSerializing(); |
if (outer_info->is_debug()) info.MarkAsDebug(); |
- Compiler::EagerInnerFunctionLiterals inner_literals; |
- if (!Renumber(&parse_info, &inner_literals) || |
- !CompileUnoptimizedInnerFunctionsRecursively(&inner_literals, |
- outer_info) || |
- !GenerateUnoptimizedCode(&info)) { |
+ if (!GenerateUnoptimizedCode(&info)) { |
if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
return false; |
} |
@@ -544,7 +536,7 @@ bool CompileUnoptimizedCode(CompilationInfo* info) { |
Compiler::EagerInnerFunctionLiterals inner_literals; |
if (!Compiler::Analyze(info->parse_info(), &inner_literals) || |
- !CompileUnoptimizedInnerFunctionsRecursively(&inner_literals, info) || |
+ !CompileUnoptimizedInnerFunctions(&inner_literals, info) || |
!GenerateUnoptimizedCode(info)) { |
if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
return false; |