| 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 #include "src/v8.h" |    5 #include "src/v8.h" | 
|    6  |    6  | 
|    7 #include "src/bootstrapper.h" |    7 #include "src/bootstrapper.h" | 
|    8 #include "src/deoptimizer.h" |    8 #include "src/deoptimizer.h" | 
|    9 #include "src/lookup.h" |    9 #include "src/lookup.h" | 
|   10 #include "src/lookup-inl.h" |   10 #include "src/lookup-inl.h" | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|   22   JSReceiver* holder = *holder_; |   22   JSReceiver* holder = *holder_; | 
|   23   Map* map = *holder_map_; |   23   Map* map = *holder_map_; | 
|   24  |   24  | 
|   25   // Perform lookup on current holder. |   25   // Perform lookup on current holder. | 
|   26   state_ = LookupInHolder(map, holder); |   26   state_ = LookupInHolder(map, holder); | 
|   27   if (IsFound()) return; |   27   if (IsFound()) return; | 
|   28  |   28  | 
|   29   // Continue lookup if lookup on current holder failed. |   29   // Continue lookup if lookup on current holder failed. | 
|   30   do { |   30   do { | 
|   31     JSReceiver* maybe_holder = NextHolder(map); |   31     JSReceiver* maybe_holder = NextHolder(map); | 
|   32     if (maybe_holder == NULL) break; |   32     if (maybe_holder == nullptr) { | 
 |   33       if (interceptor_state_ == InterceptorState::kSkipNonMasking) { | 
 |   34         RestartLookupForNonMaskingInterceptors(); | 
 |   35         return; | 
 |   36       } | 
 |   37       break; | 
 |   38     } | 
|   33     holder = maybe_holder; |   39     holder = maybe_holder; | 
|   34     map = holder->map(); |   40     map = holder->map(); | 
|   35     state_ = LookupInHolder(map, holder); |   41     state_ = LookupInHolder(map, holder); | 
|   36   } while (!IsFound()); |   42   } while (!IsFound()); | 
|   37  |   43  | 
|   38   if (holder != *holder_) { |   44   if (holder != *holder_) { | 
|   39     holder_ = handle(holder, isolate_); |   45     holder_ = handle(holder, isolate_); | 
|   40     holder_map_ = handle(map, isolate_); |   46     holder_map_ = handle(map, isolate_); | 
|   41   } |   47   } | 
|   42 } |   48 } | 
|   43  |   49  | 
|   44  |   50  | 
|   45 Handle<JSReceiver> LookupIterator::GetRoot() const { |   51 void LookupIterator::RestartLookupForNonMaskingInterceptors() { | 
|   46   if (receiver_->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver_); |   52   interceptor_state_ = InterceptorState::kProcessNonMasking; | 
|   47   Handle<Object> root = |   53   state_ = NOT_FOUND; | 
|   48       handle(receiver_->GetRootMap(isolate_)->prototype(), isolate_); |   54   property_details_ = PropertyDetails::Empty(); | 
 |   55   number_ = DescriptorArray::kNotFound; | 
 |   56   holder_ = initial_holder_; | 
 |   57   holder_map_ = handle(holder_->map(), isolate_); | 
 |   58   Next(); | 
 |   59 } | 
 |   60  | 
 |   61  | 
 |   62 Handle<JSReceiver> LookupIterator::GetRoot(Handle<Object> receiver, | 
 |   63                                            Isolate* isolate) { | 
 |   64   if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver); | 
 |   65   auto root = handle(receiver->GetRootMap(isolate)->prototype(), isolate); | 
|   49   CHECK(!root->IsNull()); |   66   CHECK(!root->IsNull()); | 
|   50   return Handle<JSReceiver>::cast(root); |   67   return Handle<JSReceiver>::cast(root); | 
|   51 } |   68 } | 
|   52  |   69  | 
|   53  |   70  | 
|   54 Handle<Map> LookupIterator::GetReceiverMap() const { |   71 Handle<Map> LookupIterator::GetReceiverMap() const { | 
|   55   if (receiver_->IsNumber()) return isolate_->factory()->heap_number_map(); |   72   if (receiver_->IsNumber()) return isolate_->factory()->heap_number_map(); | 
|   56   return handle(Handle<HeapObject>::cast(receiver_)->map(), isolate_); |   73   return handle(Handle<HeapObject>::cast(receiver_)->map(), isolate_); | 
|   57 } |   74 } | 
|   58  |   75  | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|   73  |   90  | 
|   74  |   91  | 
|   75 bool LookupIterator::HasAccess() const { |   92 bool LookupIterator::HasAccess() const { | 
|   76   DCHECK_EQ(ACCESS_CHECK, state_); |   93   DCHECK_EQ(ACCESS_CHECK, state_); | 
|   77   return isolate_->MayAccess(GetHolder<JSObject>()); |   94   return isolate_->MayAccess(GetHolder<JSObject>()); | 
|   78 } |   95 } | 
|   79  |   96  | 
|   80  |   97  | 
|   81 void LookupIterator::ReloadPropertyInformation() { |   98 void LookupIterator::ReloadPropertyInformation() { | 
|   82   state_ = BEFORE_PROPERTY; |   99   state_ = BEFORE_PROPERTY; | 
 |  100   interceptor_state_ = InterceptorState::kUninitialized; | 
|   83   state_ = LookupInHolder(*holder_map_, *holder_); |  101   state_ = LookupInHolder(*holder_map_, *holder_); | 
|   84   DCHECK(IsFound() || holder_map_->is_dictionary_map()); |  102   DCHECK(IsFound() || holder_map_->is_dictionary_map()); | 
|   85 } |  103 } | 
|   86  |  104  | 
|   87  |  105  | 
|   88 void LookupIterator::PrepareForDataProperty(Handle<Object> value) { |  106 void LookupIterator::PrepareForDataProperty(Handle<Object> value) { | 
|   89   DCHECK(state_ == DATA || state_ == ACCESSOR); |  107   DCHECK(state_ == DATA || state_ == ACCESSOR); | 
|   90   DCHECK(HolderIsReceiverOrHiddenPrototype()); |  108   DCHECK(HolderIsReceiverOrHiddenPrototype()); | 
|   91   if (holder_map_->is_dictionary_map()) return; |  109   if (holder_map_->is_dictionary_map()) return; | 
|   92   holder_map_ = |  110   holder_map_ = | 
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  347   exotic_index_state_ = |  365   exotic_index_state_ = | 
|  348       result ? ExoticIndexState::kIndex : ExoticIndexState::kNoIndex; |  366       result ? ExoticIndexState::kIndex : ExoticIndexState::kNoIndex; | 
|  349   return result; |  367   return result; | 
|  350 } |  368 } | 
|  351  |  369  | 
|  352  |  370  | 
|  353 void LookupIterator::InternalizeName() { |  371 void LookupIterator::InternalizeName() { | 
|  354   if (name_->IsUniqueName()) return; |  372   if (name_->IsUniqueName()) return; | 
|  355   name_ = factory()->InternalizeString(Handle<String>::cast(name_)); |  373   name_ = factory()->InternalizeString(Handle<String>::cast(name_)); | 
|  356 } |  374 } | 
 |  375  | 
 |  376  | 
 |  377 bool LookupIterator::SkipInterceptor(JSObject* holder) { | 
 |  378   auto info = holder->GetNamedInterceptor(); | 
 |  379   // TODO(dcarney): check for symbol/can_intercept_symbols here as well. | 
 |  380   if (info->non_masking()) { | 
 |  381     switch (interceptor_state_) { | 
 |  382       case InterceptorState::kUninitialized: | 
 |  383         interceptor_state_ = InterceptorState::kSkipNonMasking; | 
 |  384       // Fall through. | 
 |  385       case InterceptorState::kSkipNonMasking: | 
 |  386         return true; | 
 |  387       case InterceptorState::kProcessNonMasking: | 
 |  388         return false; | 
 |  389     } | 
 |  390   } | 
 |  391   return interceptor_state_ == InterceptorState::kProcessNonMasking; | 
 |  392 } | 
|  357 } }  // namespace v8::internal |  393 } }  // namespace v8::internal | 
| OLD | NEW |