| 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-inl.h" | 32 #include "type-info-inl.h" |
| 33 | 33 |
| 34 #if V8_TARGET_ARCH_IA32 | 34 #if V8_TARGET_ARCH_IA32 |
| 35 #include "ia32/register-allocator-ia32.h" | 35 #include "ia32/register-allocator-ia32.h" |
| 36 #elif V8_TARGET_ARCH_X64 | 36 #elif V8_TARGET_ARCH_X64 |
| 37 #include "x64/register-allocator-x64.h" | 37 #include "x64/register-allocator-x64.h" |
| 38 #elif V8_TARGET_ARCH_ARM | 38 #elif V8_TARGET_ARCH_ARM |
| 39 #include "arm/register-allocator-arm.h" | 39 #include "arm/register-allocator-arm.h" |
| 40 #elif V8_TARGET_ARCH_MIPS | 40 #elif V8_TARGET_ARCH_MIPS |
| 41 #include "mips/register-allocator-mips.h" | 41 #include "mips/register-allocator-mips.h" |
| 42 #else | 42 #else |
| (...skipping 15 matching lines...) Expand all Loading... |
| 58 enum Type { | 58 enum Type { |
| 59 INVALID, | 59 INVALID, |
| 60 REGISTER, | 60 REGISTER, |
| 61 CONSTANT | 61 CONSTANT |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 // Construct an invalid result. | 64 // Construct an invalid result. |
| 65 Result() { invalidate(); } | 65 Result() { invalidate(); } |
| 66 | 66 |
| 67 // Construct a register Result. | 67 // Construct a register Result. |
| 68 explicit Result(Register reg, NumberInfo info = NumberInfo::Unknown()); | 68 explicit Result(Register reg, TypeInfo info = TypeInfo::Unknown()); |
| 69 | 69 |
| 70 // Construct a Result whose value is a compile-time constant. | 70 // Construct a Result whose value is a compile-time constant. |
| 71 explicit Result(Handle<Object> value) { | 71 explicit Result(Handle<Object> value) { |
| 72 NumberInfo info = NumberInfo::TypeFromValue(value); | 72 TypeInfo info = TypeInfo::TypeFromValue(value); |
| 73 value_ = TypeField::encode(CONSTANT) | 73 value_ = TypeField::encode(CONSTANT) |
| 74 | NumberInfoField::encode(info.ToInt()) | 74 | TypeInfoField::encode(info.ToInt()) |
| 75 | IsUntaggedInt32Field::encode(false) | 75 | IsUntaggedInt32Field::encode(false) |
| 76 | DataField::encode(ConstantList()->length()); | 76 | DataField::encode(ConstantList()->length()); |
| 77 ConstantList()->Add(value); | 77 ConstantList()->Add(value); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // The copy constructor and assignment operators could each create a new | 80 // The copy constructor and assignment operators could each create a new |
| 81 // register reference. | 81 // register reference. |
| 82 inline Result(const Result& other); | 82 inline Result(const Result& other); |
| 83 | 83 |
| 84 inline Result& operator=(const Result& other); | 84 inline Result& operator=(const Result& other); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 96 static void ClearConstantList() { | 96 static void ClearConstantList() { |
| 97 ConstantList()->Clear(); | 97 ConstantList()->Clear(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 inline void Unuse(); | 100 inline void Unuse(); |
| 101 | 101 |
| 102 Type type() const { return TypeField::decode(value_); } | 102 Type type() const { return TypeField::decode(value_); } |
| 103 | 103 |
| 104 void invalidate() { value_ = TypeField::encode(INVALID); } | 104 void invalidate() { value_ = TypeField::encode(INVALID); } |
| 105 | 105 |
| 106 inline NumberInfo number_info() const; | 106 inline TypeInfo type_info() const; |
| 107 inline void set_number_info(NumberInfo info); | 107 inline void set_type_info(TypeInfo info); |
| 108 inline bool is_number() const; | 108 inline bool is_number() const; |
| 109 inline bool is_smi() const; | 109 inline bool is_smi() const; |
| 110 inline bool is_integer32() const; | 110 inline bool is_integer32() const; |
| 111 inline bool is_double() const; | 111 inline bool is_double() const; |
| 112 | 112 |
| 113 bool is_valid() const { return type() != INVALID; } | 113 bool is_valid() const { return type() != INVALID; } |
| 114 bool is_register() const { return type() == REGISTER; } | 114 bool is_register() const { return type() == REGISTER; } |
| 115 bool is_constant() const { return type() == CONSTANT; } | 115 bool is_constant() const { return type() == CONSTANT; } |
| 116 | 116 |
| 117 // An untagged int32 Result contains a signed int32 in a register | 117 // An untagged int32 Result contains a signed int32 in a register |
| (...skipping 30 matching lines...) Expand all Loading... |
| 148 // Move this result to a specified register. The register is spilled from | 148 // Move this result to a specified register. The register is spilled from |
| 149 // the frame, and the register is singly-referenced (by this result) | 149 // the frame, and the register is singly-referenced (by this result) |
| 150 // outside the frame. | 150 // outside the frame. |
| 151 void ToRegister(Register reg); | 151 void ToRegister(Register reg); |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 uint32_t value_; | 154 uint32_t value_; |
| 155 | 155 |
| 156 // Declare BitFields with template parameters <type, start, size>. | 156 // Declare BitFields with template parameters <type, start, size>. |
| 157 class TypeField: public BitField<Type, 0, 2> {}; | 157 class TypeField: public BitField<Type, 0, 2> {}; |
| 158 class NumberInfoField : public BitField<int, 2, 6> {}; | 158 class TypeInfoField : public BitField<int, 2, 6> {}; |
| 159 class IsUntaggedInt32Field : public BitField<bool, 8, 1> {}; | 159 class IsUntaggedInt32Field : public BitField<bool, 8, 1> {}; |
| 160 class DataField: public BitField<uint32_t, 9, 32 - 9> {}; | 160 class DataField: public BitField<uint32_t, 9, 32 - 9> {}; |
| 161 | 161 |
| 162 inline void CopyTo(Result* destination) const; | 162 inline void CopyTo(Result* destination) const; |
| 163 | 163 |
| 164 friend class CodeGeneratorScope; | 164 friend class CodeGeneratorScope; |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 | 167 |
| 168 // ------------------------------------------------------------------------- | 168 // ------------------------------------------------------------------------- |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 307 } |
| 308 | 308 |
| 309 private: | 309 private: |
| 310 CodeGenerator* cgen_; | 310 CodeGenerator* cgen_; |
| 311 RegisterFile registers_; | 311 RegisterFile registers_; |
| 312 }; | 312 }; |
| 313 | 313 |
| 314 } } // namespace v8::internal | 314 } } // namespace v8::internal |
| 315 | 315 |
| 316 #endif // V8_REGISTER_ALLOCATOR_H_ | 316 #endif // V8_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |