| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_REGISTER_ALLOCATOR_IA32_H_ | 28 #ifndef V8_REGISTER_ALLOCATOR_IA32_H_ |
| 29 #define V8_REGISTER_ALLOCATOR_IA32_H_ | 29 #define V8_REGISTER_ALLOCATOR_IA32_H_ |
| 30 | 30 |
| 31 #include "macro-assembler.h" | |
| 32 | |
| 33 namespace v8 { namespace internal { | 31 namespace v8 { namespace internal { |
| 34 | 32 |
| 35 | 33 |
| 36 // ------------------------------------------------------------------------- | 34 // ------------------------------------------------------------------------- |
| 37 // Results | |
| 38 // | |
| 39 // Results encapsulate the compile-time values manipulated by the code | |
| 40 // generator. They can represent registers or constants. | |
| 41 | |
| 42 class Result BASE_EMBEDDED { | |
| 43 public: | |
| 44 enum Type { | |
| 45 INVALID, | |
| 46 REGISTER, | |
| 47 CONSTANT | |
| 48 }; | |
| 49 | |
| 50 // Construct an invalid result. | |
| 51 explicit Result(CodeGenerator* cgen) : type_(INVALID), cgen_(cgen) {} | |
| 52 | |
| 53 // Construct a register Result. | |
| 54 Result(Register reg, CodeGenerator* cgen); | |
| 55 | |
| 56 // Construct a Result whose value is a compile-time constant. | |
| 57 Result(Handle<Object> value, CodeGenerator * cgen) | |
| 58 : type_(CONSTANT), | |
| 59 cgen_(cgen) { | |
| 60 data_.handle_ = value.location(); | |
| 61 } | |
| 62 | |
| 63 // The copy constructor and assignment operators could each create a new | |
| 64 // register reference. | |
| 65 Result(const Result& other) { | |
| 66 other.CopyTo(this); | |
| 67 } | |
| 68 | |
| 69 Result& operator=(const Result& other) { | |
| 70 if (this != &other) { | |
| 71 Unuse(); | |
| 72 other.CopyTo(this); | |
| 73 } | |
| 74 return *this; | |
| 75 } | |
| 76 | |
| 77 ~Result() { Unuse(); } | |
| 78 | |
| 79 void Unuse(); | |
| 80 | |
| 81 Type type() const { return type_; } | |
| 82 | |
| 83 bool is_valid() const { return type() != INVALID; } | |
| 84 bool is_register() const { return type() == REGISTER; } | |
| 85 bool is_constant() const { return type() == CONSTANT; } | |
| 86 | |
| 87 Register reg() const { | |
| 88 ASSERT(type() == REGISTER); | |
| 89 return data_.reg_; | |
| 90 } | |
| 91 | |
| 92 Handle<Object> handle() const { | |
| 93 ASSERT(type() == CONSTANT); | |
| 94 return Handle<Object>(data_.handle_); | |
| 95 } | |
| 96 | |
| 97 // Move this result to an arbitrary register. The register is not | |
| 98 // necessarily spilled from the frame or even singly-referenced outside | |
| 99 // it. | |
| 100 void ToRegister(); | |
| 101 | |
| 102 // Move this result to a specified register. The register is spilled from | |
| 103 // the frame, and the register is singly-referenced (by this result) | |
| 104 // outside the frame. | |
| 105 void ToRegister(Register reg); | |
| 106 | |
| 107 private: | |
| 108 Type type_; | |
| 109 | |
| 110 union { | |
| 111 Register reg_; | |
| 112 Object** handle_; | |
| 113 } data_; | |
| 114 | |
| 115 CodeGenerator* cgen_; | |
| 116 | |
| 117 void CopyTo(Result* destination) const; | |
| 118 }; | |
| 119 | |
| 120 | |
| 121 // ------------------------------------------------------------------------- | |
| 122 // Register file | 35 // Register file |
| 123 // | 36 // |
| 124 // The register file tracks reference counts for the processor registers. | 37 // The register file tracks reference counts for the processor registers. |
| 125 // It is used by both the register allocator and the virtual frame. | 38 // It is used by both the register allocator and the virtual frame. |
| 126 | 39 |
| 127 class RegisterFile BASE_EMBEDDED { | 40 class RegisterFile BASE_EMBEDDED { |
| 128 public: | 41 public: |
| 129 RegisterFile() { Reset(); } | 42 RegisterFile() { Reset(); } |
| 130 | 43 |
| 131 void Reset() { | 44 void Reset() { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 146 } |
| 234 | 147 |
| 235 private: | 148 private: |
| 236 CodeGenerator* cgen_; | 149 CodeGenerator* cgen_; |
| 237 RegisterFile registers_; | 150 RegisterFile registers_; |
| 238 }; | 151 }; |
| 239 | 152 |
| 240 } } // namespace v8::internal | 153 } } // namespace v8::internal |
| 241 | 154 |
| 242 #endif // V8_REGISTER_ALLOCATOR_IA32_H_ | 155 #endif // V8_REGISTER_ALLOCATOR_IA32_H_ |
| OLD | NEW |