| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 class FrameElement BASE_EMBEDDED { | 48 class FrameElement BASE_EMBEDDED { |
| 49 public: | 49 public: |
| 50 enum SyncFlag { | 50 enum SyncFlag { |
| 51 SYNCED, | 51 SYNCED, |
| 52 NOT_SYNCED | 52 NOT_SYNCED |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // The default constructor creates an invalid frame element. | 55 // The default constructor creates an invalid frame element. |
| 56 FrameElement() { | 56 FrameElement() { |
| 57 type_ = TypeField::encode(INVALID) | SyncField::encode(NOT_SYNCED); | 57 Initialize(INVALID, no_reg, NOT_SYNCED); |
| 58 data_.reg_ = no_reg; | |
| 59 } | 58 } |
| 60 | 59 |
| 61 // Factory function to construct an invalid frame element. | 60 // Factory function to construct an invalid frame element. |
| 62 static FrameElement InvalidElement() { | 61 static FrameElement InvalidElement() { |
| 63 FrameElement result; | 62 FrameElement result; |
| 64 return result; | 63 return result; |
| 65 } | 64 } |
| 66 | 65 |
| 67 // Factory function to construct an in-memory frame element. | 66 // Factory function to construct an in-memory frame element. |
| 68 static FrameElement MemoryElement() { | 67 static FrameElement MemoryElement() { |
| 69 FrameElement result; | 68 FrameElement result(MEMORY, no_reg, SYNCED); |
| 70 result.type_ = TypeField::encode(MEMORY) | SyncField::encode(SYNCED); | |
| 71 // In-memory elements have no useful data. | |
| 72 result.data_.reg_ = no_reg; | |
| 73 return result; | 69 return result; |
| 74 } | 70 } |
| 75 | 71 |
| 76 // Factory function to construct an in-register frame element. | 72 // Factory function to construct an in-register frame element. |
| 77 static FrameElement RegisterElement(Register reg, SyncFlag is_synced) { | 73 static FrameElement RegisterElement(Register reg, SyncFlag is_synced) { |
| 78 FrameElement result; | 74 FrameElement result(REGISTER, reg, is_synced); |
| 79 result.type_ = TypeField::encode(REGISTER) | SyncField::encode(is_synced); | |
| 80 result.data_.reg_ = reg; | |
| 81 return result; | 75 return result; |
| 82 } | 76 } |
| 83 | 77 |
| 84 // Factory function to construct a frame element whose value is known at | 78 // Factory function to construct a frame element whose value is known at |
| 85 // compile time. | 79 // compile time. |
| 86 static FrameElement ConstantElement(Handle<Object> value, | 80 static FrameElement ConstantElement(Handle<Object> value, |
| 87 SyncFlag is_synced) { | 81 SyncFlag is_synced) { |
| 88 FrameElement result; | 82 FrameElement result(value, is_synced); |
| 89 result.type_ = TypeField::encode(CONSTANT) | SyncField::encode(is_synced); | |
| 90 result.data_.handle_ = value.location(); | |
| 91 return result; | 83 return result; |
| 92 } | 84 } |
| 93 | 85 |
| 94 bool is_synced() const { return SyncField::decode(type_) == SYNCED; } | 86 bool is_synced() const { return SyncField::decode(type_) == SYNCED; } |
| 95 | 87 |
| 96 void set_sync() { | 88 void set_sync() { |
| 97 ASSERT(type() != MEMORY); | 89 ASSERT(type() != MEMORY); |
| 98 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(SYNCED); | 90 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(SYNCED); |
| 99 } | 91 } |
| 100 | 92 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // for non-memory elements to indicate that the element agrees with | 137 // for non-memory elements to indicate that the element agrees with |
| 146 // the value in memory in the actual frame. | 138 // the value in memory in the actual frame. |
| 147 int type_; | 139 int type_; |
| 148 | 140 |
| 149 union { | 141 union { |
| 150 Register reg_; | 142 Register reg_; |
| 151 Object** handle_; | 143 Object** handle_; |
| 152 int index_; | 144 int index_; |
| 153 } data_; | 145 } data_; |
| 154 | 146 |
| 147 // The index of the next element in a list of copies, or the frame's |
| 148 // illegal index if there is no next element. |
| 149 int next_; |
| 150 |
| 151 // Used to construct memory and register elements. |
| 152 FrameElement(Type type, Register reg, SyncFlag is_synced) { |
| 153 Initialize(type, reg, is_synced); |
| 154 } |
| 155 |
| 156 // Used to construct constant elements. |
| 157 inline FrameElement(Handle<Object> value, SyncFlag is_synced); |
| 158 |
| 159 // Used to initialize invalid, memory, and register elements. |
| 160 inline void Initialize(Type type, Register reg, SyncFlag is_synced); |
| 161 |
| 155 friend class VirtualFrame; | 162 friend class VirtualFrame; |
| 156 }; | 163 }; |
| 157 | 164 |
| 158 | 165 |
| 159 } } // namespace v8::internal | 166 } } // namespace v8::internal |
| 160 | 167 |
| 161 #ifdef ARM | 168 #ifdef ARM |
| 162 #include "virtual-frame-arm.h" | 169 #include "virtual-frame-arm.h" |
| 163 #else // ia32 | 170 #else // ia32 |
| 164 #include "virtual-frame-ia32.h" | 171 #include "virtual-frame-ia32.h" |
| 165 #endif | 172 #endif |
| 166 | 173 |
| 174 |
| 175 namespace v8 { namespace internal { |
| 176 |
| 177 FrameElement::FrameElement(Handle<Object> value, SyncFlag is_synced) { |
| 178 type_ = TypeField::encode(CONSTANT) | SyncField::encode(is_synced); |
| 179 data_.handle_ = value.location(); |
| 180 next_ = VirtualFrame::kIllegalIndex; |
| 181 } |
| 182 |
| 183 |
| 184 void FrameElement::Initialize(Type type, Register reg, SyncFlag is_synced) { |
| 185 type_ = TypeField::encode(type) | SyncField::encode(is_synced); |
| 186 data_.reg_ = reg; |
| 187 next_ = VirtualFrame::kIllegalIndex; |
| 188 } |
| 189 |
| 190 |
| 191 } } // namespace v8::internal |
| 192 |
| 167 #endif // V8_VIRTUAL_FRAME_H_ | 193 #endif // V8_VIRTUAL_FRAME_H_ |
| OLD | NEW |