| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
| 6 | 6 |
| 7 #include "src/address-map.h" | 7 #include "src/address-map.h" |
| 8 #include "src/base/adapters.h" | 8 #include "src/base/adapters.h" |
| 9 #include "src/compiler/code-generator-impl.h" | 9 #include "src/compiler/code-generator-impl.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 RpoNumber handler_rpo = i.InputRpo(instr->InputCount() - 1); | 609 RpoNumber handler_rpo = i.InputRpo(instr->InputCount() - 1); |
| 610 handlers_.push_back({caught, GetLabel(handler_rpo), masm()->pc_offset()}); | 610 handlers_.push_back({caught, GetLabel(handler_rpo), masm()->pc_offset()}); |
| 611 } | 611 } |
| 612 | 612 |
| 613 if (needs_frame_state) { | 613 if (needs_frame_state) { |
| 614 MarkLazyDeoptSite(); | 614 MarkLazyDeoptSite(); |
| 615 // If the frame state is present, it starts at argument 1 (just after the | 615 // If the frame state is present, it starts at argument 1 (just after the |
| 616 // code address). | 616 // code address). |
| 617 size_t frame_state_offset = 1; | 617 size_t frame_state_offset = 1; |
| 618 FrameStateDescriptor* descriptor = | 618 FrameStateDescriptor* descriptor = |
| 619 GetFrameStateDescriptor(instr, frame_state_offset); | 619 GetDeoptimizationEntry(instr, frame_state_offset).descriptor(); |
| 620 int pc_offset = masm()->pc_offset(); | 620 int pc_offset = masm()->pc_offset(); |
| 621 int deopt_state_id = BuildTranslation(instr, pc_offset, frame_state_offset, | 621 int deopt_state_id = BuildTranslation(instr, pc_offset, frame_state_offset, |
| 622 descriptor->state_combine()); | 622 descriptor->state_combine()); |
| 623 // If the pre-call frame state differs from the post-call one, produce the | 623 // If the pre-call frame state differs from the post-call one, produce the |
| 624 // pre-call frame state, too. | 624 // pre-call frame state, too. |
| 625 // TODO(jarin) We might want to avoid building the pre-call frame state | 625 // TODO(jarin) We might want to avoid building the pre-call frame state |
| 626 // because it is only used to get locals and arguments (by the debugger and | 626 // because it is only used to get locals and arguments (by the debugger and |
| 627 // f.arguments), and those are the same in the pre-call and post-call | 627 // f.arguments), and those are the same in the pre-call and post-call |
| 628 // states. | 628 // states. |
| 629 if (!descriptor->state_combine().IsOutputIgnored()) { | 629 if (!descriptor->state_combine().IsOutputIgnored()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 646 | 646 |
| 647 int CodeGenerator::DefineDeoptimizationLiteral(Handle<Object> literal) { | 647 int CodeGenerator::DefineDeoptimizationLiteral(Handle<Object> literal) { |
| 648 int result = static_cast<int>(deoptimization_literals_.size()); | 648 int result = static_cast<int>(deoptimization_literals_.size()); |
| 649 for (unsigned i = 0; i < deoptimization_literals_.size(); ++i) { | 649 for (unsigned i = 0; i < deoptimization_literals_.size(); ++i) { |
| 650 if (deoptimization_literals_[i].is_identical_to(literal)) return i; | 650 if (deoptimization_literals_[i].is_identical_to(literal)) return i; |
| 651 } | 651 } |
| 652 deoptimization_literals_.push_back(literal); | 652 deoptimization_literals_.push_back(literal); |
| 653 return result; | 653 return result; |
| 654 } | 654 } |
| 655 | 655 |
| 656 | 656 DeoptimizationEntry const& CodeGenerator::GetDeoptimizationEntry( |
| 657 FrameStateDescriptor* CodeGenerator::GetFrameStateDescriptor( | |
| 658 Instruction* instr, size_t frame_state_offset) { | 657 Instruction* instr, size_t frame_state_offset) { |
| 659 InstructionOperandConverter i(this, instr); | 658 InstructionOperandConverter i(this, instr); |
| 660 InstructionSequence::StateId state_id = | 659 int const state_id = i.InputInt32(frame_state_offset); |
| 661 InstructionSequence::StateId::FromInt(i.InputInt32(frame_state_offset)); | 660 return code()->GetDeoptimizationEntry(state_id); |
| 662 return code()->GetFrameStateDescriptor(state_id); | |
| 663 } | 661 } |
| 664 | 662 |
| 663 DeoptimizeReason CodeGenerator::GetDeoptimizationReason( |
| 664 int deoptimization_id) const { |
| 665 size_t const index = static_cast<size_t>(deoptimization_id); |
| 666 DCHECK_LT(index, deoptimization_states_.size()); |
| 667 return deoptimization_states_[index]->reason(); |
| 668 } |
| 665 | 669 |
| 666 void CodeGenerator::TranslateStateValueDescriptor( | 670 void CodeGenerator::TranslateStateValueDescriptor( |
| 667 StateValueDescriptor* desc, Translation* translation, | 671 StateValueDescriptor* desc, Translation* translation, |
| 668 InstructionOperandIterator* iter) { | 672 InstructionOperandIterator* iter) { |
| 669 if (desc->IsNested()) { | 673 if (desc->IsNested()) { |
| 670 translation->BeginCapturedObject(static_cast<int>(desc->size())); | 674 translation->BeginCapturedObject(static_cast<int>(desc->size())); |
| 671 for (size_t index = 0; index < desc->fields().size(); index++) { | 675 for (size_t index = 0; index < desc->fields().size(); index++) { |
| 672 TranslateStateValueDescriptor(&desc->fields()[index], translation, iter); | 676 TranslateStateValueDescriptor(&desc->fields()[index], translation, iter); |
| 673 } | 677 } |
| 674 } else if (desc->IsDuplicate()) { | 678 } else if (desc->IsDuplicate()) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 } | 777 } |
| 774 | 778 |
| 775 TranslateFrameStateDescriptorOperands(descriptor, iter, state_combine, | 779 TranslateFrameStateDescriptorOperands(descriptor, iter, state_combine, |
| 776 translation); | 780 translation); |
| 777 } | 781 } |
| 778 | 782 |
| 779 | 783 |
| 780 int CodeGenerator::BuildTranslation(Instruction* instr, int pc_offset, | 784 int CodeGenerator::BuildTranslation(Instruction* instr, int pc_offset, |
| 781 size_t frame_state_offset, | 785 size_t frame_state_offset, |
| 782 OutputFrameStateCombine state_combine) { | 786 OutputFrameStateCombine state_combine) { |
| 783 FrameStateDescriptor* descriptor = | 787 DeoptimizationEntry const& entry = |
| 784 GetFrameStateDescriptor(instr, frame_state_offset); | 788 GetDeoptimizationEntry(instr, frame_state_offset); |
| 789 FrameStateDescriptor* const descriptor = entry.descriptor(); |
| 785 frame_state_offset++; | 790 frame_state_offset++; |
| 786 | 791 |
| 787 Translation translation( | 792 Translation translation( |
| 788 &translations_, static_cast<int>(descriptor->GetFrameCount()), | 793 &translations_, static_cast<int>(descriptor->GetFrameCount()), |
| 789 static_cast<int>(descriptor->GetJSFrameCount()), zone()); | 794 static_cast<int>(descriptor->GetJSFrameCount()), zone()); |
| 790 InstructionOperandIterator iter(instr, frame_state_offset); | 795 InstructionOperandIterator iter(instr, frame_state_offset); |
| 791 BuildTranslationForFrameStateDescriptor(descriptor, &iter, &translation, | 796 BuildTranslationForFrameStateDescriptor(descriptor, &iter, &translation, |
| 792 state_combine); | 797 state_combine); |
| 793 | 798 |
| 794 int deoptimization_id = static_cast<int>(deoptimization_states_.size()); | 799 int deoptimization_id = static_cast<int>(deoptimization_states_.size()); |
| 795 | 800 |
| 796 deoptimization_states_.push_back(new (zone()) DeoptimizationState( | 801 deoptimization_states_.push_back(new (zone()) DeoptimizationState( |
| 797 descriptor->bailout_id(), translation.index(), pc_offset)); | 802 descriptor->bailout_id(), translation.index(), pc_offset, |
| 803 entry.reason())); |
| 798 | 804 |
| 799 return deoptimization_id; | 805 return deoptimization_id; |
| 800 } | 806 } |
| 801 | 807 |
| 802 | 808 |
| 803 void CodeGenerator::AddTranslationForOperand(Translation* translation, | 809 void CodeGenerator::AddTranslationForOperand(Translation* translation, |
| 804 Instruction* instr, | 810 Instruction* instr, |
| 805 InstructionOperand* op, | 811 InstructionOperand* op, |
| 806 MachineType type) { | 812 MachineType type) { |
| 807 if (op->IsStackSlot()) { | 813 if (op->IsStackSlot()) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { | 912 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { |
| 907 gen->ools_ = this; | 913 gen->ools_ = this; |
| 908 } | 914 } |
| 909 | 915 |
| 910 | 916 |
| 911 OutOfLineCode::~OutOfLineCode() {} | 917 OutOfLineCode::~OutOfLineCode() {} |
| 912 | 918 |
| 913 } // namespace compiler | 919 } // namespace compiler |
| 914 } // namespace internal | 920 } // namespace internal |
| 915 } // namespace v8 | 921 } // namespace v8 |
| OLD | NEW |