| 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 #ifndef V8_REGISTER_ALLOCATOR_H_ | 5 #ifndef V8_REGISTER_ALLOCATOR_H_ |
| 6 #define V8_REGISTER_ALLOCATOR_H_ | 6 #define V8_REGISTER_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include "src/compiler/instruction.h" | 8 #include "src/compiler/instruction.h" |
| 9 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
| 10 #include "src/register-configuration.h" | 10 #include "src/register-configuration.h" |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 class SpillRange final : public ZoneObject { | 665 class SpillRange final : public ZoneObject { |
| 666 public: | 666 public: |
| 667 static const int kUnassignedSlot = -1; | 667 static const int kUnassignedSlot = -1; |
| 668 SpillRange(TopLevelLiveRange* range, Zone* zone); | 668 SpillRange(TopLevelLiveRange* range, Zone* zone); |
| 669 | 669 |
| 670 UseInterval* interval() const { return use_interval_; } | 670 UseInterval* interval() const { return use_interval_; } |
| 671 // Currently, only 4 or 8 byte slots are supported. | 671 // Currently, only 4 or 8 byte slots are supported. |
| 672 int ByteWidth() const; | 672 int ByteWidth() const; |
| 673 bool IsEmpty() const { return live_ranges_.empty(); } | 673 bool IsEmpty() const { return live_ranges_.empty(); } |
| 674 bool TryMerge(SpillRange* other); | 674 bool TryMerge(SpillRange* other); |
| 675 bool HasSlot() const { return assigned_slot_ != kUnassignedSlot; } |
| 675 | 676 |
| 676 void set_assigned_slot(int index) { | 677 void set_assigned_slot(int index) { |
| 677 DCHECK_EQ(kUnassignedSlot, assigned_slot_); | 678 DCHECK_EQ(kUnassignedSlot, assigned_slot_); |
| 678 assigned_slot_ = index; | 679 assigned_slot_ = index; |
| 679 } | 680 } |
| 680 int assigned_slot() { | 681 int assigned_slot() { |
| 681 DCHECK_NE(kUnassignedSlot, assigned_slot_); | 682 DCHECK_NE(kUnassignedSlot, assigned_slot_); |
| 682 return assigned_slot_; | 683 return assigned_slot_; |
| 683 } | 684 } |
| 684 const ZoneVector<TopLevelLiveRange*>& live_ranges() const { | 685 const ZoneVector<TopLevelLiveRange*>& live_ranges() const { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 ZoneVector<InstructionOperand*> incoming_operands_; | 732 ZoneVector<InstructionOperand*> incoming_operands_; |
| 732 int assigned_register_; | 733 int assigned_register_; |
| 733 }; | 734 }; |
| 734 typedef ZoneMap<int, PhiMapValue*> PhiMap; | 735 typedef ZoneMap<int, PhiMapValue*> PhiMap; |
| 735 | 736 |
| 736 struct DelayedReference { | 737 struct DelayedReference { |
| 737 ReferenceMap* map; | 738 ReferenceMap* map; |
| 738 InstructionOperand* operand; | 739 InstructionOperand* operand; |
| 739 }; | 740 }; |
| 740 typedef ZoneVector<DelayedReference> DelayedReferences; | 741 typedef ZoneVector<DelayedReference> DelayedReferences; |
| 742 typedef ZoneVector<std::pair<TopLevelLiveRange*, int>> |
| 743 RangesWithPreassignedSlots; |
| 741 | 744 |
| 742 RegisterAllocationData(const RegisterConfiguration* config, | 745 RegisterAllocationData(const RegisterConfiguration* config, |
| 743 Zone* allocation_zone, Frame* frame, | 746 Zone* allocation_zone, Frame* frame, |
| 744 InstructionSequence* code, | 747 InstructionSequence* code, |
| 745 const char* debug_name = nullptr); | 748 const char* debug_name = nullptr); |
| 746 | 749 |
| 747 const ZoneVector<TopLevelLiveRange*>& live_ranges() const { | 750 const ZoneVector<TopLevelLiveRange*>& live_ranges() const { |
| 748 return live_ranges_; | 751 return live_ranges_; |
| 749 } | 752 } |
| 750 ZoneVector<TopLevelLiveRange*>& live_ranges() { return live_ranges_; } | 753 ZoneVector<TopLevelLiveRange*>& live_ranges() { return live_ranges_; } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 bool RangesDefinedInDeferredStayInDeferred(); | 800 bool RangesDefinedInDeferredStayInDeferred(); |
| 798 | 801 |
| 799 void MarkAllocated(RegisterKind kind, int index); | 802 void MarkAllocated(RegisterKind kind, int index); |
| 800 | 803 |
| 801 PhiMapValue* InitializePhiMap(const InstructionBlock* block, | 804 PhiMapValue* InitializePhiMap(const InstructionBlock* block, |
| 802 PhiInstruction* phi); | 805 PhiInstruction* phi); |
| 803 PhiMapValue* GetPhiMapValueFor(TopLevelLiveRange* top_range); | 806 PhiMapValue* GetPhiMapValueFor(TopLevelLiveRange* top_range); |
| 804 PhiMapValue* GetPhiMapValueFor(int virtual_register); | 807 PhiMapValue* GetPhiMapValueFor(int virtual_register); |
| 805 bool IsBlockBoundary(LifetimePosition pos) const; | 808 bool IsBlockBoundary(LifetimePosition pos) const; |
| 806 | 809 |
| 810 RangesWithPreassignedSlots& preassigned_slot_ranges() { |
| 811 return preassigned_slot_ranges_; |
| 812 } |
| 813 |
| 807 void Print(const InstructionSequence* instructionSequence); | 814 void Print(const InstructionSequence* instructionSequence); |
| 808 void Print(const Instruction* instruction); | 815 void Print(const Instruction* instruction); |
| 809 void Print(const LiveRange* range, bool with_children = false); | 816 void Print(const LiveRange* range, bool with_children = false); |
| 810 void Print(const InstructionOperand& op); | 817 void Print(const InstructionOperand& op); |
| 811 void Print(const MoveOperands* move); | 818 void Print(const MoveOperands* move); |
| 812 void Print(const SpillRange* spill_range); | 819 void Print(const SpillRange* spill_range); |
| 813 | 820 |
| 814 private: | 821 private: |
| 815 int GetNextLiveRangeId(); | 822 int GetNextLiveRangeId(); |
| 816 | 823 |
| 817 Zone* const allocation_zone_; | 824 Zone* const allocation_zone_; |
| 818 Frame* const frame_; | 825 Frame* const frame_; |
| 819 InstructionSequence* const code_; | 826 InstructionSequence* const code_; |
| 820 const char* const debug_name_; | 827 const char* const debug_name_; |
| 821 const RegisterConfiguration* const config_; | 828 const RegisterConfiguration* const config_; |
| 822 PhiMap phi_map_; | 829 PhiMap phi_map_; |
| 823 ZoneVector<int> allocatable_codes_; | 830 ZoneVector<int> allocatable_codes_; |
| 824 ZoneVector<int> allocatable_double_codes_; | 831 ZoneVector<int> allocatable_double_codes_; |
| 825 ZoneVector<BitVector*> live_in_sets_; | 832 ZoneVector<BitVector*> live_in_sets_; |
| 826 ZoneVector<BitVector*> live_out_sets_; | 833 ZoneVector<BitVector*> live_out_sets_; |
| 827 ZoneVector<TopLevelLiveRange*> live_ranges_; | 834 ZoneVector<TopLevelLiveRange*> live_ranges_; |
| 828 ZoneVector<TopLevelLiveRange*> fixed_live_ranges_; | 835 ZoneVector<TopLevelLiveRange*> fixed_live_ranges_; |
| 829 ZoneVector<TopLevelLiveRange*> fixed_double_live_ranges_; | 836 ZoneVector<TopLevelLiveRange*> fixed_double_live_ranges_; |
| 830 ZoneVector<SpillRange*> spill_ranges_; | 837 ZoneVector<SpillRange*> spill_ranges_; |
| 831 DelayedReferences delayed_references_; | 838 DelayedReferences delayed_references_; |
| 832 BitVector* assigned_registers_; | 839 BitVector* assigned_registers_; |
| 833 BitVector* assigned_double_registers_; | 840 BitVector* assigned_double_registers_; |
| 834 int virtual_register_count_; | 841 int virtual_register_count_; |
| 842 RangesWithPreassignedSlots preassigned_slot_ranges_; |
| 835 | 843 |
| 836 DISALLOW_COPY_AND_ASSIGN(RegisterAllocationData); | 844 DISALLOW_COPY_AND_ASSIGN(RegisterAllocationData); |
| 837 }; | 845 }; |
| 838 | 846 |
| 839 | 847 |
| 840 class ConstraintBuilder final : public ZoneObject { | 848 class ConstraintBuilder final : public ZoneObject { |
| 841 public: | 849 public: |
| 842 explicit ConstraintBuilder(RegisterAllocationData* data); | 850 explicit ConstraintBuilder(RegisterAllocationData* data); |
| 843 | 851 |
| 844 // Phase 1 : insert moves to account for fixed register operands. | 852 // Phase 1 : insert moves to account for fixed register operands. |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 RegisterAllocationData* const data_; | 1155 RegisterAllocationData* const data_; |
| 1148 | 1156 |
| 1149 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); | 1157 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); |
| 1150 }; | 1158 }; |
| 1151 | 1159 |
| 1152 } // namespace compiler | 1160 } // namespace compiler |
| 1153 } // namespace internal | 1161 } // namespace internal |
| 1154 } // namespace v8 | 1162 } // namespace v8 |
| 1155 | 1163 |
| 1156 #endif // V8_REGISTER_ALLOCATOR_H_ | 1164 #endif // V8_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |