| 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 11 matching lines...) Expand all Loading... |
| 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_H_ | 28 #ifndef V8_REGISTER_ALLOCATOR_H_ |
| 29 #define V8_REGISTER_ALLOCATOR_H_ | 29 #define V8_REGISTER_ALLOCATOR_H_ |
| 30 | 30 |
| 31 #include "macro-assembler.h" | 31 #include "macro-assembler.h" |
| 32 #include "number-info.h" |
| 32 | 33 |
| 33 #if V8_TARGET_ARCH_IA32 | 34 #if V8_TARGET_ARCH_IA32 |
| 34 #include "ia32/register-allocator-ia32.h" | 35 #include "ia32/register-allocator-ia32.h" |
| 35 #elif V8_TARGET_ARCH_X64 | 36 #elif V8_TARGET_ARCH_X64 |
| 36 #include "x64/register-allocator-x64.h" | 37 #include "x64/register-allocator-x64.h" |
| 37 #elif V8_TARGET_ARCH_ARM | 38 #elif V8_TARGET_ARCH_ARM |
| 38 #include "arm/register-allocator-arm.h" | 39 #include "arm/register-allocator-arm.h" |
| 39 #elif V8_TARGET_ARCH_MIPS | 40 #elif V8_TARGET_ARCH_MIPS |
| 40 #include "mips/register-allocator-mips.h" | 41 #include "mips/register-allocator-mips.h" |
| 41 #else | 42 #else |
| (...skipping 15 matching lines...) Expand all Loading... |
| 57 enum Type { | 58 enum Type { |
| 58 INVALID, | 59 INVALID, |
| 59 REGISTER, | 60 REGISTER, |
| 60 CONSTANT | 61 CONSTANT |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 // Construct an invalid result. | 64 // Construct an invalid result. |
| 64 Result() { invalidate(); } | 65 Result() { invalidate(); } |
| 65 | 66 |
| 66 // Construct a register Result. | 67 // Construct a register Result. |
| 67 explicit Result(Register reg); | 68 explicit Result(Register reg, NumberInfo::Type info = NumberInfo::kUnknown); |
| 68 | 69 |
| 69 // Construct a Result whose value is a compile-time constant. | 70 // Construct a Result whose value is a compile-time constant. |
| 70 explicit Result(Handle<Object> value) { | 71 explicit Result(Handle<Object> value) { |
| 71 value_ = TypeField::encode(CONSTANT) | 72 value_ = TypeField::encode(CONSTANT) |
| 73 | NumberInfoField::encode(NumberInfo::kUninitialized) |
| 72 | DataField::encode(ConstantList()->length()); | 74 | DataField::encode(ConstantList()->length()); |
| 73 ConstantList()->Add(value); | 75 ConstantList()->Add(value); |
| 74 } | 76 } |
| 75 | 77 |
| 76 // The copy constructor and assignment operators could each create a new | 78 // The copy constructor and assignment operators could each create a new |
| 77 // register reference. | 79 // register reference. |
| 78 inline Result(const Result& other); | 80 inline Result(const Result& other); |
| 79 | 81 |
| 80 inline Result& operator=(const Result& other); | 82 inline Result& operator=(const Result& other); |
| 81 | 83 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 static void ClearConstantList() { | 94 static void ClearConstantList() { |
| 93 ConstantList()->Clear(); | 95 ConstantList()->Clear(); |
| 94 } | 96 } |
| 95 | 97 |
| 96 inline void Unuse(); | 98 inline void Unuse(); |
| 97 | 99 |
| 98 Type type() const { return TypeField::decode(value_); } | 100 Type type() const { return TypeField::decode(value_); } |
| 99 | 101 |
| 100 void invalidate() { value_ = TypeField::encode(INVALID); } | 102 void invalidate() { value_ = TypeField::encode(INVALID); } |
| 101 | 103 |
| 104 NumberInfo::Type number_info(); |
| 105 void set_number_info(NumberInfo::Type info); |
| 106 bool is_number() { |
| 107 return (number_info() & NumberInfo::kNumber) != 0; |
| 108 } |
| 109 bool is_smi() { return number_info() == NumberInfo::kSmi; } |
| 110 bool is_heap_number() { return number_info() == NumberInfo::kHeapNumber; } |
| 111 |
| 102 bool is_valid() const { return type() != INVALID; } | 112 bool is_valid() const { return type() != INVALID; } |
| 103 bool is_register() const { return type() == REGISTER; } | 113 bool is_register() const { return type() == REGISTER; } |
| 104 bool is_constant() const { return type() == CONSTANT; } | 114 bool is_constant() const { return type() == CONSTANT; } |
| 105 | 115 |
| 106 Register reg() const { | 116 Register reg() const { |
| 107 ASSERT(is_register()); | 117 ASSERT(is_register()); |
| 108 uint32_t reg = DataField::decode(value_); | 118 uint32_t reg = DataField::decode(value_); |
| 109 Register result; | 119 Register result; |
| 110 result.code_ = reg; | 120 result.code_ = reg; |
| 111 return result; | 121 return result; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 123 | 133 |
| 124 // Move this result to a specified register. The register is spilled from | 134 // Move this result to a specified register. The register is spilled from |
| 125 // the frame, and the register is singly-referenced (by this result) | 135 // the frame, and the register is singly-referenced (by this result) |
| 126 // outside the frame. | 136 // outside the frame. |
| 127 void ToRegister(Register reg); | 137 void ToRegister(Register reg); |
| 128 | 138 |
| 129 private: | 139 private: |
| 130 uint32_t value_; | 140 uint32_t value_; |
| 131 | 141 |
| 132 class TypeField: public BitField<Type, 0, 2> {}; | 142 class TypeField: public BitField<Type, 0, 2> {}; |
| 133 class DataField: public BitField<uint32_t, 2, 32 - 3> {}; | 143 class NumberInfoField : public BitField<NumberInfo::Type, 2, 3> {}; |
| 144 class DataField: public BitField<uint32_t, 5, 32 - 6> {}; |
| 134 | 145 |
| 135 inline void CopyTo(Result* destination) const; | 146 inline void CopyTo(Result* destination) const; |
| 136 | 147 |
| 137 friend class CodeGeneratorScope; | 148 friend class CodeGeneratorScope; |
| 138 }; | 149 }; |
| 139 | 150 |
| 140 | 151 |
| 141 // ------------------------------------------------------------------------- | 152 // ------------------------------------------------------------------------- |
| 142 // Register file | 153 // Register file |
| 143 // | 154 // |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 291 } |
| 281 | 292 |
| 282 private: | 293 private: |
| 283 CodeGenerator* cgen_; | 294 CodeGenerator* cgen_; |
| 284 RegisterFile registers_; | 295 RegisterFile registers_; |
| 285 }; | 296 }; |
| 286 | 297 |
| 287 } } // namespace v8::internal | 298 } } // namespace v8::internal |
| 288 | 299 |
| 289 #endif // V8_REGISTER_ALLOCATOR_H_ | 300 #endif // V8_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |