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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 LifetimePosition Intersect(const UseInterval* other) const { | 187 LifetimePosition Intersect(const UseInterval* other) const { |
188 if (other->start() < start_) return other->Intersect(this); | 188 if (other->start() < start_) return other->Intersect(this); |
189 if (other->start() < end_) return other->start(); | 189 if (other->start() < end_) return other->start(); |
190 return LifetimePosition::Invalid(); | 190 return LifetimePosition::Invalid(); |
191 } | 191 } |
192 | 192 |
193 bool Contains(LifetimePosition point) const { | 193 bool Contains(LifetimePosition point) const { |
194 return start_ <= point && point < end_; | 194 return start_ <= point && point < end_; |
195 } | 195 } |
196 | 196 |
| 197 int FirstInstructionIndex() const { |
| 198 int ret = start_.ToInstructionIndex(); |
| 199 if (start_.IsInstructionPosition() && start_.IsEnd()) { |
| 200 ++ret; |
| 201 } |
| 202 return ret; |
| 203 } |
| 204 |
| 205 int LastInstructionIndex() const { |
| 206 int ret = end_.ToInstructionIndex(); |
| 207 if (end_.IsGapPosition() || end_.IsStart()) { |
| 208 --ret; |
| 209 } |
| 210 return ret; |
| 211 } |
| 212 |
197 private: | 213 private: |
198 LifetimePosition start_; | 214 LifetimePosition start_; |
199 LifetimePosition end_; | 215 LifetimePosition end_; |
200 UseInterval* next_; | 216 UseInterval* next_; |
201 | 217 |
202 DISALLOW_COPY_AND_ASSIGN(UseInterval); | 218 DISALLOW_COPY_AND_ASSIGN(UseInterval); |
203 }; | 219 }; |
204 | 220 |
205 | 221 |
206 enum class UsePositionType : uint8_t { kAny, kRequiresRegister, kRequiresSlot }; | 222 enum class UsePositionType : uint8_t { kAny, kRequiresRegister, kRequiresSlot }; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 const InstructionOperand& operand, | 559 const InstructionOperand& operand, |
544 bool might_be_duplicated); | 560 bool might_be_duplicated); |
545 | 561 |
546 // If all the children of this range are spilled in deferred blocks, and if | 562 // If all the children of this range are spilled in deferred blocks, and if |
547 // for any non-spilled child with a use position requiring a slot, that range | 563 // for any non-spilled child with a use position requiring a slot, that range |
548 // is contained in a deferred block, mark the range as | 564 // is contained in a deferred block, mark the range as |
549 // IsSpilledOnlyInDeferredBlocks, so that we avoid spilling at definition, | 565 // IsSpilledOnlyInDeferredBlocks, so that we avoid spilling at definition, |
550 // and instead let the LiveRangeConnector perform the spills within the | 566 // and instead let the LiveRangeConnector perform the spills within the |
551 // deferred blocks. If so, we insert here spills for non-spilled ranges | 567 // deferred blocks. If so, we insert here spills for non-spilled ranges |
552 // with slot use positions. | 568 // with slot use positions. |
553 void MarkSpilledInDeferredBlock(const InstructionSequence* code); | 569 void MarkSpilledInDeferredBlock() { |
| 570 spill_start_index_ = -1; |
| 571 spilled_in_deferred_blocks_ = true; |
| 572 spill_move_insertion_locations_ = nullptr; |
| 573 } |
| 574 |
554 bool TryCommitSpillInDeferredBlock(InstructionSequence* code, | 575 bool TryCommitSpillInDeferredBlock(InstructionSequence* code, |
555 const InstructionOperand& spill_operand); | 576 const InstructionOperand& spill_operand); |
556 | 577 |
557 TopLevelLiveRange* splintered_from() const { return splintered_from_; } | 578 TopLevelLiveRange* splintered_from() const { return splintered_from_; } |
558 bool IsSplinter() const { return splintered_from_ != nullptr; } | 579 bool IsSplinter() const { return splintered_from_ != nullptr; } |
559 bool MayRequireSpillRange() const { | 580 bool MayRequireSpillRange() const { |
560 DCHECK(!IsSplinter()); | 581 DCHECK(!IsSplinter()); |
561 return !HasSpillOperand() && spill_range_ == nullptr; | 582 return !HasSpillOperand() && spill_range_ == nullptr; |
562 } | 583 } |
563 void UpdateSpillRangePostMerge(TopLevelLiveRange* merged); | 584 void UpdateSpillRangePostMerge(TopLevelLiveRange* merged); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 | 785 |
765 MoveOperands* AddGapMove(int index, Instruction::GapPosition position, | 786 MoveOperands* AddGapMove(int index, Instruction::GapPosition position, |
766 const InstructionOperand& from, | 787 const InstructionOperand& from, |
767 const InstructionOperand& to); | 788 const InstructionOperand& to); |
768 | 789 |
769 bool IsReference(TopLevelLiveRange* top_range) const { | 790 bool IsReference(TopLevelLiveRange* top_range) const { |
770 return code()->IsReference(top_range->vreg()); | 791 return code()->IsReference(top_range->vreg()); |
771 } | 792 } |
772 | 793 |
773 bool ExistsUseWithoutDefinition(); | 794 bool ExistsUseWithoutDefinition(); |
| 795 bool RangesDefinedInDeferredStayInDeferred(); |
774 | 796 |
775 void MarkAllocated(RegisterKind kind, int index); | 797 void MarkAllocated(RegisterKind kind, int index); |
776 | 798 |
777 PhiMapValue* InitializePhiMap(const InstructionBlock* block, | 799 PhiMapValue* InitializePhiMap(const InstructionBlock* block, |
778 PhiInstruction* phi); | 800 PhiInstruction* phi); |
779 PhiMapValue* GetPhiMapValueFor(TopLevelLiveRange* top_range); | 801 PhiMapValue* GetPhiMapValueFor(TopLevelLiveRange* top_range); |
780 PhiMapValue* GetPhiMapValueFor(int virtual_register); | 802 PhiMapValue* GetPhiMapValueFor(int virtual_register); |
781 bool IsBlockBoundary(LifetimePosition pos) const; | 803 bool IsBlockBoundary(LifetimePosition pos) const; |
782 | 804 |
783 void Print(const InstructionSequence* instructionSequence); | 805 void Print(const InstructionSequence* instructionSequence); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 RegisterAllocationData* const data_; | 1145 RegisterAllocationData* const data_; |
1124 | 1146 |
1125 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); | 1147 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); |
1126 }; | 1148 }; |
1127 | 1149 |
1128 } // namespace compiler | 1150 } // namespace compiler |
1129 } // namespace internal | 1151 } // namespace internal |
1130 } // namespace v8 | 1152 } // namespace v8 |
1131 | 1153 |
1132 #endif // V8_REGISTER_ALLOCATOR_H_ | 1154 #endif // V8_REGISTER_ALLOCATOR_H_ |
OLD | NEW |