| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 info->AbortOptimization(kOptimizedTooManyTimes); | 685 info->AbortOptimization(kOptimizedTooManyTimes); |
| 686 return MaybeHandle<Code>(); | 686 return MaybeHandle<Code>(); |
| 687 } | 687 } |
| 688 | 688 |
| 689 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate); | 689 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate); |
| 690 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::OptimizeCode); | 690 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::OptimizeCode); |
| 691 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.OptimizeCode"); | 691 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.OptimizeCode"); |
| 692 | 692 |
| 693 // TurboFan can optimize directly from existing bytecode. | 693 // TurboFan can optimize directly from existing bytecode. |
| 694 if (FLAG_turbo_from_bytecode && use_turbofan && ShouldUseIgnition(info)) { | 694 if (FLAG_turbo_from_bytecode && use_turbofan && ShouldUseIgnition(info)) { |
| 695 if (info->is_osr() && !ignition_osr) return MaybeHandle<Code>(); |
| 695 if (!Compiler::EnsureBytecode(info)) { | 696 if (!Compiler::EnsureBytecode(info)) { |
| 696 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); | 697 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); |
| 697 return MaybeHandle<Code>(); | 698 return MaybeHandle<Code>(); |
| 698 } | 699 } |
| 699 info->MarkAsOptimizeFromBytecode(); | 700 info->MarkAsOptimizeFromBytecode(); |
| 700 } | 701 } |
| 701 | 702 |
| 702 if (IsEvalToplevel(shared)) { | 703 if (IsEvalToplevel(shared)) { |
| 703 parse_info->set_eval(); | 704 parse_info->set_eval(); |
| 704 if (function->context()->IsNativeContext()) parse_info->set_global(); | 705 if (function->context()->IsNativeContext()) parse_info->set_global(); |
| 705 parse_info->set_toplevel(); | 706 parse_info->set_toplevel(); |
| 706 parse_info->set_allow_lazy_parsing(false); | 707 parse_info->set_allow_lazy_parsing(false); |
| 707 parse_info->set_lazy(false); | 708 parse_info->set_lazy(false); |
| 708 } | 709 } |
| 709 | 710 |
| 711 // Verify that OSR compilations are delegated to the correct graph builder. |
| 712 // Depending on the underlying frame the semantics of the {BailoutId} differ |
| 713 // and the various graph builders hard-code a certain semantic: |
| 714 // - Interpreter : The BailoutId represents a bytecode offset. |
| 715 // - FullCodegen : The BailoutId represents the id of an AST node. |
| 716 DCHECK_IMPLIES(info->is_osr() && ignition_osr, |
| 717 info->is_optimizing_from_bytecode()); |
| 718 DCHECK_IMPLIES(info->is_osr() && !ignition_osr, |
| 719 !info->is_optimizing_from_bytecode()); |
| 720 |
| 710 // In case of concurrent recompilation, all handles below this point will be | 721 // In case of concurrent recompilation, all handles below this point will be |
| 711 // allocated in a deferred handle scope that is detached and handed off to | 722 // allocated in a deferred handle scope that is detached and handed off to |
| 712 // the background thread when we return. | 723 // the background thread when we return. |
| 713 std::unique_ptr<CompilationHandleScope> compilation; | 724 std::unique_ptr<CompilationHandleScope> compilation; |
| 714 if (mode == Compiler::CONCURRENT) { | 725 if (mode == Compiler::CONCURRENT) { |
| 715 compilation.reset(new CompilationHandleScope(info)); | 726 compilation.reset(new CompilationHandleScope(info)); |
| 716 } | 727 } |
| 717 | 728 |
| 718 // In case of TurboFan, all handles below will be canonicalized. | 729 // In case of TurboFan, all handles below will be canonicalized. |
| 719 std::unique_ptr<CanonicalHandleScope> canonical; | 730 std::unique_ptr<CanonicalHandleScope> canonical; |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 DCHECK(shared->is_compiled()); | 1900 DCHECK(shared->is_compiled()); |
| 1890 function->set_literals(cached.literals); | 1901 function->set_literals(cached.literals); |
| 1891 } else if (shared->is_compiled()) { | 1902 } else if (shared->is_compiled()) { |
| 1892 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1903 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
| 1893 JSFunction::EnsureLiterals(function); | 1904 JSFunction::EnsureLiterals(function); |
| 1894 } | 1905 } |
| 1895 } | 1906 } |
| 1896 | 1907 |
| 1897 } // namespace internal | 1908 } // namespace internal |
| 1898 } // namespace v8 | 1909 } // namespace v8 |
| OLD | NEW |