| 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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 return MaybeHandle<Code>(); | 884 return MaybeHandle<Code>(); |
| 885 } | 885 } |
| 886 | 886 |
| 887 MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { | 887 MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { |
| 888 Isolate* isolate = function->GetIsolate(); | 888 Isolate* isolate = function->GetIsolate(); |
| 889 DCHECK(!isolate->has_pending_exception()); | 889 DCHECK(!isolate->has_pending_exception()); |
| 890 DCHECK(!function->is_compiled()); | 890 DCHECK(!function->is_compiled()); |
| 891 TimerEventScope<TimerEventCompileCode> compile_timer(isolate); | 891 TimerEventScope<TimerEventCompileCode> compile_timer(isolate); |
| 892 TRACE_EVENT0("v8", "V8.CompileCode"); | 892 TRACE_EVENT0("v8", "V8.CompileCode"); |
| 893 AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 893 AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); |
| 894 | |
| 895 if (FLAG_turbo_cache_shared_code) { | |
| 896 CodeAndLiterals result; | |
| 897 result = function->shared()->SearchOptimizedCodeMap( | |
| 898 *isolate->native_context(), BailoutId::None()); | |
| 899 if (result.code != nullptr) { | |
| 900 return Handle<Code>(result.code); | |
| 901 } | |
| 902 } | |
| 903 | |
| 904 // If the debugger is active, do not compile with turbofan unless we can | 894 // If the debugger is active, do not compile with turbofan unless we can |
| 905 // deopt from turbofan code. | 895 // deopt from turbofan code. |
| 906 if (FLAG_turbo_asm && function->shared()->asm_function() && | 896 if (FLAG_turbo_asm && function->shared()->asm_function() && |
| 907 (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active()) && | 897 (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active()) && |
| 908 !FLAG_turbo_osr) { | 898 !FLAG_turbo_osr) { |
| 909 Handle<Code> code; | 899 Handle<Code> code; |
| 910 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT).ToHandle(&code)) { | 900 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT).ToHandle(&code)) { |
| 911 DCHECK(function->shared()->is_compiled()); | 901 DCHECK(function->shared()->is_compiled()); |
| 912 return code; | 902 return code; |
| 913 } | 903 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 return true; | 1114 return true; |
| 1125 } | 1115 } |
| 1126 | 1116 |
| 1127 bool Compiler::ParseAndAnalyze(ParseInfo* info) { | 1117 bool Compiler::ParseAndAnalyze(ParseInfo* info) { |
| 1128 if (!Parser::ParseStatic(info)) return false; | 1118 if (!Parser::ParseStatic(info)) return false; |
| 1129 return Compiler::Analyze(info); | 1119 return Compiler::Analyze(info); |
| 1130 } | 1120 } |
| 1131 | 1121 |
| 1132 bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) { | 1122 bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) { |
| 1133 if (function->is_compiled()) return true; | 1123 if (function->is_compiled()) return true; |
| 1134 | |
| 1135 MaybeHandle<Code> maybe_code = GetLazyCode(function); | 1124 MaybeHandle<Code> maybe_code = GetLazyCode(function); |
| 1136 Handle<Code> code; | 1125 Handle<Code> code; |
| 1137 if (!maybe_code.ToHandle(&code)) { | 1126 if (!maybe_code.ToHandle(&code)) { |
| 1138 if (flag == CLEAR_EXCEPTION) { | 1127 if (flag == CLEAR_EXCEPTION) { |
| 1139 function->GetIsolate()->clear_pending_exception(); | 1128 function->GetIsolate()->clear_pending_exception(); |
| 1140 } | 1129 } |
| 1141 return false; | 1130 return false; |
| 1142 } | 1131 } |
| 1143 DCHECK(code->IsJavaScriptCode()); | 1132 DCHECK(code->IsJavaScriptCode()); |
| 1144 function->ReplaceCode(*code); | 1133 function->ReplaceCode(*code); |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 MaybeHandle<Code> code; | 1701 MaybeHandle<Code> code; |
| 1713 if (cached.code != nullptr) code = handle(cached.code); | 1702 if (cached.code != nullptr) code = handle(cached.code); |
| 1714 Handle<Context> native_context(function->context()->native_context()); | 1703 Handle<Context> native_context(function->context()->native_context()); |
| 1715 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1704 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
| 1716 literals, BailoutId::None()); | 1705 literals, BailoutId::None()); |
| 1717 } | 1706 } |
| 1718 } | 1707 } |
| 1719 | 1708 |
| 1720 } // namespace internal | 1709 } // namespace internal |
| 1721 } // namespace v8 | 1710 } // namespace v8 |
| OLD | NEW |