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
3 // found in the LICENSE file.
5 #ifndef V8_LOOKUP_INL_H_
6 #define V8_LOOKUP_INL_H_
8 #include "src/lookup.h"
14 JSReceiver* LookupIterator::NextHolder(Map* map) {
15 DisallowHeapAllocation no_gc;
16 if (map->prototype()->IsNull()) return NULL;
18 JSReceiver* next = JSReceiver::cast(map->prototype());
19 DCHECK(!next->map()->IsGlobalObjectMap() ||
20 next->map()->is_hidden_prototype());
22 if (!check_prototype_chain() &&
23 !(check_hidden() && next->map()->is_hidden_prototype()) &&
24 // Always lookup behind the JSGlobalProxy into the JSGlobalObject, even
25 // when not checking other hidden prototypes.
26 !map->IsJSGlobalProxyMap()) {
34 LookupIterator::State LookupIterator::LookupInHolder(Map* const map,
35 JSReceiver* const holder) {
36 STATIC_ASSERT(INTERCEPTOR == BEFORE_PROPERTY);
37 DisallowHeapAllocation no_gc;
38 if (interceptor_state_ == InterceptorState::kProcessNonMasking) {
39 return LookupNonMaskingInterceptorInHolder(map, holder);
43 if (map->IsJSProxyMap()) return JSPROXY;
44 if (map->is_access_check_needed() &&
45 !isolate_->IsInternallyUsedPropertyName(name_)) {
50 if (exotic_index_state_ != ExoticIndexState::kNoIndex &&
51 IsIntegerIndexedExotic(holder)) {
52 return INTEGER_INDEXED_EXOTIC;
54 if (check_interceptor() && map->has_named_interceptor() &&
55 !SkipInterceptor(JSObject::cast(holder))) {
60 if (map->is_dictionary_map()) {
61 NameDictionary* dict = JSObject::cast(holder)->property_dictionary();
62 number_ = dict->FindEntry(name_);
63 if (number_ == NameDictionary::kNotFound) return NOT_FOUND;
64 if (holder->IsGlobalObject()) {
65 DCHECK(dict->ValueAt(number_)->IsPropertyCell());
66 PropertyCell* cell = PropertyCell::cast(dict->ValueAt(number_));
67 if (cell->value()->IsTheHole()) return NOT_FOUND;
69 property_details_ = dict->DetailsAt(number_);
71 DescriptorArray* descriptors = map->instance_descriptors();
72 number_ = descriptors->SearchWithCache(*name_, map);
73 if (number_ == DescriptorArray::kNotFound) return NOT_FOUND;
74 property_details_ = descriptors->GetDetails(number_);
77 switch (property_details_.kind()) {
78 case v8::internal::kData:
80 case v8::internal::kAccessor:
86 case INTEGER_INDEXED_EXOTIC:
96 LookupIterator::State LookupIterator::LookupNonMaskingInterceptorInHolder(
97 Map* const map, JSReceiver* const holder) {
100 if (check_interceptor() && map->has_named_interceptor() &&
101 !SkipInterceptor(JSObject::cast(holder))) {
112 } // namespace v8::internal
114 #endif // V8_LOOKUP_INL_H_