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