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 "number-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 NumberInfo number_info() { |
58 // Copied elements do not have number info. Instead | 58 // Copied elements do not have number 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 if (!is_constant()) { | 61 return NumberInfo::FromInt(NumberInfoField::decode(value_)); |
62 return NumberInfo::FromInt(NumberInfoField::decode(value_)); | |
63 } | |
64 Handle<Object> value = handle(); | |
65 if (value->IsSmi()) return NumberInfo::Smi(); | |
66 if (value->IsHeapNumber()) return NumberInfo::HeapNumber(); | |
67 return NumberInfo::Unknown(); | |
68 } | 62 } |
69 | 63 |
70 inline void set_number_info(NumberInfo info) { | 64 inline void set_number_info(NumberInfo info) { |
71 // Copied elements do not have number info. Instead | 65 // Copied elements do not have number info. Instead |
72 // we have to inspect their backing element in the frame. | 66 // we have to inspect their backing element in the frame. |
73 ASSERT(!is_copy()); | 67 ASSERT(!is_copy()); |
74 value_ = value_ & ~NumberInfoField::mask(); | 68 value_ = value_ & ~NumberInfoField::mask(); |
75 value_ = value_ | NumberInfoField::encode(info.ToInt()); | 69 value_ = value_ | NumberInfoField::encode(info.ToInt()); |
76 } | 70 } |
77 | 71 |
(...skipping 22 matching lines...) Expand all Loading... |
100 static FrameElement RegisterElement(Register reg, | 94 static FrameElement RegisterElement(Register reg, |
101 SyncFlag is_synced, | 95 SyncFlag is_synced, |
102 NumberInfo info) { | 96 NumberInfo info) { |
103 return FrameElement(REGISTER, reg, is_synced, info); | 97 return FrameElement(REGISTER, reg, is_synced, info); |
104 } | 98 } |
105 | 99 |
106 // 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 |
107 // compile time. | 101 // compile time. |
108 static FrameElement ConstantElement(Handle<Object> value, | 102 static FrameElement ConstantElement(Handle<Object> value, |
109 SyncFlag is_synced) { | 103 SyncFlag is_synced) { |
110 FrameElement result(value, is_synced); | 104 NumberInfo info = NumberInfo::TypeFromValue(value); |
| 105 FrameElement result(value, is_synced, info); |
111 return result; | 106 return result; |
112 } | 107 } |
113 | 108 |
114 // Static indirection table for handles to constants. If a frame | 109 // Static indirection table for handles to constants. If a frame |
115 // element represents a constant, the data contains an index into | 110 // element represents a constant, the data contains an index into |
116 // this table of handles to the actual constants. | 111 // this table of handles to the actual constants. |
117 typedef ZoneList<Handle<Object> > ZoneObjectList; | 112 typedef ZoneList<Handle<Object> > ZoneObjectList; |
118 | 113 |
119 static ZoneObjectList* ConstantList(); | 114 static ZoneObjectList* ConstantList(); |
120 | 115 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 SyncFlag is_synced, | 220 SyncFlag is_synced, |
226 NumberInfo info) { | 221 NumberInfo info) { |
227 value_ = TypeField::encode(type) | 222 value_ = TypeField::encode(type) |
228 | CopiedField::encode(false) | 223 | CopiedField::encode(false) |
229 | SyncedField::encode(is_synced != NOT_SYNCED) | 224 | SyncedField::encode(is_synced != NOT_SYNCED) |
230 | NumberInfoField::encode(info.ToInt()) | 225 | NumberInfoField::encode(info.ToInt()) |
231 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); | 226 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); |
232 } | 227 } |
233 | 228 |
234 // Used to construct constant elements. | 229 // Used to construct constant elements. |
235 FrameElement(Handle<Object> value, SyncFlag is_synced) { | 230 FrameElement(Handle<Object> value, SyncFlag is_synced, NumberInfo info) { |
236 value_ = TypeField::encode(CONSTANT) | 231 value_ = TypeField::encode(CONSTANT) |
237 | CopiedField::encode(false) | 232 | CopiedField::encode(false) |
238 | SyncedField::encode(is_synced != NOT_SYNCED) | 233 | SyncedField::encode(is_synced != NOT_SYNCED) |
239 | NumberInfoField::encode(NumberInfo::Uninitialized().ToInt()) | 234 | NumberInfoField::encode(info.ToInt()) |
240 | DataField::encode(ConstantList()->length()); | 235 | DataField::encode(ConstantList()->length()); |
241 ConstantList()->Add(value); | 236 ConstantList()->Add(value); |
242 } | 237 } |
243 | 238 |
244 Type type() const { return TypeField::decode(value_); } | 239 Type type() const { return TypeField::decode(value_); } |
245 void set_type(Type type) { | 240 void set_type(Type type) { |
246 value_ = value_ & ~TypeField::mask(); | 241 value_ = value_ & ~TypeField::mask(); |
247 value_ = value_ | TypeField::encode(type); | 242 value_ = value_ | TypeField::encode(type); |
248 } | 243 } |
249 | 244 |
(...skipping 19 matching lines...) Expand all Loading... |
269 class UntaggedInt32Field: public BitField<bool, 5, 1> {}; | 264 class UntaggedInt32Field: public BitField<bool, 5, 1> {}; |
270 class NumberInfoField: public BitField<int, 6, 6> {}; | 265 class NumberInfoField: public BitField<int, 6, 6> {}; |
271 class DataField: public BitField<uint32_t, 12, 32 - 12> {}; | 266 class DataField: public BitField<uint32_t, 12, 32 - 12> {}; |
272 | 267 |
273 friend class VirtualFrame; | 268 friend class VirtualFrame; |
274 }; | 269 }; |
275 | 270 |
276 } } // namespace v8::internal | 271 } } // namespace v8::internal |
277 | 272 |
278 #endif // V8_FRAME_ELEMENT_H_ | 273 #endif // V8_FRAME_ELEMENT_H_ |
OLD | NEW |