LCOV - code coverage report
Current view: top level - src - lookup-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 66 66 100.0 %
Date: 2019-01-20 Functions: 17 17 100.0 %

          Line data    Source code
       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             : #include "src/handles-inl.h"
      11             : #include "src/heap/factory-inl.h"
      12             : #include "src/objects-inl.h"
      13             : #include "src/objects/api-callbacks.h"
      14             : #include "src/objects/name-inl.h"
      15             : #include "src/objects/map-inl.h"
      16             : 
      17             : namespace v8 {
      18             : namespace internal {
      19             : 
      20    33370566 : LookupIterator::LookupIterator(Isolate* isolate, Handle<Object> receiver,
      21             :                                Handle<Name> name, Configuration configuration)
      22             :     : LookupIterator(isolate, receiver, name, GetRoot(isolate, receiver),
      23    33370566 :                      configuration) {}
      24             : 
      25    25875727 : LookupIterator::LookupIterator(Handle<Object> receiver, Handle<Name> name,
      26             :                                Handle<JSReceiver> holder,
      27             :                                Configuration configuration)
      28             :     : LookupIterator(holder->GetIsolate(), receiver, name, holder,
      29    25875733 :                      configuration) {}
      30             : 
      31    97522085 : LookupIterator::LookupIterator(Isolate* isolate, Handle<Object> receiver,
      32             :                                Handle<Name> name, Handle<JSReceiver> holder,
      33             :                                Configuration configuration)
      34    97522085 :     : configuration_(ComputeConfiguration(configuration, name)),
      35             :       interceptor_state_(InterceptorState::kUninitialized),
      36             :       property_details_(PropertyDetails::Empty()),
      37             :       isolate_(isolate),
      38             :       name_(isolate_->factory()->InternalizeName(name)),
      39             :       receiver_(receiver),
      40             :       initial_holder_(holder),
      41             :       // kMaxUInt32 isn't a valid index.
      42             :       index_(kMaxUInt32),
      43   292566206 :       number_(static_cast<uint32_t>(DescriptorArray::kNotFound)) {
      44             : #ifdef DEBUG
      45             :   uint32_t index;  // Assert that the name is not an array index.
      46             :   DCHECK(!name->AsArrayIndex(&index));
      47             : #endif  // DEBUG
      48    97522061 :   Start<false>();
      49    97522076 : }
      50             : 
      51    36811293 : LookupIterator::LookupIterator(Isolate* isolate, Handle<Object> receiver,
      52             :                                uint32_t index, Configuration configuration)
      53             :     : LookupIterator(isolate, receiver, index,
      54    73622585 :                      GetRoot(isolate, receiver, index), configuration) {}
      55             : 
      56    10789125 : LookupIterator LookupIterator::PropertyOrElement(
      57             :     Isolate* isolate, Handle<Object> receiver, Handle<Name> name,
      58             :     Handle<JSReceiver> holder, Configuration configuration) {
      59             :   uint32_t index;
      60    10789125 :   if (name->AsArrayIndex(&index)) {
      61             :     LookupIterator it =
      62     1231863 :         LookupIterator(isolate, receiver, index, holder, configuration);
      63     1231863 :     it.name_ = name;
      64     1231863 :     return it;
      65             :   }
      66     9557262 :   return LookupIterator(receiver, name, holder, configuration);
      67             : }
      68             : 
      69     4489807 : LookupIterator LookupIterator::PropertyOrElement(
      70             :     Isolate* isolate, Handle<Object> receiver, Handle<Name> name,
      71             :     Configuration configuration) {
      72             :   uint32_t index;
      73     4489810 :   if (name->AsArrayIndex(&index)) {
      74       77654 :     LookupIterator it = LookupIterator(isolate, receiver, index, configuration);
      75       77654 :     it.name_ = name;
      76       77654 :     return it;
      77             :   }
      78     4412165 :   return LookupIterator(isolate, receiver, name, configuration);
      79             : }
      80             : 
      81     1710611 : Handle<Name> LookupIterator::GetName() {
      82     1600427 :   if (name_.is_null()) {
      83             :     DCHECK(IsElement());
      84      220368 :     name_ = factory()->Uint32ToString(index_);
      85             :   }
      86     1600427 :   return name_;
      87             : }
      88             : 
      89     1175558 : bool LookupIterator::is_dictionary_holder() const {
      90     1175567 :   return !holder_->HasFastProperties();
      91             : }
      92             : 
      93             : Handle<Map> LookupIterator::transition_map() const {
      94             :   DCHECK_EQ(TRANSITION, state_);
      95    26658593 :   return Handle<Map>::cast(transition_);
      96             : }
      97             : 
      98             : Handle<PropertyCell> LookupIterator::transition_cell() const {
      99             :   DCHECK_EQ(TRANSITION, state_);
     100       42142 :   return Handle<PropertyCell>::cast(transition_);
     101             : }
     102             : 
     103             : template <class T>
     104       55316 : Handle<T> LookupIterator::GetHolder() const {
     105             :   DCHECK(IsFound());
     106    89448220 :   return Handle<T>::cast(holder_);
     107             : }
     108             : 
     109    40514913 : bool LookupIterator::ExtendingNonExtensible(Handle<JSReceiver> receiver) {
     110             :   DCHECK(receiver.is_identical_to(GetStoreTarget<JSReceiver>()));
     111    40514915 :   return !receiver->map()->is_extensible() &&
     112         871 :          (IsElement() || !name_->IsPrivate());
     113             : }
     114             : 
     115      475675 : bool LookupIterator::IsCacheableTransition() {
     116             :   DCHECK_EQ(TRANSITION, state_);
     117     1384883 :   return transition_->IsPropertyCell() ||
     118      971979 :          (transition_map()->is_dictionary_map() &&
     119     1447694 :           !GetStoreTarget<JSReceiver>()->HasFastProperties()) ||
     120     1322150 :          transition_map()->GetBackPointer()->IsMap();
     121             : }
     122             : 
     123   105022834 : void LookupIterator::UpdateProtector() {
     124   116927774 :   if (IsElement()) return;
     125             :   // This list must be kept in sync with
     126             :   // CodeStubAssembler::CheckForAssociatedProtector!
     127    46558956 :   ReadOnlyRoots roots(heap());
     128    93117073 :   if (*name_ == roots.is_concat_spreadable_symbol() ||
     129    84599725 :       *name_ == roots.constructor_string() || *name_ == roots.next_string() ||
     130    84490090 :       *name_ == roots.species_symbol() || *name_ == roots.iterator_symbol() ||
     131    88800189 :       *name_ == roots.resolve_string() || *name_ == roots.then_string()) {
     132     4319578 :     InternalUpdateProtector();
     133             :   }
     134             : }
     135             : 
     136             : int LookupIterator::descriptor_number() const {
     137             :   DCHECK(!IsElement());
     138             :   DCHECK(has_property_);
     139             :   DCHECK(holder_->HasFastProperties());
     140    16643178 :   return number_;
     141             : }
     142             : 
     143             : int LookupIterator::dictionary_entry() const {
     144             :   DCHECK(!IsElement());
     145             :   DCHECK(has_property_);
     146             :   DCHECK(!holder_->HasFastProperties());
     147    29432939 :   return number_;
     148             : }
     149             : 
     150    97522087 : LookupIterator::Configuration LookupIterator::ComputeConfiguration(
     151             :     Configuration configuration, Handle<Name> name) {
     152    97522096 :   return name->IsPrivate() ? OWN_SKIP_INTERCEPTOR : configuration;
     153             : }
     154             : 
     155    70181856 : Handle<JSReceiver> LookupIterator::GetRoot(Isolate* isolate,
     156             :                                            Handle<Object> receiver,
     157             :                                            uint32_t index) {
     158   140363790 :   if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
     159      369735 :   return GetRootForNonJSReceiver(isolate, receiver, index);
     160             : }
     161             : 
     162             : template <class T>
     163    42051802 : Handle<T> LookupIterator::GetStoreTarget() const {
     164             :   DCHECK(receiver_->IsJSReceiver());
     165    84103640 :   if (receiver_->IsJSGlobalProxy()) {
     166       78436 :     Map map = JSGlobalProxy::cast(*receiver_)->map();
     167       78436 :     if (map->has_hidden_prototype()) {
     168      156872 :       return handle(JSGlobalObject::cast(map->prototype()), isolate_);
     169             :     }
     170             :   }
     171    41973395 :   return Handle<T>::cast(receiver_);
     172             : }
     173             : 
     174             : template <bool is_element>
     175             : InterceptorInfo LookupIterator::GetInterceptor(JSObject holder) {
     176             :   return is_element ? holder->GetIndexedInterceptor()
     177     1473879 :                     : holder->GetNamedInterceptor();
     178             : }
     179             : 
     180      559318 : inline Handle<InterceptorInfo> LookupIterator::GetInterceptor() const {
     181             :   DCHECK_EQ(INTERCEPTOR, state_);
     182             :   InterceptorInfo result =
     183             :       IsElement() ? GetInterceptor<true>(JSObject::cast(*holder_))
     184      559318 :                   : GetInterceptor<false>(JSObject::cast(*holder_));
     185     1118636 :   return handle(result, isolate_);
     186             : }
     187             : 
     188             : }  // namespace internal
     189             : }  // namespace v8
     190             : 
     191             : #endif  // V8_LOOKUP_INL_H_

Generated by: LCOV version 1.10