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 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 return MaybeHandle<Code>(); | 1072 return MaybeHandle<Code>(); |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { | 1075 MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { |
| 1076 Isolate* isolate = function->GetIsolate(); | 1076 Isolate* isolate = function->GetIsolate(); |
| 1077 DCHECK(!isolate->has_pending_exception()); | 1077 DCHECK(!isolate->has_pending_exception()); |
| 1078 DCHECK(!function->is_compiled()); | 1078 DCHECK(!function->is_compiled()); |
| 1079 TimerEventScope<TimerEventCompileCode> compile_timer(isolate); | 1079 TimerEventScope<TimerEventCompileCode> compile_timer(isolate); |
| 1080 TRACE_EVENT0("v8", "V8.CompileCode"); | 1080 TRACE_EVENT0("v8", "V8.CompileCode"); |
| 1081 AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 1081 AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); |
| 1082 | |
| 1083 if (FLAG_turbo_cache_shared_code) { | |
| 1084 SharedFunctionInfo* shared = function->shared(); | |
| 1085 CodeAndLiterals result; | |
| 1086 result = shared->SearchOptimizedCodeMap( | |
|
Michael Starzinger
2016/04/08 12:44:02
nit: Just use "function->shared()" directly here,
mvstanton
2016/04/11 13:36:14
Done.
| |
| 1087 *function->GetIsolate()->native_context(), BailoutId::None()); | |
|
Michael Starzinger
2016/04/08 12:44:02
nit: The "isolate" variable is available, let's us
mvstanton
2016/04/11 13:36:14
Done.
| |
| 1088 if (result.code != nullptr) { | |
| 1089 return Handle<Code>(result.code); | |
| 1090 } | |
| 1091 } | |
| 1092 | |
| 1082 // If the debugger is active, do not compile with turbofan unless we can | 1093 // If the debugger is active, do not compile with turbofan unless we can |
| 1083 // deopt from turbofan code. | 1094 // deopt from turbofan code. |
| 1084 if (FLAG_turbo_asm && function->shared()->asm_function() && | 1095 if (FLAG_turbo_asm && function->shared()->asm_function() && |
| 1085 (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active()) && | 1096 (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active()) && |
| 1086 !FLAG_turbo_osr) { | 1097 !FLAG_turbo_osr) { |
| 1087 Handle<Code> code; | 1098 Handle<Code> code; |
| 1088 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT).ToHandle(&code)) { | 1099 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT).ToHandle(&code)) { |
| 1089 DCHECK(function->shared()->is_compiled()); | 1100 DCHECK(function->shared()->is_compiled()); |
| 1090 return code; | 1101 return code; |
| 1091 } | 1102 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1308 return true; | 1319 return true; |
| 1309 } | 1320 } |
| 1310 | 1321 |
| 1311 bool Compiler::ParseAndAnalyze(ParseInfo* info) { | 1322 bool Compiler::ParseAndAnalyze(ParseInfo* info) { |
| 1312 if (!Parser::ParseStatic(info)) return false; | 1323 if (!Parser::ParseStatic(info)) return false; |
| 1313 return Compiler::Analyze(info); | 1324 return Compiler::Analyze(info); |
| 1314 } | 1325 } |
| 1315 | 1326 |
| 1316 bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) { | 1327 bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) { |
| 1317 if (function->is_compiled()) return true; | 1328 if (function->is_compiled()) return true; |
| 1329 | |
| 1318 MaybeHandle<Code> maybe_code = GetLazyCode(function); | 1330 MaybeHandle<Code> maybe_code = GetLazyCode(function); |
| 1319 Handle<Code> code; | 1331 Handle<Code> code; |
| 1320 if (!maybe_code.ToHandle(&code)) { | 1332 if (!maybe_code.ToHandle(&code)) { |
| 1321 if (flag == CLEAR_EXCEPTION) { | 1333 if (flag == CLEAR_EXCEPTION) { |
| 1322 function->GetIsolate()->clear_pending_exception(); | 1334 function->GetIsolate()->clear_pending_exception(); |
| 1323 } | 1335 } |
| 1324 return false; | 1336 return false; |
| 1325 } | 1337 } |
| 1326 DCHECK(code->IsJavaScriptCode()); | 1338 DCHECK(code->IsJavaScriptCode()); |
| 1327 function->ReplaceCode(*code); | 1339 function->ReplaceCode(*code); |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1898 MaybeHandle<Code> code; | 1910 MaybeHandle<Code> code; |
| 1899 if (cached.code != nullptr) code = handle(cached.code); | 1911 if (cached.code != nullptr) code = handle(cached.code); |
| 1900 Handle<Context> native_context(function->context()->native_context()); | 1912 Handle<Context> native_context(function->context()->native_context()); |
| 1901 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1913 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
| 1902 literals, BailoutId::None()); | 1914 literals, BailoutId::None()); |
| 1903 } | 1915 } |
| 1904 } | 1916 } |
| 1905 | 1917 |
| 1906 } // namespace internal | 1918 } // namespace internal |
| 1907 } // namespace v8 | 1919 } // namespace v8 |
| OLD | NEW |