| 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/bit-vector.h" | 5 #include "src/bit-vector.h" |
| 6 #include "src/compiler/instruction.h" | 6 #include "src/compiler/instruction.h" |
| 7 #include "src/compiler/register-allocator-verifier.h" | 7 #include "src/compiler/register-allocator-verifier.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 | 47 |
| 48 void RegisterAllocatorVerifier::VerifyInput( | 48 void RegisterAllocatorVerifier::VerifyInput( |
| 49 const OperandConstraint& constraint) { | 49 const OperandConstraint& constraint) { |
| 50 CHECK_NE(kSameAsFirst, constraint.type_); | 50 CHECK_NE(kSameAsFirst, constraint.type_); |
| 51 if (constraint.type_ != kImmediate) { | 51 if (constraint.type_ != kImmediate && |
| 52 constraint.type_ != kStandardFrameRegister) { |
| 52 CHECK_NE(InstructionOperand::kInvalidVirtualRegister, | 53 CHECK_NE(InstructionOperand::kInvalidVirtualRegister, |
| 53 constraint.virtual_register_); | 54 constraint.virtual_register_); |
| 54 } | 55 } |
| 55 } | 56 } |
| 56 | 57 |
| 57 | 58 |
| 58 void RegisterAllocatorVerifier::VerifyTemp( | 59 void RegisterAllocatorVerifier::VerifyTemp( |
| 59 const OperandConstraint& constraint) { | 60 const OperandConstraint& constraint) { |
| 60 CHECK_NE(kSameAsFirst, constraint.type_); | 61 CHECK_NE(kSameAsFirst, constraint.type_); |
| 61 CHECK_NE(kImmediate, constraint.type_); | 62 CHECK_NE(kImmediate, constraint.type_); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 if (op->IsConstant()) { | 143 if (op->IsConstant()) { |
| 143 constraint->type_ = kConstant; | 144 constraint->type_ = kConstant; |
| 144 constraint->value_ = ConstantOperand::cast(op)->virtual_register(); | 145 constraint->value_ = ConstantOperand::cast(op)->virtual_register(); |
| 145 constraint->virtual_register_ = constraint->value_; | 146 constraint->virtual_register_ = constraint->value_; |
| 146 } else if (op->IsImmediate()) { | 147 } else if (op->IsImmediate()) { |
| 147 auto imm = ImmediateOperand::cast(op); | 148 auto imm = ImmediateOperand::cast(op); |
| 148 int value = imm->type() == ImmediateOperand::INLINE ? imm->inline_value() | 149 int value = imm->type() == ImmediateOperand::INLINE ? imm->inline_value() |
| 149 : imm->indexed_value(); | 150 : imm->indexed_value(); |
| 150 constraint->type_ = kImmediate; | 151 constraint->type_ = kImmediate; |
| 151 constraint->value_ = value; | 152 constraint->value_ = value; |
| 153 } else if (op->IsStackPointer() || op->IsFramePointer()) { |
| 154 constraint->type_ = kStandardFrameRegister; |
| 152 } else { | 155 } else { |
| 153 CHECK(op->IsUnallocated()); | 156 CHECK(op->IsUnallocated()); |
| 154 const auto* unallocated = UnallocatedOperand::cast(op); | 157 const auto* unallocated = UnallocatedOperand::cast(op); |
| 155 int vreg = unallocated->virtual_register(); | 158 int vreg = unallocated->virtual_register(); |
| 156 constraint->virtual_register_ = vreg; | 159 constraint->virtual_register_ = vreg; |
| 157 if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) { | 160 if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) { |
| 158 constraint->type_ = kFixedSlot; | 161 constraint->type_ = kFixedSlot; |
| 159 constraint->value_ = unallocated->fixed_slot_index(); | 162 constraint->value_ = unallocated->fixed_slot_index(); |
| 160 } else { | 163 } else { |
| 161 switch (unallocated->extended_policy()) { | 164 switch (unallocated->extended_policy()) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return; | 213 return; |
| 211 case kImmediate: { | 214 case kImmediate: { |
| 212 CHECK(op->IsImmediate()); | 215 CHECK(op->IsImmediate()); |
| 213 auto imm = ImmediateOperand::cast(op); | 216 auto imm = ImmediateOperand::cast(op); |
| 214 int value = imm->type() == ImmediateOperand::INLINE | 217 int value = imm->type() == ImmediateOperand::INLINE |
| 215 ? imm->inline_value() | 218 ? imm->inline_value() |
| 216 : imm->indexed_value(); | 219 : imm->indexed_value(); |
| 217 CHECK_EQ(value, constraint->value_); | 220 CHECK_EQ(value, constraint->value_); |
| 218 return; | 221 return; |
| 219 } | 222 } |
| 223 case kStandardFrameRegister: |
| 224 return; |
| 220 case kRegister: | 225 case kRegister: |
| 221 CHECK(op->IsRegister()); | 226 CHECK(op->IsRegister()); |
| 222 return; | 227 return; |
| 223 case kFixedRegister: | 228 case kFixedRegister: |
| 224 CHECK(op->IsRegister()); | 229 CHECK(op->IsRegister()); |
| 225 CHECK_EQ(RegisterOperand::cast(op)->index(), constraint->value_); | 230 CHECK_EQ(RegisterOperand::cast(op)->index(), constraint->value_); |
| 226 return; | 231 return; |
| 227 case kDoubleRegister: | 232 case kDoubleRegister: |
| 228 CHECK(op->IsDoubleRegister()); | 233 CHECK(op->IsDoubleRegister()); |
| 229 return; | 234 return; |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 auto current = block_maps->InitializeIncoming(block_index, initial_pass); | 678 auto current = block_maps->InitializeIncoming(block_index, initial_pass); |
| 674 const auto block = sequence()->instruction_blocks()[block_index]; | 679 const auto block = sequence()->instruction_blocks()[block_index]; |
| 675 for (int instr_index = block->code_start(); instr_index < block->code_end(); | 680 for (int instr_index = block->code_start(); instr_index < block->code_end(); |
| 676 ++instr_index) { | 681 ++instr_index) { |
| 677 const auto& instr_constraint = constraints_[instr_index]; | 682 const auto& instr_constraint = constraints_[instr_index]; |
| 678 const auto instr = instr_constraint.instruction_; | 683 const auto instr = instr_constraint.instruction_; |
| 679 current->RunGaps(zone(), instr); | 684 current->RunGaps(zone(), instr); |
| 680 const auto op_constraints = instr_constraint.operand_constraints_; | 685 const auto op_constraints = instr_constraint.operand_constraints_; |
| 681 size_t count = 0; | 686 size_t count = 0; |
| 682 for (size_t i = 0; i < instr->InputCount(); ++i, ++count) { | 687 for (size_t i = 0; i < instr->InputCount(); ++i, ++count) { |
| 683 if (op_constraints[count].type_ == kImmediate) continue; | 688 if (op_constraints[count].type_ == kImmediate || |
| 689 op_constraints[count].type_ == kStandardFrameRegister) |
| 690 continue; |
| 684 int virtual_register = op_constraints[count].virtual_register_; | 691 int virtual_register = op_constraints[count].virtual_register_; |
| 685 auto op = instr->InputAt(i); | 692 auto op = instr->InputAt(i); |
| 686 if (!block_maps->IsPhi(virtual_register)) { | 693 if (!block_maps->IsPhi(virtual_register)) { |
| 687 current->Use(op, virtual_register, initial_pass); | 694 current->Use(op, virtual_register, initial_pass); |
| 688 } else { | 695 } else { |
| 689 auto phi = block_maps->GetPhi(virtual_register); | 696 auto phi = block_maps->GetPhi(virtual_register); |
| 690 current->UsePhi(op, phi, initial_pass); | 697 current->UsePhi(op, phi, initial_pass); |
| 691 } | 698 } |
| 692 } | 699 } |
| 693 for (size_t i = 0; i < instr->TempCount(); ++i, ++count) { | 700 for (size_t i = 0; i < instr->TempCount(); ++i, ++count) { |
| 694 current->Drop(instr->TempAt(i)); | 701 current->Drop(instr->TempAt(i)); |
| 695 } | 702 } |
| 696 if (instr->IsCall()) { | 703 if (instr->IsCall()) { |
| 697 current->DropRegisters(config()); | 704 current->DropRegisters(config()); |
| 698 } | 705 } |
| 699 for (size_t i = 0; i < instr->OutputCount(); ++i, ++count) { | 706 for (size_t i = 0; i < instr->OutputCount(); ++i, ++count) { |
| 700 int virtual_register = op_constraints[count].virtual_register_; | 707 int virtual_register = op_constraints[count].virtual_register_; |
| 701 current->Define(zone(), instr->OutputAt(i), virtual_register); | 708 current->Define(zone(), instr->OutputAt(i), virtual_register); |
| 702 } | 709 } |
| 703 } | 710 } |
| 704 } | 711 } |
| 705 } | 712 } |
| 706 | 713 |
| 707 } // namespace compiler | 714 } // namespace compiler |
| 708 } // namespace internal | 715 } // namespace internal |
| 709 } // namespace v8 | 716 } // namespace v8 |
| OLD | NEW |