Chromium Code Reviews| Index: runtime/vm/locations.h |
| diff --git a/runtime/vm/locations.h b/runtime/vm/locations.h |
| index fc65d01968db6c7dbbb1b83204cb44f84dfd85db..564b756dc1571360d90987eef3af0024c45b82a1 100644 |
| --- a/runtime/vm/locations.h |
| +++ b/runtime/vm/locations.h |
| @@ -17,7 +17,7 @@ class BufferFormatter; |
| // Instruction templates used by code generator have a corresponding |
| // LocationSummary object which specifies expected location for every input |
| // and output. |
| -// Each location is encoded as a single word: low 2 bits denote location kind, |
| +// Each location is encoded as a single word: low 3 bits denote location kind, |
|
Kevin Millikin (Google)
2012/07/23 12:52:30
Not entirely true: tag is variable sized (alternat
Vyacheslav Egorov (Google)
2012/07/23 14:06:10
Rephrased to make it more clear.
|
| // rest is kind specific location payload e.g. for REGISTER kind payload is |
| // register code (value of the Register enumeration). |
| class Location : public ValueObject { |
| @@ -26,17 +26,25 @@ class Location : public ValueObject { |
| // have to be chosen in a way that their last 2 bits are never |
| // the same as kConstant. |
| enum Kind { |
| + // This location is invalid. Payload must be zero. |
| kInvalid = 0, |
| + // Constant value. This location contains a tagged Object handle. |
| kConstant = 1, |
| // Unallocated location represents a location that is not fixed and can be |
| // allocated by a register allocator. Each unallocated location has |
| - // a policy that specifies what kind of location is suitable. |
| + // a policy that specifies what kind of location is suitable. Payload |
| + // contains register allocation policy. |
| kUnallocated = 2, |
| - // Register location represents a fixed register. |
| - kRegister = 3 |
| + // Register location represents a fixed register. Payload contains |
| + // register code. |
| + kRegister = 3, |
| + |
| + // Spill slot allocated by the register allocator. Payload contains |
| + // a spill index. |
| + kSpillSlot = 4 |
| }; |
| static const uword kInvalidLocation = 0; |
| @@ -116,7 +124,22 @@ class Location : public ValueObject { |
| return static_cast<Register>(payload()); |
| } |
| + // Spill slots. |
| + static Location SpillSlot(intptr_t spill_index) { |
| + return Location(kSpillSlot, static_cast<uword>(spill_index)); |
| + } |
| + |
| + bool IsSpillSlot() const { |
| + return kind() == kSpillSlot; |
| + } |
| + |
| + intptr_t spill_index() const { |
| + ASSERT(IsSpillSlot()); |
| + return static_cast<uword>(payload()); |
|
Kevin Millikin (Google)
2012/07/23 12:52:30
payload() is a uword already.
Vyacheslav Egorov (Google)
2012/07/23 14:06:10
I guess I wanted cast to intptr_t
|
| + } |
| + |
| const char* Name() const; |
| + void PrintTo(BufferFormatter* f) const; |
| // Compare two non-constant locations. |
| bool Equals(Location other) const { |
| @@ -140,8 +163,8 @@ class Location : public ValueObject { |
| return KindField::decode(value_); |
| } |
| - typedef BitField<Kind, 0, 2> KindField; |
| - typedef BitField<uword, 2, kWordSize * kBitsPerByte - 2> PayloadField; |
| + typedef BitField<Kind, 0, 3> KindField; |
| + typedef BitField<uword, 3, kWordSize * kBitsPerByte - 2> PayloadField; |
| // Layout for kUnallocated locations payload. |
| typedef BitField<Policy, 0, 1> PolicyField; |