| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/hydrogen-osr.h" | 9 #include "src/hydrogen-osr.h" |
| 10 #include "src/ic/ic.h" | 10 #include "src/ic/ic.h" |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 environment->Register(deoptimization_index, | 767 environment->Register(deoptimization_index, |
| 768 translation.index(), | 768 translation.index(), |
| 769 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 769 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
| 770 deoptimizations_.Add(environment, zone()); | 770 deoptimizations_.Add(environment, zone()); |
| 771 } | 771 } |
| 772 } | 772 } |
| 773 | 773 |
| 774 | 774 |
| 775 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr, | 775 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr, |
| 776 Deoptimizer::BailoutType bailout_type, | 776 Deoptimizer::BailoutType bailout_type, |
| 777 Register src1, const Operand& src2) { | 777 Register src1, const Operand& src2, |
| 778 const char* reason) { |
| 778 LEnvironment* environment = instr->environment(); | 779 LEnvironment* environment = instr->environment(); |
| 779 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 780 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
| 780 DCHECK(environment->HasBeenRegistered()); | 781 DCHECK(environment->HasBeenRegistered()); |
| 781 int id = environment->deoptimization_index(); | 782 int id = environment->deoptimization_index(); |
| 782 DCHECK(info()->IsOptimizing() || info()->IsStub()); | 783 DCHECK(info()->IsOptimizing() || info()->IsStub()); |
| 783 Address entry = | 784 Address entry = |
| 784 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); | 785 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); |
| 785 if (entry == NULL) { | 786 if (entry == NULL) { |
| 786 Abort(kBailoutWasNotPrepared); | 787 Abort(kBailoutWasNotPrepared); |
| 787 return; | 788 return; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 813 } | 814 } |
| 814 __ stop("trap_on_deopt"); | 815 __ stop("trap_on_deopt"); |
| 815 __ bind(&skip); | 816 __ bind(&skip); |
| 816 } | 817 } |
| 817 | 818 |
| 818 DCHECK(info()->IsStub() || frame_is_built_); | 819 DCHECK(info()->IsStub() || frame_is_built_); |
| 819 // Go through jump table if we need to handle condition, build frame, or | 820 // Go through jump table if we need to handle condition, build frame, or |
| 820 // restore caller doubles. | 821 // restore caller doubles. |
| 821 if (condition == al && frame_is_built_ && | 822 if (condition == al && frame_is_built_ && |
| 822 !info()->saves_caller_doubles()) { | 823 !info()->saves_caller_doubles()) { |
| 824 DeoptComment(instr->Mnemonic(), reason); |
| 823 __ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2); | 825 __ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2); |
| 824 } else { | 826 } else { |
| 825 // We often have several deopts to the same entry, reuse the last | 827 // We often have several deopts to the same entry, reuse the last |
| 826 // jump entry if this is the case. | 828 // jump entry if this is the case. |
| 827 if (deopt_jump_table_.is_empty() || | 829 if (deopt_jump_table_.is_empty() || |
| 828 (deopt_jump_table_.last().address != entry) || | 830 (deopt_jump_table_.last().address != entry) || |
| 829 (deopt_jump_table_.last().bailout_type != bailout_type) || | 831 (deopt_jump_table_.last().bailout_type != bailout_type) || |
| 830 (deopt_jump_table_.last().needs_frame != !frame_is_built_)) { | 832 (deopt_jump_table_.last().needs_frame != !frame_is_built_)) { |
| 831 Deoptimizer::JumpTableEntry table_entry(entry, | 833 Deoptimizer::JumpTableEntry table_entry(entry, instr->Mnemonic(), reason, |
| 832 bailout_type, | 834 bailout_type, !frame_is_built_); |
| 833 !frame_is_built_); | |
| 834 deopt_jump_table_.Add(table_entry, zone()); | 835 deopt_jump_table_.Add(table_entry, zone()); |
| 835 } | 836 } |
| 836 __ Branch(&deopt_jump_table_.last().label, condition, src1, src2); | 837 __ Branch(&deopt_jump_table_.last().label, condition, src1, src2); |
| 837 } | 838 } |
| 838 } | 839 } |
| 839 | 840 |
| 840 | 841 |
| 841 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr, | 842 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr, |
| 842 Register src1, const Operand& src2) { | 843 Register src1, const Operand& src2, |
| 844 const char* reason) { |
| 843 Deoptimizer::BailoutType bailout_type = info()->IsStub() | 845 Deoptimizer::BailoutType bailout_type = info()->IsStub() |
| 844 ? Deoptimizer::LAZY | 846 ? Deoptimizer::LAZY |
| 845 : Deoptimizer::EAGER; | 847 : Deoptimizer::EAGER; |
| 846 DeoptimizeIf(condition, instr, bailout_type, src1, src2); | 848 DeoptimizeIf(condition, instr, bailout_type, src1, src2, reason); |
| 847 } | 849 } |
| 848 | 850 |
| 849 | 851 |
| 850 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { | 852 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { |
| 851 int length = deoptimizations_.length(); | 853 int length = deoptimizations_.length(); |
| 852 if (length == 0) return; | 854 if (length == 0) return; |
| 853 Handle<DeoptimizationInputData> data = | 855 Handle<DeoptimizationInputData> data = |
| 854 DeoptimizationInputData::New(isolate(), length, TENURED); | 856 DeoptimizationInputData::New(isolate(), length, TENURED); |
| 855 | 857 |
| 856 Handle<ByteArray> translations = | 858 Handle<ByteArray> translations = |
| (...skipping 4848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5705 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { | 5707 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { |
| 5706 Deoptimizer::BailoutType type = instr->hydrogen()->type(); | 5708 Deoptimizer::BailoutType type = instr->hydrogen()->type(); |
| 5707 // TODO(danno): Stubs expect all deopts to be lazy for historical reasons (the | 5709 // TODO(danno): Stubs expect all deopts to be lazy for historical reasons (the |
| 5708 // needed return address), even though the implementation of LAZY and EAGER is | 5710 // needed return address), even though the implementation of LAZY and EAGER is |
| 5709 // now identical. When LAZY is eventually completely folded into EAGER, remove | 5711 // now identical. When LAZY is eventually completely folded into EAGER, remove |
| 5710 // the special case below. | 5712 // the special case below. |
| 5711 if (info()->IsStub() && type == Deoptimizer::EAGER) { | 5713 if (info()->IsStub() && type == Deoptimizer::EAGER) { |
| 5712 type = Deoptimizer::LAZY; | 5714 type = Deoptimizer::LAZY; |
| 5713 } | 5715 } |
| 5714 | 5716 |
| 5715 Comment(";;; deoptimize: %s", instr->hydrogen()->reason()); | 5717 DeoptimizeIf(al, instr, type, zero_reg, Operand(zero_reg), |
| 5716 DeoptimizeIf(al, instr, type, zero_reg, Operand(zero_reg)); | 5718 instr->hydrogen()->reason()); |
| 5717 } | 5719 } |
| 5718 | 5720 |
| 5719 | 5721 |
| 5720 void LCodeGen::DoDummy(LDummy* instr) { | 5722 void LCodeGen::DoDummy(LDummy* instr) { |
| 5721 // Nothing to see here, move on! | 5723 // Nothing to see here, move on! |
| 5722 } | 5724 } |
| 5723 | 5725 |
| 5724 | 5726 |
| 5725 void LCodeGen::DoDummyUse(LDummyUse* instr) { | 5727 void LCodeGen::DoDummyUse(LDummyUse* instr) { |
| 5726 // Nothing to see here, move on! | 5728 // Nothing to see here, move on! |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5949 __ li(at, scope_info); | 5951 __ li(at, scope_info); |
| 5950 __ Push(at, ToRegister(instr->function())); | 5952 __ Push(at, ToRegister(instr->function())); |
| 5951 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5953 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 5952 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5954 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 5953 } | 5955 } |
| 5954 | 5956 |
| 5955 | 5957 |
| 5956 #undef __ | 5958 #undef __ |
| 5957 | 5959 |
| 5958 } } // namespace v8::internal | 5960 } } // namespace v8::internal |
| OLD | NEW |