Chromium Code Reviews| Index: src/register-allocator-ia32.h |
| =================================================================== |
| --- src/register-allocator-ia32.h (revision 1012) |
| +++ src/register-allocator-ia32.h (working copy) |
| @@ -41,6 +41,12 @@ |
| class Result BASE_EMBEDDED { |
| public: |
| + enum Type { |
| + INVALID, |
| + REGISTER, |
| + CONSTANT |
| + }; |
| + |
| // Construct an invalid result. |
| explicit Result(CodeGenerator* cgen) : type_(INVALID), cgen_(cgen) {} |
| @@ -60,11 +66,11 @@ |
| other.CopyTo(this); |
| } |
| - Result& operator=(Result& other) { |
| + Result& operator=(const Result& other) { |
| if (this != &other) { |
| Unuse(); |
| other.CopyTo(this); |
| - other.Unuse(); |
| + // other.Unuse(); |
| } |
| return *this; |
| } |
| @@ -73,6 +79,8 @@ |
| void Unuse(); |
| + Type type() const { return type_; } |
| + |
| bool is_valid() const { return type() != INVALID; } |
| bool is_register() const { return type() == REGISTER; } |
| bool is_constant() const { return type() == CONSTANT; } |
| @@ -87,18 +95,17 @@ |
| return Handle<Object>(data_.handle_); |
| } |
| - // Change a result to a register result. If the result is not already |
| - // in a register, allocate a register from the code generator, and emit |
| - // code to move the value into that register. |
| + // Move this result to an arbitrary register. The register is not |
| + // necessarily spilled from the frame or even singly-referenced outside |
| + // it. |
|
William Hesse
2008/12/22 13:55:21
How can we move a result into a register that isn'
Kevin Millikin (Chromium)
2008/12/22 14:40:00
Yes, the comment refers to the case where the resu
|
| void ToRegister(); |
| + // Move this result to a specified register. The register is spilled from |
| + // the frame, and the register is singly-referenced (by this result) |
| + // outside the frame. |
| + void ToRegister(Register reg); |
| + |
| private: |
| - enum Type { |
| - INVALID, |
| - REGISTER, |
| - CONSTANT |
| - }; |
| - |
| Type type_; |
| union { |
| @@ -108,8 +115,6 @@ |
| CodeGenerator* cgen_; |
| - Type type() const { return type_; } |
| - |
| void CopyTo(Result* destination) const; |
| }; |
| @@ -130,11 +135,13 @@ |
| } |
| } |
| - // Predicates and accessors for the reference counts. They take a |
| - // register code rather than a register because they are frequently used |
| - // in a loop over the register codes. |
| + // Predicates and accessors for the reference counts. The versions |
| + // that take a register code rather than a register are for |
| + // convenience in loops over the register codes. |
| bool is_used(int reg_code) const { return ref_counts_[reg_code] > 0; } |
| + bool is_used(Register reg) const { return is_used(reg.code()); } |
| int count(int reg_code) const { return ref_counts_[reg_code]; } |
| + int count(Register reg) const { return count(reg.code()); } |
| // Record a use of a register by incrementing its reference count. |
| void Use(Register reg) { |
| @@ -169,7 +176,9 @@ |
| // Predicates and accessors for the registers' reference counts. |
| bool is_used(int reg_code) const { return registers_.is_used(reg_code); } |
| - int count(int reg_code) { return registers_.count(reg_code); } |
| + bool is_used(Register reg) const { return registers_.is_used(reg.code()); } |
| + int count(int reg_code) const { return registers_.count(reg_code); } |
| + int count(Register reg) const { return registers_.count(reg.code()); } |
| // Explicitly record a reference to a register. |
| void Use(Register reg) { registers_.Use(reg); } |
| @@ -186,6 +195,10 @@ |
| // fail and return an invalid result. |
| Result Allocate(); |
| + // Allocate a specific register if possible, spilling it from the frame if |
| + // necessary, or else fail and regutrn an invalid result. |
|
William Hesse
2008/12/22 13:55:21
and return an invalid result.
|
| + Result Allocate(Register target); |
| + |
| // Allocate a free register without spilling any from the current frame or |
| // fail and return an invalid result. |
| Result AllocateWithoutSpilling(); |