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-inl.h" | 31 #include "type-info-inl.h" |
32 #include "macro-assembler.h" | 32 #include "macro-assembler.h" |
33 #include "zone.h" | 33 #include "zone.h" |
34 | 34 |
35 namespace v8 { | 35 namespace v8 { |
36 namespace internal { | 36 namespace internal { |
37 | 37 |
38 // ------------------------------------------------------------------------- | 38 // ------------------------------------------------------------------------- |
39 // Virtual frame elements | 39 // Virtual frame elements |
40 // | 40 // |
41 // The internal elements of the virtual frames. There are several kinds of | 41 // The internal elements of the virtual frames. There are several kinds of |
42 // elements: | 42 // elements: |
43 // * Invalid: elements that are uninitialized or not actually part | 43 // * Invalid: elements that are uninitialized or not actually part |
44 // of the virtual frame. They should not be read. | 44 // of the virtual frame. They should not be read. |
45 // * Memory: an element that resides in the actual frame. Its address is | 45 // * Memory: an element that resides in the actual frame. Its address is |
46 // given by its position in the virtual frame. | 46 // given by its position in the virtual frame. |
47 // * Register: an element that resides in a register. | 47 // * Register: an element that resides in a register. |
48 // * Constant: an element whose value is known at compile time. | 48 // * Constant: an element whose value is known at compile time. |
49 | 49 |
50 class FrameElement BASE_EMBEDDED { | 50 class FrameElement BASE_EMBEDDED { |
51 public: | 51 public: |
52 enum SyncFlag { | 52 enum SyncFlag { |
53 NOT_SYNCED, | 53 NOT_SYNCED, |
54 SYNCED | 54 SYNCED |
55 }; | 55 }; |
56 | 56 |
57 inline NumberInfo number_info() { | 57 inline TypeInfo type_info() { |
58 // Copied elements do not have number info. Instead | 58 // Copied elements do not have type info. Instead |
59 // we have to inspect their backing element in the frame. | 59 // we have to inspect their backing element in the frame. |
60 ASSERT(!is_copy()); | 60 ASSERT(!is_copy()); |
61 return NumberInfo::FromInt(NumberInfoField::decode(value_)); | 61 return TypeInfo::FromInt(TypeInfoField::decode(value_)); |
62 } | 62 } |
63 | 63 |
64 inline void set_number_info(NumberInfo info) { | 64 inline void set_type_info(TypeInfo info) { |
65 // Copied elements do not have number info. Instead | 65 // Copied elements do not have type info. Instead |
66 // we have to inspect their backing element in the frame. | 66 // we have to inspect their backing element in the frame. |
67 ASSERT(!is_copy()); | 67 ASSERT(!is_copy()); |
68 value_ = value_ & ~NumberInfoField::mask(); | 68 value_ = value_ & ~TypeInfoField::mask(); |
69 value_ = value_ | NumberInfoField::encode(info.ToInt()); | 69 value_ = value_ | TypeInfoField::encode(info.ToInt()); |
70 } | 70 } |
71 | 71 |
72 // The default constructor creates an invalid frame element. | 72 // The default constructor creates an invalid frame element. |
73 FrameElement() { | 73 FrameElement() { |
74 value_ = TypeField::encode(INVALID) | 74 value_ = TypeField::encode(INVALID) |
75 | CopiedField::encode(false) | 75 | CopiedField::encode(false) |
76 | SyncedField::encode(false) | 76 | SyncedField::encode(false) |
77 | NumberInfoField::encode(NumberInfo::Uninitialized().ToInt()) | 77 | TypeInfoField::encode(TypeInfo::Uninitialized().ToInt()) |
78 | DataField::encode(0); | 78 | DataField::encode(0); |
79 } | 79 } |
80 | 80 |
81 // Factory function to construct an invalid frame element. | 81 // Factory function to construct an invalid frame element. |
82 static FrameElement InvalidElement() { | 82 static FrameElement InvalidElement() { |
83 FrameElement result; | 83 FrameElement result; |
84 return result; | 84 return result; |
85 } | 85 } |
86 | 86 |
87 // Factory function to construct an in-memory frame element. | 87 // Factory function to construct an in-memory frame element. |
88 static FrameElement MemoryElement(NumberInfo info) { | 88 static FrameElement MemoryElement(TypeInfo info) { |
89 FrameElement result(MEMORY, no_reg, SYNCED, info); | 89 FrameElement result(MEMORY, no_reg, SYNCED, info); |
90 return result; | 90 return result; |
91 } | 91 } |
92 | 92 |
93 // Factory function to construct an in-register frame element. | 93 // Factory function to construct an in-register frame element. |
94 static FrameElement RegisterElement(Register reg, | 94 static FrameElement RegisterElement(Register reg, |
95 SyncFlag is_synced, | 95 SyncFlag is_synced, |
96 NumberInfo info) { | 96 TypeInfo info) { |
97 return FrameElement(REGISTER, reg, is_synced, info); | 97 return FrameElement(REGISTER, reg, is_synced, info); |
98 } | 98 } |
99 | 99 |
100 // Factory function to construct a frame element whose value is known at | 100 // Factory function to construct a frame element whose value is known at |
101 // compile time. | 101 // compile time. |
102 static FrameElement ConstantElement(Handle<Object> value, | 102 static FrameElement ConstantElement(Handle<Object> value, |
103 SyncFlag is_synced) { | 103 SyncFlag is_synced) { |
104 NumberInfo info = NumberInfo::TypeFromValue(value); | 104 TypeInfo info = TypeInfo::TypeFromValue(value); |
105 FrameElement result(value, is_synced, info); | 105 FrameElement result(value, is_synced, info); |
106 return result; | 106 return result; |
107 } | 107 } |
108 | 108 |
109 // Static indirection table for handles to constants. If a frame | 109 // Static indirection table for handles to constants. If a frame |
110 // element represents a constant, the data contains an index into | 110 // element represents a constant, the data contains an index into |
111 // this table of handles to the actual constants. | 111 // this table of handles to the actual constants. |
112 typedef ZoneList<Handle<Object> > ZoneObjectList; | 112 typedef ZoneList<Handle<Object> > ZoneObjectList; |
113 | 113 |
114 static ZoneObjectList* ConstantList(); | 114 static ZoneObjectList* ConstantList(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 MEMORY, | 211 MEMORY, |
212 REGISTER, | 212 REGISTER, |
213 CONSTANT, | 213 CONSTANT, |
214 COPY | 214 COPY |
215 }; | 215 }; |
216 | 216 |
217 // Used to construct memory and register elements. | 217 // Used to construct memory and register elements. |
218 FrameElement(Type type, | 218 FrameElement(Type type, |
219 Register reg, | 219 Register reg, |
220 SyncFlag is_synced, | 220 SyncFlag is_synced, |
221 NumberInfo info) { | 221 TypeInfo info) { |
222 value_ = TypeField::encode(type) | 222 value_ = TypeField::encode(type) |
223 | CopiedField::encode(false) | 223 | CopiedField::encode(false) |
224 | SyncedField::encode(is_synced != NOT_SYNCED) | 224 | SyncedField::encode(is_synced != NOT_SYNCED) |
225 | NumberInfoField::encode(info.ToInt()) | 225 | TypeInfoField::encode(info.ToInt()) |
226 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); | 226 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); |
227 } | 227 } |
228 | 228 |
229 // Used to construct constant elements. | 229 // Used to construct constant elements. |
230 FrameElement(Handle<Object> value, SyncFlag is_synced, NumberInfo info) { | 230 FrameElement(Handle<Object> value, SyncFlag is_synced, TypeInfo info) { |
231 value_ = TypeField::encode(CONSTANT) | 231 value_ = TypeField::encode(CONSTANT) |
232 | CopiedField::encode(false) | 232 | CopiedField::encode(false) |
233 | SyncedField::encode(is_synced != NOT_SYNCED) | 233 | SyncedField::encode(is_synced != NOT_SYNCED) |
234 | NumberInfoField::encode(info.ToInt()) | 234 | TypeInfoField::encode(info.ToInt()) |
235 | DataField::encode(ConstantList()->length()); | 235 | DataField::encode(ConstantList()->length()); |
236 ConstantList()->Add(value); | 236 ConstantList()->Add(value); |
237 } | 237 } |
238 | 238 |
239 Type type() const { return TypeField::decode(value_); } | 239 Type type() const { return TypeField::decode(value_); } |
240 void set_type(Type type) { | 240 void set_type(Type type) { |
241 value_ = value_ & ~TypeField::mask(); | 241 value_ = value_ & ~TypeField::mask(); |
242 value_ = value_ | TypeField::encode(type); | 242 value_ = value_ | TypeField::encode(type); |
243 } | 243 } |
244 | 244 |
(...skipping 10 matching lines...) Expand all Loading... |
255 } | 255 } |
256 | 256 |
257 // Encode type, copied, synced and data in one 32 bit integer. | 257 // Encode type, copied, synced and data in one 32 bit integer. |
258 uint32_t value_; | 258 uint32_t value_; |
259 | 259 |
260 // Declare BitFields with template parameters <type, start, size>. | 260 // Declare BitFields with template parameters <type, start, size>. |
261 class TypeField: public BitField<Type, 0, 3> {}; | 261 class TypeField: public BitField<Type, 0, 3> {}; |
262 class CopiedField: public BitField<bool, 3, 1> {}; | 262 class CopiedField: public BitField<bool, 3, 1> {}; |
263 class SyncedField: public BitField<bool, 4, 1> {}; | 263 class SyncedField: public BitField<bool, 4, 1> {}; |
264 class UntaggedInt32Field: public BitField<bool, 5, 1> {}; | 264 class UntaggedInt32Field: public BitField<bool, 5, 1> {}; |
265 class NumberInfoField: public BitField<int, 6, 6> {}; | 265 class TypeInfoField: public BitField<int, 6, 6> {}; |
266 class DataField: public BitField<uint32_t, 12, 32 - 12> {}; | 266 class DataField: public BitField<uint32_t, 12, 32 - 12> {}; |
267 | 267 |
268 friend class VirtualFrame; | 268 friend class VirtualFrame; |
269 }; | 269 }; |
270 | 270 |
271 } } // namespace v8::internal | 271 } } // namespace v8::internal |
272 | 272 |
273 #endif // V8_FRAME_ELEMENT_H_ | 273 #endif // V8_FRAME_ELEMENT_H_ |
OLD | NEW |