OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 CallbacksDescriptor(String* key, | 157 CallbacksDescriptor(String* key, |
158 Object* foreign, | 158 Object* foreign, |
159 PropertyAttributes attributes, | 159 PropertyAttributes attributes, |
160 int index = 0) | 160 int index = 0) |
161 : Descriptor(key, foreign, attributes, CALLBACKS, index) {} | 161 : Descriptor(key, foreign, attributes, CALLBACKS, index) {} |
162 }; | 162 }; |
163 | 163 |
164 | 164 |
165 class LookupResult BASE_EMBEDDED { | 165 class LookupResult BASE_EMBEDDED { |
166 public: | 166 public: |
167 LookupResult() | 167 explicit LookupResult(Isolate* isolate) |
168 : lookup_type_(NOT_FOUND), | 168 : isolate_(isolate), |
| 169 next_(isolate->top_lookup_result()), |
| 170 lookup_type_(NOT_FOUND), |
| 171 holder_(NULL), |
169 cacheable_(true), | 172 cacheable_(true), |
170 details_(NONE, NORMAL) {} | 173 details_(NONE, NORMAL) { |
| 174 isolate->SetTopLookupResult(this); |
| 175 } |
| 176 |
| 177 ~LookupResult() { |
| 178 ASSERT(isolate_->top_lookup_result() == this); |
| 179 isolate_->SetTopLookupResult(next_); |
| 180 } |
171 | 181 |
172 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { | 182 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { |
173 lookup_type_ = DESCRIPTOR_TYPE; | 183 lookup_type_ = DESCRIPTOR_TYPE; |
174 holder_ = holder; | 184 holder_ = holder; |
175 details_ = details; | 185 details_ = details; |
176 number_ = number; | 186 number_ = number; |
177 } | 187 } |
178 | 188 |
179 void DescriptorResult(JSObject* holder, Smi* details, int number) { | 189 void DescriptorResult(JSObject* holder, Smi* details, int number) { |
180 lookup_type_ = DESCRIPTOR_TYPE; | 190 lookup_type_ = DESCRIPTOR_TYPE; |
(...skipping 27 matching lines...) Expand all Loading... |
208 } | 218 } |
209 | 219 |
210 void InterceptorResult(JSObject* holder) { | 220 void InterceptorResult(JSObject* holder) { |
211 lookup_type_ = INTERCEPTOR_TYPE; | 221 lookup_type_ = INTERCEPTOR_TYPE; |
212 holder_ = holder; | 222 holder_ = holder; |
213 details_ = PropertyDetails(NONE, INTERCEPTOR); | 223 details_ = PropertyDetails(NONE, INTERCEPTOR); |
214 } | 224 } |
215 | 225 |
216 void NotFound() { | 226 void NotFound() { |
217 lookup_type_ = NOT_FOUND; | 227 lookup_type_ = NOT_FOUND; |
| 228 holder_ = NULL; |
218 } | 229 } |
219 | 230 |
220 JSObject* holder() { | 231 JSObject* holder() { |
221 ASSERT(IsFound()); | 232 ASSERT(IsFound()); |
222 return JSObject::cast(holder_); | 233 return JSObject::cast(holder_); |
223 } | 234 } |
224 | 235 |
225 JSProxy* proxy() { | 236 JSProxy* proxy() { |
226 ASSERT(IsFound()); | 237 ASSERT(IsFound()); |
227 return JSProxy::cast(holder_); | 238 return JSProxy::cast(holder_); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 Object* GetValue() { | 350 Object* GetValue() { |
340 if (lookup_type_ == DESCRIPTOR_TYPE) { | 351 if (lookup_type_ == DESCRIPTOR_TYPE) { |
341 DescriptorArray* descriptors = holder()->map()->instance_descriptors(); | 352 DescriptorArray* descriptors = holder()->map()->instance_descriptors(); |
342 return descriptors->GetValue(number_); | 353 return descriptors->GetValue(number_); |
343 } | 354 } |
344 // In the dictionary case, the data is held in the value field. | 355 // In the dictionary case, the data is held in the value field. |
345 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 356 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
346 return holder()->GetNormalizedProperty(this); | 357 return holder()->GetNormalizedProperty(this); |
347 } | 358 } |
348 | 359 |
| 360 void Iterate(ObjectVisitor* visitor); |
| 361 |
349 private: | 362 private: |
| 363 Isolate* isolate_; |
| 364 LookupResult* next_; |
| 365 |
350 // Where did we find the result; | 366 // Where did we find the result; |
351 enum { | 367 enum { |
352 NOT_FOUND, | 368 NOT_FOUND, |
353 DESCRIPTOR_TYPE, | 369 DESCRIPTOR_TYPE, |
354 DICTIONARY_TYPE, | 370 DICTIONARY_TYPE, |
355 HANDLER_TYPE, | 371 HANDLER_TYPE, |
356 INTERCEPTOR_TYPE, | 372 INTERCEPTOR_TYPE, |
357 CONSTANT_TYPE | 373 CONSTANT_TYPE |
358 } lookup_type_; | 374 } lookup_type_; |
359 | 375 |
360 JSReceiver* holder_; | 376 JSReceiver* holder_; |
361 int number_; | 377 int number_; |
362 bool cacheable_; | 378 bool cacheable_; |
363 PropertyDetails details_; | 379 PropertyDetails details_; |
364 }; | 380 }; |
365 | 381 |
366 | 382 |
367 } } // namespace v8::internal | 383 } } // namespace v8::internal |
368 | 384 |
369 #endif // V8_PROPERTY_H_ | 385 #endif // V8_PROPERTY_H_ |
OLD | NEW |