| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 ASSERT(type() != MEMORY); | 94 ASSERT(type() != MEMORY); |
| 95 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(NOT_SYNCED); | 95 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(NOT_SYNCED); |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool is_valid() const { return type() != INVALID; } | 98 bool is_valid() const { return type() != INVALID; } |
| 99 bool is_memory() const { return type() == MEMORY; } | 99 bool is_memory() const { return type() == MEMORY; } |
| 100 bool is_register() const { return type() == REGISTER; } | 100 bool is_register() const { return type() == REGISTER; } |
| 101 bool is_constant() const { return type() == CONSTANT; } | 101 bool is_constant() const { return type() == CONSTANT; } |
| 102 bool is_copy() const { return type() == COPY; } | 102 bool is_copy() const { return type() == COPY; } |
| 103 | 103 |
| 104 bool is_copied() const { return IsCopiedField::decode(type_); } | |
| 105 | |
| 106 void set_copied() { | |
| 107 type_ = (type_ & ~IsCopiedField::mask()) | IsCopiedField::encode(true); | |
| 108 } | |
| 109 | |
| 110 void clear_copied() { | |
| 111 type_ = (type_ & ~IsCopiedField::mask()) | IsCopiedField::encode(false); | |
| 112 } | |
| 113 | |
| 114 Register reg() const { | 104 Register reg() const { |
| 115 ASSERT(is_register()); | 105 ASSERT(is_register()); |
| 116 return data_.reg_; | 106 return data_.reg_; |
| 117 } | 107 } |
| 118 | 108 |
| 119 Handle<Object> handle() const { | 109 Handle<Object> handle() const { |
| 120 ASSERT(is_constant()); | 110 ASSERT(is_constant()); |
| 121 return Handle<Object>(data_.handle_); | 111 return Handle<Object>(data_.handle_); |
| 122 } | 112 } |
| 123 | 113 |
| 124 int index() const { | 114 int index() const { |
| 125 ASSERT(is_copy()); | 115 ASSERT(is_copy()); |
| 126 return data_.index_; | 116 return data_.index_; |
| 127 } | 117 } |
| 128 | 118 |
| 129 bool Equals(FrameElement other); | 119 bool Equals(FrameElement other); |
| 130 | 120 |
| 131 private: | 121 private: |
| 132 enum Type { | 122 enum Type { |
| 133 INVALID, | 123 INVALID, |
| 134 MEMORY, | 124 MEMORY, |
| 135 REGISTER, | 125 REGISTER, |
| 136 CONSTANT, | 126 CONSTANT, |
| 137 COPY | 127 COPY |
| 138 }; | 128 }; |
| 139 | 129 |
| 140 // BitField is <type, shift, size>. | 130 // BitField is <type, shift, size>. |
| 141 class SyncField : public BitField<SyncFlag, 0, 1> {}; | 131 class SyncField : public BitField<SyncFlag, 0, 1> {}; |
| 142 class IsCopiedField : public BitField<bool, 1, 1> {}; | 132 class TypeField : public BitField<Type, 1, 32 - 1> {}; |
| 143 class TypeField : public BitField<Type, 2, 32 - 2> {}; | |
| 144 | 133 |
| 145 Type type() const { return TypeField::decode(type_); } | 134 Type type() const { return TypeField::decode(type_); } |
| 146 | 135 |
| 147 // The element's type and a dirty bit. The dirty bit can be cleared | 136 // The element's type and a dirty bit. The dirty bit can be cleared |
| 148 // for non-memory elements to indicate that the element agrees with | 137 // for non-memory elements to indicate that the element agrees with |
| 149 // the value in memory in the actual frame. | 138 // the value in memory in the actual frame. |
| 150 int type_; | 139 int type_; |
| 151 | 140 |
| 152 union { | 141 union { |
| 153 Register reg_; | 142 Register reg_; |
| 154 Object** handle_; | 143 Object** handle_; |
| 155 int index_; | 144 int index_; |
| 156 } data_; | 145 } data_; |
| 157 | 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 |
| 158 // Used to construct memory and register elements. | 151 // Used to construct memory and register elements. |
| 159 FrameElement(Type type, Register reg, SyncFlag is_synced) { | 152 FrameElement(Type type, Register reg, SyncFlag is_synced) { |
| 160 Initialize(type, reg, is_synced); | 153 Initialize(type, reg, is_synced); |
| 161 } | 154 } |
| 162 | 155 |
| 163 // Used to construct constant elements. | 156 // Used to construct constant elements. |
| 164 inline FrameElement(Handle<Object> value, SyncFlag is_synced); | 157 inline FrameElement(Handle<Object> value, SyncFlag is_synced); |
| 165 | 158 |
| 166 // Used to initialize invalid, memory, and register elements. | 159 // Used to initialize invalid, memory, and register elements. |
| 167 inline void Initialize(Type type, Register reg, SyncFlag is_synced); | 160 inline void Initialize(Type type, Register reg, SyncFlag is_synced); |
| 168 | 161 |
| 169 friend class VirtualFrame; | 162 friend class VirtualFrame; |
| 170 }; | 163 }; |
| 171 | 164 |
| 172 | 165 |
| 173 } } // namespace v8::internal | 166 } } // namespace v8::internal |
| 174 | 167 |
| 175 #ifdef ARM | 168 #ifdef ARM |
| 176 #include "virtual-frame-arm.h" | 169 #include "virtual-frame-arm.h" |
| 177 #else // ia32 | 170 #else // ia32 |
| 178 #include "virtual-frame-ia32.h" | 171 #include "virtual-frame-ia32.h" |
| 179 #endif | 172 #endif |
| 180 | 173 |
| 181 | 174 |
| 182 namespace v8 { namespace internal { | 175 namespace v8 { namespace internal { |
| 183 | 176 |
| 184 FrameElement::FrameElement(Handle<Object> value, SyncFlag is_synced) { | 177 FrameElement::FrameElement(Handle<Object> value, SyncFlag is_synced) { |
| 185 type_ = TypeField::encode(CONSTANT) | 178 type_ = TypeField::encode(CONSTANT) | SyncField::encode(is_synced); |
| 186 | IsCopiedField::encode(false) | |
| 187 | SyncField::encode(is_synced); | |
| 188 data_.handle_ = value.location(); | 179 data_.handle_ = value.location(); |
| 180 next_ = VirtualFrame::kIllegalIndex; |
| 189 } | 181 } |
| 190 | 182 |
| 191 | 183 |
| 192 void FrameElement::Initialize(Type type, Register reg, SyncFlag is_synced) { | 184 void FrameElement::Initialize(Type type, Register reg, SyncFlag is_synced) { |
| 193 type_ = TypeField::encode(type) | 185 type_ = TypeField::encode(type) | SyncField::encode(is_synced); |
| 194 | IsCopiedField::encode(false) | |
| 195 | SyncField::encode(is_synced); | |
| 196 data_.reg_ = reg; | 186 data_.reg_ = reg; |
| 187 next_ = VirtualFrame::kIllegalIndex; |
| 197 } | 188 } |
| 198 | 189 |
| 199 | 190 |
| 200 } } // namespace v8::internal | 191 } } // namespace v8::internal |
| 201 | 192 |
| 202 #endif // V8_VIRTUAL_FRAME_H_ | 193 #endif // V8_VIRTUAL_FRAME_H_ |
| OLD | NEW |