| 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 555 |
| 556 TopLevelLiveRange* splintered_from() const { return splintered_from_; } | 556 TopLevelLiveRange* splintered_from() const { return splintered_from_; } |
| 557 bool IsSplinter() const { return splintered_from_ != nullptr; } | 557 bool IsSplinter() const { return splintered_from_ != nullptr; } |
| 558 bool MayRequireSpillRange() const { | 558 bool MayRequireSpillRange() const { |
| 559 DCHECK(!IsSplinter()); | 559 DCHECK(!IsSplinter()); |
| 560 return !HasSpillOperand() && spill_range_ == nullptr; | 560 return !HasSpillOperand() && spill_range_ == nullptr; |
| 561 } | 561 } |
| 562 void UpdateSpillRangePostMerge(TopLevelLiveRange* merged); | 562 void UpdateSpillRangePostMerge(TopLevelLiveRange* merged); |
| 563 int vreg() const { return vreg_; } | 563 int vreg() const { return vreg_; } |
| 564 | 564 |
| 565 #if DEBUG |
| 566 int debug_virt_reg() const; |
| 567 #endif |
| 568 |
| 565 int GetNextChildId() { | 569 int GetNextChildId() { |
| 566 return IsSplinter() ? splintered_from()->GetNextChildId() | 570 return IsSplinter() ? splintered_from()->GetNextChildId() |
| 567 : ++last_child_id_; | 571 : ++last_child_id_; |
| 568 } | 572 } |
| 569 | 573 |
| 570 bool IsSpilledOnlyInDeferredBlocks() const { | 574 bool IsSpilledOnlyInDeferredBlocks() const { |
| 571 return spilled_in_deferred_blocks_; | 575 return spilled_in_deferred_blocks_; |
| 572 } | 576 } |
| 573 | 577 |
| 574 struct SpillAtDefinitionList; | 578 struct SpillAtDefinitionList; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 protected: | 906 protected: |
| 903 RegisterAllocationData* data() const { return data_; } | 907 RegisterAllocationData* data() const { return data_; } |
| 904 InstructionSequence* code() const { return data()->code(); } | 908 InstructionSequence* code() const { return data()->code(); } |
| 905 RegisterKind mode() const { return mode_; } | 909 RegisterKind mode() const { return mode_; } |
| 906 int num_registers() const { return num_registers_; } | 910 int num_registers() const { return num_registers_; } |
| 907 int num_allocatable_registers() const { return num_allocatable_registers_; } | 911 int num_allocatable_registers() const { return num_allocatable_registers_; } |
| 908 int allocatable_register_code(int allocatable_index) const { | 912 int allocatable_register_code(int allocatable_index) const { |
| 909 return allocatable_register_codes_[allocatable_index]; | 913 return allocatable_register_codes_[allocatable_index]; |
| 910 } | 914 } |
| 911 | 915 |
| 916 // TODO(mtrofin): explain why splitting in gap START is always OK. |
| 917 LifetimePosition GetSplitPositionForInstruction(const LiveRange* range, |
| 918 int instruction_index); |
| 919 |
| 912 Zone* allocation_zone() const { return data()->allocation_zone(); } | 920 Zone* allocation_zone() const { return data()->allocation_zone(); } |
| 913 | 921 |
| 922 // Find the optimal split for ranges defined by a memory operand, e.g. |
| 923 // constants or function parameters passed on the stack. |
| 924 void SplitAndSpillRangesDefinedByMemoryOperand(); |
| 925 |
| 914 // Split the given range at the given position. | 926 // Split the given range at the given position. |
| 915 // If range starts at or after the given position then the | 927 // If range starts at or after the given position then the |
| 916 // original range is returned. | 928 // original range is returned. |
| 917 // Otherwise returns the live range that starts at pos and contains | 929 // Otherwise returns the live range that starts at pos and contains |
| 918 // all uses from the original range that follow pos. Uses at pos will | 930 // all uses from the original range that follow pos. Uses at pos will |
| 919 // still be owned by the original range after splitting. | 931 // still be owned by the original range after splitting. |
| 920 LiveRange* SplitRangeAt(LiveRange* range, LifetimePosition pos); | 932 LiveRange* SplitRangeAt(LiveRange* range, LifetimePosition pos); |
| 921 | 933 |
| 934 bool CanProcessRange(LiveRange* range) const { |
| 935 return range != nullptr && !range->IsEmpty() && range->kind() == mode(); |
| 936 } |
| 937 |
| 938 |
| 922 // Split the given range in a position from the interval [start, end]. | 939 // Split the given range in a position from the interval [start, end]. |
| 923 LiveRange* SplitBetween(LiveRange* range, LifetimePosition start, | 940 LiveRange* SplitBetween(LiveRange* range, LifetimePosition start, |
| 924 LifetimePosition end); | 941 LifetimePosition end); |
| 925 | 942 |
| 926 // Find a lifetime position in the interval [start, end] which | 943 // Find a lifetime position in the interval [start, end] which |
| 927 // is optimal for splitting: it is either header of the outermost | 944 // is optimal for splitting: it is either header of the outermost |
| 928 // loop covered by this interval or the latest possible position. | 945 // loop covered by this interval or the latest possible position. |
| 929 LifetimePosition FindOptimalSplitPos(LifetimePosition start, | 946 LifetimePosition FindOptimalSplitPos(LifetimePosition start, |
| 930 LifetimePosition end); | 947 LifetimePosition end); |
| 931 | 948 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 RegisterAllocationData* const data_; | 1116 RegisterAllocationData* const data_; |
| 1100 | 1117 |
| 1101 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); | 1118 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); |
| 1102 }; | 1119 }; |
| 1103 | 1120 |
| 1104 } // namespace compiler | 1121 } // namespace compiler |
| 1105 } // namespace internal | 1122 } // namespace internal |
| 1106 } // namespace v8 | 1123 } // namespace v8 |
| 1107 | 1124 |
| 1108 #endif // V8_REGISTER_ALLOCATOR_H_ | 1125 #endif // V8_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |