Index: src/compiler/register-allocator.h |
diff --git a/src/compiler/register-allocator.h b/src/compiler/register-allocator.h |
index d62ffb32fca1e0ef101a0838d3e06f692e807f12..47ff02a7ae61924fa4bba696fac997f573917ea0 100644 |
--- a/src/compiler/register-allocator.h |
+++ b/src/compiler/register-allocator.h |
@@ -583,7 +583,50 @@ class LiveRangeBuilder final : public ZoneObject { |
}; |
-class LinearScanAllocator final : public ZoneObject { |
+class RegisterAllocator : public ZoneObject { |
+ public: |
+ explicit RegisterAllocator(RegisterAllocationData* data); |
+ |
+ protected: |
+ RegisterAllocationData* data() const { return data_; } |
+ InstructionSequence* code() const { return data()->code(); } |
+ Zone* allocation_zone() const { return data()->allocation_zone(); } |
+ |
+ LiveRange* LiveRangeFor(int index) { return data()->LiveRangeFor(index); } |
+ |
+ // Split the given range at the given position. |
+ // If range starts at or after the given position then the |
+ // original range is returned. |
+ // Otherwise returns the live range that starts at pos and contains |
+ // all uses from the original range that follow pos. Uses at pos will |
+ // still be owned by the original range after splitting. |
+ LiveRange* SplitRangeAt(LiveRange* range, LifetimePosition pos); |
+ |
+ // Split the given range in a position from the interval [start, end]. |
+ LiveRange* SplitBetween(LiveRange* range, LifetimePosition start, |
+ LifetimePosition end); |
+ |
+ // Find a lifetime position in the interval [start, end] which |
+ // is optimal for splitting: it is either header of the outermost |
+ // loop covered by this interval or the latest possible position. |
+ LifetimePosition FindOptimalSplitPos(LifetimePosition start, |
+ LifetimePosition end); |
+ |
+ void Spill(LiveRange* range); |
+ |
+ // If we are trying to spill a range inside the loop try to |
+ // hoist spill position out to the point just before the loop. |
+ LifetimePosition FindOptimalSpillingPos(LiveRange* range, |
+ LifetimePosition pos); |
+ |
+ private: |
+ RegisterAllocationData* const data_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); |
+}; |
+ |
+ |
+class LinearScanAllocator final : public RegisterAllocator { |
public: |
LinearScanAllocator(RegisterAllocationData* data, RegisterKind kind, |
Zone* local_zone); |
@@ -592,9 +635,6 @@ class LinearScanAllocator final : public ZoneObject { |
void AllocateRegisters(); |
private: |
- RegisterAllocationData* data() const { return data_; } |
- InstructionSequence* code() const { return data()->code(); } |
- Zone* allocation_zone() const { return data()->allocation_zone(); } |
int num_registers() const { return num_registers_; } |
const char* RegisterName(int allocation_index) const; |
@@ -606,8 +646,6 @@ class LinearScanAllocator final : public ZoneObject { |
return inactive_live_ranges_; |
} |
- LiveRange* LiveRangeFor(int index) { return data()->LiveRangeFor(index); } |
- |
// Helper methods for updating the life range lists. |
void AddToActive(LiveRange* range); |
void AddToInactive(LiveRange* range); |
@@ -625,28 +663,6 @@ class LinearScanAllocator final : public ZoneObject { |
bool TryAllocateFreeReg(LiveRange* range); |
void AllocateBlockedReg(LiveRange* range); |
- // Live range splitting helpers. |
- |
- // Split the given range at the given position. |
- // If range starts at or after the given position then the |
- // original range is returned. |
- // Otherwise returns the live range that starts at pos and contains |
- // all uses from the original range that follow pos. Uses at pos will |
- // still be owned by the original range after splitting. |
- LiveRange* SplitRangeAt(LiveRange* range, LifetimePosition pos); |
- |
- // Split the given range in a position from the interval [start, end]. |
- LiveRange* SplitBetween(LiveRange* range, LifetimePosition start, |
- LifetimePosition end); |
- |
- // Find a lifetime position in the interval [start, end] which |
- // is optimal for splitting: it is either header of the outermost |
- // loop covered by this interval or the latest possible position. |
- LifetimePosition FindOptimalSplitPos(LifetimePosition start, |
- LifetimePosition end); |
- |
- void Spill(LiveRange* range); |
- |
// Spill the given life range after position pos. |
void SpillAfter(LiveRange* range, LifetimePosition pos); |
@@ -661,12 +677,6 @@ class LinearScanAllocator final : public ZoneObject { |
void SplitAndSpillIntersecting(LiveRange* range); |
- // If we are trying to spill a range inside the loop try to |
- // hoist spill position out to the point just before the loop. |
- LifetimePosition FindOptimalSpillingPos(LiveRange* range, |
- LifetimePosition pos); |
- |
- RegisterAllocationData* const data_; |
const RegisterKind mode_; |
const int num_registers_; |