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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after 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, TypeInfo info = TypeInfo::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 ZoneObjectList* constant_list = Isolate::Current()->result_constant_list(); |
72 TypeInfo info = TypeInfo::TypeFromValue(value); | 73 TypeInfo info = TypeInfo::TypeFromValue(value); |
73 value_ = TypeField::encode(CONSTANT) | 74 value_ = TypeField::encode(CONSTANT) |
74 | TypeInfoField::encode(info.ToInt()) | 75 | TypeInfoField::encode(info.ToInt()) |
75 | IsUntaggedInt32Field::encode(false) | 76 | IsUntaggedInt32Field::encode(false) |
76 | DataField::encode(ConstantList()->length()); | 77 | DataField::encode(constant_list->length()); |
77 ConstantList()->Add(value); | 78 constant_list->Add(value); |
78 } | 79 } |
79 | 80 |
80 // The copy constructor and assignment operators could each create a new | 81 // The copy constructor and assignment operators could each create a new |
81 // register reference. | 82 // register reference. |
82 inline Result(const Result& other); | 83 inline Result(const Result& other); |
83 | 84 |
84 inline Result& operator=(const Result& other); | 85 inline Result& operator=(const Result& other); |
85 | 86 |
86 inline ~Result(); | 87 inline ~Result(); |
87 | 88 |
88 // Static indirection table for handles to constants. If a Result | |
89 // represents a constant, the data contains an index into this table | |
90 // of handles to the actual constants. | |
91 typedef ZoneList<Handle<Object> > ZoneObjectList; | |
92 | |
93 static ZoneObjectList* ConstantList(); | |
94 | |
95 // Clear the constants indirection table. | |
96 static void ClearConstantList() { | |
97 ConstantList()->Clear(); | |
98 } | |
99 | |
100 inline void Unuse(); | 89 inline void Unuse(); |
101 | 90 |
102 Type type() const { return TypeField::decode(value_); } | 91 Type type() const { return TypeField::decode(value_); } |
103 | 92 |
104 void invalidate() { value_ = TypeField::encode(INVALID); } | 93 void invalidate() { value_ = TypeField::encode(INVALID); } |
105 | 94 |
106 inline TypeInfo type_info() const; | 95 inline TypeInfo type_info() const; |
107 inline void set_type_info(TypeInfo info); | 96 inline void set_type_info(TypeInfo info); |
108 inline bool is_number() const; | 97 inline bool is_number() const; |
109 inline bool is_smi() const; | 98 inline bool is_smi() const; |
(...skipping 20 matching lines...) Expand all Loading... |
130 Register reg() const { | 119 Register reg() const { |
131 ASSERT(is_register()); | 120 ASSERT(is_register()); |
132 uint32_t reg = DataField::decode(value_); | 121 uint32_t reg = DataField::decode(value_); |
133 Register result; | 122 Register result; |
134 result.code_ = reg; | 123 result.code_ = reg; |
135 return result; | 124 return result; |
136 } | 125 } |
137 | 126 |
138 Handle<Object> handle() const { | 127 Handle<Object> handle() const { |
139 ASSERT(type() == CONSTANT); | 128 ASSERT(type() == CONSTANT); |
140 return ConstantList()->at(DataField::decode(value_)); | 129 return Isolate::Current()->result_constant_list()-> |
| 130 at(DataField::decode(value_)); |
141 } | 131 } |
142 | 132 |
143 // Move this result to an arbitrary register. The register is not | 133 // Move this result to an arbitrary register. The register is not |
144 // necessarily spilled from the frame or even singly-referenced outside | 134 // necessarily spilled from the frame or even singly-referenced outside |
145 // it. | 135 // it. |
146 void ToRegister(); | 136 void ToRegister(); |
147 | 137 |
148 // Move this result to a specified register. The register is spilled from | 138 // Move this result to a specified register. The register is spilled from |
149 // the frame, and the register is singly-referenced (by this result) | 139 // the frame, and the register is singly-referenced (by this result) |
150 // outside the frame. | 140 // outside the frame. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } | 301 } |
312 | 302 |
313 private: | 303 private: |
314 CodeGenerator* cgen_; | 304 CodeGenerator* cgen_; |
315 RegisterFile registers_; | 305 RegisterFile registers_; |
316 }; | 306 }; |
317 | 307 |
318 } } // namespace v8::internal | 308 } } // namespace v8::internal |
319 | 309 |
320 #endif // V8_REGISTER_ALLOCATOR_H_ | 310 #endif // V8_REGISTER_ALLOCATOR_H_ |
OLD | NEW |