Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler.h" | 5 #include "src/compiler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/ast/ast-numbering.h" | 9 #include "src/ast/ast-numbering.h" |
| 10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 892 | 892 |
| 893 bool Compiler::ParseAndAnalyze(ParseInfo* info) { | 893 bool Compiler::ParseAndAnalyze(ParseInfo* info) { |
| 894 if (!Parser::ParseStatic(info)) return false; | 894 if (!Parser::ParseStatic(info)) return false; |
| 895 return Compiler::Analyze(info); | 895 return Compiler::Analyze(info); |
| 896 } | 896 } |
| 897 | 897 |
| 898 | 898 |
| 899 static bool GetOptimizedCodeNow(CompilationInfo* info) { | 899 static bool GetOptimizedCodeNow(CompilationInfo* info) { |
| 900 Isolate* isolate = info->isolate(); | 900 Isolate* isolate = info->isolate(); |
| 901 CanonicalHandleScope canonical(isolate); | 901 CanonicalHandleScope canonical(isolate); |
| 902 TimerEventScope<TimerEventOptimizeCode> optimizeCodeTimer(isolate); | |
|
Michael Starzinger
2016/02/03 15:36:26
nit: s/optimizeCodeTimer/optimize_code_timer/
Camillo Bruni
2016/02/04 17:48:33
arg, I fall back to easily to camelCase when progr
| |
| 902 | 903 |
| 903 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; | 904 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; |
| 904 | 905 |
| 905 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); | 906 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); |
| 906 | 907 |
| 907 OptimizedCompileJob job(info); | 908 OptimizedCompileJob job(info); |
| 908 if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED || | 909 if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED || |
| 909 job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED || | 910 job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED || |
| 910 job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) { | 911 job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) { |
| 911 if (FLAG_trace_opt) { | 912 if (FLAG_trace_opt) { |
| 912 PrintF("[aborted optimizing "); | 913 PrintF("[aborted optimizing "); |
| 913 info->closure()->ShortPrint(); | 914 info->closure()->ShortPrint(); |
| 914 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); | 915 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); |
| 915 } | 916 } |
| 916 return false; | 917 return false; |
| 917 } | 918 } |
| 918 | 919 |
| 919 // Success! | 920 // Success! |
| 920 DCHECK(!isolate->has_pending_exception()); | 921 DCHECK(!isolate->has_pending_exception()); |
| 921 InsertCodeIntoOptimizedCodeMap(info); | 922 InsertCodeIntoOptimizedCodeMap(info); |
| 922 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, | 923 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, |
| 923 info->shared_info()); | 924 info->shared_info()); |
| 924 return true; | 925 return true; |
| 925 } | 926 } |
| 926 | 927 |
| 927 | 928 |
| 928 static bool GetOptimizedCodeLater(CompilationInfo* info) { | 929 static bool GetOptimizedCodeLater(CompilationInfo* info) { |
| 929 Isolate* isolate = info->isolate(); | 930 Isolate* isolate = info->isolate(); |
| 930 CanonicalHandleScope canonical(isolate); | 931 CanonicalHandleScope canonical(isolate); |
| 932 TimerEventScope<TimerEventOptimizeCode> optimizeCodeTimer(isolate); | |
|
Michael Starzinger
2016/02/03 15:36:26
nit: s/optimizeCodeTimer/optimize_code_timer/
| |
| 931 | 933 |
| 932 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { | 934 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { |
| 933 if (FLAG_trace_concurrent_recompilation) { | 935 if (FLAG_trace_concurrent_recompilation) { |
| 934 PrintF(" ** Compilation queue full, will retry optimizing "); | 936 PrintF(" ** Compilation queue full, will retry optimizing "); |
| 935 info->closure()->ShortPrint(); | 937 info->closure()->ShortPrint(); |
| 936 PrintF(" later.\n"); | 938 PrintF(" later.\n"); |
| 937 } | 939 } |
| 938 return false; | 940 return false; |
| 939 } | 941 } |
| 940 | 942 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1185 Handle<ScopeInfo> scope_info = | 1187 Handle<ScopeInfo> scope_info = |
| 1186 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); | 1188 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); |
| 1187 info.shared_info()->set_scope_info(*scope_info); | 1189 info.shared_info()->set_scope_info(*scope_info); |
| 1188 } | 1190 } |
| 1189 tracker.RecordRootFunctionInfo(info.code()); | 1191 tracker.RecordRootFunctionInfo(info.code()); |
| 1190 } | 1192 } |
| 1191 | 1193 |
| 1192 | 1194 |
| 1193 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { | 1195 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { |
| 1194 Isolate* isolate = info->isolate(); | 1196 Isolate* isolate = info->isolate(); |
| 1197 TimerEventScope<TimerEventCompileCode> timer(isolate); | |
|
Michael Starzinger
2016/02/03 15:36:26
This does not cover lazily compiled functions, and
| |
| 1195 PostponeInterruptsScope postpone(isolate); | 1198 PostponeInterruptsScope postpone(isolate); |
| 1196 DCHECK(!isolate->native_context().is_null()); | 1199 DCHECK(!isolate->native_context().is_null()); |
| 1197 ParseInfo* parse_info = info->parse_info(); | 1200 ParseInfo* parse_info = info->parse_info(); |
| 1198 Handle<Script> script = parse_info->script(); | 1201 Handle<Script> script = parse_info->script(); |
| 1199 | 1202 |
| 1200 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? | 1203 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? |
| 1201 FixedArray* array = isolate->native_context()->embedder_data(); | 1204 FixedArray* array = isolate->native_context()->embedder_data(); |
| 1202 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); | 1205 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); |
| 1203 | 1206 |
| 1204 isolate->debug()->OnBeforeCompile(script); | 1207 isolate->debug()->OnBeforeCompile(script); |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1837 } | 1840 } |
| 1838 | 1841 |
| 1839 #if DEBUG | 1842 #if DEBUG |
| 1840 void CompilationInfo::PrintAstForTesting() { | 1843 void CompilationInfo::PrintAstForTesting() { |
| 1841 PrintF("--- Source from AST ---\n%s\n", | 1844 PrintF("--- Source from AST ---\n%s\n", |
| 1842 PrettyPrinter(isolate()).PrintProgram(literal())); | 1845 PrettyPrinter(isolate()).PrintProgram(literal())); |
| 1843 } | 1846 } |
| 1844 #endif | 1847 #endif |
| 1845 } // namespace internal | 1848 } // namespace internal |
| 1846 } // namespace v8 | 1849 } // namespace v8 |
| OLD | NEW |