OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
7 #include "src/compiler/instruction.h" | 7 #include "src/compiler/instruction.h" |
8 #include "src/compiler/schedule.h" | 8 #include "src/compiler/schedule.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } else if (op.IsRegister()) { | 115 } else if (op.IsRegister()) { |
116 os << "[" << LocationOperand::cast(op).GetRegister().ToString() << "|R"; | 116 os << "[" << LocationOperand::cast(op).GetRegister().ToString() << "|R"; |
117 } else { | 117 } else { |
118 DCHECK(op.IsDoubleRegister()); | 118 DCHECK(op.IsDoubleRegister()); |
119 os << "[" << LocationOperand::cast(op).GetDoubleRegister().ToString() | 119 os << "[" << LocationOperand::cast(op).GetDoubleRegister().ToString() |
120 << "|R"; | 120 << "|R"; |
121 } | 121 } |
122 if (allocated.IsExplicit()) { | 122 if (allocated.IsExplicit()) { |
123 os << "|E"; | 123 os << "|E"; |
124 } | 124 } |
125 switch (allocated.machine_type()) { | 125 switch (allocated.representation()) { |
126 case kRepWord32: | 126 case MachineRepresentation::kWord32: |
127 os << "|w32"; | 127 os << "|w32"; |
128 break; | 128 break; |
129 case kRepWord64: | 129 case MachineRepresentation::kWord64: |
130 os << "|w64"; | 130 os << "|w64"; |
131 break; | 131 break; |
132 case kRepFloat32: | 132 case MachineRepresentation::kFloat32: |
133 os << "|f32"; | 133 os << "|f32"; |
134 break; | 134 break; |
135 case kRepFloat64: | 135 case MachineRepresentation::kFloat64: |
136 os << "|f64"; | 136 os << "|f64"; |
137 break; | 137 break; |
138 case kRepTagged: | 138 case MachineRepresentation::kTagged: |
139 os << "|t"; | 139 os << "|t"; |
140 break; | 140 break; |
141 default: | 141 default: |
142 os << "|?"; | 142 os << "|?"; |
143 break; | 143 break; |
144 } | 144 } |
145 return os << "]"; | 145 return os << "]"; |
146 } | 146 } |
147 case InstructionOperand::INVALID: | 147 case InstructionOperand::INVALID: |
148 return os << "(x)"; | 148 return os << "(x)"; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 to_eliminate = curr; | 188 to_eliminate = curr; |
189 if (replacement != nullptr) break; | 189 if (replacement != nullptr) break; |
190 } | 190 } |
191 } | 191 } |
192 DCHECK_IMPLIES(replacement == to_eliminate, replacement == nullptr); | 192 DCHECK_IMPLIES(replacement == to_eliminate, replacement == nullptr); |
193 if (replacement != nullptr) move->set_source(replacement->source()); | 193 if (replacement != nullptr) move->set_source(replacement->source()); |
194 return to_eliminate; | 194 return to_eliminate; |
195 } | 195 } |
196 | 196 |
197 | 197 |
198 ExplicitOperand::ExplicitOperand(LocationKind kind, MachineType machine_type, | 198 ExplicitOperand::ExplicitOperand(LocationKind kind, MachineRepresentation rep, |
199 int index) | 199 int index) |
200 : LocationOperand(EXPLICIT, kind, machine_type, index) { | 200 : LocationOperand(EXPLICIT, kind, rep, index) { |
201 DCHECK_IMPLIES(kind == REGISTER && !IsFloatingPoint(machine_type), | 201 DCHECK_IMPLIES(kind == REGISTER && !IsFloatingPoint(rep), |
202 Register::from_code(index).IsAllocatable()); | 202 Register::from_code(index).IsAllocatable()); |
203 DCHECK_IMPLIES(kind == REGISTER && IsFloatingPoint(machine_type), | 203 DCHECK_IMPLIES(kind == REGISTER && IsFloatingPoint(rep), |
204 DoubleRegister::from_code(index).IsAllocatable()); | 204 DoubleRegister::from_code(index).IsAllocatable()); |
205 } | 205 } |
206 | 206 |
207 | 207 |
208 Instruction::Instruction(InstructionCode opcode) | 208 Instruction::Instruction(InstructionCode opcode) |
209 : opcode_(opcode), | 209 : opcode_(opcode), |
210 bit_field_(OutputCountField::encode(0) | InputCountField::encode(0) | | 210 bit_field_(OutputCountField::encode(0) | InputCountField::encode(0) | |
211 TempCountField::encode(0) | IsCallField::encode(false)), | 211 TempCountField::encode(0) | IsCallField::encode(false)), |
212 reference_map_(NULL) { | 212 reference_map_(NULL) { |
213 parallel_moves_[0] = nullptr; | 213 parallel_moves_[0] = nullptr; |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 if (end == block_starts_.end() || *end > instruction_index) --end; | 649 if (end == block_starts_.end() || *end > instruction_index) --end; |
650 DCHECK(*end <= instruction_index); | 650 DCHECK(*end <= instruction_index); |
651 size_t index = std::distance(begin, end); | 651 size_t index = std::distance(begin, end); |
652 auto block = instruction_blocks_->at(index); | 652 auto block = instruction_blocks_->at(index); |
653 DCHECK(block->code_start() <= instruction_index && | 653 DCHECK(block->code_start() <= instruction_index && |
654 instruction_index < block->code_end()); | 654 instruction_index < block->code_end()); |
655 return block; | 655 return block; |
656 } | 656 } |
657 | 657 |
658 | 658 |
659 static MachineType FilterRepresentation(MachineType rep) { | 659 static MachineRepresentation FilterRepresentation(MachineRepresentation rep) { |
660 DCHECK_EQ(rep, RepresentationOf(rep)); | |
661 switch (rep) { | 660 switch (rep) { |
662 case kRepBit: | 661 case MachineRepresentation::kBit: |
663 case kRepWord8: | 662 case MachineRepresentation::kWord8: |
664 case kRepWord16: | 663 case MachineRepresentation::kWord16: |
665 return InstructionSequence::DefaultRepresentation(); | 664 return InstructionSequence::DefaultRepresentation(); |
666 case kRepWord32: | 665 case MachineRepresentation::kWord32: |
667 case kRepWord64: | 666 case MachineRepresentation::kWord64: |
668 case kRepFloat32: | 667 case MachineRepresentation::kFloat32: |
669 case kRepFloat64: | 668 case MachineRepresentation::kFloat64: |
670 case kRepTagged: | 669 case MachineRepresentation::kTagged: |
671 return rep; | 670 return rep; |
672 default: | 671 default: |
673 break; | 672 break; |
674 } | 673 } |
675 UNREACHABLE(); | 674 UNREACHABLE(); |
676 return kMachNone; | 675 return MachineRepresentation::kNone; |
677 } | 676 } |
678 | 677 |
679 | 678 |
680 MachineType InstructionSequence::GetRepresentation(int virtual_register) const { | 679 MachineRepresentation InstructionSequence::GetRepresentation( |
| 680 int virtual_register) const { |
681 DCHECK_LE(0, virtual_register); | 681 DCHECK_LE(0, virtual_register); |
682 DCHECK_LT(virtual_register, VirtualRegisterCount()); | 682 DCHECK_LT(virtual_register, VirtualRegisterCount()); |
683 if (virtual_register >= static_cast<int>(representations_.size())) { | 683 if (virtual_register >= static_cast<int>(representations_.size())) { |
684 return DefaultRepresentation(); | 684 return DefaultRepresentation(); |
685 } | 685 } |
686 return representations_[virtual_register]; | 686 return representations_[virtual_register]; |
687 } | 687 } |
688 | 688 |
689 | 689 |
690 void InstructionSequence::MarkAsRepresentation(MachineType machine_type, | 690 void InstructionSequence::MarkAsRepresentation(MachineRepresentation rep, |
691 int virtual_register) { | 691 int virtual_register) { |
692 DCHECK_LE(0, virtual_register); | 692 DCHECK_LE(0, virtual_register); |
693 DCHECK_LT(virtual_register, VirtualRegisterCount()); | 693 DCHECK_LT(virtual_register, VirtualRegisterCount()); |
694 if (virtual_register >= static_cast<int>(representations_.size())) { | 694 if (virtual_register >= static_cast<int>(representations_.size())) { |
695 representations_.resize(VirtualRegisterCount(), DefaultRepresentation()); | 695 representations_.resize(VirtualRegisterCount(), DefaultRepresentation()); |
696 } | 696 } |
697 machine_type = FilterRepresentation(machine_type); | 697 rep = FilterRepresentation(rep); |
698 DCHECK_IMPLIES(representations_[virtual_register] != machine_type, | 698 DCHECK_IMPLIES(representations_[virtual_register] != rep, |
699 representations_[virtual_register] == DefaultRepresentation()); | 699 representations_[virtual_register] == DefaultRepresentation()); |
700 representations_[virtual_register] = machine_type; | 700 representations_[virtual_register] = rep; |
701 } | 701 } |
702 | 702 |
703 | 703 |
704 InstructionSequence::StateId InstructionSequence::AddFrameStateDescriptor( | 704 InstructionSequence::StateId InstructionSequence::AddFrameStateDescriptor( |
705 FrameStateDescriptor* descriptor) { | 705 FrameStateDescriptor* descriptor) { |
706 int deoptimization_id = static_cast<int>(deoptimization_entries_.size()); | 706 int deoptimization_id = static_cast<int>(deoptimization_entries_.size()); |
707 deoptimization_entries_.push_back(descriptor); | 707 deoptimization_entries_.push_back(descriptor); |
708 return StateId::FromInt(deoptimization_id); | 708 return StateId::FromInt(deoptimization_id); |
709 } | 709 } |
710 | 710 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 FrameStateDescriptor* outer_state) | 752 FrameStateDescriptor* outer_state) |
753 : type_(type), | 753 : type_(type), |
754 bailout_id_(bailout_id), | 754 bailout_id_(bailout_id), |
755 frame_state_combine_(state_combine), | 755 frame_state_combine_(state_combine), |
756 parameters_count_(parameters_count), | 756 parameters_count_(parameters_count), |
757 locals_count_(locals_count), | 757 locals_count_(locals_count), |
758 stack_count_(stack_count), | 758 stack_count_(stack_count), |
759 types_(zone), | 759 types_(zone), |
760 shared_info_(shared_info), | 760 shared_info_(shared_info), |
761 outer_state_(outer_state) { | 761 outer_state_(outer_state) { |
762 types_.resize(GetSize(), kMachNone); | 762 types_.resize(GetSize(), MachineType::None()); |
763 } | 763 } |
764 | 764 |
765 | 765 |
766 size_t FrameStateDescriptor::GetSize(OutputFrameStateCombine combine) const { | 766 size_t FrameStateDescriptor::GetSize(OutputFrameStateCombine combine) const { |
767 size_t size = 1 + parameters_count() + locals_count() + stack_count() + | 767 size_t size = 1 + parameters_count() + locals_count() + stack_count() + |
768 (HasContext() ? 1 : 0); | 768 (HasContext() ? 1 : 0); |
769 switch (combine.kind()) { | 769 switch (combine.kind()) { |
770 case OutputFrameStateCombine::kPushOutput: | 770 case OutputFrameStateCombine::kPushOutput: |
771 size += combine.GetPushCount(); | 771 size += combine.GetPushCount(); |
772 break; | 772 break; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 os << " B" << succ.ToInt(); | 885 os << " B" << succ.ToInt(); |
886 } | 886 } |
887 os << "\n"; | 887 os << "\n"; |
888 } | 888 } |
889 return os; | 889 return os; |
890 } | 890 } |
891 | 891 |
892 } // namespace compiler | 892 } // namespace compiler |
893 } // namespace internal | 893 } // namespace internal |
894 } // namespace v8 | 894 } // namespace v8 |
OLD | NEW |