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 #include "number-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 19 matching lines...) Expand all Loading... |
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, NumberInfo info = NumberInfo::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 value_ = TypeField::encode(CONSTANT) | 73 value_ = TypeField::encode(CONSTANT) |
73 | NumberInfoField::encode(NumberInfo::Uninitialized().ToInt()) | 74 | NumberInfoField::encode(info.ToInt()) |
74 | IsUntaggedInt32Field::encode(false) | 75 | IsUntaggedInt32Field::encode(false) |
75 | DataField::encode(ConstantList()->length()); | 76 | DataField::encode(ConstantList()->length()); |
76 ConstantList()->Add(value); | 77 ConstantList()->Add(value); |
77 } | 78 } |
78 | 79 |
79 // The copy constructor and assignment operators could each create a new | 80 // The copy constructor and assignment operators could each create a new |
80 // register reference. | 81 // register reference. |
81 inline Result(const Result& other); | 82 inline Result(const Result& other); |
82 | 83 |
83 inline Result& operator=(const Result& other); | 84 inline Result& operator=(const Result& other); |
(...skipping 16 matching lines...) Expand all Loading... |
100 | 101 |
101 Type type() const { return TypeField::decode(value_); } | 102 Type type() const { return TypeField::decode(value_); } |
102 | 103 |
103 void invalidate() { value_ = TypeField::encode(INVALID); } | 104 void invalidate() { value_ = TypeField::encode(INVALID); } |
104 | 105 |
105 inline NumberInfo number_info() const; | 106 inline NumberInfo number_info() const; |
106 inline void set_number_info(NumberInfo info); | 107 inline void set_number_info(NumberInfo info); |
107 inline bool is_number() const; | 108 inline bool is_number() const; |
108 inline bool is_smi() const; | 109 inline bool is_smi() const; |
109 inline bool is_integer32() const; | 110 inline bool is_integer32() const; |
110 inline bool is_heap_number() const; | 111 inline bool is_double() const; |
111 | 112 |
112 bool is_valid() const { return type() != INVALID; } | 113 bool is_valid() const { return type() != INVALID; } |
113 bool is_register() const { return type() == REGISTER; } | 114 bool is_register() const { return type() == REGISTER; } |
114 bool is_constant() const { return type() == CONSTANT; } | 115 bool is_constant() const { return type() == CONSTANT; } |
115 | 116 |
116 // An untagged int32 Result contains a signed int32 in a register | 117 // An untagged int32 Result contains a signed int32 in a register |
117 // or as a constant. These are only allowed in a side-effect-free | 118 // or as a constant. These are only allowed in a side-effect-free |
118 // int32 calculation, and if a non-int32 input shows up or an overflow | 119 // int32 calculation, and if a non-int32 input shows up or an overflow |
119 // occurs, we bail out and drop all the int32 values. Constants are | 120 // occurs, we bail out and drop all the int32 values. Constants are |
120 // not converted to int32 until they are loaded into a register. | 121 // not converted to int32 until they are loaded into a register. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 } | 307 } |
307 | 308 |
308 private: | 309 private: |
309 CodeGenerator* cgen_; | 310 CodeGenerator* cgen_; |
310 RegisterFile registers_; | 311 RegisterFile registers_; |
311 }; | 312 }; |
312 | 313 |
313 } } // namespace v8::internal | 314 } } // namespace v8::internal |
314 | 315 |
315 #endif // V8_REGISTER_ALLOCATOR_H_ | 316 #endif // V8_REGISTER_ALLOCATOR_H_ |
OLD | NEW |