Chromium Code Reviews| Index: src/compiler.cc |
| diff --git a/src/compiler.cc b/src/compiler.cc |
| index 8e94f7637ad2cc3c29846dcbb5285ec2785674df..4d0ac2aecb673f4b5c70fb45b2f9f87ecb22cdfd 100644 |
| --- a/src/compiler.cc |
| +++ b/src/compiler.cc |
| @@ -647,11 +647,7 @@ static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
| static bool CompileUnoptimizedCode(CompilationInfo* info) { |
| DCHECK(AllowCompilation::IsAllowed(info->isolate())); |
| - DCHECK(info->function() != NULL); |
| - if (!Rewriter::Rewrite(info)) return false; |
| - if (!Scope::Analyze(info)) return false; |
| - DCHECK(info->scope() != NULL); |
| - |
| + if (!Compiler::Analyze(info)) return false; |
| if (!FullCodeGenerator::MakeCode(info)) { |
| Isolate* isolate = info->isolate(); |
| if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
| @@ -673,7 +669,6 @@ MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( |
| shared->set_strict_mode(lit->strict_mode()); |
| SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
| shared->set_bailout_reason(lit->dont_optimize_reason()); |
| - shared->set_ast_node_count(lit->ast_node_count()); |
| // Compile unoptimized code. |
| if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); |
| @@ -743,18 +738,33 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
| } |
| -static bool CompileOptimizedPrologue(CompilationInfo* info) { |
| - if (!Parser::Parse(info)) return false; |
| +static bool Renumber(CompilationInfo* info) { |
| + if (!AstNumbering::Renumber(info->function(), info->zone())) return false; |
| + if (!info->shared_info().is_null()) { |
| + info->shared_info()->set_ast_node_count(info->function()->ast_node_count()); |
| + } |
| + return true; |
| +} |
| + |
| + |
| +bool Compiler::Analyze(CompilationInfo* info) { |
| + DCHECK(info->function() != NULL); |
| if (!Rewriter::Rewrite(info)) return false; |
| if (!Scope::Analyze(info)) return false; |
| - if (!AstNumbering::Renumber(info->function(), info->zone())) return false; |
| + if (!Renumber(info)) return false; |
| DCHECK(info->scope() != NULL); |
| return true; |
| } |
| +bool Compiler::ParseAndAnalyze(CompilationInfo* info) { |
| + if (!Parser::Parse(info)) return false; |
| + return Compiler::Analyze(info); |
| +} |
| + |
| + |
| static bool GetOptimizedCodeNow(CompilationInfo* info) { |
| - if (!CompileOptimizedPrologue(info)) return false; |
| + if (!Compiler::ParseAndAnalyze(info)) return false; |
| TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); |
| @@ -796,7 +806,7 @@ static bool GetOptimizedCodeLater(CompilationInfo* info) { |
| } |
| CompilationHandleScope handle_scope(info); |
| - if (!CompileOptimizedPrologue(info)) return false; |
| + if (!Compiler::ParseAndAnalyze(info)) return false; |
| info->SaveHandles(); // Copy handles to the compilation handle scope. |
| TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); |
| @@ -918,6 +928,7 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { |
| unoptimized.PrepareForCompilation(info->scope()); |
| unoptimized.SetContext(info->context()); |
| unoptimized.EnableDeoptimizationSupport(); |
| + if (!Renumber(&unoptimized)) return false; |
|
Sven Panne
2014/10/24 08:25:12
Why do we need that here, i.e. what is the path le
|
| if (!FullCodeGenerator::MakeCode(&unoptimized)) return false; |
| Handle<SharedFunctionInfo> shared = info->shared_info(); |
| @@ -1304,7 +1315,7 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo( |
| Handle<Code> code = isolate->builtins()->CompileLazy(); |
| info.SetCode(code); |
| scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate)); |
| - } else if (FullCodeGenerator::MakeCode(&info)) { |
| + } else if (Renumber(&info) && FullCodeGenerator::MakeCode(&info)) { |
| DCHECK(!info.code().is_null()); |
| scope_info = ScopeInfo::Create(info.scope(), info.zone()); |
| } else { |