LCOV - code coverage report
Current view: top level - src/objects - js-objects-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 332 348 95.4 %
Date: 2019-03-21 Functions: 117 121 96.7 %

          Line data    Source code
       1             : // Copyright 2018 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_OBJECTS_JS_OBJECTS_INL_H_
       6             : #define V8_OBJECTS_JS_OBJECTS_INL_H_
       7             : 
       8             : #include "src/objects/js-objects.h"
       9             : 
      10             : #include "src/feedback-vector.h"
      11             : #include "src/field-index-inl.h"
      12             : #include "src/heap/heap-write-barrier.h"
      13             : #include "src/keys.h"
      14             : #include "src/lookup-inl.h"
      15             : #include "src/objects/embedder-data-slot-inl.h"
      16             : #include "src/objects/feedback-cell-inl.h"
      17             : #include "src/objects/hash-table-inl.h"
      18             : #include "src/objects/heap-number-inl.h"
      19             : #include "src/objects/property-array-inl.h"
      20             : #include "src/objects/shared-function-info.h"
      21             : #include "src/objects/slots.h"
      22             : #include "src/objects/smi-inl.h"
      23             : #include "src/prototype-inl.h"
      24             : 
      25             : // Has to be the last include (doesn't have include guards):
      26             : #include "src/objects/object-macros.h"
      27             : 
      28             : namespace v8 {
      29             : namespace internal {
      30             : 
      31             : OBJECT_CONSTRUCTORS_IMPL(JSReceiver, HeapObject)
      32             : OBJECT_CONSTRUCTORS_IMPL(JSObject, JSReceiver)
      33             : OBJECT_CONSTRUCTORS_IMPL(JSAsyncFromSyncIterator, JSObject)
      34             : OBJECT_CONSTRUCTORS_IMPL(JSBoundFunction, JSObject)
      35             : OBJECT_CONSTRUCTORS_IMPL(JSDate, JSObject)
      36             : OBJECT_CONSTRUCTORS_IMPL(JSFunction, JSObject)
      37             : OBJECT_CONSTRUCTORS_IMPL(JSGlobalObject, JSObject)
      38             : OBJECT_CONSTRUCTORS_IMPL(JSGlobalProxy, JSObject)
      39             : JSIteratorResult::JSIteratorResult(Address ptr) : JSObject(ptr) {}
      40             : OBJECT_CONSTRUCTORS_IMPL(JSMessageObject, JSObject)
      41             : OBJECT_CONSTRUCTORS_IMPL(JSStringIterator, JSObject)
      42             : OBJECT_CONSTRUCTORS_IMPL(JSValue, JSObject)
      43             : 
      44             : NEVER_READ_ONLY_SPACE_IMPL(JSReceiver)
      45             : 
      46             : CAST_ACCESSOR(JSAsyncFromSyncIterator)
      47             : CAST_ACCESSOR(JSBoundFunction)
      48             : CAST_ACCESSOR(JSDate)
      49             : CAST_ACCESSOR(JSFunction)
      50             : CAST_ACCESSOR(JSGlobalObject)
      51             : CAST_ACCESSOR(JSGlobalProxy)
      52             : CAST_ACCESSOR(JSIteratorResult)
      53             : CAST_ACCESSOR(JSMessageObject)
      54             : CAST_ACCESSOR(JSObject)
      55             : CAST_ACCESSOR(JSReceiver)
      56             : CAST_ACCESSOR(JSStringIterator)
      57             : CAST_ACCESSOR(JSValue)
      58             : 
      59    10785821 : MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
      60             :                                             Handle<JSReceiver> receiver,
      61             :                                             Handle<Name> name) {
      62    10785821 :   LookupIterator it(isolate, receiver, name, receiver);
      63    17300604 :   if (!it.IsFound()) return it.factory()->undefined_value();
      64     4271040 :   return Object::GetProperty(&it);
      65             : }
      66             : 
      67    50331939 : MaybeHandle<Object> JSReceiver::GetElement(Isolate* isolate,
      68             :                                            Handle<JSReceiver> receiver,
      69             :                                            uint32_t index) {
      70             :   LookupIterator it(isolate, receiver, index, receiver);
      71    99896526 :   if (!it.IsFound()) return it.factory()->undefined_value();
      72      767352 :   return Object::GetProperty(&it);
      73             : }
      74             : 
      75     5700990 : Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object,
      76             :                                            Handle<Name> name) {
      77             :   LookupIterator it(object, name, object,
      78             :                     LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
      79     8041733 :   if (!it.IsFound()) return it.factory()->undefined_value();
      80     3360247 :   return GetDataProperty(&it);
      81             : }
      82             : 
      83     3271692 : MaybeHandle<Object> JSReceiver::GetPrototype(Isolate* isolate,
      84             :                                              Handle<JSReceiver> receiver) {
      85             :   // We don't expect access checks to be needed on JSProxy objects.
      86             :   DCHECK(!receiver->IsAccessCheckNeeded() || receiver->IsJSObject());
      87             :   PrototypeIterator iter(isolate, receiver, kStartAtReceiver,
      88             :                          PrototypeIterator::END_AT_NON_HIDDEN);
      89     3237791 :   do {
      90     3278327 :     if (!iter.AdvanceFollowingProxies()) return MaybeHandle<Object>();
      91             :   } while (!iter.IsAtEnd());
      92     3231156 :   return PrototypeIterator::GetCurrent(iter);
      93             : }
      94             : 
      95      291269 : MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
      96             :                                             Handle<JSReceiver> receiver,
      97             :                                             const char* name) {
      98      291269 :   Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
      99      291269 :   return GetProperty(isolate, receiver, str);
     100             : }
     101             : 
     102             : // static
     103         972 : V8_WARN_UNUSED_RESULT MaybeHandle<FixedArray> JSReceiver::OwnPropertyKeys(
     104             :     Handle<JSReceiver> object) {
     105             :   return KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly,
     106             :                                  ALL_PROPERTIES,
     107        1663 :                                  GetKeysConversion::kConvertToString);
     108             : }
     109             : 
     110     1828796 : bool JSObject::PrototypeHasNoElements(Isolate* isolate, JSObject object) {
     111             :   DisallowHeapAllocation no_gc;
     112             :   HeapObject prototype = HeapObject::cast(object->map()->prototype());
     113             :   ReadOnlyRoots roots(isolate);
     114             :   HeapObject null = roots.null_value();
     115             :   FixedArrayBase empty_fixed_array = roots.empty_fixed_array();
     116             :   FixedArrayBase empty_slow_element_dictionary =
     117             :       roots.empty_slow_element_dictionary();
     118    10901594 :   while (prototype != null) {
     119             :     Map map = prototype->map();
     120     4547373 :     if (map->IsCustomElementsReceiverMap()) return false;
     121             :     FixedArrayBase elements = JSObject::cast(prototype)->elements();
     122     4544882 :     if (elements != empty_fixed_array &&
     123             :         elements != empty_slow_element_dictionary) {
     124             :       return false;
     125             :     }
     126             :     prototype = HeapObject::cast(map->prototype());
     127             :   }
     128             :   return true;
     129             : }
     130             : 
     131   574538961 : ACCESSORS(JSReceiver, raw_properties_or_hash, Object, kPropertiesOrHashOffset)
     132             : 
     133      131452 : FixedArrayBase JSObject::elements() const {
     134   698175926 :   Object array = READ_FIELD(*this, kElementsOffset);
     135      131452 :   return FixedArrayBase::cast(array);
     136             : }
     137             : 
     138       90695 : void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) {
     139       90695 :   JSObject::ValidateElements(*object);
     140             :   ElementsKind elements_kind = object->map()->elements_kind();
     141       90695 :   if (!IsObjectElementsKind(elements_kind)) {
     142           0 :     if (IsHoleyElementsKind(elements_kind)) {
     143           0 :       TransitionElementsKind(object, HOLEY_ELEMENTS);
     144             :     } else {
     145           0 :       TransitionElementsKind(object, PACKED_ELEMENTS);
     146             :     }
     147             :   }
     148       90695 : }
     149             : 
     150             : template <typename TSlot>
     151      535903 : void JSObject::EnsureCanContainElements(Handle<JSObject> object, TSlot objects,
     152             :                                         uint32_t count,
     153             :                                         EnsureElementsMode mode) {
     154             :   static_assert(std::is_same<TSlot, FullObjectSlot>::value ||
     155             :                     std::is_same<TSlot, ObjectSlot>::value,
     156             :                 "Only ObjectSlot and FullObjectSlot are expected here");
     157      535903 :   ElementsKind current_kind = object->GetElementsKind();
     158             :   ElementsKind target_kind = current_kind;
     159             :   {
     160             :     DisallowHeapAllocation no_allocation;
     161             :     DCHECK(mode != ALLOW_COPIED_DOUBLE_ELEMENTS);
     162             :     bool is_holey = IsHoleyElementsKind(current_kind);
     163      535903 :     if (current_kind == HOLEY_ELEMENTS) return;
     164             :     Object the_hole = object->GetReadOnlyRoots().the_hole_value();
     165    29463589 :     for (uint32_t i = 0; i < count; ++i, ++objects) {
     166             :       Object current = *objects;
     167    14463855 :       if (current == the_hole) {
     168             :         is_holey = true;
     169             :         target_kind = GetHoleyElementsKind(target_kind);
     170    12972931 :       } else if (!current->IsSmi()) {
     171    10356945 :         if (mode == ALLOW_CONVERTED_DOUBLE_ELEMENTS && current->IsNumber()) {
     172     1734444 :           if (IsSmiElementsKind(target_kind)) {
     173         217 :             if (is_holey) {
     174             :               target_kind = HOLEY_DOUBLE_ELEMENTS;
     175             :             } else {
     176             :               target_kind = PACKED_DOUBLE_ELEMENTS;
     177             :             }
     178             :           }
     179     3625902 :         } else if (is_holey) {
     180             :           target_kind = HOLEY_ELEMENTS;
     181             :           break;
     182             :         } else {
     183             :           target_kind = PACKED_ELEMENTS;
     184             :         }
     185             :       }
     186             :     }
     187             :   }
     188      535879 :   if (target_kind != current_kind) {
     189       94812 :     TransitionElementsKind(object, target_kind);
     190             :   }
     191             : }
     192             : 
     193       93626 : void JSObject::EnsureCanContainElements(Handle<JSObject> object,
     194             :                                         Handle<FixedArrayBase> elements,
     195             :                                         uint32_t length,
     196             :                                         EnsureElementsMode mode) {
     197             :   ReadOnlyRoots roots = object->GetReadOnlyRoots();
     198       93626 :   if (elements->map() != roots.fixed_double_array_map()) {
     199             :     DCHECK(elements->map() == roots.fixed_array_map() ||
     200             :            elements->map() == roots.fixed_cow_array_map());
     201       93626 :     if (mode == ALLOW_COPIED_DOUBLE_ELEMENTS) {
     202             :       mode = DONT_ALLOW_DOUBLE_ELEMENTS;
     203             :     }
     204             :     ObjectSlot objects =
     205       93626 :         Handle<FixedArray>::cast(elements)->GetFirstElementAddress();
     206       93626 :     EnsureCanContainElements(object, objects, length, mode);
     207             :     return;
     208             :   }
     209             : 
     210             :   DCHECK(mode == ALLOW_COPIED_DOUBLE_ELEMENTS);
     211           0 :   if (object->GetElementsKind() == HOLEY_SMI_ELEMENTS) {
     212           0 :     TransitionElementsKind(object, HOLEY_DOUBLE_ELEMENTS);
     213           0 :   } else if (object->GetElementsKind() == PACKED_SMI_ELEMENTS) {
     214             :     Handle<FixedDoubleArray> double_array =
     215             :         Handle<FixedDoubleArray>::cast(elements);
     216           0 :     for (uint32_t i = 0; i < length; ++i) {
     217           0 :       if (double_array->is_the_hole(i)) {
     218           0 :         TransitionElementsKind(object, HOLEY_DOUBLE_ELEMENTS);
     219             :         return;
     220             :       }
     221             :     }
     222           0 :     TransitionElementsKind(object, PACKED_DOUBLE_ELEMENTS);
     223             :   }
     224             : }
     225             : 
     226      726356 : void JSObject::SetMapAndElements(Handle<JSObject> object, Handle<Map> new_map,
     227             :                                  Handle<FixedArrayBase> value) {
     228      726356 :   JSObject::MigrateToMap(object, new_map);
     229             :   DCHECK((object->map()->has_fast_smi_or_object_elements() ||
     230             :           (*value == object->GetReadOnlyRoots().empty_fixed_array()) ||
     231             :           object->map()->has_fast_string_wrapper_elements()) ==
     232             :          (value->map() == object->GetReadOnlyRoots().fixed_array_map() ||
     233             :           value->map() == object->GetReadOnlyRoots().fixed_cow_array_map()));
     234             :   DCHECK((*value == object->GetReadOnlyRoots().empty_fixed_array()) ||
     235             :          (object->map()->has_fast_double_elements() ==
     236             :           value->IsFixedDoubleArray()));
     237      726356 :   object->set_elements(*value);
     238      726356 : }
     239             : 
     240     6215046 : void JSObject::set_elements(FixedArrayBase value, WriteBarrierMode mode) {
     241     7574694 :   WRITE_FIELD(*this, kElementsOffset, value);
     242    12430093 :   CONDITIONAL_WRITE_BARRIER(*this, kElementsOffset, value, mode);
     243     6215045 : }
     244             : 
     245    39512896 : void JSObject::initialize_elements() {
     246    39512896 :   FixedArrayBase elements = map()->GetInitialElements();
     247    39512907 :   WRITE_FIELD(*this, kElementsOffset, elements);
     248    39512907 : }
     249             : 
     250      668103 : InterceptorInfo JSObject::GetIndexedInterceptor() {
     251      668103 :   return map()->GetIndexedInterceptor();
     252             : }
     253             : 
     254     1626139 : InterceptorInfo JSObject::GetNamedInterceptor() {
     255     1626139 :   return map()->GetNamedInterceptor();
     256             : }
     257             : 
     258             : int JSObject::GetHeaderSize() const { return GetHeaderSize(map()); }
     259             : 
     260   112125860 : int JSObject::GetHeaderSize(const Map map) {
     261             :   // Check for the most common kind of JavaScript object before
     262             :   // falling into the generic switch. This speeds up the internal
     263             :   // field operations considerably on average.
     264             :   InstanceType instance_type = map->instance_type();
     265             :   return instance_type == JS_OBJECT_TYPE
     266             :              ? JSObject::kHeaderSize
     267   191248009 :              : GetHeaderSize(instance_type, map->has_prototype_slot());
     268             : }
     269             : 
     270             : // static
     271             : int JSObject::GetEmbedderFieldsStartOffset(const Map map) {
     272             :   // Embedder fields are located after the object header.
     273    28364076 :   return GetHeaderSize(map);
     274             : }
     275             : 
     276     2069481 : int JSObject::GetEmbedderFieldsStartOffset() {
     277     2069515 :   return GetEmbedderFieldsStartOffset(map());
     278             : }
     279             : 
     280             : // static
     281    26294555 : int JSObject::GetEmbedderFieldCount(const Map map) {
     282             :   int instance_size = map->instance_size();
     283    26294555 :   if (instance_size == kVariableSizeSentinel) return 0;
     284             :   // Embedder fields are located after the object header, whereas in-object
     285             :   // properties are located at the end of the object. We don't have to round up
     286             :   // the header size here because division by kEmbedderDataSlotSizeInTaggedSlots
     287             :   // will swallow potential padding in case of (kTaggedSize !=
     288             :   // kSystemPointerSize) anyway.
     289    26294576 :   return (((instance_size - GetEmbedderFieldsStartOffset(map)) >>
     290    26294572 :            kTaggedSizeLog2) -
     291    26294576 :           map->GetInObjectProperties()) /
     292    26294572 :          kEmbedderDataSlotSizeInTaggedSlots;
     293             : }
     294             : 
     295      700374 : int JSObject::GetEmbedderFieldCount() const {
     296      700374 :   return GetEmbedderFieldCount(map());
     297             : }
     298             : 
     299     2067273 : int JSObject::GetEmbedderFieldOffset(int index) {
     300             :   DCHECK_LT(static_cast<unsigned>(index),
     301             :             static_cast<unsigned>(GetEmbedderFieldCount()));
     302     2069481 :   return GetEmbedderFieldsStartOffset() + (kEmbedderDataSlotSize * index);
     303             : }
     304             : 
     305     1032642 : Object JSObject::GetEmbedderField(int index) {
     306     1032640 :   return EmbedderDataSlot(*this, index).load_tagged();
     307             : }
     308             : 
     309     1034555 : void JSObject::SetEmbedderField(int index, Object value) {
     310             :   EmbedderDataSlot::store_tagged(*this, index, value);
     311     1034604 : }
     312             : 
     313             : void JSObject::SetEmbedderField(int index, Smi value) {
     314             :   EmbedderDataSlot(*this, index).store_smi(value);
     315             : }
     316             : 
     317             : bool JSObject::IsUnboxedDoubleField(FieldIndex index) {
     318             :   if (!FLAG_unbox_double_fields) return false;
     319             :   return map()->IsUnboxedDoubleField(index);
     320             : }
     321             : 
     322             : // Access fast-case object properties at index. The use of these routines
     323             : // is needed to correctly distinguish between properties stored in-object and
     324             : // properties stored in the properties array.
     325    93730780 : Object JSObject::RawFastPropertyAt(FieldIndex index) {
     326             :   DCHECK(!IsUnboxedDoubleField(index));
     327    93730780 :   if (index.is_inobject()) {
     328    12923961 :     return READ_FIELD(*this, index.offset());
     329             :   } else {
     330   161613638 :     return property_array()->get(index.outobject_array_index());
     331             :   }
     332             : }
     333             : 
     334             : double JSObject::RawFastDoublePropertyAt(FieldIndex index) {
     335             :   DCHECK(IsUnboxedDoubleField(index));
     336           0 :   return READ_DOUBLE_FIELD(*this, index.offset());
     337             : }
     338             : 
     339             : uint64_t JSObject::RawFastDoublePropertyAsBitsAt(FieldIndex index) {
     340             :   DCHECK(IsUnboxedDoubleField(index));
     341             :   return READ_UINT64_FIELD(*this, index.offset());
     342             : }
     343             : 
     344   100135620 : void JSObject::RawFastPropertyAtPut(FieldIndex index, Object value) {
     345   100135620 :   if (index.is_inobject()) {
     346             :     int offset = index.offset();
     347    80682765 :     WRITE_FIELD(*this, offset, value);
     348    80682765 :     WRITE_BARRIER(*this, offset, value);
     349             :   } else {
     350    19452855 :     property_array()->set(index.outobject_array_index(), value);
     351             :   }
     352   100135611 : }
     353             : 
     354             : void JSObject::RawFastDoublePropertyAsBitsAtPut(FieldIndex index,
     355             :                                                 uint64_t bits) {
     356             :   // Double unboxing is enabled only on 64-bit platforms without pointer
     357             :   // compression.
     358             :   DCHECK_EQ(kDoubleSize, kTaggedSize);
     359             :   Address field_addr = FIELD_ADDR(*this, index.offset());
     360             :   base::Relaxed_Store(reinterpret_cast<base::AtomicWord*>(field_addr),
     361             :                       static_cast<base::AtomicWord>(bits));
     362             : }
     363             : 
     364             : void JSObject::FastPropertyAtPut(FieldIndex index, Object value) {
     365             :   if (IsUnboxedDoubleField(index)) {
     366             :     DCHECK(value->IsMutableHeapNumber());
     367             :     // Ensure that all bits of the double value are preserved.
     368             :     RawFastDoublePropertyAsBitsAtPut(
     369             :         index, MutableHeapNumber::cast(value)->value_as_bits());
     370             :   } else {
     371      363834 :     RawFastPropertyAtPut(index, value);
     372             :   }
     373             : }
     374             : 
     375    56882411 : void JSObject::WriteToField(int descriptor, PropertyDetails details,
     376             :                             Object value) {
     377             :   DCHECK_EQ(kField, details.location());
     378             :   DCHECK_EQ(kData, details.kind());
     379             :   DisallowHeapAllocation no_gc;
     380    56882411 :   FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor);
     381    56882433 :   if (details.representation().IsDouble()) {
     382             :     // Nothing more to be done.
     383       50242 :     if (value->IsUninitialized()) {
     384        1267 :       return;
     385             :     }
     386             :     // Manipulating the signaling NaN used for the hole and uninitialized
     387             :     // double field sentinel in C++, e.g. with bit_cast or value()/set_value(),
     388             :     // will change its value on ia32 (the x87 stack is used to return values
     389             :     // and stores to the stack silently clear the signalling bit).
     390             :     uint64_t bits;
     391       48975 :     if (value->IsSmi()) {
     392        6374 :       bits = bit_cast<uint64_t>(static_cast<double>(Smi::ToInt(value)));
     393             :     } else {
     394             :       DCHECK(value->IsHeapNumber());
     395             :       bits = HeapNumber::cast(value)->value_as_bits();
     396             :     }
     397             :     if (IsUnboxedDoubleField(index)) {
     398             :       RawFastDoublePropertyAsBitsAtPut(index, bits);
     399             :     } else {
     400       48975 :       auto box = MutableHeapNumber::cast(RawFastPropertyAt(index));
     401             :       box->set_value_as_bits(bits);
     402             :     }
     403             :   } else {
     404    56832191 :     RawFastPropertyAtPut(index, value);
     405             :   }
     406             : }
     407             : 
     408      554670 : int JSObject::GetInObjectPropertyOffset(int index) {
     409      554670 :   return map()->GetInObjectPropertyOffset(index);
     410             : }
     411             : 
     412           0 : Object JSObject::InObjectPropertyAt(int index) {
     413           0 :   int offset = GetInObjectPropertyOffset(index);
     414           0 :   return READ_FIELD(*this, offset);
     415             : }
     416             : 
     417      554670 : Object JSObject::InObjectPropertyAtPut(int index, Object value,
     418             :                                        WriteBarrierMode mode) {
     419             :   // Adjust for the number of properties stored in the object.
     420      554670 :   int offset = GetInObjectPropertyOffset(index);
     421      554670 :   WRITE_FIELD(*this, offset, value);
     422      652349 :   CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode);
     423      554670 :   return value;
     424             : }
     425             : 
     426    21023717 : void JSObject::InitializeBody(Map map, int start_offset,
     427             :                               Object pre_allocated_value, Object filler_value) {
     428             :   DCHECK_IMPLIES(filler_value->IsHeapObject(),
     429             :                  !ObjectInYoungGeneration(filler_value));
     430             :   DCHECK_IMPLIES(pre_allocated_value->IsHeapObject(),
     431             :                  !ObjectInYoungGeneration(pre_allocated_value));
     432             :   int size = map->instance_size();
     433             :   int offset = start_offset;
     434    21023717 :   if (filler_value != pre_allocated_value) {
     435             :     int end_of_pre_allocated_offset =
     436      230087 :         size - (map->UnusedPropertyFields() * kTaggedSize);
     437             :     DCHECK_LE(kHeaderSize, end_of_pre_allocated_offset);
     438      534755 :     while (offset < end_of_pre_allocated_offset) {
     439      152334 :       WRITE_FIELD(*this, offset, pre_allocated_value);
     440      152334 :       offset += kTaggedSize;
     441             :     }
     442             :   }
     443   296518767 :   while (offset < size) {
     444   137747525 :     WRITE_FIELD(*this, offset, filler_value);
     445   137747525 :     offset += kTaggedSize;
     446             :   }
     447    21023717 : }
     448             : 
     449             : Object JSBoundFunction::raw_bound_target_function() const {
     450             :   return READ_FIELD(*this, kBoundTargetFunctionOffset);
     451             : }
     452             : 
     453        5782 : ACCESSORS(JSBoundFunction, bound_target_function, JSReceiver,
     454             :           kBoundTargetFunctionOffset)
     455        3215 : ACCESSORS(JSBoundFunction, bound_this, Object, kBoundThisOffset)
     456        3964 : ACCESSORS(JSBoundFunction, bound_arguments, FixedArray, kBoundArgumentsOffset)
     457             : 
     458   180026451 : ACCESSORS(JSFunction, raw_feedback_cell, FeedbackCell, kFeedbackCellOffset)
     459             : 
     460    18157192 : ACCESSORS(JSGlobalObject, native_context, NativeContext, kNativeContextOffset)
     461      500139 : ACCESSORS(JSGlobalObject, global_proxy, JSGlobalProxy, kGlobalProxyOffset)
     462             : 
     463     6491224 : ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset)
     464             : 
     465    11963086 : FeedbackVector JSFunction::feedback_vector() const {
     466             :   DCHECK(has_feedback_vector());
     467    11963086 :   return FeedbackVector::cast(raw_feedback_cell()->value());
     468             : }
     469             : 
     470     3082423 : FixedArray JSFunction::closure_feedback_cell_array() const {
     471             :   DCHECK(has_closure_feedback_cell_array());
     472     3082423 :   return FixedArray::cast(raw_feedback_cell()->value());
     473             : }
     474             : 
     475             : // Code objects that are marked for deoptimization are not considered to be
     476             : // optimized. This is because the JSFunction might have been already
     477             : // deoptimized but its code() still needs to be unlinked, which will happen on
     478             : // its next activation.
     479             : // TODO(jupvfranco): rename this function. Maybe RunOptimizedCode,
     480             : // or IsValidOptimizedCode.
     481     3882725 : bool JSFunction::IsOptimized() {
     482     8231231 :   return is_compiled() && code()->kind() == Code::OPTIMIZED_FUNCTION &&
     483     4526214 :          !code()->marked_for_deoptimization();
     484             : }
     485             : 
     486      625619 : bool JSFunction::HasOptimizedCode() {
     487     1248190 :   return IsOptimized() ||
     488     1868299 :          (has_feedback_vector() && feedback_vector()->has_optimized_code() &&
     489      626268 :           !feedback_vector()->optimized_code()->marked_for_deoptimization());
     490             : }
     491             : 
     492      488804 : bool JSFunction::HasOptimizationMarker() {
     493      488804 :   return has_feedback_vector() && feedback_vector()->has_optimization_marker();
     494             : }
     495             : 
     496             : void JSFunction::ClearOptimizationMarker() {
     497             :   DCHECK(has_feedback_vector());
     498      335317 :   feedback_vector()->ClearOptimizationMarker();
     499             : }
     500             : 
     501             : // Optimized code marked for deoptimization will tier back down to running
     502             : // interpreted on its next activation, and already doesn't count as IsOptimized.
     503        6104 : bool JSFunction::IsInterpreted() {
     504       17694 :   return is_compiled() && (code()->is_interpreter_trampoline_builtin() ||
     505        5504 :                            (code()->kind() == Code::OPTIMIZED_FUNCTION &&
     506       11608 :                             code()->marked_for_deoptimization()));
     507             : }
     508             : 
     509             : bool JSFunction::ChecksOptimizationMarker() {
     510             :   return code()->checks_optimization_marker();
     511             : }
     512             : 
     513      158492 : bool JSFunction::IsMarkedForOptimization() {
     514      316976 :   return has_feedback_vector() && feedback_vector()->optimization_marker() ==
     515      158492 :                                       OptimizationMarker::kCompileOptimized;
     516             : }
     517             : 
     518      150893 : bool JSFunction::IsMarkedForConcurrentOptimization() {
     519      301786 :   return has_feedback_vector() &&
     520      150893 :          feedback_vector()->optimization_marker() ==
     521      150893 :              OptimizationMarker::kCompileOptimizedConcurrent;
     522             : }
     523             : 
     524      199324 : bool JSFunction::IsInOptimizationQueue() {
     525      398624 :   return has_feedback_vector() && feedback_vector()->optimization_marker() ==
     526      199324 :                                       OptimizationMarker::kInOptimizationQueue;
     527             : }
     528             : 
     529      309921 : void JSFunction::CompleteInobjectSlackTrackingIfActive() {
     530      309921 :   if (!has_prototype_slot()) return;
     531      324129 :   if (has_initial_map() && initial_map()->IsInobjectSlackTrackingInProgress()) {
     532      115309 :     initial_map()->CompleteInobjectSlackTracking(GetIsolate());
     533             :   }
     534             : }
     535             : 
     536         199 : AbstractCode JSFunction::abstract_code() {
     537         199 :   if (IsInterpreted()) {
     538         146 :     return AbstractCode::cast(shared()->GetBytecodeArray());
     539             :   } else {
     540             :     return AbstractCode::cast(code());
     541             :   }
     542             : }
     543             : 
     544      982782 : Code JSFunction::code() const {
     545    28638260 :   return Code::cast(RELAXED_READ_FIELD(*this, kCodeOffset));
     546             : }
     547             : 
     548    17178290 : void JSFunction::set_code(Code value) {
     549             :   DCHECK(!ObjectInYoungGeneration(value));
     550    17178290 :   RELAXED_WRITE_FIELD(*this, kCodeOffset, value);
     551    17178290 :   MarkingBarrier(*this, RawField(kCodeOffset), value);
     552    17178306 : }
     553             : 
     554             : void JSFunction::set_code_no_write_barrier(Code value) {
     555             :   DCHECK(!ObjectInYoungGeneration(value));
     556             :   RELAXED_WRITE_FIELD(*this, kCodeOffset, value);
     557             : }
     558             : 
     559     1603598 : SharedFunctionInfo JSFunction::shared() const {
     560             :   return SharedFunctionInfo::cast(
     561   366805687 :       RELAXED_READ_FIELD(*this, kSharedFunctionInfoOffset));
     562             : }
     563             : 
     564    15477415 : void JSFunction::set_shared(SharedFunctionInfo value, WriteBarrierMode mode) {
     565             :   // Release semantics to support acquire read in NeedsResetDueToFlushedBytecode
     566    15477415 :   RELEASE_WRITE_FIELD(*this, kSharedFunctionInfoOffset, value);
     567    30954833 :   CONDITIONAL_WRITE_BARRIER(*this, kSharedFunctionInfoOffset, value, mode);
     568    15477416 : }
     569             : 
     570             : void JSFunction::ClearOptimizedCodeSlot(const char* reason) {
     571             :   if (has_feedback_vector() && feedback_vector()->has_optimized_code()) {
     572             :     if (FLAG_trace_opt) {
     573             :       PrintF("[evicting entry from optimizing code feedback slot (%s) for ",
     574             :              reason);
     575             :       ShortPrint();
     576             :       PrintF("]\n");
     577             :     }
     578             :     feedback_vector()->ClearOptimizedCode();
     579             :   }
     580             : }
     581             : 
     582             : void JSFunction::SetOptimizationMarker(OptimizationMarker marker) {
     583             :   DCHECK(has_feedback_vector());
     584             :   DCHECK(ChecksOptimizationMarker());
     585             :   DCHECK(!HasOptimizedCode());
     586             : 
     587      500590 :   feedback_vector()->SetOptimizationMarker(marker);
     588             : }
     589             : 
     590    28128307 : bool JSFunction::has_feedback_vector() const {
     591    84384147 :   return shared()->is_compiled() &&
     592    43063667 :          !raw_feedback_cell()->value()->IsUndefined() &&
     593    28128377 :          raw_feedback_cell()->value()->IsFeedbackVector();
     594             : }
     595             : 
     596     3082418 : bool JSFunction::has_closure_feedback_cell_array() const {
     597     9247270 :   return shared()->is_compiled() &&
     598     3082425 :          !raw_feedback_cell()->value()->IsUndefined() &&
     599     3082425 :          raw_feedback_cell()->value()->IsFixedArray();
     600             : }
     601             : 
     602             : Context JSFunction::context() {
     603    26334966 :   return Context::cast(READ_FIELD(*this, kContextOffset));
     604             : }
     605             : 
     606      408261 : bool JSFunction::has_context() const {
     607      816522 :   return READ_FIELD(*this, kContextOffset)->IsContext();
     608             : }
     609             : 
     610     2181738 : JSGlobalProxy JSFunction::global_proxy() { return context()->global_proxy(); }
     611             : 
     612     8038498 : NativeContext JSFunction::native_context() {
     613     8038498 :   return context()->native_context();
     614             : }
     615             : 
     616    15477171 : void JSFunction::set_context(Object value) {
     617             :   DCHECK(value->IsUndefined() || value->IsContext());
     618    15477171 :   WRITE_FIELD(*this, kContextOffset, value);
     619    15477171 :   WRITE_BARRIER(*this, kContextOffset, value);
     620    15477170 : }
     621             : 
     622   163275068 : ACCESSORS_CHECKED(JSFunction, prototype_or_initial_map, Object,
     623             :                   kPrototypeOrInitialMapOffset, map()->has_prototype_slot())
     624             : 
     625    23707982 : bool JSFunction::has_prototype_slot() const {
     626    23707982 :   return map()->has_prototype_slot();
     627             : }
     628             : 
     629             : Map JSFunction::initial_map() { return Map::cast(prototype_or_initial_map()); }
     630             : 
     631    41902197 : bool JSFunction::has_initial_map() {
     632             :   DCHECK(has_prototype_slot());
     633    41902211 :   return prototype_or_initial_map()->IsMap();
     634             : }
     635             : 
     636     6835701 : bool JSFunction::has_instance_prototype() {
     637             :   DCHECK(has_prototype_slot());
     638     7606443 :   return has_initial_map() || !prototype_or_initial_map()->IsTheHole();
     639             : }
     640             : 
     641     6546375 : bool JSFunction::has_prototype() {
     642             :   DCHECK(has_prototype_slot());
     643     6546375 :   return map()->has_non_instance_prototype() || has_instance_prototype();
     644             : }
     645             : 
     646     7512867 : bool JSFunction::has_prototype_property() {
     647    15027274 :   return (has_prototype_slot() && IsConstructor()) ||
     648     7512875 :          IsGeneratorFunction(shared()->kind());
     649             : }
     650             : 
     651     7512867 : bool JSFunction::PrototypeRequiresRuntimeLookup() {
     652    13988440 :   return !has_prototype_property() || map()->has_non_instance_prototype();
     653             : }
     654             : 
     655     5257507 : Object JSFunction::instance_prototype() {
     656             :   DCHECK(has_instance_prototype());
     657     5257507 :   if (has_initial_map()) return initial_map()->prototype();
     658             :   // When there is no initial map and the prototype is a JSReceiver, the
     659             :   // initial map field is used for the prototype field.
     660             :   return prototype_or_initial_map();
     661             : }
     662             : 
     663     4343573 : Object JSFunction::prototype() {
     664             :   DCHECK(has_prototype());
     665             :   // If the function's prototype property has been set to a non-JSReceiver
     666             :   // value, that value is stored in the constructor field of the map.
     667     4343573 :   if (map()->has_non_instance_prototype()) {
     668       13406 :     Object prototype = map()->GetConstructor();
     669             :     // The map must have a prototype in that field, not a back pointer.
     670             :     DCHECK(!prototype->IsMap());
     671             :     DCHECK(!prototype->IsFunctionTemplateInfo());
     672       13406 :     return prototype;
     673             :   }
     674     4330167 :   return instance_prototype();
     675             : }
     676             : 
     677     4550942 : bool JSFunction::is_compiled() const {
     678     8787314 :   return code()->builtin_index() != Builtins::kCompileLazy &&
     679     8787314 :          shared()->is_compiled();
     680             : }
     681             : 
     682    61003255 : bool JSFunction::NeedsResetDueToFlushedBytecode() {
     683    61003255 :   if (!FLAG_flush_bytecode) return false;
     684             : 
     685             :   // Do a raw read for shared and code fields here since this function may be
     686             :   // called on a concurrent thread and the JSFunction might not be fully
     687             :   // initialized yet.
     688   122173902 :   Object maybe_shared = ACQUIRE_READ_FIELD(*this, kSharedFunctionInfoOffset);
     689   121919342 :   Object maybe_code = RELAXED_READ_FIELD(*this, kCodeOffset);
     690             : 
     691   121565401 :   if (!maybe_shared->IsSharedFunctionInfo() || !maybe_code->IsCode()) {
     692             :     return false;
     693             :   }
     694             : 
     695    60684190 :   SharedFunctionInfo shared = SharedFunctionInfo::cast(maybe_shared);
     696             :   Code code = Code::cast(maybe_code);
     697    65768124 :   return !shared->is_compiled() &&
     698             :          code->builtin_index() != Builtins::kCompileLazy;
     699             : }
     700             : 
     701     1537227 : void JSFunction::ResetIfBytecodeFlushed() {
     702     1537227 :   if (NeedsResetDueToFlushedBytecode()) {
     703             :     // Bytecode was flushed and function is now uncompiled, reset JSFunction
     704             :     // by setting code to CompileLazy and clearing the feedback vector.
     705        8352 :     set_code(GetIsolate()->builtins()->builtin(i::Builtins::kCompileLazy));
     706       16704 :     raw_feedback_cell()->set_value(
     707       25056 :         ReadOnlyRoots(GetIsolate()).undefined_value());
     708             :   }
     709     1537226 : }
     710             : 
     711      574114 : ACCESSORS(JSValue, value, Object, kValueOffset)
     712             : 
     713      872182 : ACCESSORS(JSDate, value, Object, kValueOffset)
     714      167496 : ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset)
     715       12429 : ACCESSORS(JSDate, year, Object, kYearOffset)
     716       11781 : ACCESSORS(JSDate, month, Object, kMonthOffset)
     717       11610 : ACCESSORS(JSDate, day, Object, kDayOffset)
     718       11538 : ACCESSORS(JSDate, weekday, Object, kWeekdayOffset)
     719       14688 : ACCESSORS(JSDate, hour, Object, kHourOffset)
     720       12384 : ACCESSORS(JSDate, min, Object, kMinOffset)
     721       11763 : ACCESSORS(JSDate, sec, Object, kSecOffset)
     722             : 
     723             : MessageTemplate JSMessageObject::type() const {
     724        4236 :   Object value = READ_FIELD(*this, kTypeOffset);
     725             :   return MessageTemplateFromInt(Smi::ToInt(value));
     726             : }
     727             : void JSMessageObject::set_type(MessageTemplate value) {
     728     1359648 :   WRITE_FIELD(*this, kTypeOffset, Smi::FromInt(static_cast<int>(value)));
     729             : }
     730     6834801 : ACCESSORS(JSMessageObject, argument, Object, kArgumentsOffset)
     731     6852774 : ACCESSORS(JSMessageObject, script, Script, kScriptOffset)
     732     6800339 : ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset)
     733     1428875 : SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset)
     734     1374071 : SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset)
     735     1384560 : SMI_ACCESSORS(JSMessageObject, error_level, kErrorLevelOffset)
     736             : 
     737   336875519 : ElementsKind JSObject::GetElementsKind() const {
     738             :   ElementsKind kind = map()->elements_kind();
     739             : #if VERIFY_HEAP && DEBUG
     740             :   FixedArrayBase fixed_array =
     741             :       FixedArrayBase::unchecked_cast(READ_FIELD(*this, kElementsOffset));
     742             : 
     743             :   // If a GC was caused while constructing this object, the elements
     744             :   // pointer may point to a one pointer filler map.
     745             :   if (ElementsAreSafeToExamine()) {
     746             :     Map map = fixed_array->map();
     747             :     if (IsSmiOrObjectElementsKind(kind)) {
     748             :       DCHECK(map == GetReadOnlyRoots().fixed_array_map() ||
     749             :              map == GetReadOnlyRoots().fixed_cow_array_map());
     750             :     } else if (IsDoubleElementsKind(kind)) {
     751             :       DCHECK(fixed_array->IsFixedDoubleArray() ||
     752             :              fixed_array == GetReadOnlyRoots().empty_fixed_array());
     753             :     } else if (kind == DICTIONARY_ELEMENTS) {
     754             :       DCHECK(fixed_array->IsFixedArray());
     755             :       DCHECK(fixed_array->IsDictionary());
     756             :     } else {
     757             :       DCHECK(kind > DICTIONARY_ELEMENTS);
     758             :     }
     759             :     DCHECK(!IsSloppyArgumentsElementsKind(kind) ||
     760             :            (elements()->IsFixedArray() && elements()->length() >= 2));
     761             :   }
     762             : #endif
     763   336875519 :   return kind;
     764             : }
     765             : 
     766     1568417 : bool JSObject::HasObjectElements() {
     767     3560889 :   return IsObjectElementsKind(GetElementsKind());
     768             : }
     769             : 
     770     2043129 : bool JSObject::HasSmiElements() { return IsSmiElementsKind(GetElementsKind()); }
     771             : 
     772     1350000 : bool JSObject::HasSmiOrObjectElements() {
     773     2704433 :   return IsSmiOrObjectElementsKind(GetElementsKind());
     774             : }
     775             : 
     776     1353067 : bool JSObject::HasDoubleElements() {
     777     3375614 :   return IsDoubleElementsKind(GetElementsKind());
     778             : }
     779             : 
     780     4951690 : bool JSObject::HasHoleyElements() {
     781     9906071 :   return IsHoleyElementsKind(GetElementsKind());
     782             : }
     783             : 
     784       90758 : bool JSObject::HasFastElements() {
     785     2295465 :   return IsFastElementsKind(GetElementsKind());
     786             : }
     787             : 
     788      123280 : bool JSObject::HasFastPackedElements() {
     789      246560 :   return IsFastPackedElementsKind(GetElementsKind());
     790             : }
     791             : 
     792         613 : bool JSObject::HasDictionaryElements() {
     793      506061 :   return GetElementsKind() == DICTIONARY_ELEMENTS;
     794             : }
     795             : 
     796         105 : bool JSObject::HasPackedElements() {
     797         105 :   return GetElementsKind() == PACKED_ELEMENTS;
     798             : }
     799             : 
     800             : bool JSObject::HasFastArgumentsElements() {
     801             :   return GetElementsKind() == FAST_SLOPPY_ARGUMENTS_ELEMENTS;
     802             : }
     803             : 
     804             : bool JSObject::HasSlowArgumentsElements() {
     805      165080 :   return GetElementsKind() == SLOW_SLOPPY_ARGUMENTS_ELEMENTS;
     806             : }
     807             : 
     808          63 : bool JSObject::HasSloppyArgumentsElements() {
     809    22388205 :   return IsSloppyArgumentsElementsKind(GetElementsKind());
     810             : }
     811             : 
     812             : bool JSObject::HasStringWrapperElements() {
     813      125725 :   return IsStringWrapperElementsKind(GetElementsKind());
     814             : }
     815             : 
     816             : bool JSObject::HasFastStringWrapperElements() {
     817     1082807 :   return GetElementsKind() == FAST_STRING_WRAPPER_ELEMENTS;
     818             : }
     819             : 
     820             : bool JSObject::HasSlowStringWrapperElements() {
     821      236233 :   return GetElementsKind() == SLOW_STRING_WRAPPER_ELEMENTS;
     822             : }
     823             : 
     824     1567796 : bool JSObject::HasFixedTypedArrayElements() {
     825             :   DCHECK(!elements().is_null());
     826     1567796 :   return map()->has_fixed_typed_array_elements();
     827             : }
     828             : 
     829             : #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype)            \
     830             :   bool JSObject::HasFixed##Type##Elements() {                          \
     831             :     FixedArrayBase array = elements();                                 \
     832             :     return array->map()->instance_type() == FIXED_##TYPE##_ARRAY_TYPE; \
     833             :   }
     834             : 
     835         900 : TYPED_ARRAYS(FIXED_TYPED_ELEMENTS_CHECK)
     836             : 
     837             : #undef FIXED_TYPED_ELEMENTS_CHECK
     838             : 
     839     6408026 : bool JSObject::HasNamedInterceptor() { return map()->has_named_interceptor(); }
     840             : 
     841     1229144 : bool JSObject::HasIndexedInterceptor() {
     842     1229144 :   return map()->has_indexed_interceptor();
     843             : }
     844             : 
     845             : void JSGlobalObject::set_global_dictionary(GlobalDictionary dictionary) {
     846             :   DCHECK(IsJSGlobalObject());
     847       91464 :   set_raw_properties_or_hash(dictionary);
     848             : }
     849             : 
     850    78887041 : GlobalDictionary JSGlobalObject::global_dictionary() {
     851             :   DCHECK(!HasFastProperties());
     852             :   DCHECK(IsJSGlobalObject());
     853    78887034 :   return GlobalDictionary::cast(raw_properties_or_hash());
     854             : }
     855             : 
     856             : NumberDictionary JSObject::element_dictionary() {
     857             :   DCHECK(HasDictionaryElements() || HasSlowStringWrapperElements());
     858             :   return NumberDictionary::cast(elements());
     859             : }
     860             : 
     861    15475789 : void JSReceiver::initialize_properties() {
     862             :   ReadOnlyRoots roots = GetReadOnlyRoots();
     863             :   DCHECK(!ObjectInYoungGeneration(roots.empty_fixed_array()));
     864             :   DCHECK(!ObjectInYoungGeneration(roots.empty_property_dictionary()));
     865    15475789 :   if (map()->is_dictionary_map()) {
     866          29 :     WRITE_FIELD(*this, kPropertiesOrHashOffset,
     867             :                 roots.empty_property_dictionary());
     868             :   } else {
     869    15475760 :     WRITE_FIELD(*this, kPropertiesOrHashOffset, roots.empty_fixed_array());
     870             :   }
     871    15475789 : }
     872             : 
     873   117387819 : bool JSReceiver::HasFastProperties() const {
     874             :   DCHECK(
     875             :       raw_properties_or_hash()->IsSmi() ||
     876             :       (raw_properties_or_hash()->IsDictionary() == map()->is_dictionary_map()));
     877   117387819 :   return !map()->is_dictionary_map();
     878             : }
     879             : 
     880     9864729 : NameDictionary JSReceiver::property_dictionary() const {
     881             :   DCHECK(!IsJSGlobalObject());
     882             :   DCHECK(!HasFastProperties());
     883             : 
     884             :   Object prop = raw_properties_or_hash();
     885     9864729 :   if (prop->IsSmi()) {
     886             :     return GetReadOnlyRoots().empty_property_dictionary();
     887             :   }
     888             : 
     889             :   return NameDictionary::cast(prop);
     890             : }
     891             : 
     892             : // TODO(gsathya): Pass isolate directly to this function and access
     893             : // the heap from this.
     894   118356401 : PropertyArray JSReceiver::property_array() const {
     895             :   DCHECK(HasFastProperties());
     896             : 
     897             :   Object prop = raw_properties_or_hash();
     898   236710791 :   if (prop->IsSmi() || prop == GetReadOnlyRoots().empty_fixed_array()) {
     899             :     return GetReadOnlyRoots().empty_property_array();
     900             :   }
     901             : 
     902             :   return PropertyArray::cast(prop);
     903             : }
     904             : 
     905      108649 : Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
     906             :                                     Handle<Name> name) {
     907             :   LookupIterator it = LookupIterator::PropertyOrElement(object->GetIsolate(),
     908      108649 :                                                         object, name, object);
     909      108649 :   return HasProperty(&it);
     910             : }
     911             : 
     912        7327 : Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
     913             :                                        uint32_t index) {
     914        7327 :   if (object->IsJSModuleNamespace()) return Just(false);
     915             : 
     916        7327 :   if (object->IsJSObject()) {  // Shortcut.
     917             :     LookupIterator it(object->GetIsolate(), object, index, object,
     918             :                       LookupIterator::OWN);
     919        7246 :     return HasProperty(&it);
     920             :   }
     921             : 
     922             :   Maybe<PropertyAttributes> attributes =
     923          81 :       JSReceiver::GetOwnPropertyAttributes(object, index);
     924          81 :   MAYBE_RETURN(attributes, Nothing<bool>());
     925          81 :   return Just(attributes.FromJust() != ABSENT);
     926             : }
     927             : 
     928     6896656 : Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
     929             :     Handle<JSReceiver> object, Handle<Name> name) {
     930             :   LookupIterator it = LookupIterator::PropertyOrElement(object->GetIsolate(),
     931     6896656 :                                                         object, name, object);
     932     6896656 :   return GetPropertyAttributes(&it);
     933             : }
     934             : 
     935      628175 : Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
     936             :     Handle<JSReceiver> object, Handle<Name> name) {
     937             :   LookupIterator it = LookupIterator::PropertyOrElement(
     938      628175 :       object->GetIsolate(), object, name, object, LookupIterator::OWN);
     939      628175 :   return GetPropertyAttributes(&it);
     940             : }
     941             : 
     942          81 : Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
     943             :     Handle<JSReceiver> object, uint32_t index) {
     944             :   LookupIterator it(object->GetIsolate(), object, index, object,
     945             :                     LookupIterator::OWN);
     946          81 :   return GetPropertyAttributes(&it);
     947             : }
     948             : 
     949     1745648 : Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
     950             :   LookupIterator it(object->GetIsolate(), object, index, object);
     951     1745648 :   return HasProperty(&it);
     952             : }
     953             : 
     954             : Maybe<PropertyAttributes> JSReceiver::GetElementAttributes(
     955             :     Handle<JSReceiver> object, uint32_t index) {
     956             :   Isolate* isolate = object->GetIsolate();
     957             :   LookupIterator it(isolate, object, index, object);
     958             :   return GetPropertyAttributes(&it);
     959             : }
     960             : 
     961             : Maybe<PropertyAttributes> JSReceiver::GetOwnElementAttributes(
     962             :     Handle<JSReceiver> object, uint32_t index) {
     963             :   Isolate* isolate = object->GetIsolate();
     964             :   LookupIterator it(isolate, object, index, object, LookupIterator::OWN);
     965             :   return GetPropertyAttributes(&it);
     966             : }
     967             : 
     968             : bool JSGlobalObject::IsDetached() {
     969             :   return global_proxy()->IsDetachedFrom(*this);
     970             : }
     971             : 
     972      495536 : bool JSGlobalProxy::IsDetachedFrom(JSGlobalObject global) const {
     973             :   const PrototypeIterator iter(this->GetIsolate(), *this);
     974      495535 :   return iter.GetCurrent() != global;
     975             : }
     976             : 
     977             : inline int JSGlobalProxy::SizeWithEmbedderFields(int embedder_field_count) {
     978             :   DCHECK_GE(embedder_field_count, 0);
     979       90393 :   return kSize + embedder_field_count * kEmbedderDataSlotSize;
     980             : }
     981             : 
     982       92373 : ACCESSORS(JSIteratorResult, value, Object, kValueOffset)
     983       90855 : ACCESSORS(JSIteratorResult, done, Object, kDoneOffset)
     984             : 
     985        1055 : ACCESSORS(JSAsyncFromSyncIterator, sync_iterator, JSReceiver,
     986             :           kSyncIteratorOffset)
     987        1055 : ACCESSORS(JSAsyncFromSyncIterator, next, Object, kNextOffset)
     988             : 
     989           0 : ACCESSORS(JSStringIterator, string, String, kStringOffset)
     990           0 : SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
     991             : 
     992     4130602 : static inline bool ShouldConvertToSlowElements(JSObject object,
     993             :                                                uint32_t capacity,
     994             :                                                uint32_t index,
     995             :                                                uint32_t* new_capacity) {
     996             :   STATIC_ASSERT(JSObject::kMaxUncheckedOldFastElementsLength <=
     997             :                 JSObject::kMaxUncheckedFastElementsLength);
     998     4130602 :   if (index < capacity) {
     999     3570336 :     *new_capacity = capacity;
    1000     3570336 :     return false;
    1001             :   }
    1002      560266 :   if (index - capacity >= JSObject::kMaxGap) return true;
    1003      617392 :   *new_capacity = JSObject::NewElementsCapacity(index + 1);
    1004             :   DCHECK_LT(index, *new_capacity);
    1005             :   // TODO(ulan): Check if it works with young large objects.
    1006      617392 :   if (*new_capacity <= JSObject::kMaxUncheckedOldFastElementsLength ||
    1007       44279 :       (*new_capacity <= JSObject::kMaxUncheckedFastElementsLength &&
    1008             :        ObjectInYoungGeneration(object))) {
    1009             :     return false;
    1010             :   }
    1011             :   // If the fast-case backing storage takes up much more memory than a
    1012             :   // dictionary backing storage would, the object should have slow elements.
    1013        2283 :   int used_elements = object->GetFastElementsUsage();
    1014             :   uint32_t size_threshold = NumberDictionary::kPreferFastElementsSizeFactor *
    1015        2283 :                             NumberDictionary::ComputeCapacity(used_elements) *
    1016        2283 :                             NumberDictionary::kEntrySize;
    1017        2283 :   return size_threshold <= *new_capacity;
    1018             : }
    1019             : 
    1020             : }  // namespace internal
    1021             : }  // namespace v8
    1022             : 
    1023             : #include "src/objects/object-macros-undef.h"
    1024             : 
    1025             : #endif  // V8_OBJECTS_JS_OBJECTS_INL_H_

Generated by: LCOV version 1.10