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