OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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_FRAME_ELEMENT_H_ | 28 #ifndef V8_FRAME_ELEMENT_H_ |
29 #define V8_FRAME_ELEMENT_H_ | 29 #define V8_FRAME_ELEMENT_H_ |
30 | 30 |
| 31 #include "number-info.h" |
31 #include "macro-assembler.h" | 32 #include "macro-assembler.h" |
32 | 33 |
33 namespace v8 { | 34 namespace v8 { |
34 namespace internal { | 35 namespace internal { |
35 | 36 |
36 // ------------------------------------------------------------------------- | 37 // ------------------------------------------------------------------------- |
37 // Virtual frame elements | 38 // Virtual frame elements |
38 // | 39 // |
39 // The internal elements of the virtual frames. There are several kinds of | 40 // The internal elements of the virtual frames. There are several kinds of |
40 // elements: | 41 // elements: |
41 // * Invalid: elements that are uninitialized or not actually part | 42 // * Invalid: elements that are uninitialized or not actually part |
42 // of the virtual frame. They should not be read. | 43 // of the virtual frame. They should not be read. |
43 // * Memory: an element that resides in the actual frame. Its address is | 44 // * Memory: an element that resides in the actual frame. Its address is |
44 // given by its position in the virtual frame. | 45 // given by its position in the virtual frame. |
45 // * Register: an element that resides in a register. | 46 // * Register: an element that resides in a register. |
46 // * Constant: an element whose value is known at compile time. | 47 // * Constant: an element whose value is known at compile time. |
47 | 48 |
48 class FrameElement BASE_EMBEDDED { | 49 class FrameElement BASE_EMBEDDED { |
49 public: | 50 public: |
50 enum SyncFlag { | 51 enum SyncFlag { |
51 NOT_SYNCED, | 52 NOT_SYNCED, |
52 SYNCED | 53 SYNCED |
53 }; | 54 }; |
54 | 55 |
| 56 NumberInfo::Type number_info(); |
| 57 void set_number_info(NumberInfo::Type info) { |
| 58 value_ = value_ & ~NumberInfoField::mask(); |
| 59 value_ = value_ | NumberInfoField::encode(info); |
| 60 } |
| 61 |
55 // The default constructor creates an invalid frame element. | 62 // The default constructor creates an invalid frame element. |
56 FrameElement() { | 63 FrameElement() { |
57 value_ = TypeField::encode(INVALID) | 64 value_ = TypeField::encode(INVALID) |
58 | CopiedField::encode(false) | 65 | CopiedField::encode(false) |
59 | SyncedField::encode(false) | 66 | SyncedField::encode(false) |
| 67 | NumberInfoField::encode(NumberInfo::kUninitialized) |
60 | DataField::encode(0); | 68 | DataField::encode(0); |
61 } | 69 } |
62 | 70 |
63 // Factory function to construct an invalid frame element. | 71 // Factory function to construct an invalid frame element. |
64 static FrameElement InvalidElement() { | 72 static FrameElement InvalidElement() { |
65 FrameElement result; | 73 FrameElement result; |
66 return result; | 74 return result; |
67 } | 75 } |
68 | 76 |
69 // Factory function to construct an in-memory frame element. | 77 // Factory function to construct an in-memory frame element. |
70 static FrameElement MemoryElement() { | 78 static FrameElement MemoryElement(NumberInfo::Type info) { |
71 FrameElement result(MEMORY, no_reg, SYNCED); | 79 FrameElement result(MEMORY, no_reg, SYNCED, info); |
72 return result; | 80 return result; |
73 } | 81 } |
74 | 82 |
75 // Factory function to construct an in-register frame element. | 83 // Factory function to construct an in-register frame element. |
76 static FrameElement RegisterElement(Register reg, | 84 static FrameElement RegisterElement(Register reg, |
77 SyncFlag is_synced) { | 85 SyncFlag is_synced, |
78 return FrameElement(REGISTER, reg, is_synced); | 86 NumberInfo::Type info) { |
| 87 return FrameElement(REGISTER, reg, is_synced, info); |
79 } | 88 } |
80 | 89 |
81 // Factory function to construct a frame element whose value is known at | 90 // Factory function to construct a frame element whose value is known at |
82 // compile time. | 91 // compile time. |
83 static FrameElement ConstantElement(Handle<Object> value, | 92 static FrameElement ConstantElement(Handle<Object> value, |
84 SyncFlag is_synced) { | 93 SyncFlag is_synced) { |
85 FrameElement result(value, is_synced); | 94 FrameElement result(value, is_synced); |
86 return result; | 95 return result; |
87 } | 96 } |
88 | 97 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 private: | 187 private: |
179 enum Type { | 188 enum Type { |
180 INVALID, | 189 INVALID, |
181 MEMORY, | 190 MEMORY, |
182 REGISTER, | 191 REGISTER, |
183 CONSTANT, | 192 CONSTANT, |
184 COPY | 193 COPY |
185 }; | 194 }; |
186 | 195 |
187 // Used to construct memory and register elements. | 196 // Used to construct memory and register elements. |
188 FrameElement(Type type, Register reg, SyncFlag is_synced) { | 197 FrameElement(Type type, |
| 198 Register reg, |
| 199 SyncFlag is_synced, |
| 200 NumberInfo::Type info) { |
189 value_ = TypeField::encode(type) | 201 value_ = TypeField::encode(type) |
190 | CopiedField::encode(false) | 202 | CopiedField::encode(false) |
191 | SyncedField::encode(is_synced != NOT_SYNCED) | 203 | SyncedField::encode(is_synced != NOT_SYNCED) |
| 204 | NumberInfoField::encode(info) |
192 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); | 205 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); |
193 } | 206 } |
194 | 207 |
195 // Used to construct constant elements. | 208 // Used to construct constant elements. |
196 FrameElement(Handle<Object> value, SyncFlag is_synced) { | 209 FrameElement(Handle<Object> value, SyncFlag is_synced) { |
197 value_ = TypeField::encode(CONSTANT) | 210 value_ = TypeField::encode(CONSTANT) |
198 | CopiedField::encode(false) | 211 | CopiedField::encode(false) |
199 | SyncedField::encode(is_synced != NOT_SYNCED) | 212 | SyncedField::encode(is_synced != NOT_SYNCED) |
| 213 | NumberInfoField::encode(NumberInfo::kUninitialized) |
200 | DataField::encode(ConstantList()->length()); | 214 | DataField::encode(ConstantList()->length()); |
201 ConstantList()->Add(value); | 215 ConstantList()->Add(value); |
202 } | 216 } |
203 | 217 |
204 Type type() const { return TypeField::decode(value_); } | 218 Type type() const { return TypeField::decode(value_); } |
205 void set_type(Type type) { | 219 void set_type(Type type) { |
206 value_ = value_ & ~TypeField::mask(); | 220 value_ = value_ & ~TypeField::mask(); |
207 value_ = value_ | TypeField::encode(type); | 221 value_ = value_ | TypeField::encode(type); |
208 } | 222 } |
209 | 223 |
210 void set_index(int new_index) { | 224 void set_index(int new_index) { |
211 ASSERT(is_copy()); | 225 ASSERT(is_copy()); |
212 value_ = value_ & ~DataField::mask(); | 226 value_ = value_ & ~DataField::mask(); |
213 value_ = value_ | DataField::encode(new_index); | 227 value_ = value_ | DataField::encode(new_index); |
214 } | 228 } |
215 | 229 |
216 void set_reg(Register new_reg) { | 230 void set_reg(Register new_reg) { |
217 ASSERT(is_register()); | 231 ASSERT(is_register()); |
218 value_ = value_ & ~DataField::mask(); | 232 value_ = value_ & ~DataField::mask(); |
219 value_ = value_ | DataField::encode(new_reg.code_); | 233 value_ = value_ | DataField::encode(new_reg.code_); |
220 } | 234 } |
221 | 235 |
222 // Encode type, copied, synced and data in one 32 bit integer. | 236 // Encode type, copied, synced and data in one 32 bit integer. |
223 uint32_t value_; | 237 uint32_t value_; |
224 | 238 |
225 class TypeField: public BitField<Type, 0, 3> {}; | 239 class TypeField: public BitField<Type, 0, 3> {}; |
226 class CopiedField: public BitField<uint32_t, 3, 1> {}; | 240 class CopiedField: public BitField<bool, 3, 1> {}; |
227 class SyncedField: public BitField<uint32_t, 4, 1> {}; | 241 class SyncedField: public BitField<bool, 4, 1> {}; |
228 class DataField: public BitField<uint32_t, 5, 32 - 6> {}; | 242 class NumberInfoField: public BitField<NumberInfo::Type, 5, 3> {}; |
| 243 class DataField: public BitField<uint32_t, 8, 32 - 9> {}; |
229 | 244 |
230 friend class VirtualFrame; | 245 friend class VirtualFrame; |
231 }; | 246 }; |
232 | 247 |
233 } } // namespace v8::internal | 248 } } // namespace v8::internal |
234 | 249 |
235 #endif // V8_FRAME_ELEMENT_H_ | 250 #endif // V8_FRAME_ELEMENT_H_ |
OLD | NEW |