| 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 12 matching lines...) Expand all Loading... |
| 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.h" |
| 32 #include "macro-assembler.h" | 32 #include "macro-assembler.h" |
| 33 #include "zone.h" |
| 33 | 34 |
| 34 namespace v8 { | 35 namespace v8 { |
| 35 namespace internal { | 36 namespace internal { |
| 36 | 37 |
| 37 // ------------------------------------------------------------------------- | 38 // ------------------------------------------------------------------------- |
| 38 // Virtual frame elements | 39 // Virtual frame elements |
| 39 // | 40 // |
| 40 // 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 |
| 41 // elements: | 42 // elements: |
| 42 // * Invalid: elements that are uninitialized or not actually part | 43 // * Invalid: elements that are uninitialized or not actually part |
| 43 // of the virtual frame. They should not be read. | 44 // of the virtual frame. They should not be read. |
| 44 // * 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 |
| 45 // given by its position in the virtual frame. | 46 // given by its position in the virtual frame. |
| 46 // * Register: an element that resides in a register. | 47 // * Register: an element that resides in a register. |
| 47 // * Constant: an element whose value is known at compile time. | 48 // * Constant: an element whose value is known at compile time. |
| 48 | 49 |
| 49 class FrameElement BASE_EMBEDDED { | 50 class FrameElement BASE_EMBEDDED { |
| 50 public: | 51 public: |
| 51 enum SyncFlag { | 52 enum SyncFlag { |
| 52 NOT_SYNCED, | 53 NOT_SYNCED, |
| 53 SYNCED | 54 SYNCED |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 inline NumberInfo::Type number_info() { | 57 inline NumberInfo number_info() { |
| 57 // Copied elements do not have number info. Instead | 58 // Copied elements do not have number info. Instead |
| 58 // we have to inspect their backing element in the frame. | 59 // we have to inspect their backing element in the frame. |
| 59 ASSERT(!is_copy()); | 60 ASSERT(!is_copy()); |
| 60 if (!is_constant()) return NumberInfoField::decode(value_); | 61 if (!is_constant()) { |
| 62 return NumberInfo::FromInt(NumberInfoField::decode(value_)); |
| 63 } |
| 61 Handle<Object> value = handle(); | 64 Handle<Object> value = handle(); |
| 62 if (value->IsSmi()) return NumberInfo::kSmi; | 65 if (value->IsSmi()) return NumberInfo::Smi(); |
| 63 if (value->IsHeapNumber()) return NumberInfo::kHeapNumber; | 66 if (value->IsHeapNumber()) return NumberInfo::HeapNumber(); |
| 64 return NumberInfo::kUnknown; | 67 return NumberInfo::Unknown(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 inline void set_number_info(NumberInfo::Type info) { | 70 inline void set_number_info(NumberInfo info) { |
| 68 // Copied elements do not have number info. Instead | 71 // Copied elements do not have number info. Instead |
| 69 // we have to inspect their backing element in the frame. | 72 // we have to inspect their backing element in the frame. |
| 70 ASSERT(!is_copy()); | 73 ASSERT(!is_copy()); |
| 71 value_ = value_ & ~NumberInfoField::mask(); | 74 value_ = value_ & ~NumberInfoField::mask(); |
| 72 value_ = value_ | NumberInfoField::encode(info); | 75 value_ = value_ | NumberInfoField::encode(info.ToInt()); |
| 73 } | 76 } |
| 74 | 77 |
| 75 // The default constructor creates an invalid frame element. | 78 // The default constructor creates an invalid frame element. |
| 76 FrameElement() { | 79 FrameElement() { |
| 77 value_ = TypeField::encode(INVALID) | 80 value_ = TypeField::encode(INVALID) |
| 78 | CopiedField::encode(false) | 81 | CopiedField::encode(false) |
| 79 | SyncedField::encode(false) | 82 | SyncedField::encode(false) |
| 80 | NumberInfoField::encode(NumberInfo::kUninitialized) | 83 | NumberInfoField::encode(NumberInfo::Uninitialized().ToInt()) |
| 81 | DataField::encode(0); | 84 | DataField::encode(0); |
| 82 } | 85 } |
| 83 | 86 |
| 84 // Factory function to construct an invalid frame element. | 87 // Factory function to construct an invalid frame element. |
| 85 static FrameElement InvalidElement() { | 88 static FrameElement InvalidElement() { |
| 86 FrameElement result; | 89 FrameElement result; |
| 87 return result; | 90 return result; |
| 88 } | 91 } |
| 89 | 92 |
| 90 // Factory function to construct an in-memory frame element. | 93 // Factory function to construct an in-memory frame element. |
| 91 static FrameElement MemoryElement(NumberInfo::Type info) { | 94 static FrameElement MemoryElement(NumberInfo info) { |
| 92 FrameElement result(MEMORY, no_reg, SYNCED, info); | 95 FrameElement result(MEMORY, no_reg, SYNCED, info); |
| 93 return result; | 96 return result; |
| 94 } | 97 } |
| 95 | 98 |
| 96 // Factory function to construct an in-register frame element. | 99 // Factory function to construct an in-register frame element. |
| 97 static FrameElement RegisterElement(Register reg, | 100 static FrameElement RegisterElement(Register reg, |
| 98 SyncFlag is_synced, | 101 SyncFlag is_synced, |
| 99 NumberInfo::Type info) { | 102 NumberInfo info) { |
| 100 return FrameElement(REGISTER, reg, is_synced, info); | 103 return FrameElement(REGISTER, reg, is_synced, info); |
| 101 } | 104 } |
| 102 | 105 |
| 103 // Factory function to construct a frame element whose value is known at | 106 // Factory function to construct a frame element whose value is known at |
| 104 // compile time. | 107 // compile time. |
| 105 static FrameElement ConstantElement(Handle<Object> value, | 108 static FrameElement ConstantElement(Handle<Object> value, |
| 106 SyncFlag is_synced) { | 109 SyncFlag is_synced) { |
| 107 FrameElement result(value, is_synced); | 110 FrameElement result(value, is_synced); |
| 108 return result; | 111 return result; |
| 109 } | 112 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 MEMORY, | 206 MEMORY, |
| 204 REGISTER, | 207 REGISTER, |
| 205 CONSTANT, | 208 CONSTANT, |
| 206 COPY | 209 COPY |
| 207 }; | 210 }; |
| 208 | 211 |
| 209 // Used to construct memory and register elements. | 212 // Used to construct memory and register elements. |
| 210 FrameElement(Type type, | 213 FrameElement(Type type, |
| 211 Register reg, | 214 Register reg, |
| 212 SyncFlag is_synced, | 215 SyncFlag is_synced, |
| 213 NumberInfo::Type info) { | 216 NumberInfo info) { |
| 214 value_ = TypeField::encode(type) | 217 value_ = TypeField::encode(type) |
| 215 | CopiedField::encode(false) | 218 | CopiedField::encode(false) |
| 216 | SyncedField::encode(is_synced != NOT_SYNCED) | 219 | SyncedField::encode(is_synced != NOT_SYNCED) |
| 217 | NumberInfoField::encode(info) | 220 | NumberInfoField::encode(info.ToInt()) |
| 218 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); | 221 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); |
| 219 } | 222 } |
| 220 | 223 |
| 221 // Used to construct constant elements. | 224 // Used to construct constant elements. |
| 222 FrameElement(Handle<Object> value, SyncFlag is_synced) { | 225 FrameElement(Handle<Object> value, SyncFlag is_synced) { |
| 223 value_ = TypeField::encode(CONSTANT) | 226 value_ = TypeField::encode(CONSTANT) |
| 224 | CopiedField::encode(false) | 227 | CopiedField::encode(false) |
| 225 | SyncedField::encode(is_synced != NOT_SYNCED) | 228 | SyncedField::encode(is_synced != NOT_SYNCED) |
| 226 | NumberInfoField::encode(NumberInfo::kUninitialized) | 229 | NumberInfoField::encode(NumberInfo::Uninitialized().ToInt()) |
| 227 | DataField::encode(ConstantList()->length()); | 230 | DataField::encode(ConstantList()->length()); |
| 228 ConstantList()->Add(value); | 231 ConstantList()->Add(value); |
| 229 } | 232 } |
| 230 | 233 |
| 231 Type type() const { return TypeField::decode(value_); } | 234 Type type() const { return TypeField::decode(value_); } |
| 232 void set_type(Type type) { | 235 void set_type(Type type) { |
| 233 value_ = value_ & ~TypeField::mask(); | 236 value_ = value_ & ~TypeField::mask(); |
| 234 value_ = value_ | TypeField::encode(type); | 237 value_ = value_ | TypeField::encode(type); |
| 235 } | 238 } |
| 236 | 239 |
| 237 void set_index(int new_index) { | 240 void set_index(int new_index) { |
| 238 ASSERT(is_copy()); | 241 ASSERT(is_copy()); |
| 239 value_ = value_ & ~DataField::mask(); | 242 value_ = value_ & ~DataField::mask(); |
| 240 value_ = value_ | DataField::encode(new_index); | 243 value_ = value_ | DataField::encode(new_index); |
| 241 } | 244 } |
| 242 | 245 |
| 243 void set_reg(Register new_reg) { | 246 void set_reg(Register new_reg) { |
| 244 ASSERT(is_register()); | 247 ASSERT(is_register()); |
| 245 value_ = value_ & ~DataField::mask(); | 248 value_ = value_ & ~DataField::mask(); |
| 246 value_ = value_ | DataField::encode(new_reg.code_); | 249 value_ = value_ | DataField::encode(new_reg.code_); |
| 247 } | 250 } |
| 248 | 251 |
| 249 // Encode type, copied, synced and data in one 32 bit integer. | 252 // Encode type, copied, synced and data in one 32 bit integer. |
| 250 uint32_t value_; | 253 uint32_t value_; |
| 251 | 254 |
| 252 class TypeField: public BitField<Type, 0, 3> {}; | 255 class TypeField: public BitField<Type, 0, 3> {}; |
| 253 class CopiedField: public BitField<bool, 3, 1> {}; | 256 class CopiedField: public BitField<bool, 3, 1> {}; |
| 254 class SyncedField: public BitField<bool, 4, 1> {}; | 257 class SyncedField: public BitField<bool, 4, 1> {}; |
| 255 class NumberInfoField: public BitField<NumberInfo::Type, 5, 3> {}; | 258 class NumberInfoField: public BitField<int, 5, 4> {}; |
| 256 class DataField: public BitField<uint32_t, 8, 32 - 8> {}; | 259 class DataField: public BitField<uint32_t, 9, 32 - 9> {}; |
| 257 | 260 |
| 258 friend class VirtualFrame; | 261 friend class VirtualFrame; |
| 259 }; | 262 }; |
| 260 | 263 |
| 261 } } // namespace v8::internal | 264 } } // namespace v8::internal |
| 262 | 265 |
| 263 #endif // V8_FRAME_ELEMENT_H_ | 266 #endif // V8_FRAME_ELEMENT_H_ |
| OLD | NEW |