Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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_H_ |
| 6 | #define V8_LOOKUP_H_ |
| 7 | |
| 8 | #include "src/factory.h" |
| 9 | #include "src/isolate.h" |
| 10 | #include "src/objects.h" |
| 11 | |
| 12 | namespace v8 { |
| 13 | namespace internal { |
| 14 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 15 | class LookupIterator final BASE_EMBEDDED { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 16 | public: |
| 17 | enum Configuration { |
| 18 | // Configuration bits. |
| 19 | kHidden = 1 << 0, |
| 20 | kInterceptor = 1 << 1, |
| 21 | kPrototypeChain = 1 << 2, |
| 22 | |
| 23 | // Convience combinations of bits. |
| 24 | OWN_SKIP_INTERCEPTOR = 0, |
| 25 | OWN = kInterceptor, |
| 26 | HIDDEN_SKIP_INTERCEPTOR = kHidden, |
| 27 | HIDDEN = kHidden | kInterceptor, |
| 28 | PROTOTYPE_CHAIN_SKIP_INTERCEPTOR = kHidden | kPrototypeChain, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 29 | PROTOTYPE_CHAIN = kHidden | kPrototypeChain | kInterceptor, |
| 30 | DEFAULT = PROTOTYPE_CHAIN |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | enum State { |
| 34 | ACCESS_CHECK, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 35 | INTEGER_INDEXED_EXOTIC, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 36 | INTERCEPTOR, |
| 37 | JSPROXY, |
| 38 | NOT_FOUND, |
| 39 | ACCESSOR, |
| 40 | DATA, |
| 41 | TRANSITION, |
| 42 | // Set state_ to BEFORE_PROPERTY to ensure that the next lookup will be a |
| 43 | // PROPERTY lookup. |
| 44 | BEFORE_PROPERTY = INTERCEPTOR |
| 45 | }; |
| 46 | |
| 47 | LookupIterator(Handle<Object> receiver, Handle<Name> name, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 48 | Configuration configuration = DEFAULT) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 49 | : configuration_(ComputeConfiguration(configuration, name)), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 50 | interceptor_state_(InterceptorState::kUninitialized), |
| 51 | property_details_(PropertyDetails::Empty()), |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 52 | isolate_(name->GetIsolate()), |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 53 | name_(isolate_->factory()->InternalizeName(name)), |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 54 | receiver_(receiver), |
| 55 | initial_holder_(GetRoot(isolate_, receiver)), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 56 | // kMaxUInt32 isn't a valid index. |
| 57 | index_(kMaxUInt32), |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 58 | number_(DescriptorArray::kNotFound) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 59 | #ifdef DEBUG |
| 60 | uint32_t index; // Assert that the name is not an array index. |
| 61 | DCHECK(!name->AsArrayIndex(&index)); |
| 62 | #endif // DEBUG |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 63 | Start<false>(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | LookupIterator(Handle<Object> receiver, Handle<Name> name, |
| 67 | Handle<JSReceiver> holder, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 68 | Configuration configuration = DEFAULT) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 69 | : configuration_(ComputeConfiguration(configuration, name)), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 70 | interceptor_state_(InterceptorState::kUninitialized), |
| 71 | property_details_(PropertyDetails::Empty()), |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 72 | isolate_(name->GetIsolate()), |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 73 | name_(isolate_->factory()->InternalizeName(name)), |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 74 | receiver_(receiver), |
| 75 | initial_holder_(holder), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 76 | // kMaxUInt32 isn't a valid index. |
| 77 | index_(kMaxUInt32), |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 78 | number_(DescriptorArray::kNotFound) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 79 | #ifdef DEBUG |
| 80 | uint32_t index; // Assert that the name is not an array index. |
| 81 | DCHECK(!name->AsArrayIndex(&index)); |
| 82 | #endif // DEBUG |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 83 | Start<false>(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 86 | LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, |
| 87 | Configuration configuration = DEFAULT) |
| 88 | : configuration_(configuration), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 89 | interceptor_state_(InterceptorState::kUninitialized), |
| 90 | property_details_(PropertyDetails::Empty()), |
| 91 | isolate_(isolate), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 92 | receiver_(receiver), |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 93 | initial_holder_(GetRoot(isolate, receiver, index)), |
| 94 | index_(index), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 95 | number_(DescriptorArray::kNotFound) { |
| 96 | // kMaxUInt32 isn't a valid index. |
| 97 | DCHECK_NE(kMaxUInt32, index_); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 98 | Start<true>(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, |
| 102 | Handle<JSReceiver> holder, |
| 103 | Configuration configuration = DEFAULT) |
| 104 | : configuration_(configuration), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 105 | interceptor_state_(InterceptorState::kUninitialized), |
| 106 | property_details_(PropertyDetails::Empty()), |
| 107 | isolate_(isolate), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 108 | receiver_(receiver), |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 109 | initial_holder_(holder), |
| 110 | index_(index), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 111 | number_(DescriptorArray::kNotFound) { |
| 112 | // kMaxUInt32 isn't a valid index. |
| 113 | DCHECK_NE(kMaxUInt32, index_); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 114 | Start<true>(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | static LookupIterator PropertyOrElement( |
| 118 | Isolate* isolate, Handle<Object> receiver, Handle<Name> name, |
| 119 | Configuration configuration = DEFAULT) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 120 | uint32_t index; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 121 | if (name->AsArrayIndex(&index)) { |
| 122 | LookupIterator it = |
| 123 | LookupIterator(isolate, receiver, index, configuration); |
| 124 | it.name_ = name; |
| 125 | return it; |
| 126 | } |
| 127 | return LookupIterator(receiver, name, configuration); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | static LookupIterator PropertyOrElement( |
| 131 | Isolate* isolate, Handle<Object> receiver, Handle<Name> name, |
| 132 | Handle<JSReceiver> holder, Configuration configuration = DEFAULT) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 133 | uint32_t index; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 134 | if (name->AsArrayIndex(&index)) { |
| 135 | LookupIterator it = |
| 136 | LookupIterator(isolate, receiver, index, holder, configuration); |
| 137 | it.name_ = name; |
| 138 | return it; |
| 139 | } |
| 140 | return LookupIterator(receiver, name, holder, configuration); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | static LookupIterator PropertyOrElement( |
| 144 | Isolate* isolate, Handle<Object> receiver, Handle<Object> key, |
| 145 | bool* success, Configuration configuration = DEFAULT); |
| 146 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 147 | void Restart() { |
| 148 | InterceptorState state = InterceptorState::kUninitialized; |
| 149 | IsElement() ? RestartInternal<true>(state) : RestartInternal<false>(state); |
| 150 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 151 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 152 | Isolate* isolate() const { return isolate_; } |
| 153 | State state() const { return state_; } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 154 | |
| 155 | Handle<Name> name() const { |
| 156 | DCHECK(!IsElement()); |
| 157 | return name_; |
| 158 | } |
| 159 | Handle<Name> GetName() { |
| 160 | if (name_.is_null()) { |
| 161 | DCHECK(IsElement()); |
| 162 | name_ = factory()->Uint32ToString(index_); |
| 163 | } |
| 164 | return name_; |
| 165 | } |
| 166 | uint32_t index() const { return index_; } |
| 167 | |
| 168 | bool IsElement() const { return index_ != kMaxUInt32; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 169 | |
| 170 | bool IsFound() const { return state_ != NOT_FOUND; } |
| 171 | void Next(); |
| 172 | void NotFound() { |
| 173 | has_property_ = false; |
| 174 | state_ = NOT_FOUND; |
| 175 | } |
| 176 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 177 | Heap* heap() const { return isolate_->heap(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 178 | Factory* factory() const { return isolate_->factory(); } |
| 179 | Handle<Object> GetReceiver() const { return receiver_; } |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 180 | |
| 181 | Handle<JSObject> GetStoreTarget() const { |
| 182 | if (receiver_->IsJSGlobalProxy()) { |
| 183 | Map* map = JSGlobalProxy::cast(*receiver_)->map(); |
| 184 | if (map->has_hidden_prototype()) { |
| 185 | return handle(JSGlobalObject::cast(map->prototype()), isolate_); |
| 186 | } |
| 187 | } |
| 188 | return Handle<JSObject>::cast(receiver_); |
| 189 | } |
| 190 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 191 | bool is_dictionary_holder() const { return !holder_->HasFastProperties(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 192 | Handle<Map> transition_map() const { |
| 193 | DCHECK_EQ(TRANSITION, state_); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 194 | return Handle<Map>::cast(transition_); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 195 | } |
| 196 | template <class T> |
| 197 | Handle<T> GetHolder() const { |
| 198 | DCHECK(IsFound()); |
| 199 | return Handle<T>::cast(holder_); |
| 200 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 201 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 202 | bool HolderIsReceiverOrHiddenPrototype() const; |
| 203 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 204 | bool check_prototype_chain() const { |
| 205 | return (configuration_ & kPrototypeChain) != 0; |
| 206 | } |
| 207 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 208 | /* ACCESS_CHECK */ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 209 | bool HasAccess() const; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 210 | |
| 211 | /* PROPERTY */ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 212 | bool ExtendingNonExtensible(Handle<JSObject> receiver) { |
| 213 | DCHECK(receiver.is_identical_to(GetStoreTarget())); |
| 214 | return !receiver->map()->is_extensible() && |
| 215 | (IsElement() || !name_->IsPrivate()); |
| 216 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 217 | void PrepareForDataProperty(Handle<Object> value); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 218 | void PrepareTransitionToDataProperty(Handle<JSObject> receiver, |
| 219 | Handle<Object> value, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 220 | PropertyAttributes attributes, |
| 221 | Object::StoreFromKeyed store_mode); |
| 222 | bool IsCacheableTransition() { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 223 | DCHECK_EQ(TRANSITION, state_); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 224 | return transition_->IsPropertyCell() || |
| 225 | (!transition_map()->is_dictionary_map() && |
| 226 | transition_map()->GetBackPointer()->IsMap()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 227 | } |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 228 | void ApplyTransitionToDataProperty(Handle<JSObject> receiver); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 229 | void ReconfigureDataProperty(Handle<Object> value, |
| 230 | PropertyAttributes attributes); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 231 | void Delete(); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 232 | void TransitionToAccessorProperty(AccessorComponent component, |
| 233 | Handle<Object> accessor, |
| 234 | PropertyAttributes attributes); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 235 | void TransitionToAccessorPair(Handle<Object> pair, |
| 236 | PropertyAttributes attributes); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 237 | PropertyDetails property_details() const { |
| 238 | DCHECK(has_property_); |
| 239 | return property_details_; |
| 240 | } |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 241 | PropertyAttributes property_attributes() const { |
| 242 | return property_details().attributes(); |
| 243 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 244 | bool IsConfigurable() const { return property_details().IsConfigurable(); } |
| 245 | bool IsReadOnly() const { return property_details().IsReadOnly(); } |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 246 | bool IsEnumerable() const { return property_details().IsEnumerable(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 247 | Representation representation() const { |
| 248 | return property_details().representation(); |
| 249 | } |
| 250 | FieldIndex GetFieldIndex() const; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 251 | Handle<FieldType> GetFieldType() const; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 252 | int GetAccessorIndex() const; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 253 | int GetConstantIndex() const; |
| 254 | Handle<PropertyCell> GetPropertyCell() const; |
| 255 | Handle<Object> GetAccessors() const; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 256 | inline Handle<InterceptorInfo> GetInterceptor() const { |
| 257 | DCHECK_EQ(INTERCEPTOR, state_); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 258 | InterceptorInfo* result = |
| 259 | IsElement() ? GetInterceptor<true>(JSObject::cast(*holder_)) |
| 260 | : GetInterceptor<false>(JSObject::cast(*holder_)); |
| 261 | return handle(result, isolate_); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 262 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 263 | Handle<Object> GetDataValue() const; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 264 | void WriteDataValue(Handle<Object> value); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 265 | inline void UpdateProtector() { |
| 266 | if (FLAG_harmony_species && !IsElement() && |
| 267 | (*name_ == heap()->constructor_string() || |
| 268 | *name_ == heap()->species_symbol())) { |
| 269 | InternalUpdateProtector(); |
| 270 | } |
| 271 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 272 | |
| 273 | private: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 274 | void InternalUpdateProtector(); |
| 275 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 276 | enum class InterceptorState { |
| 277 | kUninitialized, |
| 278 | kSkipNonMasking, |
| 279 | kProcessNonMasking |
| 280 | }; |
| 281 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 282 | Handle<Map> GetReceiverMap() const; |
| 283 | |
| 284 | MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 285 | |
| 286 | template <bool is_element> |
| 287 | void Start(); |
| 288 | template <bool is_element> |
| 289 | void NextInternal(Map* map, JSReceiver* holder); |
| 290 | template <bool is_element> |
| 291 | inline State LookupInHolder(Map* map, JSReceiver* holder) { |
| 292 | return map->instance_type() <= LAST_SPECIAL_RECEIVER_TYPE |
| 293 | ? LookupInSpecialHolder<is_element>(map, holder) |
| 294 | : LookupInRegularHolder<is_element>(map, holder); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 295 | } |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 296 | template <bool is_element> |
| 297 | State LookupInRegularHolder(Map* map, JSReceiver* holder); |
| 298 | template <bool is_element> |
| 299 | State LookupInSpecialHolder(Map* map, JSReceiver* holder); |
| 300 | template <bool is_element> |
| 301 | void RestartLookupForNonMaskingInterceptors() { |
| 302 | RestartInternal<is_element>(InterceptorState::kProcessNonMasking); |
| 303 | } |
| 304 | template <bool is_element> |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 305 | void RestartInternal(InterceptorState interceptor_state); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 306 | Handle<Object> FetchValue() const; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 307 | template <bool is_element> |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 308 | void ReloadPropertyInformation(); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 309 | |
| 310 | template <bool is_element> |
| 311 | bool SkipInterceptor(JSObject* holder); |
| 312 | template <bool is_element> |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 313 | inline InterceptorInfo* GetInterceptor(JSObject* holder) const { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 314 | return is_element ? holder->GetIndexedInterceptor() |
| 315 | : holder->GetNamedInterceptor(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 316 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 317 | |
| 318 | bool check_hidden() const { return (configuration_ & kHidden) != 0; } |
| 319 | bool check_interceptor() const { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 320 | return (configuration_ & kInterceptor) != 0; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 321 | } |
| 322 | int descriptor_number() const { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 323 | DCHECK(!IsElement()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 324 | DCHECK(has_property_); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 325 | DCHECK(holder_->HasFastProperties()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 326 | return number_; |
| 327 | } |
| 328 | int dictionary_entry() const { |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 329 | DCHECK(!IsElement()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 330 | DCHECK(has_property_); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 331 | DCHECK(!holder_->HasFastProperties()); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 332 | return number_; |
| 333 | } |
| 334 | |
| 335 | static Configuration ComputeConfiguration( |
| 336 | Configuration configuration, Handle<Name> name) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 337 | if (name->IsPrivate()) { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 338 | return static_cast<Configuration>(configuration & |
| 339 | HIDDEN_SKIP_INTERCEPTOR); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 340 | } else { |
| 341 | return configuration; |
| 342 | } |
| 343 | } |
| 344 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 345 | static Handle<JSReceiver> GetRootForNonJSReceiver( |
| 346 | Isolate* isolate, Handle<Object> receiver, uint32_t index = kMaxUInt32); |
| 347 | inline static Handle<JSReceiver> GetRoot(Isolate* isolate, |
| 348 | Handle<Object> receiver, |
| 349 | uint32_t index = kMaxUInt32) { |
| 350 | if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver); |
| 351 | return GetRootForNonJSReceiver(isolate, receiver, index); |
| 352 | } |
| 353 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 354 | State NotFound(JSReceiver* const holder) const; |
| 355 | |
| 356 | bool HolderIsInContextIndex(uint32_t index) const; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 357 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 358 | // If configuration_ becomes mutable, update |
| 359 | // HolderIsReceiverOrHiddenPrototype. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 360 | const Configuration configuration_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 361 | State state_; |
| 362 | bool has_property_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 363 | InterceptorState interceptor_state_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 364 | PropertyDetails property_details_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 365 | Isolate* const isolate_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 366 | Handle<Name> name_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 367 | Handle<Object> transition_; |
| 368 | const Handle<Object> receiver_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 369 | Handle<JSReceiver> holder_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 370 | const Handle<JSReceiver> initial_holder_; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 371 | const uint32_t index_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 372 | uint32_t number_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 373 | }; |
| 374 | |
| 375 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 376 | } // namespace internal |
| 377 | } // namespace v8 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 378 | |
| 379 | #endif // V8_LOOKUP_H_ |