| 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/base/adapters.h" | 5 #include "src/base/adapters.h" |
| 6 #include "src/compiler/linkage.h" | 6 #include "src/compiler/linkage.h" |
| 7 #include "src/compiler/register-allocator.h" | 7 #include "src/compiler/register-allocator.h" |
| 8 #include "src/string-stream.h" | 8 #include "src/string-stream.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 Instruction* GetLastInstruction(InstructionSequence* code, | 64 Instruction* GetLastInstruction(InstructionSequence* code, |
| 65 const InstructionBlock* block) { | 65 const InstructionBlock* block) { |
| 66 return code->InstructionAt(block->last_instruction_index()); | 66 return code->InstructionAt(block->last_instruction_index()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 bool IsOutputRegisterOf(Instruction* instr, Register reg) { | 70 bool IsOutputRegisterOf(Instruction* instr, Register reg) { |
| 71 for (size_t i = 0; i < instr->OutputCount(); i++) { | 71 for (size_t i = 0; i < instr->OutputCount(); i++) { |
| 72 auto output = instr->OutputAt(i); | 72 auto output = instr->OutputAt(i); |
| 73 if (output->IsRegister() && | 73 if (output->IsRegister() && |
| 74 RegisterOperand::cast(output)->GetRegister().is(reg)) { | 74 LocationOperand::cast(output)->GetRegister().is(reg)) { |
| 75 return true; | 75 return true; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 bool IsOutputDoubleRegisterOf(Instruction* instr, DoubleRegister reg) { | 82 bool IsOutputDoubleRegisterOf(Instruction* instr, DoubleRegister reg) { |
| 83 for (size_t i = 0; i < instr->OutputCount(); i++) { | 83 for (size_t i = 0; i < instr->OutputCount(); i++) { |
| 84 auto output = instr->OutputAt(i); | 84 auto output = instr->OutputAt(i); |
| 85 if (output->IsDoubleRegister() && | 85 if (output->IsDoubleRegister() && |
| 86 DoubleRegisterOperand::cast(output)->GetDoubleRegister().is(reg)) { | 86 LocationOperand::cast(output)->GetDoubleRegister().is(reg)) { |
| 87 return true; | 87 return true; |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 | 93 |
| 94 // TODO(dcarney): fix frame to allow frame accesses to half size location. | 94 // TODO(dcarney): fix frame to allow frame accesses to half size location. |
| 95 int GetByteWidth(MachineType machine_type) { | 95 int GetByteWidth(MachineType machine_type) { |
| 96 DCHECK_EQ(RepresentationOf(machine_type), machine_type); | 96 DCHECK_EQ(RepresentationOf(machine_type), machine_type); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 auto use_pos = reinterpret_cast<UsePosition*>(hint_); | 154 auto use_pos = reinterpret_cast<UsePosition*>(hint_); |
| 155 int assigned_register = AssignedRegisterField::decode(use_pos->flags_); | 155 int assigned_register = AssignedRegisterField::decode(use_pos->flags_); |
| 156 if (assigned_register == kUnassignedRegister) return false; | 156 if (assigned_register == kUnassignedRegister) return false; |
| 157 *register_code = assigned_register; | 157 *register_code = assigned_register; |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 case UsePositionHintType::kOperand: { | 160 case UsePositionHintType::kOperand: { |
| 161 auto operand = reinterpret_cast<InstructionOperand*>(hint_); | 161 auto operand = reinterpret_cast<InstructionOperand*>(hint_); |
| 162 int assigned_register = | 162 int assigned_register = |
| 163 operand->IsRegister() | 163 operand->IsRegister() |
| 164 ? RegisterOperand::cast(operand)->GetRegister().code() | 164 ? LocationOperand::cast(operand)->GetRegister().code() |
| 165 : DoubleRegisterOperand::cast(operand) | 165 : LocationOperand::cast(operand)->GetDoubleRegister().code(); |
| 166 ->GetDoubleRegister() | |
| 167 .code(); | |
| 168 *register_code = assigned_register; | 166 *register_code = assigned_register; |
| 169 return true; | 167 return true; |
| 170 } | 168 } |
| 171 case UsePositionHintType::kPhi: { | 169 case UsePositionHintType::kPhi: { |
| 172 auto phi = reinterpret_cast<RegisterAllocationData::PhiMapValue*>(hint_); | 170 auto phi = reinterpret_cast<RegisterAllocationData::PhiMapValue*>(hint_); |
| 173 int assigned_register = phi->assigned_register(); | 171 int assigned_register = phi->assigned_register(); |
| 174 if (assigned_register == kUnassignedRegister) return false; | 172 if (assigned_register == kUnassignedRegister) return false; |
| 175 *register_code = assigned_register; | 173 *register_code = assigned_register; |
| 176 return true; | 174 return true; |
| 177 } | 175 } |
| 178 } | 176 } |
| 179 UNREACHABLE(); | 177 UNREACHABLE(); |
| 180 return false; | 178 return false; |
| 181 } | 179 } |
| 182 | 180 |
| 183 | 181 |
| 184 UsePositionHintType UsePosition::HintTypeForOperand( | 182 UsePositionHintType UsePosition::HintTypeForOperand( |
| 185 const InstructionOperand& op) { | 183 const InstructionOperand& op) { |
| 186 switch (op.kind()) { | 184 switch (op.kind()) { |
| 187 case InstructionOperand::CONSTANT: | 185 case InstructionOperand::CONSTANT: |
| 188 case InstructionOperand::IMMEDIATE: | 186 case InstructionOperand::IMMEDIATE: |
| 187 case InstructionOperand::EXPLICIT: |
| 189 return UsePositionHintType::kNone; | 188 return UsePositionHintType::kNone; |
| 190 case InstructionOperand::UNALLOCATED: | 189 case InstructionOperand::UNALLOCATED: |
| 191 return UsePositionHintType::kUnresolved; | 190 return UsePositionHintType::kUnresolved; |
| 192 case InstructionOperand::ALLOCATED: | 191 case InstructionOperand::ALLOCATED: |
| 193 switch (AllocatedOperand::cast(op).allocated_kind()) { | 192 if (op.IsRegister() || op.IsDoubleRegister()) { |
| 194 case AllocatedOperand::REGISTER: | 193 return UsePositionHintType::kOperand; |
| 195 case AllocatedOperand::DOUBLE_REGISTER: | 194 } else { |
| 196 return UsePositionHintType::kOperand; | 195 DCHECK(op.IsStackSlot() || op.IsDoubleStackSlot()); |
| 197 case AllocatedOperand::STACK_SLOT: | 196 return UsePositionHintType::kNone; |
| 198 case AllocatedOperand::DOUBLE_STACK_SLOT: | |
| 199 return UsePositionHintType::kNone; | |
| 200 } | 197 } |
| 201 case InstructionOperand::INVALID: | 198 case InstructionOperand::INVALID: |
| 202 break; | 199 break; |
| 203 } | 200 } |
| 204 UNREACHABLE(); | 201 UNREACHABLE(); |
| 205 return UsePositionHintType::kNone; | 202 return UsePositionHintType::kNone; |
| 206 } | 203 } |
| 207 | 204 |
| 208 | 205 |
| 209 void UsePosition::ResolveHint(UsePosition* use_pos) { | 206 void UsePosition::ResolveHint(UsePosition* use_pos) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 return use_pos->pos() > pos.NextStart().End(); | 390 return use_pos->pos() > pos.NextStart().End(); |
| 394 } | 391 } |
| 395 | 392 |
| 396 | 393 |
| 397 bool LiveRange::IsTopLevel() const { return top_level_ == this; } | 394 bool LiveRange::IsTopLevel() const { return top_level_ == this; } |
| 398 | 395 |
| 399 | 396 |
| 400 InstructionOperand LiveRange::GetAssignedOperand() const { | 397 InstructionOperand LiveRange::GetAssignedOperand() const { |
| 401 if (HasRegisterAssigned()) { | 398 if (HasRegisterAssigned()) { |
| 402 DCHECK(!spilled()); | 399 DCHECK(!spilled()); |
| 403 switch (kind()) { | 400 return AllocatedOperand(LocationOperand::REGISTER, machine_type(), |
| 404 case GENERAL_REGISTERS: | 401 assigned_register()); |
| 405 return RegisterOperand(machine_type(), assigned_register()); | |
| 406 case DOUBLE_REGISTERS: | |
| 407 return DoubleRegisterOperand(machine_type(), assigned_register()); | |
| 408 } | |
| 409 } | 402 } |
| 410 DCHECK(spilled()); | 403 DCHECK(spilled()); |
| 411 DCHECK(!HasRegisterAssigned()); | 404 DCHECK(!HasRegisterAssigned()); |
| 412 if (TopLevel()->HasSpillOperand()) { | 405 if (TopLevel()->HasSpillOperand()) { |
| 413 auto op = TopLevel()->GetSpillOperand(); | 406 auto op = TopLevel()->GetSpillOperand(); |
| 414 DCHECK(!op->IsUnallocated()); | 407 DCHECK(!op->IsUnallocated()); |
| 415 return *op; | 408 return *op; |
| 416 } | 409 } |
| 417 return TopLevel()->GetSpillRangeOperand(); | 410 return TopLevel()->GetSpillRangeOperand(); |
| 418 } | 411 } |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 void TopLevelLiveRange::SetSpillRange(SpillRange* spill_range) { | 819 void TopLevelLiveRange::SetSpillRange(SpillRange* spill_range) { |
| 827 DCHECK(!HasSpillOperand()); | 820 DCHECK(!HasSpillOperand()); |
| 828 DCHECK(spill_range); | 821 DCHECK(spill_range); |
| 829 spill_range_ = spill_range; | 822 spill_range_ = spill_range; |
| 830 } | 823 } |
| 831 | 824 |
| 832 | 825 |
| 833 AllocatedOperand TopLevelLiveRange::GetSpillRangeOperand() const { | 826 AllocatedOperand TopLevelLiveRange::GetSpillRangeOperand() const { |
| 834 auto spill_range = GetSpillRange(); | 827 auto spill_range = GetSpillRange(); |
| 835 int index = spill_range->assigned_slot(); | 828 int index = spill_range->assigned_slot(); |
| 836 switch (kind()) { | 829 return AllocatedOperand(LocationOperand::STACK_SLOT, machine_type(), index); |
| 837 case GENERAL_REGISTERS: | |
| 838 return StackSlotOperand(machine_type(), index); | |
| 839 case DOUBLE_REGISTERS: | |
| 840 return DoubleStackSlotOperand(machine_type(), index); | |
| 841 } | |
| 842 UNREACHABLE(); | |
| 843 return StackSlotOperand(kMachNone, 0); | |
| 844 } | 830 } |
| 845 | 831 |
| 846 | 832 |
| 847 void TopLevelLiveRange::Splinter(LifetimePosition start, LifetimePosition end, | 833 void TopLevelLiveRange::Splinter(LifetimePosition start, LifetimePosition end, |
| 848 TopLevelLiveRange* result, Zone* zone) { | 834 TopLevelLiveRange* result, Zone* zone) { |
| 849 DCHECK(start != Start() || end != End()); | 835 DCHECK(start != Start() || end != End()); |
| 850 DCHECK(start < end); | 836 DCHECK(start < end); |
| 851 | 837 |
| 852 result->set_spill_type(spill_type()); | 838 result->set_spill_type(spill_type()); |
| 853 | 839 |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 UnallocatedOperand* operand, int pos, bool is_tagged) { | 1472 UnallocatedOperand* operand, int pos, bool is_tagged) { |
| 1487 TRACE("Allocating fixed reg for op %d\n", operand->virtual_register()); | 1473 TRACE("Allocating fixed reg for op %d\n", operand->virtual_register()); |
| 1488 DCHECK(operand->HasFixedPolicy()); | 1474 DCHECK(operand->HasFixedPolicy()); |
| 1489 InstructionOperand allocated; | 1475 InstructionOperand allocated; |
| 1490 MachineType machine_type = InstructionSequence::DefaultRepresentation(); | 1476 MachineType machine_type = InstructionSequence::DefaultRepresentation(); |
| 1491 int virtual_register = operand->virtual_register(); | 1477 int virtual_register = operand->virtual_register(); |
| 1492 if (virtual_register != InstructionOperand::kInvalidVirtualRegister) { | 1478 if (virtual_register != InstructionOperand::kInvalidVirtualRegister) { |
| 1493 machine_type = data()->MachineTypeFor(virtual_register); | 1479 machine_type = data()->MachineTypeFor(virtual_register); |
| 1494 } | 1480 } |
| 1495 if (operand->HasFixedSlotPolicy()) { | 1481 if (operand->HasFixedSlotPolicy()) { |
| 1496 AllocatedOperand::AllocatedKind kind = | 1482 allocated = AllocatedOperand(AllocatedOperand::STACK_SLOT, machine_type, |
| 1497 IsFloatingPoint(machine_type) ? AllocatedOperand::DOUBLE_STACK_SLOT | 1483 operand->fixed_slot_index()); |
| 1498 : AllocatedOperand::STACK_SLOT; | |
| 1499 allocated = | |
| 1500 AllocatedOperand(kind, machine_type, operand->fixed_slot_index()); | |
| 1501 } else if (operand->HasFixedRegisterPolicy()) { | 1484 } else if (operand->HasFixedRegisterPolicy()) { |
| 1485 DCHECK(!IsFloatingPoint(machine_type)); |
| 1502 allocated = AllocatedOperand(AllocatedOperand::REGISTER, machine_type, | 1486 allocated = AllocatedOperand(AllocatedOperand::REGISTER, machine_type, |
| 1503 operand->fixed_register_index()); | 1487 operand->fixed_register_index()); |
| 1504 } else if (operand->HasFixedDoubleRegisterPolicy()) { | 1488 } else if (operand->HasFixedDoubleRegisterPolicy()) { |
| 1489 DCHECK(IsFloatingPoint(machine_type)); |
| 1505 DCHECK_NE(InstructionOperand::kInvalidVirtualRegister, virtual_register); | 1490 DCHECK_NE(InstructionOperand::kInvalidVirtualRegister, virtual_register); |
| 1506 allocated = AllocatedOperand(AllocatedOperand::DOUBLE_REGISTER, | 1491 allocated = AllocatedOperand(AllocatedOperand::REGISTER, machine_type, |
| 1507 machine_type, operand->fixed_register_index()); | 1492 operand->fixed_register_index()); |
| 1508 } else { | 1493 } else { |
| 1509 UNREACHABLE(); | 1494 UNREACHABLE(); |
| 1510 } | 1495 } |
| 1511 InstructionOperand::ReplaceWith(operand, &allocated); | 1496 InstructionOperand::ReplaceWith(operand, &allocated); |
| 1512 if (is_tagged) { | 1497 if (is_tagged) { |
| 1513 TRACE("Fixed reg is tagged at %d\n", pos); | 1498 TRACE("Fixed reg is tagged at %d\n", pos); |
| 1514 auto instr = code()->InstructionAt(pos); | 1499 auto instr = code()->InstructionAt(pos); |
| 1515 if (instr->HasReferenceMap()) { | 1500 if (instr->HasReferenceMap()) { |
| 1516 instr->reference_map()->RecordReference(*AllocatedOperand::cast(operand)); | 1501 instr->reference_map()->RecordReference(*AllocatedOperand::cast(operand)); |
| 1517 } | 1502 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1548 auto output_operand = last_instruction->OutputAt(i); | 1533 auto output_operand = last_instruction->OutputAt(i); |
| 1549 DCHECK(!output_operand->IsConstant()); | 1534 DCHECK(!output_operand->IsConstant()); |
| 1550 auto output = UnallocatedOperand::cast(output_operand); | 1535 auto output = UnallocatedOperand::cast(output_operand); |
| 1551 int output_vreg = output->virtual_register(); | 1536 int output_vreg = output->virtual_register(); |
| 1552 auto range = data()->GetOrCreateLiveRangeFor(output_vreg); | 1537 auto range = data()->GetOrCreateLiveRangeFor(output_vreg); |
| 1553 bool assigned = false; | 1538 bool assigned = false; |
| 1554 if (output->HasFixedPolicy()) { | 1539 if (output->HasFixedPolicy()) { |
| 1555 AllocateFixed(output, -1, false); | 1540 AllocateFixed(output, -1, false); |
| 1556 // This value is produced on the stack, we never need to spill it. | 1541 // This value is produced on the stack, we never need to spill it. |
| 1557 if (output->IsStackSlot()) { | 1542 if (output->IsStackSlot()) { |
| 1558 DCHECK(StackSlotOperand::cast(output)->index() < | 1543 DCHECK(LocationOperand::cast(output)->index() < |
| 1559 data()->frame()->GetSpillSlotCount()); | 1544 data()->frame()->GetSpillSlotCount()); |
| 1560 range->SetSpillOperand(StackSlotOperand::cast(output)); | 1545 range->SetSpillOperand(LocationOperand::cast(output)); |
| 1561 range->SetSpillStartIndex(end); | 1546 range->SetSpillStartIndex(end); |
| 1562 assigned = true; | 1547 assigned = true; |
| 1563 } | 1548 } |
| 1564 | 1549 |
| 1565 for (auto succ : block->successors()) { | 1550 for (auto succ : block->successors()) { |
| 1566 const InstructionBlock* successor = code()->InstructionBlockAt(succ); | 1551 const InstructionBlock* successor = code()->InstructionBlockAt(succ); |
| 1567 DCHECK(successor->PredecessorCount() == 1); | 1552 DCHECK(successor->PredecessorCount() == 1); |
| 1568 int gap_index = successor->first_instruction_index(); | 1553 int gap_index = successor->first_instruction_index(); |
| 1569 // Create an unconstrained operand for the same virtual register | 1554 // Create an unconstrained operand for the same virtual register |
| 1570 // and insert a gap move from the fixed output to the operand. | 1555 // and insert a gap move from the fixed output to the operand. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 data()->GetOrCreateLiveRangeFor(first_output->virtual_register()); | 1593 data()->GetOrCreateLiveRangeFor(first_output->virtual_register()); |
| 1609 bool assigned = false; | 1594 bool assigned = false; |
| 1610 if (first_output->HasFixedPolicy()) { | 1595 if (first_output->HasFixedPolicy()) { |
| 1611 int output_vreg = first_output->virtual_register(); | 1596 int output_vreg = first_output->virtual_register(); |
| 1612 UnallocatedOperand output_copy(UnallocatedOperand::ANY, output_vreg); | 1597 UnallocatedOperand output_copy(UnallocatedOperand::ANY, output_vreg); |
| 1613 bool is_tagged = code()->IsReference(output_vreg); | 1598 bool is_tagged = code()->IsReference(output_vreg); |
| 1614 AllocateFixed(first_output, instr_index, is_tagged); | 1599 AllocateFixed(first_output, instr_index, is_tagged); |
| 1615 | 1600 |
| 1616 // This value is produced on the stack, we never need to spill it. | 1601 // This value is produced on the stack, we never need to spill it. |
| 1617 if (first_output->IsStackSlot()) { | 1602 if (first_output->IsStackSlot()) { |
| 1618 DCHECK(StackSlotOperand::cast(first_output)->index() < | 1603 DCHECK(LocationOperand::cast(first_output)->index() < |
| 1619 data()->frame()->GetTotalFrameSlotCount()); | 1604 data()->frame()->GetTotalFrameSlotCount()); |
| 1620 range->SetSpillOperand(StackSlotOperand::cast(first_output)); | 1605 range->SetSpillOperand(LocationOperand::cast(first_output)); |
| 1621 range->SetSpillStartIndex(instr_index + 1); | 1606 range->SetSpillStartIndex(instr_index + 1); |
| 1622 assigned = true; | 1607 assigned = true; |
| 1623 } | 1608 } |
| 1624 data()->AddGapMove(instr_index + 1, Instruction::START, *first_output, | 1609 data()->AddGapMove(instr_index + 1, Instruction::START, *first_output, |
| 1625 output_copy); | 1610 output_copy); |
| 1626 } | 1611 } |
| 1627 // Make sure we add a gap move for spilling (if we have not done | 1612 // Make sure we add a gap move for spilling (if we have not done |
| 1628 // so already). | 1613 // so already). |
| 1629 if (!assigned) { | 1614 if (!assigned) { |
| 1630 range->SpillAtDefinition(allocation_zone(), instr_index + 1, | 1615 range->SpillAtDefinition(allocation_zone(), instr_index + 1, |
| 1631 first_output); | 1616 first_output); |
| 1632 range->SetSpillStartIndex(instr_index + 1); | 1617 range->SetSpillStartIndex(instr_index + 1); |
| 1633 } | 1618 } |
| 1634 } | 1619 } |
| 1635 } | 1620 } |
| 1636 | 1621 |
| 1637 | 1622 |
| 1638 void ConstraintBuilder::MeetConstraintsBefore(int instr_index) { | 1623 void ConstraintBuilder::MeetConstraintsBefore(int instr_index) { |
| 1639 auto second = code()->InstructionAt(instr_index); | 1624 auto second = code()->InstructionAt(instr_index); |
| 1640 // Handle fixed input operands of second instruction. | 1625 // Handle fixed input operands of second instruction. |
| 1641 for (size_t i = 0; i < second->InputCount(); i++) { | 1626 for (size_t i = 0; i < second->InputCount(); i++) { |
| 1642 auto input = second->InputAt(i); | 1627 auto input = second->InputAt(i); |
| 1643 if (input->IsImmediate()) continue; // Ignore immediates. | 1628 if (input->IsImmediate() || input->IsExplicit()) { |
| 1629 continue; // Ignore immediates and explicitly reserved registers. |
| 1630 } |
| 1644 auto cur_input = UnallocatedOperand::cast(input); | 1631 auto cur_input = UnallocatedOperand::cast(input); |
| 1645 if (cur_input->HasFixedPolicy()) { | 1632 if (cur_input->HasFixedPolicy()) { |
| 1646 int input_vreg = cur_input->virtual_register(); | 1633 int input_vreg = cur_input->virtual_register(); |
| 1647 UnallocatedOperand input_copy(UnallocatedOperand::ANY, input_vreg); | 1634 UnallocatedOperand input_copy(UnallocatedOperand::ANY, input_vreg); |
| 1648 bool is_tagged = code()->IsReference(input_vreg); | 1635 bool is_tagged = code()->IsReference(input_vreg); |
| 1649 AllocateFixed(cur_input, instr_index, is_tagged); | 1636 AllocateFixed(cur_input, instr_index, is_tagged); |
| 1650 data()->AddGapMove(instr_index, Instruction::END, input_copy, *cur_input); | 1637 data()->AddGapMove(instr_index, Instruction::END, input_copy, *cur_input); |
| 1651 } | 1638 } |
| 1652 } | 1639 } |
| 1653 // Handle "output same as input" for second instruction. | 1640 // Handle "output same as input" for second instruction. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1813 | 1800 |
| 1814 TopLevelLiveRange* LiveRangeBuilder::LiveRangeFor(InstructionOperand* operand) { | 1801 TopLevelLiveRange* LiveRangeBuilder::LiveRangeFor(InstructionOperand* operand) { |
| 1815 if (operand->IsUnallocated()) { | 1802 if (operand->IsUnallocated()) { |
| 1816 return data()->GetOrCreateLiveRangeFor( | 1803 return data()->GetOrCreateLiveRangeFor( |
| 1817 UnallocatedOperand::cast(operand)->virtual_register()); | 1804 UnallocatedOperand::cast(operand)->virtual_register()); |
| 1818 } else if (operand->IsConstant()) { | 1805 } else if (operand->IsConstant()) { |
| 1819 return data()->GetOrCreateLiveRangeFor( | 1806 return data()->GetOrCreateLiveRangeFor( |
| 1820 ConstantOperand::cast(operand)->virtual_register()); | 1807 ConstantOperand::cast(operand)->virtual_register()); |
| 1821 } else if (operand->IsRegister()) { | 1808 } else if (operand->IsRegister()) { |
| 1822 return FixedLiveRangeFor( | 1809 return FixedLiveRangeFor( |
| 1823 RegisterOperand::cast(operand)->GetRegister().code()); | 1810 LocationOperand::cast(operand)->GetRegister().code()); |
| 1824 } else if (operand->IsDoubleRegister()) { | 1811 } else if (operand->IsDoubleRegister()) { |
| 1825 return FixedDoubleLiveRangeFor( | 1812 return FixedDoubleLiveRangeFor( |
| 1826 DoubleRegisterOperand::cast(operand)->GetDoubleRegister().code()); | 1813 LocationOperand::cast(operand)->GetDoubleRegister().code()); |
| 1827 } else { | 1814 } else { |
| 1828 return nullptr; | 1815 return nullptr; |
| 1829 } | 1816 } |
| 1830 } | 1817 } |
| 1831 | 1818 |
| 1832 | 1819 |
| 1833 UsePosition* LiveRangeBuilder::NewUsePosition(LifetimePosition pos, | 1820 UsePosition* LiveRangeBuilder::NewUsePosition(LifetimePosition pos, |
| 1834 InstructionOperand* operand, | 1821 InstructionOperand* operand, |
| 1835 void* hint, | 1822 void* hint, |
| 1836 UsePositionHintType hint_type) { | 1823 UsePositionHintType hint_type) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1930 if (!IsOutputDoubleRegisterOf(instr, DoubleRegister::from_code(code))) { | 1917 if (!IsOutputDoubleRegisterOf(instr, DoubleRegister::from_code(code))) { |
| 1931 auto range = FixedDoubleLiveRangeFor(code); | 1918 auto range = FixedDoubleLiveRangeFor(code); |
| 1932 range->AddUseInterval(curr_position, curr_position.End(), | 1919 range->AddUseInterval(curr_position, curr_position.End(), |
| 1933 allocation_zone()); | 1920 allocation_zone()); |
| 1934 } | 1921 } |
| 1935 } | 1922 } |
| 1936 } | 1923 } |
| 1937 | 1924 |
| 1938 for (size_t i = 0; i < instr->InputCount(); i++) { | 1925 for (size_t i = 0; i < instr->InputCount(); i++) { |
| 1939 auto input = instr->InputAt(i); | 1926 auto input = instr->InputAt(i); |
| 1940 if (input->IsImmediate()) continue; // Ignore immediates. | 1927 if (input->IsImmediate() || input->IsExplicit()) { |
| 1928 continue; // Ignore immediates and explicitly reserved registers. |
| 1929 } |
| 1941 LifetimePosition use_pos; | 1930 LifetimePosition use_pos; |
| 1942 if (input->IsUnallocated() && | 1931 if (input->IsUnallocated() && |
| 1943 UnallocatedOperand::cast(input)->IsUsedAtStart()) { | 1932 UnallocatedOperand::cast(input)->IsUsedAtStart()) { |
| 1944 use_pos = curr_position; | 1933 use_pos = curr_position; |
| 1945 } else { | 1934 } else { |
| 1946 use_pos = curr_position.End(); | 1935 use_pos = curr_position.End(); |
| 1947 } | 1936 } |
| 1948 | 1937 |
| 1949 if (input->IsUnallocated()) { | 1938 if (input->IsUnallocated()) { |
| 1950 UnallocatedOperand* unalloc = UnallocatedOperand::cast(input); | 1939 UnallocatedOperand* unalloc = UnallocatedOperand::cast(input); |
| (...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3361 auto eliminate = moves->PrepareInsertAfter(move); | 3350 auto eliminate = moves->PrepareInsertAfter(move); |
| 3362 to_insert.push_back(move); | 3351 to_insert.push_back(move); |
| 3363 if (eliminate != nullptr) to_eliminate.push_back(eliminate); | 3352 if (eliminate != nullptr) to_eliminate.push_back(eliminate); |
| 3364 } | 3353 } |
| 3365 } | 3354 } |
| 3366 | 3355 |
| 3367 | 3356 |
| 3368 } // namespace compiler | 3357 } // namespace compiler |
| 3369 } // namespace internal | 3358 } // namespace internal |
| 3370 } // namespace v8 | 3359 } // namespace v8 |
| OLD | NEW |