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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 bool is_dictionary_holder() const { return holder_map_->is_dictionary_map(); } | 196 bool is_dictionary_holder() const { return holder_map_->is_dictionary_map(); } |
197 Handle<Map> transition_map() const { | 197 Handle<Map> transition_map() const { |
198 DCHECK_EQ(TRANSITION, state_); | 198 DCHECK_EQ(TRANSITION, state_); |
199 return Handle<Map>::cast(transition_); | 199 return Handle<Map>::cast(transition_); |
200 } | 200 } |
201 template <class T> | 201 template <class T> |
202 Handle<T> GetHolder() const { | 202 Handle<T> GetHolder() const { |
203 DCHECK(IsFound()); | 203 DCHECK(IsFound()); |
204 return Handle<T>::cast(holder_); | 204 return Handle<T>::cast(holder_); |
205 } | 205 } |
206 static Handle<JSReceiver> GetRoot(Isolate* isolate, Handle<Object> receiver, | 206 |
207 uint32_t index = kMaxUInt32); | |
208 bool HolderIsReceiverOrHiddenPrototype() const; | 207 bool HolderIsReceiverOrHiddenPrototype() const; |
209 | 208 |
210 /* ACCESS_CHECK */ | 209 /* ACCESS_CHECK */ |
211 bool HasAccess() const; | 210 bool HasAccess() const; |
212 | 211 |
213 /* PROPERTY */ | 212 /* PROPERTY */ |
214 void PrepareForDataProperty(Handle<Object> value); | 213 void PrepareForDataProperty(Handle<Object> value); |
215 void PrepareTransitionToDataProperty(Handle<Object> value, | 214 void PrepareTransitionToDataProperty(Handle<Object> value, |
216 PropertyAttributes attributes, | 215 PropertyAttributes attributes, |
217 Object::StoreFromKeyed store_mode); | 216 Object::StoreFromKeyed store_mode); |
(...skipping 20 matching lines...) Expand all Loading... |
238 bool IsReadOnly() const { return property_details().IsReadOnly(); } | 237 bool IsReadOnly() const { return property_details().IsReadOnly(); } |
239 Representation representation() const { | 238 Representation representation() const { |
240 return property_details().representation(); | 239 return property_details().representation(); |
241 } | 240 } |
242 FieldIndex GetFieldIndex() const; | 241 FieldIndex GetFieldIndex() const; |
243 Handle<HeapType> GetFieldType() const; | 242 Handle<HeapType> GetFieldType() const; |
244 int GetAccessorIndex() const; | 243 int GetAccessorIndex() const; |
245 int GetConstantIndex() const; | 244 int GetConstantIndex() const; |
246 Handle<PropertyCell> GetPropertyCell() const; | 245 Handle<PropertyCell> GetPropertyCell() const; |
247 Handle<Object> GetAccessors() const; | 246 Handle<Object> GetAccessors() const; |
248 Handle<InterceptorInfo> GetInterceptor() const; | 247 inline Handle<InterceptorInfo> GetInterceptor() const { |
| 248 DCHECK_EQ(INTERCEPTOR, state_); |
| 249 return handle(GetInterceptor(JSObject::cast(*holder_)), isolate_); |
| 250 } |
249 Handle<Object> GetDataValue() const; | 251 Handle<Object> GetDataValue() const; |
250 void WriteDataValue(Handle<Object> value); | 252 void WriteDataValue(Handle<Object> value); |
251 void InternalizeName(); | 253 void InternalizeName(); |
252 void ReloadHolderMap(); | 254 void ReloadHolderMap(); |
253 | 255 |
254 private: | 256 private: |
255 enum class InterceptorState { | 257 enum class InterceptorState { |
256 kUninitialized, | 258 kUninitialized, |
257 kSkipNonMasking, | 259 kSkipNonMasking, |
258 kProcessNonMasking | 260 kProcessNonMasking |
259 }; | 261 }; |
260 | 262 |
261 Handle<Map> GetReceiverMap() const; | 263 Handle<Map> GetReceiverMap() const; |
262 | 264 |
263 MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map); | 265 MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map); |
264 inline State LookupInHolder(Map* map, JSReceiver* holder); | 266 inline State LookupInHolder(Map* map, JSReceiver* holder); |
265 void RestartLookupForNonMaskingInterceptors() { | 267 void RestartLookupForNonMaskingInterceptors() { |
266 RestartInternal(InterceptorState::kProcessNonMasking); | 268 RestartInternal(InterceptorState::kProcessNonMasking); |
267 } | 269 } |
268 void RestartInternal(InterceptorState interceptor_state); | 270 void RestartInternal(InterceptorState interceptor_state); |
269 State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder); | 271 State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder); |
270 Handle<Object> FetchValue() const; | 272 Handle<Object> FetchValue() const; |
271 void ReloadPropertyInformation(); | 273 void ReloadPropertyInformation(); |
272 bool SkipInterceptor(JSObject* holder); | 274 inline bool SkipInterceptor(JSObject* holder); |
273 bool HasInterceptor(Map* map) const; | 275 bool HasInterceptor(Map* map) const; |
274 bool InternalHolderIsReceiverOrHiddenPrototype() const; | 276 bool InternalHolderIsReceiverOrHiddenPrototype() const; |
275 InterceptorInfo* GetInterceptor(JSObject* holder) const; | 277 inline InterceptorInfo* GetInterceptor(JSObject* holder) const { |
| 278 if (IsElement()) return holder->GetIndexedInterceptor(); |
| 279 return holder->GetNamedInterceptor(); |
| 280 } |
276 | 281 |
277 bool check_hidden() const { return (configuration_ & kHidden) != 0; } | 282 bool check_hidden() const { return (configuration_ & kHidden) != 0; } |
278 bool check_interceptor() const { | 283 bool check_interceptor() const { |
279 return (configuration_ & kInterceptor) != 0; | 284 return (configuration_ & kInterceptor) != 0; |
280 } | 285 } |
281 bool check_prototype_chain() const { | 286 bool check_prototype_chain() const { |
282 return (configuration_ & kPrototypeChain) != 0; | 287 return (configuration_ & kPrototypeChain) != 0; |
283 } | 288 } |
284 int descriptor_number() const { | 289 int descriptor_number() const { |
285 DCHECK(has_property_); | 290 DCHECK(has_property_); |
286 DCHECK(!holder_map_->is_dictionary_map()); | 291 DCHECK(!holder_map_->is_dictionary_map()); |
287 return number_; | 292 return number_; |
288 } | 293 } |
289 int dictionary_entry() const { | 294 int dictionary_entry() const { |
290 DCHECK(has_property_); | 295 DCHECK(has_property_); |
291 DCHECK(holder_map_->is_dictionary_map()); | 296 DCHECK(holder_map_->is_dictionary_map()); |
292 return number_; | 297 return number_; |
293 } | 298 } |
294 | 299 |
295 static Configuration ComputeConfiguration( | 300 static Configuration ComputeConfiguration( |
296 Configuration configuration, Handle<Name> name) { | 301 Configuration configuration, Handle<Name> name) { |
297 if (name->IsPrivate()) { | 302 if (name->IsPrivate()) { |
298 return static_cast<Configuration>(configuration & | 303 return static_cast<Configuration>(configuration & |
299 HIDDEN_SKIP_INTERCEPTOR); | 304 HIDDEN_SKIP_INTERCEPTOR); |
300 } else { | 305 } else { |
301 return configuration; | 306 return configuration; |
302 } | 307 } |
303 } | 308 } |
304 | 309 |
| 310 static Handle<JSReceiver> GetRootForNonJSReceiver( |
| 311 Isolate* isolate, Handle<Object> receiver, uint32_t index = kMaxUInt32); |
| 312 inline static Handle<JSReceiver> GetRoot(Isolate* isolate, |
| 313 Handle<Object> receiver, |
| 314 uint32_t index = kMaxUInt32) { |
| 315 if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver); |
| 316 return GetRootForNonJSReceiver(isolate, receiver, index); |
| 317 } |
| 318 |
305 enum class ExoticIndexState { kUninitialized, kNotExotic, kExotic }; | 319 enum class ExoticIndexState { kUninitialized, kNotExotic, kExotic }; |
306 bool IsIntegerIndexedExotic(JSReceiver* holder); | 320 inline bool IsIntegerIndexedExotic(JSReceiver* holder); |
307 | 321 |
308 // If configuration_ becomes mutable, update | 322 // If configuration_ becomes mutable, update |
309 // HolderIsReceiverOrHiddenPrototype. | 323 // HolderIsReceiverOrHiddenPrototype. |
310 const Configuration configuration_; | 324 const Configuration configuration_; |
311 State state_; | 325 State state_; |
312 bool has_property_; | 326 bool has_property_; |
313 ExoticIndexState exotic_index_state_; | 327 ExoticIndexState exotic_index_state_; |
314 InterceptorState interceptor_state_; | 328 InterceptorState interceptor_state_; |
315 PropertyDetails property_details_; | 329 PropertyDetails property_details_; |
316 Isolate* const isolate_; | 330 Isolate* const isolate_; |
317 Handle<Name> name_; | 331 Handle<Name> name_; |
318 uint32_t index_; | 332 uint32_t index_; |
319 Handle<Object> transition_; | 333 Handle<Object> transition_; |
320 const Handle<Object> receiver_; | 334 const Handle<Object> receiver_; |
321 Handle<JSReceiver> holder_; | 335 Handle<JSReceiver> holder_; |
322 Handle<Map> holder_map_; | 336 Handle<Map> holder_map_; |
323 const Handle<JSReceiver> initial_holder_; | 337 const Handle<JSReceiver> initial_holder_; |
324 uint32_t number_; | 338 uint32_t number_; |
325 }; | 339 }; |
326 | 340 |
327 | 341 |
328 } // namespace internal | 342 } // namespace internal |
329 } // namespace v8 | 343 } // namespace v8 |
330 | 344 |
331 #endif // V8_LOOKUP_H_ | 345 #endif // V8_LOOKUP_H_ |
OLD | NEW |