| 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 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 | 888 |
| 889 MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { | 889 MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { |
| 890 Isolate* isolate = function->GetIsolate(); | 890 Isolate* isolate = function->GetIsolate(); |
| 891 DCHECK(!isolate->has_pending_exception()); | 891 DCHECK(!isolate->has_pending_exception()); |
| 892 DCHECK(!function->is_compiled()); | 892 DCHECK(!function->is_compiled()); |
| 893 TimerEventScope<TimerEventCompileCode> compile_timer(isolate); | 893 TimerEventScope<TimerEventCompileCode> compile_timer(isolate); |
| 894 TRACE_EVENT0("v8", "V8.CompileCode"); | 894 TRACE_EVENT0("v8", "V8.CompileCode"); |
| 895 AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 895 AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); |
| 896 | 896 |
| 897 if (FLAG_turbo_cache_shared_code) { | 897 if (FLAG_turbo_cache_shared_code) { |
| 898 CodeAndLiterals result; | 898 Handle<Code> cached_code; |
| 899 result = function->shared()->SearchOptimizedCodeMap( | 899 if (GetCodeFromOptimizedCodeMap(function, BailoutId::None()) |
| 900 *isolate->native_context(), BailoutId::None()); | 900 .ToHandle(&cached_code)) { |
| 901 if (result.code != nullptr) { | 901 if (FLAG_trace_opt) { |
| 902 return Handle<Code>(result.code); | 902 PrintF("[found optimized code for "); |
| 903 function->ShortPrint(); |
| 904 PrintF(" during unoptimized compile]\n"); |
| 905 } |
| 906 DCHECK(function->shared()->is_compiled()); |
| 907 return cached_code; |
| 903 } | 908 } |
| 904 } | 909 } |
| 905 | 910 |
| 906 // If the debugger is active, do not compile with turbofan unless we can | 911 // If the debugger is active, do not compile with turbofan unless we can |
| 907 // deopt from turbofan code. | 912 // deopt from turbofan code. |
| 908 if (FLAG_turbo_asm && function->shared()->asm_function() && | 913 if (FLAG_turbo_asm && function->shared()->asm_function() && |
| 909 (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active()) && | 914 (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active()) && |
| 910 !FLAG_turbo_osr) { | 915 !FLAG_turbo_osr) { |
| 911 Handle<Code> code; | 916 Handle<Code> code; |
| 912 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT).ToHandle(&code)) { | 917 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT).ToHandle(&code)) { |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 MaybeHandle<Code> code; | 1719 MaybeHandle<Code> code; |
| 1715 if (cached.code != nullptr) code = handle(cached.code); | 1720 if (cached.code != nullptr) code = handle(cached.code); |
| 1716 Handle<Context> native_context(function->context()->native_context()); | 1721 Handle<Context> native_context(function->context()->native_context()); |
| 1717 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1722 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
| 1718 literals, BailoutId::None()); | 1723 literals, BailoutId::None()); |
| 1719 } | 1724 } |
| 1720 } | 1725 } |
| 1721 | 1726 |
| 1722 } // namespace internal | 1727 } // namespace internal |
| 1723 } // namespace v8 | 1728 } // namespace v8 |
| OLD | NEW |