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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 LookupIterator(Handle<Object> receiver, Handle<Name> name, | 46 LookupIterator(Handle<Object> receiver, Handle<Name> name, |
47 Configuration configuration = PROTOTYPE_CHAIN) | 47 Configuration configuration = PROTOTYPE_CHAIN) |
48 : configuration_(ComputeConfiguration(configuration, name)), | 48 : configuration_(ComputeConfiguration(configuration, name)), |
49 state_(NOT_FOUND), | 49 state_(NOT_FOUND), |
50 exotic_index_state_(ExoticIndexState::kUninitialized), | 50 exotic_index_state_(ExoticIndexState::kUninitialized), |
51 interceptor_state_(InterceptorState::kUninitialized), | 51 interceptor_state_(InterceptorState::kUninitialized), |
52 property_details_(PropertyDetails::Empty()), | 52 property_details_(PropertyDetails::Empty()), |
53 isolate_(name->GetIsolate()), | 53 isolate_(name->GetIsolate()), |
54 name_(name), | 54 name_(name), |
| 55 index_(kMaxUInt32), |
55 receiver_(receiver), | 56 receiver_(receiver), |
56 holder_(GetRoot(receiver_, isolate_)), | 57 holder_(GetRoot(receiver_, isolate_)), |
57 holder_map_(holder_->map(), isolate_), | 58 holder_map_(holder_->map(), isolate_), |
58 initial_holder_(holder_), | 59 initial_holder_(holder_), |
59 number_(DescriptorArray::kNotFound) { | 60 number_(DescriptorArray::kNotFound) { |
60 Next(); | 61 Next(); |
61 } | 62 } |
62 | 63 |
63 LookupIterator(Handle<Object> receiver, Handle<Name> name, | 64 LookupIterator(Handle<Object> receiver, Handle<Name> name, |
64 Handle<JSReceiver> holder, | 65 Handle<JSReceiver> holder, |
65 Configuration configuration = PROTOTYPE_CHAIN) | 66 Configuration configuration = PROTOTYPE_CHAIN) |
66 : configuration_(ComputeConfiguration(configuration, name)), | 67 : configuration_(ComputeConfiguration(configuration, name)), |
67 state_(NOT_FOUND), | 68 state_(NOT_FOUND), |
68 exotic_index_state_(ExoticIndexState::kUninitialized), | 69 exotic_index_state_(ExoticIndexState::kUninitialized), |
69 interceptor_state_(InterceptorState::kUninitialized), | 70 interceptor_state_(InterceptorState::kUninitialized), |
70 property_details_(PropertyDetails::Empty()), | 71 property_details_(PropertyDetails::Empty()), |
71 isolate_(name->GetIsolate()), | 72 isolate_(name->GetIsolate()), |
72 name_(name), | 73 name_(name), |
| 74 index_(kMaxUInt32), |
73 receiver_(receiver), | 75 receiver_(receiver), |
74 holder_(holder), | 76 holder_(holder), |
75 holder_map_(holder_->map(), isolate_), | 77 holder_map_(holder_->map(), isolate_), |
| 78 initial_holder_(holder_), |
| 79 number_(DescriptorArray::kNotFound) { |
| 80 Next(); |
| 81 } |
| 82 |
| 83 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, |
| 84 Configuration configuration = PROTOTYPE_CHAIN) |
| 85 : configuration_(configuration), |
| 86 state_(NOT_FOUND), |
| 87 exotic_index_state_(ExoticIndexState::kNotExotic), |
| 88 interceptor_state_(InterceptorState::kUninitialized), |
| 89 property_details_(PropertyDetails::Empty()), |
| 90 isolate_(isolate), |
| 91 name_(), |
| 92 index_(index), |
| 93 receiver_(receiver), |
| 94 holder_(GetRoot(receiver_, isolate_)), |
| 95 holder_map_(holder_->map(), isolate_), |
| 96 initial_holder_(holder_), |
| 97 number_(DescriptorArray::kNotFound) { |
| 98 Next(); |
| 99 } |
| 100 |
| 101 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, |
| 102 Handle<JSReceiver> holder, |
| 103 Configuration configuration = PROTOTYPE_CHAIN) |
| 104 : configuration_(configuration), |
| 105 state_(NOT_FOUND), |
| 106 exotic_index_state_(ExoticIndexState::kNotExotic), |
| 107 interceptor_state_(InterceptorState::kUninitialized), |
| 108 property_details_(PropertyDetails::Empty()), |
| 109 isolate_(isolate), |
| 110 name_(), |
| 111 index_(index), |
| 112 receiver_(receiver), |
| 113 holder_(holder), |
| 114 holder_map_(holder_->map(), isolate_), |
76 initial_holder_(holder_), | 115 initial_holder_(holder_), |
77 number_(DescriptorArray::kNotFound) { | 116 number_(DescriptorArray::kNotFound) { |
78 Next(); | 117 Next(); |
79 } | 118 } |
80 | 119 |
81 Isolate* isolate() const { return isolate_; } | 120 Isolate* isolate() const { return isolate_; } |
82 State state() const { return state_; } | 121 State state() const { return state_; } |
| 122 |
83 Handle<Name> name() const { return name_; } | 123 Handle<Name> name() const { return name_; } |
| 124 uint32_t index() const { return index_; } |
| 125 |
| 126 bool IsElement() const { return index_ != kMaxUInt32; } |
84 | 127 |
85 bool IsFound() const { return state_ != NOT_FOUND; } | 128 bool IsFound() const { return state_ != NOT_FOUND; } |
86 void Next(); | 129 void Next(); |
87 void NotFound() { | 130 void NotFound() { |
88 has_property_ = false; | 131 has_property_ = false; |
89 state_ = NOT_FOUND; | 132 state_ = NOT_FOUND; |
90 } | 133 } |
91 | 134 |
92 Factory* factory() const { return isolate_->factory(); } | 135 Factory* factory() const { return isolate_->factory(); } |
93 Handle<Object> GetReceiver() const { return receiver_; } | 136 Handle<Object> GetReceiver() const { return receiver_; } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 197 |
155 Handle<Map> GetReceiverMap() const; | 198 Handle<Map> GetReceiverMap() const; |
156 | 199 |
157 MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map); | 200 MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map); |
158 inline State LookupInHolder(Map* map, JSReceiver* holder); | 201 inline State LookupInHolder(Map* map, JSReceiver* holder); |
159 void RestartLookupForNonMaskingInterceptors(); | 202 void RestartLookupForNonMaskingInterceptors(); |
160 State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder); | 203 State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder); |
161 Handle<Object> FetchValue() const; | 204 Handle<Object> FetchValue() const; |
162 void ReloadPropertyInformation(); | 205 void ReloadPropertyInformation(); |
163 bool SkipInterceptor(JSObject* holder); | 206 bool SkipInterceptor(JSObject* holder); |
| 207 bool HasInterceptor(Map* map) const; |
164 | 208 |
165 bool IsBootstrapping() const; | 209 bool IsBootstrapping() const; |
166 | 210 |
167 bool check_hidden() const { return (configuration_ & kHidden) != 0; } | 211 bool check_hidden() const { return (configuration_ & kHidden) != 0; } |
168 bool check_interceptor() const { | 212 bool check_interceptor() const { |
169 return !IsBootstrapping() && (configuration_ & kInterceptor) != 0; | 213 return !IsBootstrapping() && (configuration_ & kInterceptor) != 0; |
170 } | 214 } |
171 bool check_prototype_chain() const { | 215 bool check_prototype_chain() const { |
172 return (configuration_ & kPrototypeChain) != 0; | 216 return (configuration_ & kPrototypeChain) != 0; |
173 } | 217 } |
(...skipping 11 matching lines...) Expand all Loading... |
185 static Configuration ComputeConfiguration( | 229 static Configuration ComputeConfiguration( |
186 Configuration configuration, Handle<Name> name) { | 230 Configuration configuration, Handle<Name> name) { |
187 if (name->IsOwn()) { | 231 if (name->IsOwn()) { |
188 return static_cast<Configuration>(configuration & | 232 return static_cast<Configuration>(configuration & |
189 HIDDEN_SKIP_INTERCEPTOR); | 233 HIDDEN_SKIP_INTERCEPTOR); |
190 } else { | 234 } else { |
191 return configuration; | 235 return configuration; |
192 } | 236 } |
193 } | 237 } |
194 | 238 |
195 enum class ExoticIndexState { kUninitialized, kNoIndex, kIndex }; | 239 enum class ExoticIndexState { kUninitialized, kNotExotic, kExotic }; |
196 bool IsIntegerIndexedExotic(JSReceiver* holder); | 240 bool IsIntegerIndexedExotic(JSReceiver* holder); |
197 | 241 |
198 // If configuration_ becomes mutable, update | 242 // If configuration_ becomes mutable, update |
199 // HolderIsReceiverOrHiddenPrototype. | 243 // HolderIsReceiverOrHiddenPrototype. |
200 const Configuration configuration_; | 244 const Configuration configuration_; |
201 State state_; | 245 State state_; |
202 bool has_property_; | 246 bool has_property_; |
203 ExoticIndexState exotic_index_state_; | 247 ExoticIndexState exotic_index_state_; |
204 InterceptorState interceptor_state_; | 248 InterceptorState interceptor_state_; |
205 PropertyDetails property_details_; | 249 PropertyDetails property_details_; |
206 Isolate* const isolate_; | 250 Isolate* const isolate_; |
207 Handle<Name> name_; | 251 Handle<Name> name_; |
| 252 uint32_t index_; |
208 Handle<Object> transition_; | 253 Handle<Object> transition_; |
209 const Handle<Object> receiver_; | 254 const Handle<Object> receiver_; |
210 Handle<JSReceiver> holder_; | 255 Handle<JSReceiver> holder_; |
211 Handle<Map> holder_map_; | 256 Handle<Map> holder_map_; |
212 const Handle<JSReceiver> initial_holder_; | 257 const Handle<JSReceiver> initial_holder_; |
213 int number_; | 258 uint32_t number_; |
214 }; | 259 }; |
215 | 260 |
216 | 261 |
217 } } // namespace v8::internal | 262 } } // namespace v8::internal |
218 | 263 |
219 #endif // V8_LOOKUP_H_ | 264 #endif // V8_LOOKUP_H_ |
OLD | NEW |