OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_LOOKUP_H_ | 5 #ifndef V8_LOOKUP_H_ |
6 #define V8_LOOKUP_H_ | 6 #define V8_LOOKUP_H_ |
7 | 7 |
8 #include "src/factory.h" | 8 #include "src/factory.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 TRANSITION, | 41 TRANSITION, |
42 // Set state_ to BEFORE_PROPERTY to ensure that the next lookup will be a | 42 // Set state_ to BEFORE_PROPERTY to ensure that the next lookup will be a |
43 // PROPERTY lookup. | 43 // PROPERTY lookup. |
44 BEFORE_PROPERTY = INTERCEPTOR | 44 BEFORE_PROPERTY = INTERCEPTOR |
45 }; | 45 }; |
46 | 46 |
47 LookupIterator(Handle<Object> receiver, Handle<Name> name, | 47 LookupIterator(Handle<Object> receiver, Handle<Name> name, |
48 Configuration configuration = DEFAULT) | 48 Configuration configuration = DEFAULT) |
49 : configuration_(ComputeConfiguration(configuration, name)), | 49 : configuration_(ComputeConfiguration(configuration, name)), |
50 state_(NOT_FOUND), | 50 state_(NOT_FOUND), |
51 exotic_index_state_(ExoticIndexState::kUninitialized), | |
52 interceptor_state_(InterceptorState::kUninitialized), | 51 interceptor_state_(InterceptorState::kUninitialized), |
53 property_details_(PropertyDetails::Empty()), | 52 property_details_(PropertyDetails::Empty()), |
54 isolate_(name->GetIsolate()), | 53 isolate_(name->GetIsolate()), |
55 name_(Name::Flatten(name)), | 54 name_(Name::Flatten(name)), |
56 // kMaxUInt32 isn't a valid index. | 55 // kMaxUInt32 isn't a valid index. |
57 index_(kMaxUInt32), | 56 index_(kMaxUInt32), |
58 receiver_(receiver), | 57 receiver_(receiver), |
59 holder_(GetRoot(isolate_, receiver)), | 58 holder_(GetRoot(isolate_, receiver)), |
60 holder_map_(holder_->map(), isolate_), | 59 holder_map_(holder_->map(), isolate_), |
61 initial_holder_(holder_), | 60 initial_holder_(holder_), |
62 number_(DescriptorArray::kNotFound) { | 61 number_(DescriptorArray::kNotFound) { |
63 #ifdef DEBUG | 62 #ifdef DEBUG |
64 uint32_t index; // Assert that the name is not an array index. | 63 uint32_t index; // Assert that the name is not an array index. |
65 DCHECK(!name->AsArrayIndex(&index)); | 64 DCHECK(!name->AsArrayIndex(&index)); |
66 #endif // DEBUG | 65 #endif // DEBUG |
67 Next(); | 66 Next(); |
68 } | 67 } |
69 | 68 |
70 LookupIterator(Handle<Object> receiver, Handle<Name> name, | 69 LookupIterator(Handle<Object> receiver, Handle<Name> name, |
71 Handle<JSReceiver> holder, | 70 Handle<JSReceiver> holder, |
72 Configuration configuration = DEFAULT) | 71 Configuration configuration = DEFAULT) |
73 : configuration_(ComputeConfiguration(configuration, name)), | 72 : configuration_(ComputeConfiguration(configuration, name)), |
74 state_(NOT_FOUND), | 73 state_(NOT_FOUND), |
75 exotic_index_state_(ExoticIndexState::kUninitialized), | |
76 interceptor_state_(InterceptorState::kUninitialized), | 74 interceptor_state_(InterceptorState::kUninitialized), |
77 property_details_(PropertyDetails::Empty()), | 75 property_details_(PropertyDetails::Empty()), |
78 isolate_(name->GetIsolate()), | 76 isolate_(name->GetIsolate()), |
79 name_(Name::Flatten(name)), | 77 name_(Name::Flatten(name)), |
80 // kMaxUInt32 isn't a valid index. | 78 // kMaxUInt32 isn't a valid index. |
81 index_(kMaxUInt32), | 79 index_(kMaxUInt32), |
82 receiver_(receiver), | 80 receiver_(receiver), |
83 holder_(holder), | 81 holder_(holder), |
84 holder_map_(holder_->map(), isolate_), | 82 holder_map_(holder_->map(), isolate_), |
85 initial_holder_(holder_), | 83 initial_holder_(holder_), |
86 number_(DescriptorArray::kNotFound) { | 84 number_(DescriptorArray::kNotFound) { |
87 #ifdef DEBUG | 85 #ifdef DEBUG |
88 uint32_t index; // Assert that the name is not an array index. | 86 uint32_t index; // Assert that the name is not an array index. |
89 DCHECK(!name->AsArrayIndex(&index)); | 87 DCHECK(!name->AsArrayIndex(&index)); |
90 #endif // DEBUG | 88 #endif // DEBUG |
91 Next(); | 89 Next(); |
92 } | 90 } |
93 | 91 |
94 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, | 92 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, |
95 Configuration configuration = DEFAULT) | 93 Configuration configuration = DEFAULT) |
96 : configuration_(configuration), | 94 : configuration_(configuration), |
97 state_(NOT_FOUND), | 95 state_(NOT_FOUND), |
98 exotic_index_state_(ExoticIndexState::kUninitialized), | |
99 interceptor_state_(InterceptorState::kUninitialized), | 96 interceptor_state_(InterceptorState::kUninitialized), |
100 property_details_(PropertyDetails::Empty()), | 97 property_details_(PropertyDetails::Empty()), |
101 isolate_(isolate), | 98 isolate_(isolate), |
102 name_(), | 99 name_(), |
103 index_(index), | 100 index_(index), |
104 receiver_(receiver), | 101 receiver_(receiver), |
105 holder_(GetRoot(isolate, receiver, index)), | 102 holder_(GetRoot(isolate, receiver, index)), |
106 holder_map_(holder_->map(), isolate_), | 103 holder_map_(holder_->map(), isolate_), |
107 initial_holder_(holder_), | 104 initial_holder_(holder_), |
108 number_(DescriptorArray::kNotFound) { | 105 number_(DescriptorArray::kNotFound) { |
109 // kMaxUInt32 isn't a valid index. | 106 // kMaxUInt32 isn't a valid index. |
110 DCHECK_NE(kMaxUInt32, index_); | 107 DCHECK_NE(kMaxUInt32, index_); |
111 Next(); | 108 Next(); |
112 } | 109 } |
113 | 110 |
114 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, | 111 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, |
115 Handle<JSReceiver> holder, | 112 Handle<JSReceiver> holder, |
116 Configuration configuration = DEFAULT) | 113 Configuration configuration = DEFAULT) |
117 : configuration_(configuration), | 114 : configuration_(configuration), |
118 state_(NOT_FOUND), | 115 state_(NOT_FOUND), |
119 exotic_index_state_(ExoticIndexState::kUninitialized), | |
120 interceptor_state_(InterceptorState::kUninitialized), | 116 interceptor_state_(InterceptorState::kUninitialized), |
121 property_details_(PropertyDetails::Empty()), | 117 property_details_(PropertyDetails::Empty()), |
122 isolate_(isolate), | 118 isolate_(isolate), |
123 name_(), | 119 name_(), |
124 index_(index), | 120 index_(index), |
125 receiver_(receiver), | 121 receiver_(receiver), |
126 holder_(holder), | 122 holder_(holder), |
127 holder_map_(holder_->map(), isolate_), | 123 holder_map_(holder_->map(), isolate_), |
128 initial_holder_(holder_), | 124 initial_holder_(holder_), |
129 number_(DescriptorArray::kNotFound) { | 125 number_(DescriptorArray::kNotFound) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 inline State LookupInHolder(Map* map, JSReceiver* holder); | 269 inline State LookupInHolder(Map* map, JSReceiver* holder); |
274 void RestartLookupForNonMaskingInterceptors() { | 270 void RestartLookupForNonMaskingInterceptors() { |
275 RestartInternal(InterceptorState::kProcessNonMasking); | 271 RestartInternal(InterceptorState::kProcessNonMasking); |
276 } | 272 } |
277 void RestartInternal(InterceptorState interceptor_state); | 273 void RestartInternal(InterceptorState interceptor_state); |
278 State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder); | 274 State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder); |
279 Handle<Object> FetchValue() const; | 275 Handle<Object> FetchValue() const; |
280 void ReloadPropertyInformation(); | 276 void ReloadPropertyInformation(); |
281 inline bool SkipInterceptor(JSObject* holder); | 277 inline bool SkipInterceptor(JSObject* holder); |
282 bool HasInterceptor(Map* map) const; | 278 bool HasInterceptor(Map* map) const; |
283 bool InternalHolderIsReceiverOrHiddenPrototype() const; | 279 // Checks whether |object| is receiver_ or one of its hidden prototypes. |
| 280 // |object| has to be initial_holder_ or on its prototype chain. |
| 281 bool IsReceiverOrHiddenPrototype(JSReceiver* object) const; |
284 inline InterceptorInfo* GetInterceptor(JSObject* holder) const { | 282 inline InterceptorInfo* GetInterceptor(JSObject* holder) const { |
285 if (IsElement()) return holder->GetIndexedInterceptor(); | 283 if (IsElement()) return holder->GetIndexedInterceptor(); |
286 return holder->GetNamedInterceptor(); | 284 return holder->GetNamedInterceptor(); |
287 } | 285 } |
288 | 286 |
289 bool check_hidden() const { return (configuration_ & kHidden) != 0; } | 287 bool check_hidden() const { return (configuration_ & kHidden) != 0; } |
290 bool check_interceptor() const { | 288 bool check_interceptor() const { |
291 return (configuration_ & kInterceptor) != 0; | 289 return (configuration_ & kInterceptor) != 0; |
292 } | 290 } |
293 int descriptor_number() const { | 291 int descriptor_number() const { |
(...skipping 19 matching lines...) Expand all Loading... |
313 | 311 |
314 static Handle<JSReceiver> GetRootForNonJSReceiver( | 312 static Handle<JSReceiver> GetRootForNonJSReceiver( |
315 Isolate* isolate, Handle<Object> receiver, uint32_t index = kMaxUInt32); | 313 Isolate* isolate, Handle<Object> receiver, uint32_t index = kMaxUInt32); |
316 inline static Handle<JSReceiver> GetRoot(Isolate* isolate, | 314 inline static Handle<JSReceiver> GetRoot(Isolate* isolate, |
317 Handle<Object> receiver, | 315 Handle<Object> receiver, |
318 uint32_t index = kMaxUInt32) { | 316 uint32_t index = kMaxUInt32) { |
319 if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver); | 317 if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver); |
320 return GetRootForNonJSReceiver(isolate, receiver, index); | 318 return GetRootForNonJSReceiver(isolate, receiver, index); |
321 } | 319 } |
322 | 320 |
323 enum class ExoticIndexState { kUninitialized, kNotExotic, kExotic }; | |
324 inline bool IsIntegerIndexedExotic(JSReceiver* holder); | 321 inline bool IsIntegerIndexedExotic(JSReceiver* holder); |
325 | 322 |
326 // If configuration_ becomes mutable, update | 323 // If configuration_ becomes mutable, update |
327 // HolderIsReceiverOrHiddenPrototype. | 324 // HolderIsReceiverOrHiddenPrototype. |
328 const Configuration configuration_; | 325 const Configuration configuration_; |
329 State state_; | 326 State state_; |
330 bool has_property_; | 327 bool has_property_; |
331 ExoticIndexState exotic_index_state_; | |
332 InterceptorState interceptor_state_; | 328 InterceptorState interceptor_state_; |
333 PropertyDetails property_details_; | 329 PropertyDetails property_details_; |
334 Isolate* const isolate_; | 330 Isolate* const isolate_; |
335 Handle<Name> name_; | 331 Handle<Name> name_; |
336 uint32_t index_; | 332 uint32_t index_; |
337 Handle<Object> transition_; | 333 Handle<Object> transition_; |
338 const Handle<Object> receiver_; | 334 const Handle<Object> receiver_; |
339 Handle<JSReceiver> holder_; | 335 Handle<JSReceiver> holder_; |
340 Handle<Map> holder_map_; | 336 Handle<Map> holder_map_; |
341 const Handle<JSReceiver> initial_holder_; | 337 const Handle<JSReceiver> initial_holder_; |
342 uint32_t number_; | 338 uint32_t number_; |
343 }; | 339 }; |
344 | 340 |
345 | 341 |
346 } // namespace internal | 342 } // namespace internal |
347 } // namespace v8 | 343 } // namespace v8 |
348 | 344 |
349 #endif // V8_LOOKUP_H_ | 345 #endif // V8_LOOKUP_H_ |
OLD | NEW |