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 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 932 | 932 |
| 933 // Install compilation result on the shared function info | 933 // Install compilation result on the shared function info |
| 934 InstallSharedCompilationResult(&info, shared); | 934 InstallSharedCompilationResult(&info, shared); |
| 935 | 935 |
| 936 // Record the function compilation event. | 936 // Record the function compilation event. |
| 937 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, &info); | 937 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, &info); |
| 938 | 938 |
| 939 return info.code(); | 939 return info.code(); |
| 940 } | 940 } |
| 941 | 941 |
| 942 bool ShouldOptimizeForAsm(Isolate* isolate, Handle<JSFunction> function) { | |
| 943 // If the debugger is active, do not compile with turbofan unless we can | |
| 944 // deopt from turbofan code. | |
| 945 return FLAG_turbo_asm && function->shared()->asm_function() && | |
| 946 (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active()); | |
|
Michael Starzinger
2016/05/20 11:45:10
What would you thing about guarding this by FLAG_i
rmcilroy
2016/05/20 12:42:03
Is there any particularly reason we abandoned it?
Michael Starzinger
2016/05/23 14:45:38
As discussed offline: I am afraid this will tank o
rmcilroy
2016/05/23 15:07:53
Sounds good, I've updated this CL to only do this
titzer
2016/05/23 15:48:34
It's not type feedback, it's just that TF is too h
| |
| 947 } | |
| 948 | |
| 942 MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { | 949 MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { |
| 943 Isolate* isolate = function->GetIsolate(); | 950 Isolate* isolate = function->GetIsolate(); |
| 944 DCHECK(!isolate->has_pending_exception()); | 951 DCHECK(!isolate->has_pending_exception()); |
| 945 DCHECK(!function->is_compiled()); | 952 DCHECK(!function->is_compiled()); |
| 946 TimerEventScope<TimerEventCompileCode> compile_timer(isolate); | 953 TimerEventScope<TimerEventCompileCode> compile_timer(isolate); |
| 947 TRACE_EVENT0("v8", "V8.CompileCode"); | 954 TRACE_EVENT0("v8", "V8.CompileCode"); |
| 948 AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 955 AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); |
| 949 | 956 |
| 950 if (FLAG_turbo_cache_shared_code) { | 957 if (FLAG_turbo_cache_shared_code) { |
| 951 Handle<Code> cached_code; | 958 Handle<Code> cached_code; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 964 if (function->shared()->is_compiled()) { | 971 if (function->shared()->is_compiled()) { |
| 965 return Handle<Code>(function->shared()->code()); | 972 return Handle<Code>(function->shared()->code()); |
| 966 } | 973 } |
| 967 | 974 |
| 968 Zone zone(isolate->allocator()); | 975 Zone zone(isolate->allocator()); |
| 969 ParseInfo parse_info(&zone, function); | 976 ParseInfo parse_info(&zone, function); |
| 970 CompilationInfo info(&parse_info, function); | 977 CompilationInfo info(&parse_info, function); |
| 971 Handle<Code> result; | 978 Handle<Code> result; |
| 972 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); | 979 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); |
| 973 | 980 |
| 974 if (FLAG_always_opt) { | 981 if (FLAG_always_opt || ShouldOptimizeForAsm(isolate, function)) { |
|
Michael Starzinger
2016/05/20 11:45:10
Can we keep the optimization path for production a
rmcilroy
2016/05/20 12:42:03
Done.
| |
| 975 Handle<Code> opt_code; | 982 Handle<Code> opt_code; |
| 976 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) | 983 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) |
| 977 .ToHandle(&opt_code)) { | 984 .ToHandle(&opt_code)) { |
| 978 result = opt_code; | 985 result = opt_code; |
| 979 } | 986 } |
| 980 } | 987 } |
| 981 | 988 |
| 982 return result; | 989 return result; |
| 983 } | 990 } |
| 984 | 991 |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1757 if (FLAG_trace_opt) { | 1764 if (FLAG_trace_opt) { |
| 1758 PrintF("[aborted optimizing "); | 1765 PrintF("[aborted optimizing "); |
| 1759 info->closure()->ShortPrint(); | 1766 info->closure()->ShortPrint(); |
| 1760 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); | 1767 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); |
| 1761 } | 1768 } |
| 1762 info->closure()->ReplaceCode(shared->code()); | 1769 info->closure()->ReplaceCode(shared->code()); |
| 1763 } | 1770 } |
| 1764 | 1771 |
| 1765 void Compiler::PostInstantiation(Handle<JSFunction> function, | 1772 void Compiler::PostInstantiation(Handle<JSFunction> function, |
| 1766 PretenureFlag pretenure) { | 1773 PretenureFlag pretenure) { |
| 1774 Isolate* isolate = function->GetIsolate(); | |
| 1767 Handle<SharedFunctionInfo> shared(function->shared()); | 1775 Handle<SharedFunctionInfo> shared(function->shared()); |
| 1768 | 1776 |
| 1769 if (FLAG_always_opt && shared->allows_lazy_compilation()) { | 1777 if ((FLAG_always_opt || ShouldOptimizeForAsm(isolate, function)) && |
|
Michael Starzinger
2016/05/20 11:45:10
I am not entirely sure why this is needed. For fun
rmcilroy
2016/05/20 12:42:03
This is for the eager compilation pipeline (--igni
rmcilroy
2016/05/23 09:28:16
I just realized, this would mark all new functions
Michael Starzinger
2016/05/23 14:45:38
Acknowledged. New version in patch set #5 works fo
| |
| 1778 shared->allows_lazy_compilation()) { | |
| 1770 function->MarkForOptimization(); | 1779 function->MarkForOptimization(); |
| 1771 } | 1780 } |
| 1772 | 1781 |
| 1773 CodeAndLiterals cached = shared->SearchOptimizedCodeMap( | 1782 CodeAndLiterals cached = shared->SearchOptimizedCodeMap( |
| 1774 function->context()->native_context(), BailoutId::None()); | 1783 function->context()->native_context(), BailoutId::None()); |
| 1775 if (cached.code != nullptr) { | 1784 if (cached.code != nullptr) { |
| 1776 // Caching of optimized code enabled and optimized code found. | 1785 // Caching of optimized code enabled and optimized code found. |
| 1777 DCHECK(!cached.code->marked_for_deoptimization()); | 1786 DCHECK(!cached.code->marked_for_deoptimization()); |
| 1778 DCHECK(function->shared()->is_compiled()); | 1787 DCHECK(function->shared()->is_compiled()); |
| 1779 function->ReplaceCode(cached.code); | 1788 function->ReplaceCode(cached.code); |
| 1780 } | 1789 } |
| 1781 | 1790 |
| 1782 if (cached.literals != nullptr) { | 1791 if (cached.literals != nullptr) { |
| 1783 function->set_literals(cached.literals); | 1792 function->set_literals(cached.literals); |
| 1784 } else { | 1793 } else { |
| 1785 Isolate* isolate = function->GetIsolate(); | |
| 1786 int number_of_literals = shared->num_literals(); | 1794 int number_of_literals = shared->num_literals(); |
| 1787 Handle<LiteralsArray> literals = | 1795 Handle<LiteralsArray> literals = |
| 1788 LiteralsArray::New(isolate, handle(shared->feedback_vector()), | 1796 LiteralsArray::New(isolate, handle(shared->feedback_vector()), |
| 1789 number_of_literals, pretenure); | 1797 number_of_literals, pretenure); |
| 1790 function->set_literals(*literals); | 1798 function->set_literals(*literals); |
| 1791 | 1799 |
| 1792 // Cache context-specific literals. | 1800 // Cache context-specific literals. |
| 1793 MaybeHandle<Code> code; | 1801 MaybeHandle<Code> code; |
| 1794 if (cached.code != nullptr) code = handle(cached.code); | 1802 if (cached.code != nullptr) code = handle(cached.code); |
| 1795 Handle<Context> native_context(function->context()->native_context()); | 1803 Handle<Context> native_context(function->context()->native_context()); |
| 1796 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1804 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
| 1797 literals, BailoutId::None()); | 1805 literals, BailoutId::None()); |
| 1798 } | 1806 } |
| 1799 } | 1807 } |
| 1800 | 1808 |
| 1801 } // namespace internal | 1809 } // namespace internal |
| 1802 } // namespace v8 | 1810 } // namespace v8 |
| OLD | NEW |