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 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { | 578 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
| 579 Handle<Code> code = info->code(); | 579 Handle<Code> code = info->code(); |
| 580 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. | 580 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. |
| 581 | 581 |
| 582 // Function context specialization folds-in the function context, | 582 // Function context specialization folds-in the function context, |
| 583 // so no sharing can occur. | 583 // so no sharing can occur. |
| 584 if (info->is_function_context_specializing()) return; | 584 if (info->is_function_context_specializing()) return; |
| 585 // Frame specialization implies function context specialization. | 585 // Frame specialization implies function context specialization. |
| 586 DCHECK(!info->is_frame_specializing()); | 586 DCHECK(!info->is_frame_specializing()); |
| 587 | 587 |
| 588 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive | |
| 589 // from bytecode offset and overlap with actual BailoutId. No caching! | |
| 590 if (info->is_osr() && info->is_optimizing_from_bytecode()) return; | |
| 591 | |
| 588 // Cache optimized context-specific code. | 592 // Cache optimized context-specific code. |
| 589 Handle<JSFunction> function = info->closure(); | 593 Handle<JSFunction> function = info->closure(); |
| 590 Handle<SharedFunctionInfo> shared(function->shared()); | 594 Handle<SharedFunctionInfo> shared(function->shared()); |
| 591 Handle<LiteralsArray> literals(function->literals()); | 595 Handle<LiteralsArray> literals(function->literals()); |
| 592 Handle<Context> native_context(function->context()->native_context()); | 596 Handle<Context> native_context(function->context()->native_context()); |
| 593 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 597 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
| 594 literals, info->osr_ast_id()); | 598 literals, info->osr_ast_id()); |
| 595 | 599 |
| 596 // Do not cache (native) context-independent code compiled for OSR. | 600 // Do not cache (native) context-independent code compiled for OSR. |
| 597 if (code->is_turbofanned() && info->is_osr()) return; | 601 if (code->is_turbofanned() && info->is_osr()) return; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 return true; | 742 return true; |
| 739 } | 743 } |
| 740 | 744 |
| 741 MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function, | 745 MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function, |
| 742 Compiler::ConcurrencyMode mode, | 746 Compiler::ConcurrencyMode mode, |
| 743 BailoutId osr_ast_id = BailoutId::None(), | 747 BailoutId osr_ast_id = BailoutId::None(), |
| 744 JavaScriptFrame* osr_frame = nullptr) { | 748 JavaScriptFrame* osr_frame = nullptr) { |
| 745 Isolate* isolate = function->GetIsolate(); | 749 Isolate* isolate = function->GetIsolate(); |
| 746 Handle<SharedFunctionInfo> shared(function->shared(), isolate); | 750 Handle<SharedFunctionInfo> shared(function->shared(), isolate); |
| 747 | 751 |
| 748 // TODO(4764): Remove this guard once OSR graph construction works. | 752 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive |
| 749 if (!osr_ast_id.IsNone() && osr_frame->is_interpreted()) { | 753 // from bytecode offset and overlap with actual BailoutId. No lookup! |
|
rmcilroy
2016/07/26 11:23:37
This comment should maybe be in the if below?
Michael Starzinger
2016/07/26 14:43:15
Done.
| |
| 750 return MaybeHandle<Code>(); | 754 bool ignition_osr = !osr_ast_id.IsNone() && osr_frame->is_interpreted(); |
|
rmcilroy
2016/07/26 11:23:37
Should this check just be osr_frame->is_interprete
Michael Starzinger
2016/07/26 14:43:15
Done. As discussed offline, we still need to check
| |
| 751 } | 755 DCHECK_IMPLIES(ignition_osr, FLAG_ignition_osr); // Only when enabled. |
| 756 if (ignition_osr && !FLAG_turbo_from_bytecode) return MaybeHandle<Code>(); | |
|
rmcilroy
2016/07/26 11:23:37
nit - newline above to make this bailout clear.
Michael Starzinger
2016/07/26 14:43:15
Done. Also added a comment explaining this bailout
| |
| 752 | 757 |
| 753 Handle<Code> cached_code; | 758 Handle<Code> cached_code; |
| 754 if (GetCodeFromOptimizedCodeMap(function, osr_ast_id) | 759 if (!ignition_osr && |
| 760 GetCodeFromOptimizedCodeMap(function, osr_ast_id) | |
| 755 .ToHandle(&cached_code)) { | 761 .ToHandle(&cached_code)) { |
| 756 if (FLAG_trace_opt) { | 762 if (FLAG_trace_opt) { |
| 757 PrintF("[found optimized code for "); | 763 PrintF("[found optimized code for "); |
| 758 function->ShortPrint(); | 764 function->ShortPrint(); |
| 759 if (!osr_ast_id.IsNone()) { | 765 if (!osr_ast_id.IsNone()) { |
| 760 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); | 766 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); |
| 761 } | 767 } |
| 762 PrintF("]\n"); | 768 PrintF("]\n"); |
| 763 } | 769 } |
| 764 return cached_code; | 770 return cached_code; |
| 765 } | 771 } |
| 766 | 772 |
| 767 // Reset profiler ticks, function is no longer considered hot. | 773 // Reset profiler ticks, function is no longer considered hot. |
| 768 if (shared->is_compiled()) { | 774 if (shared->is_compiled()) { |
| 769 shared->code()->set_profiler_ticks(0); | 775 shared->code()->set_profiler_ticks(0); |
| 770 } | 776 } |
| 771 | 777 |
| 772 VMState<COMPILER> state(isolate); | 778 VMState<COMPILER> state(isolate); |
| 773 DCHECK(!isolate->has_pending_exception()); | 779 DCHECK(!isolate->has_pending_exception()); |
| 774 PostponeInterruptsScope postpone(isolate); | 780 PostponeInterruptsScope postpone(isolate); |
| 775 bool use_turbofan = UseTurboFan(shared); | 781 bool use_turbofan = UseTurboFan(shared) || ignition_osr; |
| 776 std::unique_ptr<CompilationJob> job( | 782 std::unique_ptr<CompilationJob> job( |
| 777 use_turbofan ? compiler::Pipeline::NewCompilationJob(function) | 783 use_turbofan ? compiler::Pipeline::NewCompilationJob(function) |
| 778 : new HCompilationJob(function)); | 784 : new HCompilationJob(function)); |
| 779 CompilationInfo* info = job->info(); | 785 CompilationInfo* info = job->info(); |
| 780 ParseInfo* parse_info = info->parse_info(); | 786 ParseInfo* parse_info = info->parse_info(); |
| 781 | 787 |
| 782 info->SetOptimizingForOsr(osr_ast_id, osr_frame); | 788 info->SetOptimizingForOsr(osr_ast_id, osr_frame); |
| 783 | 789 |
| 784 // Do not use Crankshaft/TurboFan if we need to be able to set break points. | 790 // Do not use Crankshaft/TurboFan if we need to be able to set break points. |
| 785 if (info->shared_info()->HasDebugInfo()) { | 791 if (info->shared_info()->HasDebugInfo()) { |
| (...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1916 DCHECK(shared->is_compiled()); | 1922 DCHECK(shared->is_compiled()); |
| 1917 function->set_literals(cached.literals); | 1923 function->set_literals(cached.literals); |
| 1918 } else if (shared->is_compiled()) { | 1924 } else if (shared->is_compiled()) { |
| 1919 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1925 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
| 1920 JSFunction::EnsureLiterals(function); | 1926 JSFunction::EnsureLiterals(function); |
| 1921 } | 1927 } |
| 1922 } | 1928 } |
| 1923 | 1929 |
| 1924 } // namespace internal | 1930 } // namespace internal |
| 1925 } // namespace v8 | 1931 } // namespace v8 |
| OLD | NEW |