| 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/linkage.h" | 5 #include "src/compiler/linkage.h" |
| 6 #include "src/compiler/register-allocator.h" | 6 #include "src/compiler/register-allocator.h" |
| 7 #include "src/string-stream.h" | 7 #include "src/string-stream.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 TraceAlloc("Fixed reg is tagged at %d\n", pos); | 729 TraceAlloc("Fixed reg is tagged at %d\n", pos); |
| 730 auto instr = InstructionAt(pos); | 730 auto instr = InstructionAt(pos); |
| 731 if (instr->HasPointerMap()) { | 731 if (instr->HasPointerMap()) { |
| 732 instr->pointer_map()->RecordPointer(operand, code_zone()); | 732 instr->pointer_map()->RecordPointer(operand, code_zone()); |
| 733 } | 733 } |
| 734 } | 734 } |
| 735 return operand; | 735 return operand; |
| 736 } | 736 } |
| 737 | 737 |
| 738 | 738 |
| 739 LiveRange* RegisterAllocator::NewLiveRange(int index) { |
| 740 // The LiveRange object itself can go in the local zone, but the |
| 741 // InstructionOperand needs to go in the code zone, since it may survive |
| 742 // register allocation. |
| 743 return new (local_zone()) LiveRange(index, code_zone()); |
| 744 } |
| 745 |
| 746 |
| 739 LiveRange* RegisterAllocator::FixedLiveRangeFor(int index) { | 747 LiveRange* RegisterAllocator::FixedLiveRangeFor(int index) { |
| 740 DCHECK(index < config()->num_general_registers()); | 748 DCHECK(index < config()->num_general_registers()); |
| 741 auto result = fixed_live_ranges()[index]; | 749 auto result = fixed_live_ranges()[index]; |
| 742 if (result == nullptr) { | 750 if (result == nullptr) { |
| 743 // TODO(titzer): add a utility method to allocate a new LiveRange: | 751 result = NewLiveRange(FixedLiveRangeID(index)); |
| 744 // The LiveRange object itself can go in this zone, but the | |
| 745 // InstructionOperand needs | |
| 746 // to go in the code zone, since it may survive register allocation. | |
| 747 result = new (local_zone()) LiveRange(FixedLiveRangeID(index), code_zone()); | |
| 748 DCHECK(result->IsFixed()); | 752 DCHECK(result->IsFixed()); |
| 749 result->kind_ = GENERAL_REGISTERS; | 753 result->kind_ = GENERAL_REGISTERS; |
| 750 SetLiveRangeAssignedRegister(result, index); | 754 SetLiveRangeAssignedRegister(result, index); |
| 751 fixed_live_ranges()[index] = result; | 755 fixed_live_ranges()[index] = result; |
| 752 } | 756 } |
| 753 return result; | 757 return result; |
| 754 } | 758 } |
| 755 | 759 |
| 756 | 760 |
| 757 LiveRange* RegisterAllocator::FixedDoubleLiveRangeFor(int index) { | 761 LiveRange* RegisterAllocator::FixedDoubleLiveRangeFor(int index) { |
| 758 DCHECK(index < config()->num_aliased_double_registers()); | 762 DCHECK(index < config()->num_aliased_double_registers()); |
| 759 auto result = fixed_double_live_ranges()[index]; | 763 auto result = fixed_double_live_ranges()[index]; |
| 760 if (result == nullptr) { | 764 if (result == nullptr) { |
| 761 result = new (local_zone()) | 765 result = NewLiveRange(FixedDoubleLiveRangeID(index)); |
| 762 LiveRange(FixedDoubleLiveRangeID(index), code_zone()); | |
| 763 DCHECK(result->IsFixed()); | 766 DCHECK(result->IsFixed()); |
| 764 result->kind_ = DOUBLE_REGISTERS; | 767 result->kind_ = DOUBLE_REGISTERS; |
| 765 SetLiveRangeAssignedRegister(result, index); | 768 SetLiveRangeAssignedRegister(result, index); |
| 766 fixed_double_live_ranges()[index] = result; | 769 fixed_double_live_ranges()[index] = result; |
| 767 } | 770 } |
| 768 return result; | 771 return result; |
| 769 } | 772 } |
| 770 | 773 |
| 771 | 774 |
| 772 LiveRange* RegisterAllocator::LiveRangeFor(int index) { | 775 LiveRange* RegisterAllocator::LiveRangeFor(int index) { |
| 773 if (index >= static_cast<int>(live_ranges().size())) { | 776 if (index >= static_cast<int>(live_ranges().size())) { |
| 774 live_ranges().resize(index + 1, nullptr); | 777 live_ranges().resize(index + 1, nullptr); |
| 775 } | 778 } |
| 776 auto result = live_ranges()[index]; | 779 auto result = live_ranges()[index]; |
| 777 if (result == nullptr) { | 780 if (result == nullptr) { |
| 778 result = new (local_zone()) LiveRange(index, code_zone()); | 781 result = NewLiveRange(index); |
| 779 live_ranges()[index] = result; | 782 live_ranges()[index] = result; |
| 780 } | 783 } |
| 781 return result; | 784 return result; |
| 782 } | 785 } |
| 783 | 786 |
| 784 | 787 |
| 785 GapInstruction* RegisterAllocator::GetLastGap(const InstructionBlock* block) { | 788 GapInstruction* RegisterAllocator::GetLastGap(const InstructionBlock* block) { |
| 786 int last_instruction = block->last_instruction_index(); | 789 int last_instruction = block->last_instruction_index(); |
| 787 return code()->GapAt(last_instruction - 1); | 790 return code()->GapAt(last_instruction - 1); |
| 788 } | 791 } |
| (...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2582 } else { | 2585 } else { |
| 2583 DCHECK(range->Kind() == GENERAL_REGISTERS); | 2586 DCHECK(range->Kind() == GENERAL_REGISTERS); |
| 2584 assigned_registers_->Add(reg); | 2587 assigned_registers_->Add(reg); |
| 2585 } | 2588 } |
| 2586 range->set_assigned_register(reg, operand_cache()); | 2589 range->set_assigned_register(reg, operand_cache()); |
| 2587 } | 2590 } |
| 2588 | 2591 |
| 2589 } // namespace compiler | 2592 } // namespace compiler |
| 2590 } // namespace internal | 2593 } // namespace internal |
| 2591 } // namespace v8 | 2594 } // namespace v8 |
| OLD | NEW |