Chromium Code Reviews| Index: src/lithium-allocator.h |
| diff --git a/src/lithium-allocator.h b/src/lithium-allocator.h |
| index 52fee6455f9df96fcc141f417ec0b98313daa92e..b9ce3dea4b7ad6ddecd1a9257dcdbd7bdfa52425 100644 |
| --- a/src/lithium-allocator.h |
| +++ b/src/lithium-allocator.h |
| @@ -55,6 +55,7 @@ class LPointerMap; |
| class LStackSlot; |
| class LRegister; |
| + |
| // This class represents a single point of a LOperand's lifetime. |
| // For each lithium instruction there are exactly two lifetime positions: |
| // the beginning and the end of the instruction. Lifetime positions for |
| @@ -121,7 +122,13 @@ class LifetimePosition { |
| // instruction. |
| bool IsValid() const { return value_ != -1; } |
| - static LifetimePosition Invalid() { return LifetimePosition(); } |
| + static inline LifetimePosition Invalid() { return LifetimePosition(); } |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
I don't usually write inline here.
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
I prefer to state intention clearly.
|
| + |
| + static inline LifetimePosition MaxPosition() { |
| + // We have to use this kind of getter instead of static member due to |
| + // crash bug in GDB. |
| + return LifetimePosition(kMaxInt); |
| + } |
| private: |
| static const int kStep = 2; |
| @@ -135,6 +142,13 @@ class LifetimePosition { |
| }; |
| +enum RegistersClass { |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
RegisterKind?
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + NONE, |
| + CPU_REGISTERS, |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
Maybe GENERAL_REGISTERS is better? They're all CP
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + DOUBLE_REGISTERS |
| +}; |
| + |
| + |
| class LOperand: public ZoneObject { |
| public: |
| enum Kind { |
| @@ -594,8 +608,8 @@ class LiveRange: public ZoneObject { |
| explicit LiveRange(int id) |
| : id_(id), |
| spilled_(false), |
| - assigned_double_(false), |
| assigned_register_(kInvalidAssignment), |
| + assigned_register_class_(NONE), |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
assigned_register_kind_?
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| last_interval_(NULL), |
| first_interval_(NULL), |
| first_pos_(NULL), |
| @@ -620,10 +634,10 @@ class LiveRange: public ZoneObject { |
| LOperand* CreateAssignedOperand(); |
| int assigned_register() const { return assigned_register_; } |
| int spill_start_index() const { return spill_start_index_; } |
| - void set_assigned_register(int reg, bool double_reg) { |
| + void set_assigned_register(int reg, RegistersClass reg_class) { |
| ASSERT(!HasRegisterAssigned() && !IsSpilled()); |
| assigned_register_ = reg; |
| - assigned_double_ = double_reg; |
| + assigned_register_class_ = reg_class; |
| ConvertOperands(); |
| } |
| void MakeSpilled() { |
| @@ -652,9 +666,13 @@ class LiveRange: public ZoneObject { |
| // Can this live range be spilled at this position. |
| bool CanBeSpilled(LifetimePosition pos); |
| + // Split this live range at given position which must follow start of |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
follow the start of
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + // the range. |
| + // All uses following the given position will be moved from this |
| + // live range to result live range. |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
to the result
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| void SplitAt(LifetimePosition position, LiveRange* result); |
| - bool IsDouble() const { return assigned_double_; } |
| + bool IsDouble() const { return assigned_register_class_ == DOUBLE_REGISTERS; } |
| bool HasRegisterAssigned() const { |
| return assigned_register_ != kInvalidAssignment; |
| } |
| @@ -721,8 +739,8 @@ class LiveRange: public ZoneObject { |
| int id_; |
| bool spilled_; |
| - bool assigned_double_; |
| int assigned_register_; |
| + RegistersClass assigned_register_class_; |
| UseInterval* last_interval_; |
| UseInterval* first_interval_; |
| UsePosition* first_pos_; |
| @@ -774,8 +792,8 @@ class LAllocator BASE_EMBEDDED { |
| // Checks whether the value of a given virtual register is tagged. |
| bool HasTaggedValue(int virtual_register) const; |
| - // Checks whether the value of a given virtual register is a double. |
| - bool HasDoubleValue(int virtual_register) const; |
| + // Returns register class required by given virtual register. |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
Returns the register kind
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + RegistersClass RequiredRegisterClass(int virtual_register) const; |
| // Begin a new instruction. |
| void BeginInstruction(); |
| @@ -814,12 +832,6 @@ class LAllocator BASE_EMBEDDED { |
| #endif |
| private: |
| - enum OperationMode { |
| - NONE, |
| - CPU_REGISTERS, |
| - XMM_REGISTERS |
| - }; |
| - |
| void MeetRegisterConstraints(); |
| void ResolvePhis(); |
| void BuildLiveRanges(); |
| @@ -871,17 +883,39 @@ class LAllocator BASE_EMBEDDED { |
| // Helper methods for allocating registers. |
| bool TryAllocateFreeReg(LiveRange* range); |
| void AllocateBlockedReg(LiveRange* range); |
| - void SplitAndSpillIntersecting(LiveRange* range); |
| + |
| + // Live range splitting helpers. |
| + |
| + // Split given range at position pos. |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
the given range
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + // If range starts at pos or range start follows pos then |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
Something like: If the range starts at or after po
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + // original range is returned. |
| + // Otherwise returns live range that starts at pos and contains |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
the live range
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + // all uses from original range that follow pos. Uses at pos will |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
from the origiinal
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + // still be owned by original range after splitting. |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
by the original
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + LiveRange* SplitAt(LiveRange* range, LifetimePosition pos); |
| + |
| + // Split given range in position from interval [start, end]. |
| + LiveRange* SplitBetween(LiveRange* range, |
| + LifetimePosition start, |
| + LifetimePosition end); |
| + |
| + // Find lifetime position in interval [start, end] that |
| + // is optimal for splitting: it is either header of outermost |
| + // loop covered by this interval or latest possible position. |
| LifetimePosition FindOptimalSplitPos(LifetimePosition start, |
| LifetimePosition end); |
| - LiveRange* Split(LiveRange* range, |
| - LifetimePosition start, |
| - LifetimePosition end); |
| - LiveRange* Split(LiveRange* range, LifetimePosition split_pos); |
| - void SplitAndSpill(LiveRange* range, |
| - LifetimePosition start, |
| - LifetimePosition end); |
| - void SplitAndSpill(LiveRange* range, LifetimePosition at); |
| + |
| + // Spill give life range after position pos. |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
the given live range
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + void SpillAfter(LiveRange* range, LifetimePosition pos); |
| + |
| + // Spill given life range after position start and up to end. |
|
Kevin Millikin (Chromium)
2010/12/10 07:39:19
the given live range
Vyacheslav Egorov (Chromium)
2010/12/10 14:18:27
Done.
|
| + void SpillBetween(LiveRange* range, |
| + LifetimePosition start, |
| + LifetimePosition end); |
| + |
| + |
| + void SplitAndSpillIntersecting(LiveRange* range); |
| + |
| void Spill(LiveRange* range); |
| bool IsBlockBoundary(LifetimePosition pos); |
| void AddGapMove(int pos, LiveRange* prev, LiveRange* next); |
| @@ -938,7 +972,7 @@ class LAllocator BASE_EMBEDDED { |
| // Next virtual register number to be assigned to temporaries. |
| int next_virtual_register_; |
| - OperationMode mode_; |
| + RegistersClass mode_; |
| int num_registers_; |
| HGraph* graph_; |