deps: update v8 to 4.3.61.21
[platform/upstream/nodejs.git] / deps / v8 / src / lookup-inl.h
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.
4
5 #ifndef V8_LOOKUP_INL_H_
6 #define V8_LOOKUP_INL_H_
7
8 #include "src/lookup.h"
9
10 namespace v8 {
11 namespace internal {
12
13
14 JSReceiver* LookupIterator::NextHolder(Map* map) {
15   DisallowHeapAllocation no_gc;
16   if (map->prototype()->IsNull()) return NULL;
17
18   JSReceiver* next = JSReceiver::cast(map->prototype());
19   DCHECK(!next->map()->IsGlobalObjectMap() ||
20          next->map()->is_hidden_prototype());
21
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()) {
27     return NULL;
28   }
29
30   return next;
31 }
32
33
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);
40   }
41   switch (state_) {
42     case NOT_FOUND:
43       if (map->IsJSProxyMap()) return JSPROXY;
44       if (map->is_access_check_needed() &&
45           !isolate_->IsInternallyUsedPropertyName(name_)) {
46         return ACCESS_CHECK;
47       }
48     // Fall through.
49     case ACCESS_CHECK:
50       if (exotic_index_state_ != ExoticIndexState::kNoIndex &&
51           IsIntegerIndexedExotic(holder)) {
52         return INTEGER_INDEXED_EXOTIC;
53       }
54       if (check_interceptor() && map->has_named_interceptor() &&
55           !SkipInterceptor(JSObject::cast(holder))) {
56         return INTERCEPTOR;
57       }
58     // Fall through.
59     case INTERCEPTOR:
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;
68         }
69         property_details_ = dict->DetailsAt(number_);
70       } else {
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_);
75       }
76       has_property_ = true;
77       switch (property_details_.kind()) {
78         case v8::internal::kData:
79           return DATA;
80         case v8::internal::kAccessor:
81           return ACCESSOR;
82       }
83     case ACCESSOR:
84     case DATA:
85       return NOT_FOUND;
86     case INTEGER_INDEXED_EXOTIC:
87     case JSPROXY:
88     case TRANSITION:
89       UNREACHABLE();
90   }
91   UNREACHABLE();
92   return state_;
93 }
94
95
96 LookupIterator::State LookupIterator::LookupNonMaskingInterceptorInHolder(
97     Map* const map, JSReceiver* const holder) {
98   switch (state_) {
99     case NOT_FOUND:
100       if (check_interceptor() && map->has_named_interceptor() &&
101           !SkipInterceptor(JSObject::cast(holder))) {
102         return INTERCEPTOR;
103       }
104     // Fall through.
105     default:
106       return NOT_FOUND;
107   }
108   UNREACHABLE();
109   return state_;
110 }
111 }
112 }  // namespace v8::internal
113
114 #endif  // V8_LOOKUP_INL_H_