LCOV - code coverage report
Current view: top level - src - objects-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2282 2394 95.3 %
Date: 2017-04-26 Functions: 750 838 89.5 %

          Line data    Source code
       1             : // Copyright 2012 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             : // Review notes:
       6             : //
       7             : // - The use of macros in these inline functions may seem superfluous
       8             : // but it is absolutely needed to make sure gcc generates optimal
       9             : // code. gcc is not happy when attempting to inline too deep.
      10             : //
      11             : 
      12             : #ifndef V8_OBJECTS_INL_H_
      13             : #define V8_OBJECTS_INL_H_
      14             : 
      15             : #include "src/base/atomicops.h"
      16             : #include "src/base/bits.h"
      17             : #include "src/builtins/builtins.h"
      18             : #include "src/contexts-inl.h"
      19             : #include "src/conversions-inl.h"
      20             : #include "src/factory.h"
      21             : #include "src/feedback-vector-inl.h"
      22             : #include "src/field-index-inl.h"
      23             : #include "src/field-type.h"
      24             : #include "src/handles-inl.h"
      25             : #include "src/heap/heap-inl.h"
      26             : #include "src/heap/heap.h"
      27             : #include "src/isolate-inl.h"
      28             : #include "src/isolate.h"
      29             : #include "src/keys.h"
      30             : #include "src/layout-descriptor-inl.h"
      31             : #include "src/lookup-cache-inl.h"
      32             : #include "src/lookup.h"
      33             : #include "src/objects.h"
      34             : #include "src/objects/literal-objects.h"
      35             : #include "src/objects/module-info.h"
      36             : #include "src/objects/regexp-match-info.h"
      37             : #include "src/objects/scope-info.h"
      38             : #include "src/property.h"
      39             : #include "src/prototype.h"
      40             : #include "src/transitions-inl.h"
      41             : #include "src/v8memory.h"
      42             : 
      43             : // Has to be the last include (doesn't have include guards):
      44             : #include "src/objects/object-macros.h"
      45             : 
      46             : namespace v8 {
      47             : namespace internal {
      48             : 
      49           0 : PropertyDetails::PropertyDetails(Smi* smi) {
      50  3153647064 :   value_ = smi->value();
      51           0 : }
      52             : 
      53             : 
      54     5375921 : Smi* PropertyDetails::AsSmi() const {
      55             :   // Ensure the upper 2 bits have the same value by sign extending it. This is
      56             :   // necessary to be able to use the 31st bit of the property details.
      57   479037341 :   int value = value_ << 1;
      58   484413262 :   return Smi::FromInt(value >> 1);
      59             : }
      60             : 
      61             : 
      62       24272 : int PropertyDetails::field_width_in_words() const {
      63             :   DCHECK(location() == kField);
      64             :   if (!FLAG_unbox_double_fields) return 1;
      65             :   if (kDoubleSize == kPointerSize) return 1;
      66             :   return representation().IsDouble() ? kDoubleSize / kPointerSize : 1;
      67             : }
      68             : 
      69             : #define INT_ACCESSORS(holder, name, offset)                                   \
      70             :   int holder::name() const { return READ_INT_FIELD(this, offset); }           \
      71             :   void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); }
      72             : 
      73             : #define ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \
      74             :                            set_condition)                             \
      75             :   type* holder::name() const {                                        \
      76             :     DCHECK(get_condition);                                            \
      77             :     return type::cast(READ_FIELD(this, offset));                      \
      78             :   }                                                                   \
      79             :   void holder::set_##name(type* value, WriteBarrierMode mode) {       \
      80             :     DCHECK(set_condition);                                            \
      81             :     WRITE_FIELD(this, offset, value);                                 \
      82             :     CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode);  \
      83             :   }
      84             : #define ACCESSORS_CHECKED(holder, name, type, offset, condition) \
      85             :   ACCESSORS_CHECKED2(holder, name, type, offset, condition, condition)
      86             : 
      87             : #define ACCESSORS(holder, name, type, offset) \
      88             :   ACCESSORS_CHECKED(holder, name, type, offset, true)
      89             : 
      90             : // Getter that returns a Smi as an int and writes an int as a Smi.
      91             : #define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \
      92             :   int holder::name() const {                                   \
      93             :     DCHECK(condition);                                         \
      94             :     Object* value = READ_FIELD(this, offset);                  \
      95             :     return Smi::cast(value)->value();                          \
      96             :   }                                                            \
      97             :   void holder::set_##name(int value) {                         \
      98             :     DCHECK(condition);                                         \
      99             :     WRITE_FIELD(this, offset, Smi::FromInt(value));            \
     100             :   }
     101             : 
     102             : #define SMI_ACCESSORS(holder, name, offset) \
     103             :   SMI_ACCESSORS_CHECKED(holder, name, offset, true)
     104             : 
     105             : #define SYNCHRONIZED_SMI_ACCESSORS(holder, name, offset)    \
     106             :   int holder::synchronized_##name() const {                 \
     107             :     Object* value = ACQUIRE_READ_FIELD(this, offset);       \
     108             :     return Smi::cast(value)->value();                       \
     109             :   }                                                         \
     110             :   void holder::synchronized_set_##name(int value) {         \
     111             :     RELEASE_WRITE_FIELD(this, offset, Smi::FromInt(value)); \
     112             :   }
     113             : 
     114             : #define NOBARRIER_SMI_ACCESSORS(holder, name, offset)          \
     115             :   int holder::nobarrier_##name() const {                       \
     116             :     Object* value = NOBARRIER_READ_FIELD(this, offset);        \
     117             :     return Smi::cast(value)->value();                          \
     118             :   }                                                            \
     119             :   void holder::nobarrier_set_##name(int value) {               \
     120             :     NOBARRIER_WRITE_FIELD(this, offset, Smi::FromInt(value));  \
     121             :   }
     122             : 
     123             : #define BOOL_GETTER(holder, field, name, offset)           \
     124             :   bool holder::name() const {                              \
     125             :     return BooleanBit::get(field(), offset);               \
     126             :   }                                                        \
     127             : 
     128             : 
     129             : #define BOOL_ACCESSORS(holder, field, name, offset)        \
     130             :   bool holder::name() const {                              \
     131             :     return BooleanBit::get(field(), offset);               \
     132             :   }                                                        \
     133             :   void holder::set_##name(bool value) {                    \
     134             :     set_##field(BooleanBit::set(field(), offset, value));  \
     135             :   }
     136             : 
     137             : #define TYPE_CHECKER(type, instancetype)           \
     138             :   bool HeapObject::Is##type() const {              \
     139             :     return map()->instance_type() == instancetype; \
     140             :   }
     141             : 
     142        2010 : TYPE_CHECKER(BreakPointInfo, TUPLE2_TYPE)
     143    36796037 : TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE)
     144    54466136 : TYPE_CHECKER(BytecodeArray, BYTECODE_ARRAY_TYPE)
     145      256032 : TYPE_CHECKER(CallHandlerInfo, TUPLE2_TYPE)
     146    17668102 : TYPE_CHECKER(Cell, CELL_TYPE)
     147  1491041173 : TYPE_CHECKER(Code, CODE_TYPE)
     148     1923952 : TYPE_CHECKER(ConstantElementsPair, TUPLE2_TYPE)
     149     1990810 : TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE)
     150       54140 : TYPE_CHECKER(Foreign, FOREIGN_TYPE)
     151      303344 : TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE)
     152   399696487 : TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE)
     153      414030 : TYPE_CHECKER(JSArgumentsObject, JS_ARGUMENTS_TYPE)
     154   382287221 : TYPE_CHECKER(JSArray, JS_ARRAY_TYPE)
     155     3783255 : TYPE_CHECKER(JSArrayBuffer, JS_ARRAY_BUFFER_TYPE)
     156    26852563 : TYPE_CHECKER(JSAsyncGeneratorObject, JS_ASYNC_GENERATOR_OBJECT_TYPE)
     157     7243356 : TYPE_CHECKER(JSBoundFunction, JS_BOUND_FUNCTION_TYPE)
     158     5805273 : TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE)
     159      204662 : TYPE_CHECKER(JSDataView, JS_DATA_VIEW_TYPE)
     160     1360876 : TYPE_CHECKER(JSDate, JS_DATE_TYPE)
     161    10169736 : TYPE_CHECKER(JSError, JS_ERROR_TYPE)
     162   492175085 : TYPE_CHECKER(JSFunction, JS_FUNCTION_TYPE)
     163   351649288 : TYPE_CHECKER(JSGlobalObject, JS_GLOBAL_OBJECT_TYPE)
     164     1849051 : TYPE_CHECKER(JSMap, JS_MAP_TYPE)
     165    10391187 : TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE)
     166             : TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE)
     167             : TYPE_CHECKER(JSModuleNamespace, JS_MODULE_NAMESPACE_TYPE)
     168             : TYPE_CHECKER(JSPromiseCapability, JS_PROMISE_CAPABILITY_TYPE)
     169    10632270 : TYPE_CHECKER(JSPromise, JS_PROMISE_TYPE)
     170    17747281 : TYPE_CHECKER(JSRegExp, JS_REGEXP_TYPE)
     171     1731734 : TYPE_CHECKER(JSSet, JS_SET_TYPE)
     172    10393862 : TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE)
     173             : TYPE_CHECKER(JSAsyncFromSyncIterator, JS_ASYNC_FROM_SYNC_ITERATOR_TYPE)
     174             : TYPE_CHECKER(JSStringIterator, JS_STRING_ITERATOR_TYPE)
     175   567760026 : TYPE_CHECKER(JSTypedArray, JS_TYPED_ARRAY_TYPE)
     176     6665312 : TYPE_CHECKER(JSValue, JS_VALUE_TYPE)
     177      736901 : TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE)
     178      667923 : TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE)
     179   774564187 : TYPE_CHECKER(Map, MAP_TYPE)
     180      201237 : TYPE_CHECKER(MutableHeapNumber, MUTABLE_HEAP_NUMBER_TYPE)
     181   100666315 : TYPE_CHECKER(Oddball, ODDBALL_TYPE)
     182    13633981 : TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE)
     183    84513293 : TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE)
     184       56561 : TYPE_CHECKER(SourcePositionTableWithFrameCache, TUPLE2_TYPE)
     185   494950535 : TYPE_CHECKER(Symbol, SYMBOL_TYPE)
     186    30776036 : TYPE_CHECKER(TransitionArray, TRANSITION_ARRAY_TYPE)
     187      924671 : TYPE_CHECKER(TypeFeedbackInfo, TUPLE3_TYPE)
     188   182413790 : TYPE_CHECKER(WeakCell, WEAK_CELL_TYPE)
     189    13689420 : TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE)
     190             : 
     191             : #define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype, size) \
     192             :   TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE)
     193             : TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER)
     194             : #undef TYPED_ARRAY_TYPE_CHECKER
     195             : 
     196             : #undef TYPE_CHECKER
     197             : 
     198             : bool HeapObject::IsFixedArrayBase() const {
     199             :   return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase();
     200             : }
     201             : 
     202             : bool HeapObject::IsFixedArray() const {
     203   105492215 :   InstanceType instance_type = map()->instance_type();
     204    87055697 :   return instance_type == FIXED_ARRAY_TYPE ||
     205        9260 :          instance_type == TRANSITION_ARRAY_TYPE;
     206             : }
     207             : 
     208             : bool HeapObject::IsSloppyArgumentsElements() const { return IsFixedArray(); }
     209             : 
     210             : bool HeapObject::IsJSSloppyArgumentsObject() const {
     211             :   return IsJSArgumentsObject();
     212             : }
     213             : 
     214             : bool HeapObject::IsJSGeneratorObject() const {
     215    53933845 :   return map()->instance_type() == JS_GENERATOR_OBJECT_TYPE ||
     216             :          IsJSAsyncGeneratorObject();
     217             : }
     218             : 
     219             : bool HeapObject::IsBoilerplateDescription() const { return IsFixedArray(); }
     220             : 
     221             : // External objects are not extensible, so the map check is enough.
     222             : bool HeapObject::IsExternal() const {
     223           6 :   return map() == GetHeap()->external_map();
     224             : }
     225             : 
     226             : #define IS_TYPE_FUNCTION_DEF(type_)                               \
     227             :   bool Object::Is##type_() const {                                \
     228             :     return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \
     229             :   }
     230  8707114860 : HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF)
     231             : #undef IS_TYPE_FUNCTION_DEF
     232             : 
     233             : #define IS_TYPE_FUNCTION_DEF(Type, Value)             \
     234             :   bool Object::Is##Type(Isolate* isolate) const {     \
     235             :     return this == isolate->heap()->Value();          \
     236             :   }                                                   \
     237             :   bool HeapObject::Is##Type(Isolate* isolate) const { \
     238             :     return this == isolate->heap()->Value();          \
     239             :   }
     240  2361344014 : ODDBALL_LIST(IS_TYPE_FUNCTION_DEF)
     241             : #undef IS_TYPE_FUNCTION_DEF
     242             : 
     243             : bool Object::IsNullOrUndefined(Isolate* isolate) const {
     244   146760753 :   Heap* heap = isolate->heap();
     245   146775099 :   return this == heap->null_value() || this == heap->undefined_value();
     246             : }
     247             : 
     248             : bool HeapObject::IsNullOrUndefined(Isolate* isolate) const {
     249             :   Heap* heap = isolate->heap();
     250             :   return this == heap->null_value() || this == heap->undefined_value();
     251             : }
     252             : 
     253             : bool HeapObject::IsString() const {
     254  1854351131 :   return map()->instance_type() < FIRST_NONSTRING_TYPE;
     255             : }
     256             : 
     257             : bool HeapObject::IsName() const {
     258   221678411 :   return map()->instance_type() <= LAST_NAME_TYPE;
     259             : }
     260             : 
     261             : bool HeapObject::IsUniqueName() const {
     262     3682608 :   return IsInternalizedString() || IsSymbol();
     263             : }
     264             : 
     265      317969 : bool Name::IsUniqueName() const {
     266             :   uint32_t type = map()->instance_type();
     267   390950068 :   return (type & (kIsNotStringMask | kIsNotInternalizedMask)) !=
     268      317969 :          (kStringTag | kNotInternalizedTag);
     269             : }
     270             : 
     271             : bool HeapObject::IsFunction() const {
     272             :   STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
     273    66765249 :   return map()->instance_type() >= FIRST_FUNCTION_TYPE;
     274             : }
     275             : 
     276    26150311 : bool HeapObject::IsCallable() const { return map()->is_callable(); }
     277             : 
     278      166085 : bool HeapObject::IsConstructor() const { return map()->is_constructor(); }
     279             : 
     280             : bool HeapObject::IsTemplateInfo() const {
     281     1080138 :   return IsObjectTemplateInfo() || IsFunctionTemplateInfo();
     282             : }
     283             : 
     284             : bool HeapObject::IsInternalizedString() const {
     285   276694098 :   uint32_t type = map()->instance_type();
     286             :   STATIC_ASSERT(kNotInternalizedTag != 0);
     287   276694094 :   return (type & (kIsNotStringMask | kIsNotInternalizedMask)) ==
     288         956 :       (kStringTag | kInternalizedTag);
     289             : }
     290             : 
     291             : bool HeapObject::IsConsString() const {
     292   120237522 :   if (!IsString()) return false;
     293   119968635 :   return StringShape(String::cast(this)).IsCons();
     294             : }
     295             : 
     296             : bool HeapObject::IsThinString() const {
     297   318915053 :   if (!IsString()) return false;
     298   318915049 :   return StringShape(String::cast(this)).IsThin();
     299             : }
     300             : 
     301             : bool HeapObject::IsSlicedString() const {
     302    18418687 :   if (!IsString()) return false;
     303    18418687 :   return StringShape(String::cast(this)).IsSliced();
     304             : }
     305             : 
     306             : bool HeapObject::IsSeqString() const {
     307         315 :   if (!IsString()) return false;
     308         315 :   return StringShape(String::cast(this)).IsSequential();
     309             : }
     310             : 
     311             : bool HeapObject::IsSeqOneByteString() const {
     312   121849887 :   if (!IsString()) return false;
     313   235320139 :   return StringShape(String::cast(this)).IsSequential() &&
     314   113470253 :          String::cast(this)->IsOneByteRepresentation();
     315             : }
     316             : 
     317             : bool HeapObject::IsSeqTwoByteString() const {
     318      110315 :   if (!IsString()) return false;
     319      220445 :   return StringShape(String::cast(this)).IsSequential() &&
     320      110130 :          String::cast(this)->IsTwoByteRepresentation();
     321             : }
     322             : 
     323             : bool HeapObject::IsExternalString() const {
     324    25977793 :   if (!IsString()) return false;
     325    24580648 :   return StringShape(String::cast(this)).IsExternal();
     326             : }
     327             : 
     328             : bool HeapObject::IsExternalOneByteString() const {
     329   563115918 :   if (!IsString()) return false;
     330    84651380 :   return StringShape(String::cast(this)).IsExternal() &&
     331     1433771 :          String::cast(this)->IsOneByteRepresentation();
     332             : }
     333             : 
     334             : bool HeapObject::IsExternalTwoByteString() const {
     335     5265233 :   if (!IsString()) return false;
     336     5265328 :   return StringShape(String::cast(this)).IsExternal() &&
     337          95 :          String::cast(this)->IsTwoByteRepresentation();
     338             : }
     339             : 
     340   511181588 : bool Object::IsNumber() const { return IsSmi() || IsHeapNumber(); }
     341             : 
     342             : bool HeapObject::IsFiller() const {
     343   543976606 :   InstanceType instance_type = map()->instance_type();
     344   543976606 :   return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE;
     345             : }
     346             : 
     347             : bool HeapObject::IsFixedTypedArrayBase() const {
     348    18128442 :   InstanceType instance_type = map()->instance_type();
     349    18128443 :   return (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE &&
     350             :           instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE);
     351             : }
     352             : 
     353             : bool HeapObject::IsJSReceiver() const {
     354             :   STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
     355   387646329 :   return map()->instance_type() >= FIRST_JS_RECEIVER_TYPE;
     356             : }
     357             : 
     358             : bool HeapObject::IsJSObject() const {
     359             :   STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
     360   407014532 :   return map()->IsJSObjectMap();
     361             : }
     362             : 
     363   108924332 : bool HeapObject::IsJSProxy() const { return map()->IsJSProxyMap(); }
     364             : 
     365             : bool HeapObject::IsJSArrayIterator() const {
     366             :   InstanceType instance_type = map()->instance_type();
     367             :   return (instance_type >= FIRST_ARRAY_ITERATOR_TYPE &&
     368             :           instance_type <= LAST_ARRAY_ITERATOR_TYPE);
     369             : }
     370             : 
     371             : bool HeapObject::IsJSWeakCollection() const {
     372      411218 :   return IsJSWeakMap() || IsJSWeakSet();
     373             : }
     374             : 
     375           0 : bool HeapObject::IsJSCollection() const { return IsJSMap() || IsJSSet(); }
     376             : 
     377             : bool HeapObject::IsDescriptorArray() const { return IsFixedArray(); }
     378             : 
     379             : bool HeapObject::IsFrameArray() const { return IsFixedArray(); }
     380             : 
     381             : bool HeapObject::IsArrayList() const { return IsFixedArray(); }
     382             : 
     383             : bool HeapObject::IsRegExpMatchInfo() const { return IsFixedArray(); }
     384             : 
     385             : bool Object::IsLayoutDescriptor() const {
     386             :   return IsSmi() || IsFixedTypedArrayBase();
     387             : }
     388             : 
     389             : bool HeapObject::IsFeedbackVector() const {
     390    17717049 :   return map() == GetHeap()->feedback_vector_map();
     391             : }
     392             : 
     393             : bool HeapObject::IsFeedbackMetadata() const { return IsFixedArray(); }
     394             : 
     395             : bool HeapObject::IsDeoptimizationInputData() const {
     396             :   // Must be a fixed array.
     397             :   if (!IsFixedArray()) return false;
     398             : 
     399             :   // There's no sure way to detect the difference between a fixed array and
     400             :   // a deoptimization data array.  Since this is used for asserts we can
     401             :   // check that the length is zero or else the fixed size plus a multiple of
     402             :   // the entry size.
     403             :   int length = FixedArray::cast(this)->length();
     404             :   if (length == 0) return true;
     405             : 
     406             :   length -= DeoptimizationInputData::kFirstDeoptEntryIndex;
     407             :   return length >= 0 && length % DeoptimizationInputData::kDeoptEntrySize == 0;
     408             : }
     409             : 
     410             : bool HeapObject::IsDeoptimizationOutputData() const {
     411             :   if (!IsFixedArray()) return false;
     412             :   // There's actually no way to see the difference between a fixed array and
     413             :   // a deoptimization data array.  Since this is used for asserts we can check
     414             :   // that the length is plausible though.
     415             :   if (FixedArray::cast(this)->length() % 2 != 0) return false;
     416             :   return true;
     417             : }
     418             : 
     419             : bool HeapObject::IsHandlerTable() const {
     420             :   if (!IsFixedArray()) return false;
     421             :   // There's actually no way to see the difference between a fixed array and
     422             :   // a handler table array.
     423             :   return true;
     424             : }
     425             : 
     426             : bool HeapObject::IsTemplateList() const {
     427             :   if (!IsFixedArray()) return false;
     428             :   // There's actually no way to see the difference between a fixed array and
     429             :   // a template list.
     430             :   if (FixedArray::cast(this)->length() < 1) return false;
     431             :   return true;
     432             : }
     433             : 
     434             : bool HeapObject::IsDependentCode() const {
     435     1051520 :   if (!IsFixedArray()) return false;
     436             :   // There's actually no way to see the difference between a fixed array and
     437             :   // a dependent codes array.
     438             :   return true;
     439             : }
     440             : 
     441             : bool HeapObject::IsContext() const {
     442    47791961 :   Map* map = this->map();
     443    47791961 :   Heap* heap = GetHeap();
     444             :   return (
     445   117778947 :       map == heap->function_context_map() || map == heap->catch_context_map() ||
     446    81740722 :       map == heap->with_context_map() || map == heap->native_context_map() ||
     447    35002974 :       map == heap->block_context_map() || map == heap->module_context_map() ||
     448    82179542 :       map == heap->eval_context_map() || map == heap->script_context_map() ||
     449    11184137 :       map == heap->debug_evaluate_context_map());
     450             : }
     451             : 
     452             : bool HeapObject::IsNativeContext() const {
     453     3134521 :   return map() == GetHeap()->native_context_map();
     454             : }
     455             : 
     456             : bool HeapObject::IsScriptContextTable() const {
     457             :   return map() == GetHeap()->script_context_table_map();
     458             : }
     459             : 
     460             : bool HeapObject::IsScopeInfo() const {
     461     2133444 :   return map() == GetHeap()->scope_info_map();
     462             : }
     463             : 
     464             : bool HeapObject::IsModuleInfo() const {
     465        7405 :   return map() == GetHeap()->module_info_map();
     466             : }
     467             : 
     468             : template <>
     469             : inline bool Is<JSFunction>(Object* obj) {
     470             :   return obj->IsJSFunction();
     471             : }
     472             : 
     473             : bool HeapObject::IsAbstractCode() const {
     474    88177329 :   return IsBytecodeArray() || IsCode();
     475             : }
     476             : 
     477             : bool HeapObject::IsStringWrapper() const {
     478     4660351 :   return IsJSValue() && JSValue::cast(this)->value()->IsString();
     479             : }
     480             : 
     481             : bool HeapObject::IsBoolean() const {
     482    73668476 :   return IsOddball() &&
     483    17932109 :          ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0);
     484             : }
     485             : 
     486             : bool HeapObject::IsJSArrayBufferView() const {
     487      363564 :   return IsJSDataView() || IsJSTypedArray();
     488             : }
     489             : 
     490             : template <>
     491             : inline bool Is<JSArray>(Object* obj) {
     492             :   return obj->IsJSArray();
     493             : }
     494             : 
     495             : bool HeapObject::IsHashTable() const {
     496   300551015 :   return map() == GetHeap()->hash_table_map();
     497             : }
     498             : 
     499             : bool HeapObject::IsWeakHashTable() const { return IsHashTable(); }
     500             : 
     501             : bool HeapObject::IsDictionary() const {
     502   300481804 :   return IsHashTable() && this != GetHeap()->string_table();
     503             : }
     504             : 
     505             : bool Object::IsNameDictionary() const { return IsDictionary(); }
     506             : 
     507             : bool Object::IsGlobalDictionary() const { return IsDictionary(); }
     508             : 
     509             : bool Object::IsSeededNumberDictionary() const { return IsDictionary(); }
     510             : 
     511             : bool HeapObject::IsUnseededNumberDictionary() const {
     512       41117 :   return map() == GetHeap()->unseeded_number_dictionary_map();
     513             : }
     514             : 
     515             : bool HeapObject::IsStringTable() const { return IsHashTable(); }
     516             : 
     517             : bool HeapObject::IsStringSet() const { return IsHashTable(); }
     518             : 
     519             : bool HeapObject::IsObjectHashSet() const { return IsHashTable(); }
     520             : 
     521             : bool HeapObject::IsNormalizedMapCache() const {
     522             :   return NormalizedMapCache::IsNormalizedMapCache(this);
     523             : }
     524             : 
     525             : int NormalizedMapCache::GetIndex(Handle<Map> map) {
     526     1412102 :   return map->Hash() % NormalizedMapCache::kEntries;
     527             : }
     528             : 
     529             : bool NormalizedMapCache::IsNormalizedMapCache(const HeapObject* obj) {
     530             :   if (!obj->IsFixedArray()) return false;
     531             :   if (FixedArray::cast(obj)->length() != NormalizedMapCache::kEntries) {
     532             :     return false;
     533             :   }
     534             : #ifdef VERIFY_HEAP
     535             :   if (FLAG_verify_heap) {
     536             :     reinterpret_cast<NormalizedMapCache*>(const_cast<HeapObject*>(obj))
     537             :         ->NormalizedMapCacheVerify();
     538             :   }
     539             : #endif
     540             :   return true;
     541             : }
     542             : 
     543             : bool HeapObject::IsCompilationCacheTable() const { return IsHashTable(); }
     544             : 
     545             : bool HeapObject::IsCodeCacheHashTable() const { return IsHashTable(); }
     546             : 
     547             : bool HeapObject::IsMapCache() const { return IsHashTable(); }
     548             : 
     549             : bool HeapObject::IsObjectHashTable() const { return IsHashTable(); }
     550             : 
     551             : bool HeapObject::IsOrderedHashTable() const {
     552             :   return map() == GetHeap()->ordered_hash_table_map();
     553             : }
     554             : 
     555             : bool Object::IsOrderedHashSet() const { return IsOrderedHashTable(); }
     556             : 
     557             : bool Object::IsOrderedHashMap() const { return IsOrderedHashTable(); }
     558             : 
     559             : bool Object::IsPrimitive() const {
     560    15484315 :   return IsSmi() || HeapObject::cast(this)->map()->IsPrimitiveMap();
     561             : }
     562             : 
     563             : bool HeapObject::IsJSGlobalProxy() const {
     564   259677990 :   bool result = map()->instance_type() == JS_GLOBAL_PROXY_TYPE;
     565             :   DCHECK(!result || map()->is_access_check_needed());
     566             :   return result;
     567             : }
     568             : 
     569     4710001 : bool HeapObject::IsUndetectable() const { return map()->is_undetectable(); }
     570             : 
     571             : bool HeapObject::IsAccessCheckNeeded() const {
     572    65801137 :   if (IsJSGlobalProxy()) {
     573             :     const JSGlobalProxy* proxy = JSGlobalProxy::cast(this);
     574      130716 :     JSGlobalObject* global = proxy->GetIsolate()->context()->global_object();
     575      130716 :     return proxy->IsDetachedFrom(global);
     576             :   }
     577    65670421 :   return map()->is_access_check_needed();
     578             : }
     579             : 
     580             : bool HeapObject::IsStruct() const {
     581             :   switch (map()->instance_type()) {
     582             : #define MAKE_STRUCT_CASE(NAME, Name, name) \
     583             :   case NAME##_TYPE:                        \
     584             :     return true;
     585             :     STRUCT_LIST(MAKE_STRUCT_CASE)
     586             : #undef MAKE_STRUCT_CASE
     587             :     default:
     588             :       return false;
     589             :   }
     590             : }
     591             : 
     592             : #define MAKE_STRUCT_PREDICATE(NAME, Name, name)                  \
     593             :   bool Object::Is##Name() const {                                \
     594             :     return IsHeapObject() && HeapObject::cast(this)->Is##Name(); \
     595             :   }                                                              \
     596             :   bool HeapObject::Is##Name() const {                            \
     597             :     return map()->instance_type() == NAME##_TYPE;                \
     598             :   }
     599  1506907776 : STRUCT_LIST(MAKE_STRUCT_PREDICATE)
     600             : #undef MAKE_STRUCT_PREDICATE
     601             : 
     602     2126394 : double Object::Number() const {
     603             :   DCHECK(IsNumber());
     604             :   return IsSmi()
     605             :              ? static_cast<double>(reinterpret_cast<const Smi*>(this)->value())
     606   449166177 :              : reinterpret_cast<const HeapNumber*>(this)->value();
     607             : }
     608             : 
     609             : bool Object::IsNaN() const {
     610        9314 :   return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value());
     611             : }
     612             : 
     613             : bool Object::IsMinusZero() const {
     614        9012 :   return this->IsHeapNumber() &&
     615        4273 :          i::IsMinusZero(HeapNumber::cast(this)->value());
     616             : }
     617             : 
     618             : // ------------------------------------
     619             : // Cast operations
     620             : 
     621             : CAST_ACCESSOR(AbstractCode)
     622             : CAST_ACCESSOR(ArrayList)
     623             : CAST_ACCESSOR(BoilerplateDescription)
     624             : CAST_ACCESSOR(BreakPointInfo)
     625             : CAST_ACCESSOR(ByteArray)
     626             : CAST_ACCESSOR(BytecodeArray)
     627             : CAST_ACCESSOR(CallHandlerInfo)
     628             : CAST_ACCESSOR(Cell)
     629             : CAST_ACCESSOR(Code)
     630             : CAST_ACCESSOR(ConsString)
     631             : CAST_ACCESSOR(ConstantElementsPair)
     632             : CAST_ACCESSOR(DeoptimizationInputData)
     633             : CAST_ACCESSOR(DeoptimizationOutputData)
     634             : CAST_ACCESSOR(DependentCode)
     635             : CAST_ACCESSOR(DescriptorArray)
     636             : CAST_ACCESSOR(ExternalOneByteString)
     637             : CAST_ACCESSOR(ExternalString)
     638             : CAST_ACCESSOR(ExternalTwoByteString)
     639             : CAST_ACCESSOR(FixedArray)
     640             : CAST_ACCESSOR(FixedArrayBase)
     641             : CAST_ACCESSOR(FixedDoubleArray)
     642             : CAST_ACCESSOR(FixedTypedArrayBase)
     643             : CAST_ACCESSOR(Foreign)
     644             : CAST_ACCESSOR(GlobalDictionary)
     645             : CAST_ACCESSOR(HandlerTable)
     646             : CAST_ACCESSOR(HeapObject)
     647             : CAST_ACCESSOR(JSArgumentsObject);
     648             : CAST_ACCESSOR(JSArray)
     649             : CAST_ACCESSOR(JSArrayBuffer)
     650             : CAST_ACCESSOR(JSArrayBufferView)
     651             : CAST_ACCESSOR(JSBoundFunction)
     652             : CAST_ACCESSOR(JSDataView)
     653             : CAST_ACCESSOR(JSDate)
     654             : CAST_ACCESSOR(JSFunction)
     655             : CAST_ACCESSOR(JSGeneratorObject)
     656             : CAST_ACCESSOR(JSAsyncGeneratorObject)
     657             : CAST_ACCESSOR(JSGlobalObject)
     658             : CAST_ACCESSOR(JSGlobalProxy)
     659             : CAST_ACCESSOR(JSMap)
     660             : CAST_ACCESSOR(JSMapIterator)
     661             : CAST_ACCESSOR(JSMessageObject)
     662             : CAST_ACCESSOR(JSModuleNamespace)
     663             : CAST_ACCESSOR(JSObject)
     664             : CAST_ACCESSOR(JSProxy)
     665             : CAST_ACCESSOR(JSReceiver)
     666             : CAST_ACCESSOR(JSRegExp)
     667             : CAST_ACCESSOR(JSPromiseCapability)
     668             : CAST_ACCESSOR(JSPromise)
     669             : CAST_ACCESSOR(JSSet)
     670             : CAST_ACCESSOR(JSSetIterator)
     671             : CAST_ACCESSOR(JSSloppyArgumentsObject)
     672             : CAST_ACCESSOR(JSAsyncFromSyncIterator)
     673             : CAST_ACCESSOR(JSStringIterator)
     674             : CAST_ACCESSOR(JSArrayIterator)
     675             : CAST_ACCESSOR(JSTypedArray)
     676             : CAST_ACCESSOR(JSValue)
     677             : CAST_ACCESSOR(JSWeakCollection)
     678             : CAST_ACCESSOR(JSWeakMap)
     679             : CAST_ACCESSOR(JSWeakSet)
     680             : CAST_ACCESSOR(LayoutDescriptor)
     681             : CAST_ACCESSOR(Map)
     682             : CAST_ACCESSOR(ModuleInfo)
     683             : CAST_ACCESSOR(Name)
     684             : CAST_ACCESSOR(NameDictionary)
     685             : CAST_ACCESSOR(NormalizedMapCache)
     686             : CAST_ACCESSOR(Object)
     687             : CAST_ACCESSOR(ObjectHashTable)
     688             : CAST_ACCESSOR(ObjectHashSet)
     689             : CAST_ACCESSOR(Oddball)
     690             : CAST_ACCESSOR(OrderedHashMap)
     691             : CAST_ACCESSOR(OrderedHashSet)
     692             : CAST_ACCESSOR(PropertyCell)
     693             : CAST_ACCESSOR(TemplateList)
     694             : CAST_ACCESSOR(RegExpMatchInfo)
     695             : CAST_ACCESSOR(ScopeInfo)
     696             : CAST_ACCESSOR(SeededNumberDictionary)
     697             : CAST_ACCESSOR(SeqOneByteString)
     698             : CAST_ACCESSOR(SeqString)
     699             : CAST_ACCESSOR(SeqTwoByteString)
     700             : CAST_ACCESSOR(SharedFunctionInfo)
     701             : CAST_ACCESSOR(SourcePositionTableWithFrameCache)
     702             : CAST_ACCESSOR(SlicedString)
     703             : CAST_ACCESSOR(SloppyArgumentsElements)
     704             : CAST_ACCESSOR(Smi)
     705             : CAST_ACCESSOR(String)
     706             : CAST_ACCESSOR(StringSet)
     707             : CAST_ACCESSOR(StringTable)
     708             : CAST_ACCESSOR(Struct)
     709             : CAST_ACCESSOR(Symbol)
     710             : CAST_ACCESSOR(TemplateInfo)
     711             : CAST_ACCESSOR(ThinString)
     712             : CAST_ACCESSOR(TypeFeedbackInfo)
     713             : CAST_ACCESSOR(UnseededNumberDictionary)
     714             : CAST_ACCESSOR(WeakCell)
     715             : CAST_ACCESSOR(WeakFixedArray)
     716             : CAST_ACCESSOR(WeakHashTable)
     717             : 
     718             : #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name)
     719             : STRUCT_LIST(MAKE_STRUCT_CAST)
     720             : #undef MAKE_STRUCT_CAST
     721             : 
     722             : #undef CAST_ACCESSOR
     723             : 
     724             : bool Object::HasValidElements() {
     725             :   // Dictionary is covered under FixedArray.
     726             :   return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase();
     727             : }
     728             : 
     729             : bool Object::KeyEquals(Object* second) {
     730             :   Object* first = this;
     731             :   if (second->IsNumber()) {
     732             :     if (first->IsNumber()) return first->Number() == second->Number();
     733             :     Object* temp = first;
     734             :     first = second;
     735             :     second = temp;
     736             :   }
     737             :   if (first->IsNumber()) {
     738             :     DCHECK_LE(0, first->Number());
     739             :     uint32_t expected = static_cast<uint32_t>(first->Number());
     740             :     uint32_t index;
     741             :     return Name::cast(second)->AsArrayIndex(&index) && index == expected;
     742             :   }
     743             :   return Name::cast(first)->Equals(Name::cast(second));
     744             : }
     745             : 
     746    18292106 : bool Object::FilterKey(PropertyFilter filter) {
     747    18292106 :   if (IsSymbol()) {
     748      117093 :     if (filter & SKIP_SYMBOLS) return true;
     749       38964 :     if (Symbol::cast(this)->is_private()) return true;
     750             :   } else {
     751    18175013 :     if (filter & SKIP_STRINGS) return true;
     752             :   }
     753    14775777 :   return false;
     754             : }
     755             : 
     756    15745758 : Handle<Object> Object::NewStorageFor(Isolate* isolate, Handle<Object> object,
     757             :                                      Representation representation) {
     758    15745758 :   if (!representation.IsDouble()) return object;
     759        2821 :   Handle<HeapNumber> result = isolate->factory()->NewHeapNumber(MUTABLE);
     760        2821 :   if (object->IsUninitialized(isolate)) {
     761             :     result->set_value_as_bits(kHoleNanInt64);
     762        1819 :   } else if (object->IsMutableHeapNumber()) {
     763             :     // Ensure that all bits of the double value are preserved.
     764             :     result->set_value_as_bits(HeapNumber::cast(*object)->value_as_bits());
     765             :   } else {
     766             :     result->set_value(object->Number());
     767             :   }
     768        2821 :   return result;
     769             : }
     770             : 
     771    58139836 : Handle<Object> Object::WrapForRead(Isolate* isolate, Handle<Object> object,
     772             :                                    Representation representation) {
     773             :   DCHECK(!object->IsUninitialized(isolate));
     774    58139836 :   if (!representation.IsDouble()) {
     775             :     DCHECK(object->FitsRepresentation(representation));
     776    58130216 :     return object;
     777             :   }
     778        9620 :   return isolate->factory()->NewHeapNumber(HeapNumber::cast(*object)->value());
     779             : }
     780             : 
     781  1404510327 : StringShape::StringShape(const String* str)
     782  1404510327 :     : type_(str->map()->instance_type()) {
     783             :   set_valid();
     784             :   DCHECK((type_ & kIsNotStringMask) == kStringTag);
     785  1404510327 : }
     786             : 
     787             : StringShape::StringShape(Map* map) : type_(map->instance_type()) {
     788             :   set_valid();
     789             :   DCHECK((type_ & kIsNotStringMask) == kStringTag);
     790             : }
     791             : 
     792             : StringShape::StringShape(InstanceType t) : type_(static_cast<uint32_t>(t)) {
     793             :   set_valid();
     794             :   DCHECK((type_ & kIsNotStringMask) == kStringTag);
     795             : }
     796             : 
     797             : bool StringShape::IsInternalized() {
     798             :   DCHECK(valid());
     799             :   STATIC_ASSERT(kNotInternalizedTag != 0);
     800        8470 :   return (type_ & (kIsNotStringMask | kIsNotInternalizedMask)) ==
     801             :          (kStringTag | kInternalizedTag);
     802             : }
     803             : 
     804   114912185 : bool String::IsOneByteRepresentation() const {
     805             :   uint32_t type = map()->instance_type();
     806   259135400 :   return (type & kStringEncodingMask) == kOneByteStringTag;
     807             : }
     808             : 
     809      110225 : bool String::IsTwoByteRepresentation() const {
     810             :   uint32_t type = map()->instance_type();
     811      110253 :   return (type & kStringEncodingMask) == kTwoByteStringTag;
     812             : }
     813             : 
     814     6862241 : bool String::IsOneByteRepresentationUnderneath() {
     815             :   uint32_t type = map()->instance_type();
     816             :   STATIC_ASSERT(kIsIndirectStringTag != 0);
     817             :   STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0);
     818             :   DCHECK(IsFlat());
     819     6862241 :   switch (type & (kIsIndirectStringMask | kStringEncodingMask)) {
     820             :     case kOneByteStringTag:
     821             :       return true;
     822             :     case kTwoByteStringTag:
     823     2579029 :       return false;
     824             :     default:  // Cons or sliced string.  Need to go deeper.
     825        2781 :       return GetUnderlying()->IsOneByteRepresentation();
     826             :   }
     827             : }
     828             : 
     829             : bool String::IsTwoByteRepresentationUnderneath() {
     830             :   uint32_t type = map()->instance_type();
     831             :   STATIC_ASSERT(kIsIndirectStringTag != 0);
     832             :   STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0);
     833             :   DCHECK(IsFlat());
     834             :   switch (type & (kIsIndirectStringMask | kStringEncodingMask)) {
     835             :     case kOneByteStringTag:
     836             :       return false;
     837             :     case kTwoByteStringTag:
     838             :       return true;
     839             :     default:  // Cons or sliced string.  Need to go deeper.
     840             :       return GetUnderlying()->IsTwoByteRepresentation();
     841             :   }
     842             : }
     843             : 
     844    19310565 : bool String::HasOnlyOneByteChars() {
     845             :   uint32_t type = map()->instance_type();
     846    38620945 :   return (type & kOneByteDataHintMask) == kOneByteDataHintTag ||
     847    19310565 :          IsOneByteRepresentation();
     848             : }
     849             : 
     850             : bool StringShape::HasOnlyOneByteChars() {
     851       25653 :   return (type_ & kStringEncodingMask) == kOneByteStringTag ||
     852       25653 :          (type_ & kOneByteDataHintMask) == kOneByteDataHintTag;
     853             : }
     854             : 
     855   119968633 : bool StringShape::IsCons() {
     856   170341549 :   return (type_ & kStringRepresentationMask) == kConsStringTag;
     857             : }
     858             : 
     859   318915045 : bool StringShape::IsThin() {
     860   319615409 :   return (type_ & kStringRepresentationMask) == kThinStringTag;
     861             : }
     862             : 
     863    18418687 : bool StringShape::IsSliced() {
     864    19119051 :   return (type_ & kStringRepresentationMask) == kSlicedStringTag;
     865             : }
     866             : 
     867             : bool StringShape::IsIndirect() {
     868         926 :   return (type_ & kIsIndirectStringMask) == kIsIndirectStringTag;
     869             : }
     870             : 
     871   113063509 : bool StringShape::IsExternal() {
     872   113156347 :   return (type_ & kStringRepresentationMask) == kExternalStringTag;
     873             : }
     874             : 
     875   121960512 : bool StringShape::IsSequential() {
     876   121960512 :   return (type_ & kStringRepresentationMask) == kSeqStringTag;
     877             : }
     878             : 
     879             : StringRepresentationTag StringShape::representation_tag() {
     880   377494777 :   uint32_t tag = (type_ & kStringRepresentationMask);
     881             :   return static_cast<StringRepresentationTag>(tag);
     882             : }
     883             : 
     884   125882649 : uint32_t StringShape::encoding_tag() { return type_ & kStringEncodingMask; }
     885             : 
     886   712184027 : uint32_t StringShape::full_representation_tag() {
     887  1084641168 :   return (type_ & (kStringRepresentationMask | kStringEncodingMask));
     888             : }
     889             : 
     890             : STATIC_ASSERT((kStringRepresentationMask | kStringEncodingMask) ==
     891             :               Internals::kFullStringRepresentationMask);
     892             : 
     893             : STATIC_ASSERT(static_cast<uint32_t>(kStringEncodingMask) ==
     894             :               Internals::kStringEncodingMask);
     895             : 
     896             : bool StringShape::IsSequentialOneByte() {
     897             :   return full_representation_tag() == (kSeqStringTag | kOneByteStringTag);
     898             : }
     899             : 
     900             : bool StringShape::IsSequentialTwoByte() {
     901             :   return full_representation_tag() == (kSeqStringTag | kTwoByteStringTag);
     902             : }
     903             : 
     904             : bool StringShape::IsExternalOneByte() {
     905         116 :   return full_representation_tag() == (kExternalStringTag | kOneByteStringTag);
     906             : }
     907             : 
     908             : STATIC_ASSERT((kExternalStringTag | kOneByteStringTag) ==
     909             :               Internals::kExternalOneByteRepresentationTag);
     910             : 
     911             : STATIC_ASSERT(v8::String::ONE_BYTE_ENCODING == kOneByteStringTag);
     912             : 
     913             : bool StringShape::IsExternalTwoByte() {
     914         164 :   return full_representation_tag() == (kExternalStringTag | kTwoByteStringTag);
     915             : }
     916             : 
     917             : STATIC_ASSERT((kExternalStringTag | kTwoByteStringTag) ==
     918             :               Internals::kExternalTwoByteRepresentationTag);
     919             : 
     920             : STATIC_ASSERT(v8::String::TWO_BYTE_ENCODING == kTwoByteStringTag);
     921             : 
     922    15603390 : uc32 FlatStringReader::Get(int index) {
     923    15603390 :   if (is_one_byte_) {
     924    14739438 :     return Get<uint8_t>(index);
     925             :   } else {
     926      863952 :     return Get<uc16>(index);
     927             :   }
     928             : }
     929             : 
     930             : template <typename Char>
     931    38296272 : Char FlatStringReader::Get(int index) {
     932             :   DCHECK_EQ(is_one_byte_, sizeof(Char) == 1);
     933             :   DCHECK(0 <= index && index <= length_);
     934             :   if (sizeof(Char) == 1) {
     935    53018574 :     return static_cast<Char>(static_cast<const uint8_t*>(start_)[index]);
     936             :   } else {
     937      881088 :     return static_cast<Char>(static_cast<const uc16*>(start_)[index]);
     938             :   }
     939             : }
     940             : 
     941             : Handle<Object> StringTableShape::AsHandle(Isolate* isolate, HashTableKey* key) {
     942             :   return key->AsHandle(isolate);
     943             : }
     944             : 
     945             : template <typename Char>
     946           0 : class SequentialStringKey : public HashTableKey {
     947             :  public:
     948             :   explicit SequentialStringKey(Vector<const Char> string, uint32_t seed)
     949      205971 :       : string_(string), hash_field_(0), seed_(seed) {}
     950             : 
     951      261654 :   uint32_t Hash() override {
     952      261654 :     hash_field_ = StringHasher::HashSequentialString<Char>(
     953      261654 :         string_.start(), string_.length(), seed_);
     954             : 
     955      261654 :     uint32_t result = hash_field_ >> String::kHashShift;
     956             :     DCHECK(result != 0);  // Ensure that the hash value of 0 is never computed.
     957      261654 :     return result;
     958             :   }
     959             : 
     960      435600 :   uint32_t HashForObject(Object* other) override {
     961      435600 :     return String::cast(other)->Hash();
     962             :   }
     963             : 
     964             :   Vector<const Char> string_;
     965             :   uint32_t hash_field_;
     966             :   uint32_t seed_;
     967             : };
     968             : 
     969           0 : class OneByteStringKey : public SequentialStringKey<uint8_t> {
     970             :  public:
     971             :   OneByteStringKey(Vector<const uint8_t> str, uint32_t seed)
     972      205971 :       : SequentialStringKey<uint8_t>(str, seed) {}
     973             : 
     974      400132 :   bool IsMatch(Object* string) override {
     975      400132 :     return String::cast(string)->IsOneByteEqualTo(string_);
     976             :   }
     977             : 
     978             :   Handle<Object> AsHandle(Isolate* isolate) override;
     979             : };
     980             : 
     981           0 : class SeqOneByteSubStringKey : public HashTableKey {
     982             :  public:
     983             :   SeqOneByteSubStringKey(Handle<SeqOneByteString> string, int from, int length)
     984      115049 :       : string_(string), from_(from), length_(length) {
     985             :     DCHECK(string_->IsSeqOneByteString());
     986             :   }
     987             : 
     988             : // VS 2017 on official builds gives this spurious warning:
     989             : // warning C4789: buffer 'key' of size 16 bytes will be overrun; 4 bytes will
     990             : // be written starting at offset 16
     991             : // https://bugs.chromium.org/p/v8/issues/detail?id=6068
     992             : #if defined(V8_CC_MSVC)
     993             : #pragma warning(push)
     994             : #pragma warning(disable : 4789)
     995             : #endif
     996      230098 :   uint32_t Hash() override {
     997             :     DCHECK(length_ >= 0);
     998             :     DCHECK(from_ + length_ <= string_->length());
     999      230098 :     const uint8_t* chars = string_->GetChars() + from_;
    1000             :     hash_field_ = StringHasher::HashSequentialString(
    1001      230098 :         chars, length_, string_->GetHeap()->HashSeed());
    1002      230098 :     uint32_t result = hash_field_ >> String::kHashShift;
    1003             :     DCHECK(result != 0);  // Ensure that the hash value of 0 is never computed.
    1004      230098 :     return result;
    1005             :   }
    1006             : #if defined(V8_CC_MSVC)
    1007             : #pragma warning(pop)
    1008             : #endif
    1009             : 
    1010       64467 :   uint32_t HashForObject(Object* other) override {
    1011       64467 :     return String::cast(other)->Hash();
    1012             :   }
    1013             : 
    1014             :   bool IsMatch(Object* string) override;
    1015             :   Handle<Object> AsHandle(Isolate* isolate) override;
    1016             : 
    1017             :  private:
    1018             :   Handle<SeqOneByteString> string_;
    1019             :   int from_;
    1020             :   int length_;
    1021             :   uint32_t hash_field_;
    1022             : };
    1023             : 
    1024           0 : class TwoByteStringKey : public SequentialStringKey<uc16> {
    1025             :  public:
    1026             :   explicit TwoByteStringKey(Vector<const uc16> str, uint32_t seed)
    1027           0 :       : SequentialStringKey<uc16>(str, seed) {}
    1028             : 
    1029           0 :   bool IsMatch(Object* string) override {
    1030           0 :     return String::cast(string)->IsTwoByteEqualTo(string_);
    1031             :   }
    1032             : 
    1033             :   Handle<Object> AsHandle(Isolate* isolate) override;
    1034             : };
    1035             : 
    1036             : // Utf8StringKey carries a vector of chars as key.
    1037           0 : class Utf8StringKey : public HashTableKey {
    1038             :  public:
    1039             :   explicit Utf8StringKey(Vector<const char> string, uint32_t seed)
    1040    24519251 :       : string_(string), hash_field_(0), seed_(seed) {}
    1041             : 
    1042    57778127 :   bool IsMatch(Object* string) override {
    1043    57778127 :     return String::cast(string)->IsUtf8EqualTo(string_);
    1044             :   }
    1045             : 
    1046    24688102 :   uint32_t Hash() override {
    1047    24688102 :     if (hash_field_ != 0) return hash_field_ >> String::kHashShift;
    1048    24519251 :     hash_field_ = StringHasher::ComputeUtf8Hash(string_, seed_, &chars_);
    1049    24519251 :     uint32_t result = hash_field_ >> String::kHashShift;
    1050             :     DCHECK(result != 0);  // Ensure that the hash value of 0 is never computed.
    1051    24519251 :     return result;
    1052             :   }
    1053             : 
    1054       56401 :   uint32_t HashForObject(Object* other) override {
    1055       56401 :     return String::cast(other)->Hash();
    1056             :   }
    1057             : 
    1058      168851 :   Handle<Object> AsHandle(Isolate* isolate) override {
    1059      168851 :     if (hash_field_ == 0) Hash();
    1060             :     return isolate->factory()->NewInternalizedStringFromUtf8(string_, chars_,
    1061      168851 :                                                              hash_field_);
    1062             :   }
    1063             : 
    1064             :   Vector<const char> string_;
    1065             :   uint32_t hash_field_;
    1066             :   int chars_;  // Caches the number of characters when computing the hash code.
    1067             :   uint32_t seed_;
    1068             : };
    1069             : 
    1070    18500060 : Representation Object::OptimalRepresentation() {
    1071    18500060 :   if (!FLAG_track_fields) return Representation::Tagged();
    1072    18500060 :   if (IsSmi()) {
    1073             :     return Representation::Smi();
    1074    27420650 :   } else if (FLAG_track_double_fields && IsHeapNumber()) {
    1075             :     return Representation::Double();
    1076    27414667 :   } else if (FLAG_track_computed_fields &&
    1077             :              IsUninitialized(HeapObject::cast(this)->GetIsolate())) {
    1078             :     return Representation::None();
    1079    13267640 :   } else if (FLAG_track_heap_object_fields) {
    1080             :     DCHECK(IsHeapObject());
    1081             :     return Representation::HeapObject();
    1082             :   } else {
    1083             :     return Representation::Tagged();
    1084             :   }
    1085             : }
    1086             : 
    1087             : 
    1088    15212783 : ElementsKind Object::OptimalElementsKind() {
    1089    15212783 :   if (IsSmi()) return FAST_SMI_ELEMENTS;
    1090     3557071 :   if (IsNumber()) return FAST_DOUBLE_ELEMENTS;
    1091     1268447 :   return FAST_ELEMENTS;
    1092             : }
    1093             : 
    1094             : 
    1095    67618204 : bool Object::FitsRepresentation(Representation representation) {
    1096    67618204 :   if (FLAG_track_fields && representation.IsSmi()) {
    1097     6879336 :     return IsSmi();
    1098    60738868 :   } else if (FLAG_track_double_fields && representation.IsDouble()) {
    1099      119796 :     return IsMutableHeapNumber() || IsNumber();
    1100    60678970 :   } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) {
    1101    56408248 :     return IsHeapObject();
    1102     4270722 :   } else if (FLAG_track_fields && representation.IsNone()) {
    1103             :     return false;
    1104             :   }
    1105     3866109 :   return true;
    1106             : }
    1107             : 
    1108   147349547 : bool Object::ToUint32(uint32_t* value) {
    1109   147349547 :   if (IsSmi()) {
    1110             :     int num = Smi::cast(this)->value();
    1111    47616429 :     if (num < 0) return false;
    1112    47551558 :     *value = static_cast<uint32_t>(num);
    1113    47551558 :     return true;
    1114             :   }
    1115    99733118 :   if (IsHeapNumber()) {
    1116             :     double num = HeapNumber::cast(this)->value();
    1117       87775 :     return DoubleToUint32IfEqualToSelf(num, value);
    1118             :   }
    1119             :   return false;
    1120             : }
    1121             : 
    1122             : // static
    1123    14380164 : MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
    1124             :                                          Handle<Object> object) {
    1125    14380164 :   if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object);
    1126        8463 :   return ToObject(isolate, object, isolate->native_context());
    1127             : }
    1128             : 
    1129             : 
    1130             : // static
    1131    92260687 : MaybeHandle<Name> Object::ToName(Isolate* isolate, Handle<Object> input) {
    1132    92260687 :   if (input->IsName()) return Handle<Name>::cast(input);
    1133     4574649 :   return ConvertToName(isolate, input);
    1134             : }
    1135             : 
    1136             : // static
    1137      337215 : MaybeHandle<Object> Object::ToPropertyKey(Isolate* isolate,
    1138             :                                           Handle<Object> value) {
    1139      592689 :   if (value->IsSmi() || HeapObject::cast(*value)->IsName()) return value;
    1140         744 :   return ConvertToPropertyKey(isolate, value);
    1141             : }
    1142             : 
    1143             : // static
    1144     5143838 : MaybeHandle<Object> Object::ToPrimitive(Handle<Object> input,
    1145             :                                         ToPrimitiveHint hint) {
    1146     5143838 :   if (input->IsPrimitive()) return input;
    1147     4513792 :   return JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input), hint);
    1148             : }
    1149             : 
    1150             : // static
    1151    21170792 : MaybeHandle<Object> Object::ToNumber(Handle<Object> input) {
    1152    21170792 :   if (input->IsNumber()) return input;
    1153     2911918 :   return ConvertToNumber(HeapObject::cast(*input)->GetIsolate(), input);
    1154             : }
    1155             : 
    1156             : // static
    1157       11216 : MaybeHandle<Object> Object::ToInteger(Isolate* isolate, Handle<Object> input) {
    1158    17338986 :   if (input->IsSmi()) return input;
    1159       29747 :   return ConvertToInteger(isolate, input);
    1160             : }
    1161             : 
    1162             : // static
    1163             : MaybeHandle<Object> Object::ToInt32(Isolate* isolate, Handle<Object> input) {
    1164       10635 :   if (input->IsSmi()) return input;
    1165        1232 :   return ConvertToInt32(isolate, input);
    1166             : }
    1167             : 
    1168             : // static
    1169      533162 : MaybeHandle<Object> Object::ToUint32(Isolate* isolate, Handle<Object> input) {
    1170      533162 :   if (input->IsSmi()) return handle(Smi::cast(*input)->ToUint32Smi(), isolate);
    1171      533104 :   return ConvertToUint32(isolate, input);
    1172             : }
    1173             : 
    1174             : // static
    1175    29683680 : MaybeHandle<String> Object::ToString(Isolate* isolate, Handle<Object> input) {
    1176    29683680 :   if (input->IsString()) return Handle<String>::cast(input);
    1177     8540798 :   return ConvertToString(isolate, input);
    1178             : }
    1179             : 
    1180             : // static
    1181       72783 : MaybeHandle<Object> Object::ToLength(Isolate* isolate, Handle<Object> input) {
    1182       72783 :   if (input->IsSmi()) {
    1183      215175 :     int value = std::max(Smi::cast(*input)->value(), 0);
    1184             :     return handle(Smi::FromInt(value), isolate);
    1185             :   }
    1186        1058 :   return ConvertToLength(isolate, input);
    1187             : }
    1188             : 
    1189             : // static
    1190       24570 : MaybeHandle<Object> Object::ToIndex(Isolate* isolate, Handle<Object> input,
    1191             :                                     MessageTemplate::Template error_index) {
    1192       44537 :   if (input->IsSmi() && Smi::cast(*input)->value() >= 0) return input;
    1193        5303 :   return ConvertToIndex(isolate, input, error_index);
    1194             : }
    1195             : 
    1196    61262842 : bool Object::HasSpecificClassOf(String* name) {
    1197    61262842 :   return this->IsJSObject() && (JSObject::cast(this)->class_name() == name);
    1198             : }
    1199             : 
    1200     1730771 : MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
    1201             :                                         Handle<Name> name) {
    1202     1730771 :   LookupIterator it(object, name);
    1203     1730771 :   if (!it.IsFound()) return it.factory()->undefined_value();
    1204     1573866 :   return GetProperty(&it);
    1205             : }
    1206             : 
    1207    39945445 : MaybeHandle<Object> JSReceiver::GetProperty(Handle<JSReceiver> receiver,
    1208             :                                             Handle<Name> name) {
    1209    39945445 :   LookupIterator it(receiver, name, receiver);
    1210    39945445 :   if (!it.IsFound()) return it.factory()->undefined_value();
    1211    23169180 :   return Object::GetProperty(&it);
    1212             : }
    1213             : 
    1214        3656 : MaybeHandle<Object> Object::GetElement(Isolate* isolate, Handle<Object> object,
    1215             :                                        uint32_t index) {
    1216        3656 :   LookupIterator it(isolate, object, index);
    1217        3656 :   if (!it.IsFound()) return it.factory()->undefined_value();
    1218        3626 :   return GetProperty(&it);
    1219             : }
    1220             : 
    1221   150440070 : MaybeHandle<Object> JSReceiver::GetElement(Isolate* isolate,
    1222             :                                            Handle<JSReceiver> receiver,
    1223             :                                            uint32_t index) {
    1224             :   LookupIterator it(isolate, receiver, index, receiver);
    1225   150440070 :   if (!it.IsFound()) return it.factory()->undefined_value();
    1226    72328030 :   return Object::GetProperty(&it);
    1227             : }
    1228             : 
    1229     8349524 : Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object,
    1230             :                                            Handle<Name> name) {
    1231             :   LookupIterator it(object, name, object,
    1232     8349524 :                     LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
    1233    13518046 :   if (!it.IsFound()) return it.factory()->undefined_value();
    1234     3181002 :   return GetDataProperty(&it);
    1235             : }
    1236             : 
    1237      292602 : MaybeHandle<Object> Object::SetElement(Isolate* isolate, Handle<Object> object,
    1238             :                                        uint32_t index, Handle<Object> value,
    1239             :                                        LanguageMode language_mode) {
    1240      292602 :   LookupIterator it(isolate, object, index);
    1241      292602 :   MAYBE_RETURN_NULL(
    1242             :       SetProperty(&it, value, language_mode, MAY_BE_STORE_FROM_KEYED));
    1243             :   return value;
    1244             : }
    1245             : 
    1246     5050536 : MaybeHandle<Object> JSReceiver::GetPrototype(Isolate* isolate,
    1247             :                                              Handle<JSReceiver> receiver) {
    1248             :   // We don't expect access checks to be needed on JSProxy objects.
    1249             :   DCHECK(!receiver->IsAccessCheckNeeded() || receiver->IsJSObject());
    1250             :   PrototypeIterator iter(isolate, receiver, kStartAtReceiver,
    1251     5050536 :                          PrototypeIterator::END_AT_NON_HIDDEN);
    1252     5081977 :   do {
    1253     5082033 :     if (!iter.AdvanceFollowingProxies()) return MaybeHandle<Object>();
    1254     5081977 :   } while (!iter.IsAtEnd());
    1255             :   return PrototypeIterator::GetCurrent(iter);
    1256             : }
    1257             : 
    1258      201781 : MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
    1259             :                                             Handle<JSReceiver> receiver,
    1260             :                                             const char* name) {
    1261      201781 :   Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
    1262      201781 :   return GetProperty(receiver, str);
    1263             : }
    1264             : 
    1265             : // static
    1266        1529 : MUST_USE_RESULT MaybeHandle<FixedArray> JSReceiver::OwnPropertyKeys(
    1267             :     Handle<JSReceiver> object) {
    1268             :   return KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly,
    1269             :                                  ALL_PROPERTIES,
    1270        3832 :                                  GetKeysConversion::kConvertToString);
    1271             : }
    1272             : 
    1273     2360212 : bool JSObject::PrototypeHasNoElements(Isolate* isolate, JSObject* object) {
    1274             :   DisallowHeapAllocation no_gc;
    1275             :   HeapObject* prototype = HeapObject::cast(object->map()->prototype());
    1276     2360212 :   HeapObject* null = isolate->heap()->null_value();
    1277     2360212 :   HeapObject* empty = isolate->heap()->empty_fixed_array();
    1278     9401033 :   while (prototype != null) {
    1279             :     Map* map = prototype->map();
    1280     4701229 :     if (map->instance_type() <= LAST_CUSTOM_ELEMENTS_RECEIVER) return false;
    1281     4697573 :     if (JSObject::cast(prototype)->elements() != empty) return false;
    1282             :     prototype = HeapObject::cast(map->prototype());
    1283             :   }
    1284             :   return true;
    1285             : }
    1286             : 
    1287             : #define ACQUIRE_READ_FIELD(p, offset)           \
    1288             :   reinterpret_cast<Object*>(base::Acquire_Load( \
    1289             :       reinterpret_cast<const base::AtomicWord*>(FIELD_ADDR_CONST(p, offset))))
    1290             : 
    1291             : #define NOBARRIER_READ_FIELD(p, offset)           \
    1292             :   reinterpret_cast<Object*>(base::NoBarrier_Load( \
    1293             :       reinterpret_cast<const base::AtomicWord*>(FIELD_ADDR_CONST(p, offset))))
    1294             : 
    1295             : #define RELEASE_WRITE_FIELD(p, offset, value)                     \
    1296             :   base::Release_Store(                                            \
    1297             :       reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset)), \
    1298             :       reinterpret_cast<base::AtomicWord>(value));
    1299             : 
    1300             : #define NOBARRIER_WRITE_FIELD(p, offset, value)                   \
    1301             :   base::NoBarrier_Store(                                          \
    1302             :       reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset)), \
    1303             :       reinterpret_cast<base::AtomicWord>(value));
    1304             : 
    1305             : #define WRITE_BARRIER(heap, object, offset, value)          \
    1306             :   heap->incremental_marking()->RecordWrite(                 \
    1307             :       object, HeapObject::RawField(object, offset), value); \
    1308             :   heap->RecordWrite(object, offset, value);
    1309             : 
    1310             : #define FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(heap, array, start, length) \
    1311             :   do {                                                                 \
    1312             :     heap->RecordFixedArrayElements(array, start, length);              \
    1313             :     heap->incremental_marking()->IterateBlackObject(array);            \
    1314             :   } while (false)
    1315             : 
    1316             : #define CONDITIONAL_WRITE_BARRIER(heap, object, offset, value, mode) \
    1317             :   if (mode != SKIP_WRITE_BARRIER) {                                  \
    1318             :     if (mode == UPDATE_WRITE_BARRIER) {                              \
    1319             :       heap->incremental_marking()->RecordWrite(                      \
    1320             :           object, HeapObject::RawField(object, offset), value);      \
    1321             :     }                                                                \
    1322             :     heap->RecordWrite(object, offset, value);                        \
    1323             :   }
    1324             : 
    1325             : #define READ_DOUBLE_FIELD(p, offset) \
    1326             :   ReadDoubleValue(FIELD_ADDR_CONST(p, offset))
    1327             : 
    1328             : #define WRITE_DOUBLE_FIELD(p, offset, value) \
    1329             :   WriteDoubleValue(FIELD_ADDR(p, offset), value)
    1330             : 
    1331             : #define READ_INT_FIELD(p, offset) \
    1332             :   (*reinterpret_cast<const int*>(FIELD_ADDR_CONST(p, offset)))
    1333             : 
    1334             : #define WRITE_INT_FIELD(p, offset, value) \
    1335             :   (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)) = value)
    1336             : 
    1337             : #define READ_INTPTR_FIELD(p, offset) \
    1338             :   (*reinterpret_cast<const intptr_t*>(FIELD_ADDR_CONST(p, offset)))
    1339             : 
    1340             : #define WRITE_INTPTR_FIELD(p, offset, value) \
    1341             :   (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value)
    1342             : 
    1343             : #define READ_UINT8_FIELD(p, offset) \
    1344             :   (*reinterpret_cast<const uint8_t*>(FIELD_ADDR_CONST(p, offset)))
    1345             : 
    1346             : #define WRITE_UINT8_FIELD(p, offset, value) \
    1347             :   (*reinterpret_cast<uint8_t*>(FIELD_ADDR(p, offset)) = value)
    1348             : 
    1349             : #define READ_INT8_FIELD(p, offset) \
    1350             :   (*reinterpret_cast<const int8_t*>(FIELD_ADDR_CONST(p, offset)))
    1351             : 
    1352             : #define WRITE_INT8_FIELD(p, offset, value) \
    1353             :   (*reinterpret_cast<int8_t*>(FIELD_ADDR(p, offset)) = value)
    1354             : 
    1355             : #define READ_UINT16_FIELD(p, offset) \
    1356             :   (*reinterpret_cast<const uint16_t*>(FIELD_ADDR_CONST(p, offset)))
    1357             : 
    1358             : #define WRITE_UINT16_FIELD(p, offset, value) \
    1359             :   (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)) = value)
    1360             : 
    1361             : #define READ_INT16_FIELD(p, offset) \
    1362             :   (*reinterpret_cast<const int16_t*>(FIELD_ADDR_CONST(p, offset)))
    1363             : 
    1364             : #define WRITE_INT16_FIELD(p, offset, value) \
    1365             :   (*reinterpret_cast<int16_t*>(FIELD_ADDR(p, offset)) = value)
    1366             : 
    1367             : #define READ_UINT32_FIELD(p, offset) \
    1368             :   (*reinterpret_cast<const uint32_t*>(FIELD_ADDR_CONST(p, offset)))
    1369             : 
    1370             : #define WRITE_UINT32_FIELD(p, offset, value) \
    1371             :   (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value)
    1372             : 
    1373             : #define READ_INT32_FIELD(p, offset) \
    1374             :   (*reinterpret_cast<const int32_t*>(FIELD_ADDR_CONST(p, offset)))
    1375             : 
    1376             : #define WRITE_INT32_FIELD(p, offset, value) \
    1377             :   (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value)
    1378             : 
    1379             : #define READ_FLOAT_FIELD(p, offset) \
    1380             :   (*reinterpret_cast<const float*>(FIELD_ADDR_CONST(p, offset)))
    1381             : 
    1382             : #define WRITE_FLOAT_FIELD(p, offset, value) \
    1383             :   (*reinterpret_cast<float*>(FIELD_ADDR(p, offset)) = value)
    1384             : 
    1385             : #define READ_UINT64_FIELD(p, offset) \
    1386             :   (*reinterpret_cast<const uint64_t*>(FIELD_ADDR_CONST(p, offset)))
    1387             : 
    1388             : #define WRITE_UINT64_FIELD(p, offset, value) \
    1389             :   (*reinterpret_cast<uint64_t*>(FIELD_ADDR(p, offset)) = value)
    1390             : 
    1391             : #define READ_INT64_FIELD(p, offset) \
    1392             :   (*reinterpret_cast<const int64_t*>(FIELD_ADDR_CONST(p, offset)))
    1393             : 
    1394             : #define WRITE_INT64_FIELD(p, offset, value) \
    1395             :   (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)) = value)
    1396             : 
    1397             : #define READ_BYTE_FIELD(p, offset) \
    1398             :   (*reinterpret_cast<const byte*>(FIELD_ADDR_CONST(p, offset)))
    1399             : 
    1400             : #define NOBARRIER_READ_BYTE_FIELD(p, offset) \
    1401             :   static_cast<byte>(base::NoBarrier_Load(    \
    1402             :       reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset))))
    1403             : 
    1404             : #define WRITE_BYTE_FIELD(p, offset, value) \
    1405             :   (*reinterpret_cast<byte*>(FIELD_ADDR(p, offset)) = value)
    1406             : 
    1407             : #define NOBARRIER_WRITE_BYTE_FIELD(p, offset, value)           \
    1408             :   base::NoBarrier_Store(                                       \
    1409             :       reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset)), \
    1410             :       static_cast<base::Atomic8>(value));
    1411             : 
    1412    42100014 : Object** HeapObject::RawField(HeapObject* obj, int byte_offset) {
    1413   669380150 :   return reinterpret_cast<Object**>(FIELD_ADDR(obj, byte_offset));
    1414             : }
    1415             : 
    1416             : 
    1417             : MapWord MapWord::FromMap(const Map* map) {
    1418   849811772 :   return MapWord(reinterpret_cast<uintptr_t>(map));
    1419             : }
    1420             : 
    1421             : 
    1422             : Map* MapWord::ToMap() {
    1423 44628803021 :   return reinterpret_cast<Map*>(value_);
    1424             : }
    1425             : 
    1426         179 : bool MapWord::IsForwardingAddress() const {
    1427   632103666 :   return HAS_SMI_TAG(reinterpret_cast<Object*>(value_));
    1428             : }
    1429             : 
    1430             : 
    1431   116029442 : MapWord MapWord::FromForwardingAddress(HeapObject* object) {
    1432   117233418 :   Address raw = reinterpret_cast<Address>(object) - kHeapObjectTag;
    1433   117233418 :   return MapWord(reinterpret_cast<uintptr_t>(raw));
    1434             : }
    1435             : 
    1436             : 
    1437          88 : HeapObject* MapWord::ToForwardingAddress() {
    1438             :   DCHECK(IsForwardingAddress());
    1439   114973698 :   return HeapObject::FromAddress(reinterpret_cast<Address>(value_));
    1440             : }
    1441             : 
    1442             : 
    1443             : #ifdef VERIFY_HEAP
    1444             : void HeapObject::VerifyObjectField(int offset) {
    1445             :   VerifyPointer(READ_FIELD(this, offset));
    1446             : }
    1447             : 
    1448             : void HeapObject::VerifySmiField(int offset) {
    1449             :   CHECK(READ_FIELD(this, offset)->IsSmi());
    1450             : }
    1451             : #endif
    1452             : 
    1453             : 
    1454   967967638 : Heap* HeapObject::GetHeap() const {
    1455             :   Heap* heap = MemoryChunk::FromAddress(
    1456             :                    reinterpret_cast<Address>(const_cast<HeapObject*>(this)))
    1457 12138934204 :                    ->heap();
    1458             :   SLOW_DCHECK(heap != NULL);
    1459   967967638 :   return heap;
    1460             : }
    1461             : 
    1462             : 
    1463   826055262 : Isolate* HeapObject::GetIsolate() const {
    1464   826055262 :   return GetHeap()->isolate();
    1465             : }
    1466             : 
    1467             : 
    1468 12066111512 : Map* HeapObject::map() const {
    1469 12066111512 :   return map_word().ToMap();
    1470             : }
    1471             : 
    1472             : 
    1473    20948196 : void HeapObject::set_map(Map* value) {
    1474             :   set_map_word(MapWord::FromMap(value));
    1475    20948196 :   if (value != nullptr) {
    1476             :     // TODO(1600) We are passing NULL as a slot because maps can never be on
    1477             :     // evacuation candidate.
    1478    20948156 :     value->GetHeap()->incremental_marking()->RecordWrite(this, nullptr, value);
    1479             : #ifdef VERIFY_HEAP
    1480             :     value->GetHeap()->VerifyObjectLayoutChange(this, value);
    1481             : #endif
    1482             :   }
    1483    20948197 : }
    1484             : 
    1485             : 
    1486             : Map* HeapObject::synchronized_map() {
    1487             :   return synchronized_map_word().ToMap();
    1488             : }
    1489             : 
    1490             : 
    1491    64457919 : void HeapObject::synchronized_set_map(Map* value) {
    1492             :   synchronized_set_map_word(MapWord::FromMap(value));
    1493    64457919 :   if (value != nullptr) {
    1494             :     // TODO(1600) We are passing NULL as a slot because maps can never be on
    1495             :     // evacuation candidate.
    1496    64457922 :     value->GetHeap()->incremental_marking()->RecordWrite(this, nullptr, value);
    1497             : #ifdef VERIFY_HEAP
    1498             :     value->GetHeap()->VerifyObjectLayoutChange(this, value);
    1499             : #endif
    1500             :   }
    1501    64457919 : }
    1502             : 
    1503             : 
    1504             : void HeapObject::synchronized_set_map_no_write_barrier(Map* value) {
    1505             :   synchronized_set_map_word(MapWord::FromMap(value));
    1506             : }
    1507             : 
    1508             : 
    1509             : // Unsafe accessor omitting write barrier.
    1510             : void HeapObject::set_map_no_write_barrier(Map* value) {
    1511             :   set_map_word(MapWord::FromMap(value));
    1512             : }
    1513             : 
    1514             : 
    1515         179 : MapWord HeapObject::map_word() const {
    1516             :   return MapWord(
    1517 44473166075 :       reinterpret_cast<uintptr_t>(NOBARRIER_READ_FIELD(this, kMapOffset)));
    1518             : }
    1519             : 
    1520             : 
    1521   116029442 : void HeapObject::set_map_word(MapWord map_word) {
    1522   767976635 :   NOBARRIER_WRITE_FIELD(
    1523             :       this, kMapOffset, reinterpret_cast<Object*>(map_word.value_));
    1524   116029442 : }
    1525             : 
    1526             : 
    1527             : MapWord HeapObject::synchronized_map_word() const {
    1528             :   return MapWord(
    1529   629192154 :       reinterpret_cast<uintptr_t>(ACQUIRE_READ_FIELD(this, kMapOffset)));
    1530             : }
    1531             : 
    1532             : 
    1533             : void HeapObject::synchronized_set_map_word(MapWord map_word) {
    1534    64457919 :   RELEASE_WRITE_FIELD(
    1535             :       this, kMapOffset, reinterpret_cast<Object*>(map_word.value_));
    1536             : }
    1537             : 
    1538             : 
    1539  1137869477 : int HeapObject::Size() {
    1540  1137869477 :   return SizeFromMap(map());
    1541             : }
    1542             : 
    1543             : 
    1544        8364 : double HeapNumber::value() const {
    1545        8364 :   return READ_DOUBLE_FIELD(this, kValueOffset);
    1546             : }
    1547             : 
    1548             : 
    1549             : void HeapNumber::set_value(double value) {
    1550             :   WRITE_DOUBLE_FIELD(this, kValueOffset, value);
    1551             : }
    1552             : 
    1553             : uint64_t HeapNumber::value_as_bits() const {
    1554      108536 :   return READ_UINT64_FIELD(this, kValueOffset);
    1555             : }
    1556             : 
    1557             : void HeapNumber::set_value_as_bits(uint64_t bits) {
    1558       62666 :   WRITE_UINT64_FIELD(this, kValueOffset, bits);
    1559             : }
    1560             : 
    1561             : int HeapNumber::get_exponent() {
    1562             :   return ((READ_INT_FIELD(this, kExponentOffset) & kExponentMask) >>
    1563             :           kExponentShift) - kExponentBias;
    1564             : }
    1565             : 
    1566             : 
    1567             : int HeapNumber::get_sign() {
    1568             :   return READ_INT_FIELD(this, kExponentOffset) & kSignMask;
    1569             : }
    1570             : 
    1571   874092271 : ACCESSORS(JSReceiver, properties, FixedArray, kPropertiesOffset)
    1572             : 
    1573             : 
    1574             : Object** FixedArray::GetFirstElementAddress() {
    1575             :   return reinterpret_cast<Object**>(FIELD_ADDR(this, OffsetOfElementAt(0)));
    1576             : }
    1577             : 
    1578             : 
    1579             : bool FixedArray::ContainsOnlySmisOrHoles() {
    1580             :   Object* the_hole = GetHeap()->the_hole_value();
    1581             :   Object** current = GetFirstElementAddress();
    1582             :   for (int i = 0; i < length(); ++i) {
    1583             :     Object* candidate = *current++;
    1584             :     if (!candidate->IsSmi() && candidate != the_hole) return false;
    1585             :   }
    1586             :   return true;
    1587             : }
    1588             : 
    1589             : 
    1590     1549251 : FixedArrayBase* JSObject::elements() const {
    1591   596385504 :   Object* array = READ_FIELD(this, kElementsOffset);
    1592     1549251 :   return static_cast<FixedArrayBase*>(array);
    1593             : }
    1594             : 
    1595             : Context* SloppyArgumentsElements::context() {
    1596             :   return Context::cast(get(kContextIndex));
    1597             : }
    1598             : 
    1599             : FixedArray* SloppyArgumentsElements::arguments() {
    1600             :   return FixedArray::cast(get(kArgumentsIndex));
    1601             : }
    1602             : 
    1603             : void SloppyArgumentsElements::set_arguments(FixedArray* arguments) {
    1604       34062 :   set(kArgumentsIndex, arguments);
    1605             : }
    1606             : 
    1607             : uint32_t SloppyArgumentsElements::parameter_map_length() {
    1608      924771 :   return length() - kParameterMapStart;
    1609             : }
    1610             : 
    1611             : Object* SloppyArgumentsElements::get_mapped_entry(uint32_t entry) {
    1612      161202 :   return get(entry + kParameterMapStart);
    1613             : }
    1614             : 
    1615             : void SloppyArgumentsElements::set_mapped_entry(uint32_t entry, Object* object) {
    1616         834 :   set(entry + kParameterMapStart, object);
    1617             : }
    1618             : 
    1619     1593496 : void AllocationSite::Initialize() {
    1620     1593496 :   set_transition_info(Smi::kZero);
    1621     1593496 :   SetElementsKind(GetInitialFastElementsKind());
    1622     1593496 :   set_nested_site(Smi::kZero);
    1623             :   set_pretenure_data(0);
    1624             :   set_pretenure_create_count(0);
    1625     1593496 :   set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()),
    1626     1593496 :                      SKIP_WRITE_BARRIER);
    1627     1593496 : }
    1628             : 
    1629             : 
    1630             : bool AllocationSite::IsZombie() { return pretenure_decision() == kZombie; }
    1631             : 
    1632             : 
    1633             : bool AllocationSite::IsMaybeTenure() {
    1634             :   return pretenure_decision() == kMaybeTenure;
    1635             : }
    1636             : 
    1637             : 
    1638             : bool AllocationSite::PretenuringDecisionMade() {
    1639             :   return pretenure_decision() != kUndecided;
    1640             : }
    1641             : 
    1642             : 
    1643             : void AllocationSite::MarkZombie() {
    1644             :   DCHECK(!IsZombie());
    1645      324714 :   Initialize();
    1646             :   set_pretenure_decision(kZombie);
    1647             : }
    1648             : 
    1649             : 
    1650             : ElementsKind AllocationSite::GetElementsKind() {
    1651             :   DCHECK(!SitePointsToLiteral());
    1652             :   int value = Smi::cast(transition_info())->value();
    1653     1071060 :   return ElementsKindBits::decode(value);
    1654             : }
    1655             : 
    1656             : 
    1657     1617060 : void AllocationSite::SetElementsKind(ElementsKind kind) {
    1658             :   int value = Smi::cast(transition_info())->value();
    1659     3234120 :   set_transition_info(Smi::FromInt(ElementsKindBits::update(value, kind)),
    1660     1617060 :                       SKIP_WRITE_BARRIER);
    1661     1617060 : }
    1662             : 
    1663             : 
    1664             : bool AllocationSite::CanInlineCall() {
    1665             :   int value = Smi::cast(transition_info())->value();
    1666        1258 :   return DoNotInlineBit::decode(value) == 0;
    1667             : }
    1668             : 
    1669             : 
    1670        3506 : void AllocationSite::SetDoNotInlineCall() {
    1671             :   int value = Smi::cast(transition_info())->value();
    1672        7012 :   set_transition_info(Smi::FromInt(DoNotInlineBit::update(value, true)),
    1673        3506 :                       SKIP_WRITE_BARRIER);
    1674        3506 : }
    1675             : 
    1676             : 
    1677      650858 : bool AllocationSite::SitePointsToLiteral() {
    1678             :   // If transition_info is a smi, then it represents an ElementsKind
    1679             :   // for a constructed array. Otherwise, it must be a boilerplate
    1680             :   // for an object or array literal.
    1681      685381 :   return transition_info()->IsJSArray() || transition_info()->IsJSObject();
    1682             : }
    1683             : 
    1684             : 
    1685             : // Heuristic: We only need to create allocation site info if the boilerplate
    1686             : // elements kind is the initial elements kind.
    1687             : AllocationSiteMode AllocationSite::GetMode(
    1688             :     ElementsKind boilerplate_elements_kind) {
    1689     1514267 :   if (IsFastSmiElementsKind(boilerplate_elements_kind)) {
    1690             :     return TRACK_ALLOCATION_SITE;
    1691             :   }
    1692             : 
    1693             :   return DONT_TRACK_ALLOCATION_SITE;
    1694             : }
    1695             : 
    1696   151489692 : inline bool AllocationSite::CanTrack(InstanceType type) {
    1697   151489692 :   if (FLAG_turbo) {
    1698             :     // TurboFan doesn't care at all about String pretenuring feedback,
    1699             :     // so don't bother even trying to track that.
    1700    92316435 :     return type == JS_ARRAY_TYPE || type == JS_OBJECT_TYPE;
    1701             :   }
    1702    59173257 :   if (FLAG_allocation_site_pretenuring) {
    1703   118346514 :     return type == JS_ARRAY_TYPE ||
    1704   169396150 :         type == JS_OBJECT_TYPE ||
    1705   110222893 :         type < FIRST_NONSTRING_TYPE;
    1706             :   }
    1707           0 :   return type == JS_ARRAY_TYPE;
    1708             : }
    1709             : 
    1710             : 
    1711             : AllocationSite::PretenureDecision AllocationSite::pretenure_decision() {
    1712             :   int value = pretenure_data();
    1713     7703776 :   return PretenureDecisionBits::decode(value);
    1714             : }
    1715             : 
    1716             : 
    1717             : void AllocationSite::set_pretenure_decision(PretenureDecision decision) {
    1718             :   int value = pretenure_data();
    1719      655318 :   set_pretenure_data(PretenureDecisionBits::update(value, decision));
    1720             : }
    1721             : 
    1722             : 
    1723             : bool AllocationSite::deopt_dependent_code() {
    1724             :   int value = pretenure_data();
    1725        1041 :   return DeoptDependentCodeBit::decode(value);
    1726             : }
    1727             : 
    1728             : 
    1729             : void AllocationSite::set_deopt_dependent_code(bool deopt) {
    1730             :   int value = pretenure_data();
    1731         759 :   set_pretenure_data(DeoptDependentCodeBit::update(value, deopt));
    1732             : }
    1733             : 
    1734             : 
    1735             : int AllocationSite::memento_found_count() {
    1736             :   int value = pretenure_data();
    1737             :   return MementoFoundCountBits::decode(value);
    1738             : }
    1739             : 
    1740             : 
    1741             : inline void AllocationSite::set_memento_found_count(int count) {
    1742             :   int value = pretenure_data();
    1743             :   // Verify that we can count more mementos than we can possibly find in one
    1744             :   // new space collection.
    1745             :   DCHECK((GetHeap()->MaxSemiSpaceSize() /
    1746             :           (Heap::kMinObjectSizeInWords * kPointerSize +
    1747             :            AllocationMemento::kSize)) < MementoFoundCountBits::kMax);
    1748             :   DCHECK(count < MementoFoundCountBits::kMax);
    1749     3220308 :   set_pretenure_data(MementoFoundCountBits::update(value, count));
    1750             : }
    1751             : 
    1752             : 
    1753             : int AllocationSite::memento_create_count() { return pretenure_create_count(); }
    1754             : 
    1755             : 
    1756             : void AllocationSite::set_memento_create_count(int count) {
    1757             :   set_pretenure_create_count(count);
    1758             : }
    1759             : 
    1760             : 
    1761             : bool AllocationSite::IncrementMementoFoundCount(int increment) {
    1762     3212534 :   if (IsZombie()) return false;
    1763             : 
    1764             :   int value = memento_found_count();
    1765     3212534 :   set_memento_found_count(value + increment);
    1766     3212534 :   return memento_found_count() >= kPretenureMinimumCreated;
    1767             : }
    1768             : 
    1769             : 
    1770             : inline void AllocationSite::IncrementMementoCreateCount() {
    1771             :   DCHECK(FLAG_allocation_site_pretenuring);
    1772             :   int value = memento_create_count();
    1773     7458958 :   set_memento_create_count(value + 1);
    1774             : }
    1775             : 
    1776             : 
    1777        3887 : inline bool AllocationSite::MakePretenureDecision(
    1778             :     PretenureDecision current_decision,
    1779             :     double ratio,
    1780             :     bool maximum_size_scavenge) {
    1781             :   // Here we just allow state transitions from undecided or maybe tenure
    1782             :   // to don't tenure, maybe tenure, or tenure.
    1783        3887 :   if ((current_decision == kUndecided || current_decision == kMaybeTenure)) {
    1784        2945 :     if (ratio >= kPretenureRatio) {
    1785             :       // We just transition into tenure state when the semi-space was at
    1786             :       // maximum capacity.
    1787        2181 :       if (maximum_size_scavenge) {
    1788             :         set_deopt_dependent_code(true);
    1789             :         set_pretenure_decision(kTenure);
    1790             :         // Currently we just need to deopt when we make a state transition to
    1791             :         // tenure.
    1792         139 :         return true;
    1793             :       }
    1794             :       set_pretenure_decision(kMaybeTenure);
    1795             :     } else {
    1796             :       set_pretenure_decision(kDontTenure);
    1797             :     }
    1798             :   }
    1799             :   return false;
    1800             : }
    1801             : 
    1802             : 
    1803        3887 : inline bool AllocationSite::DigestPretenuringFeedback(
    1804             :     bool maximum_size_scavenge) {
    1805             :   bool deopt = false;
    1806             :   int create_count = memento_create_count();
    1807             :   int found_count = memento_found_count();
    1808        3887 :   bool minimum_mementos_created = create_count >= kPretenureMinimumCreated;
    1809             :   double ratio =
    1810           0 :       minimum_mementos_created || FLAG_trace_pretenuring_statistics ?
    1811        7774 :           static_cast<double>(found_count) / create_count : 0.0;
    1812             :   PretenureDecision current_decision = pretenure_decision();
    1813             : 
    1814        3887 :   if (minimum_mementos_created) {
    1815             :     deopt = MakePretenureDecision(
    1816        3887 :         current_decision, ratio, maximum_size_scavenge);
    1817             :   }
    1818             : 
    1819        3887 :   if (FLAG_trace_pretenuring_statistics) {
    1820             :     PrintIsolate(GetIsolate(),
    1821             :                  "pretenuring: AllocationSite(%p): (created, found, ratio) "
    1822             :                  "(%d, %d, %f) %s => %s\n",
    1823             :                  static_cast<void*>(this), create_count, found_count, ratio,
    1824             :                  PretenureDecisionName(current_decision),
    1825           0 :                  PretenureDecisionName(pretenure_decision()));
    1826             :   }
    1827             : 
    1828             :   // Clear feedback calculation fields until the next gc.
    1829             :   set_memento_found_count(0);
    1830             :   set_memento_create_count(0);
    1831        3887 :   return deopt;
    1832             : }
    1833             : 
    1834             : 
    1835     3618680 : bool AllocationMemento::IsValid() {
    1836     7237360 :   return allocation_site()->IsAllocationSite() &&
    1837     3618680 :          !AllocationSite::cast(allocation_site())->IsZombie();
    1838             : }
    1839             : 
    1840             : 
    1841             : AllocationSite* AllocationMemento::GetAllocationSite() {
    1842             :   DCHECK(IsValid());
    1843             :   return AllocationSite::cast(allocation_site());
    1844             : }
    1845             : 
    1846             : Address AllocationMemento::GetAllocationSiteUnchecked() {
    1847             :   return reinterpret_cast<Address>(allocation_site());
    1848             : }
    1849             : 
    1850      189268 : void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) {
    1851      189268 :   JSObject::ValidateElements(object);
    1852             :   ElementsKind elements_kind = object->map()->elements_kind();
    1853      189268 :   if (!IsFastObjectElementsKind(elements_kind)) {
    1854           0 :     if (IsFastHoleyElementsKind(elements_kind)) {
    1855           0 :       TransitionElementsKind(object, FAST_HOLEY_ELEMENTS);
    1856             :     } else {
    1857           0 :       TransitionElementsKind(object, FAST_ELEMENTS);
    1858             :     }
    1859             :   }
    1860      189268 : }
    1861             : 
    1862             : 
    1863     1285401 : void JSObject::EnsureCanContainElements(Handle<JSObject> object,
    1864             :                                         Object** objects,
    1865             :                                         uint32_t count,
    1866             :                                         EnsureElementsMode mode) {
    1867             :   ElementsKind current_kind = object->GetElementsKind();
    1868             :   ElementsKind target_kind = current_kind;
    1869             :   {
    1870             :     DisallowHeapAllocation no_allocation;
    1871             :     DCHECK(mode != ALLOW_COPIED_DOUBLE_ELEMENTS);
    1872             :     bool is_holey = IsFastHoleyElementsKind(current_kind);
    1873     2570802 :     if (current_kind == FAST_HOLEY_ELEMENTS) return;
    1874     1285401 :     Object* the_hole = object->GetHeap()->the_hole_value();
    1875    27925302 :     for (uint32_t i = 0; i < count; ++i) {
    1876    26639901 :       Object* current = *objects++;
    1877    26639901 :       if (current == the_hole) {
    1878             :         is_holey = true;
    1879             :         target_kind = GetHoleyElementsKind(target_kind);
    1880    24364381 :       } else if (!current->IsSmi()) {
    1881    13736480 :         if (mode == ALLOW_CONVERTED_DOUBLE_ELEMENTS && current->IsNumber()) {
    1882     1400641 :           if (IsFastSmiElementsKind(target_kind)) {
    1883         126 :             if (is_holey) {
    1884             :               target_kind = FAST_HOLEY_DOUBLE_ELEMENTS;
    1885             :             } else {
    1886             :               target_kind = FAST_DOUBLE_ELEMENTS;
    1887             :             }
    1888             :           }
    1889     5762997 :         } else if (is_holey) {
    1890             :           target_kind = FAST_HOLEY_ELEMENTS;
    1891             :           break;
    1892             :         } else {
    1893             :           target_kind = FAST_ELEMENTS;
    1894             :         }
    1895             :       }
    1896             :     }
    1897             :   }
    1898     1285401 :   if (target_kind != current_kind) {
    1899      142380 :     TransitionElementsKind(object, target_kind);
    1900             :   }
    1901             : }
    1902             : 
    1903             : 
    1904      141370 : void JSObject::EnsureCanContainElements(Handle<JSObject> object,
    1905             :                                         Handle<FixedArrayBase> elements,
    1906             :                                         uint32_t length,
    1907             :                                         EnsureElementsMode mode) {
    1908      141370 :   Heap* heap = object->GetHeap();
    1909      141370 :   if (elements->map() != heap->fixed_double_array_map()) {
    1910             :     DCHECK(elements->map() == heap->fixed_array_map() ||
    1911             :            elements->map() == heap->fixed_cow_array_map());
    1912      141370 :     if (mode == ALLOW_COPIED_DOUBLE_ELEMENTS) {
    1913             :       mode = DONT_ALLOW_DOUBLE_ELEMENTS;
    1914             :     }
    1915             :     Object** objects =
    1916      141370 :         Handle<FixedArray>::cast(elements)->GetFirstElementAddress();
    1917      141370 :     EnsureCanContainElements(object, objects, length, mode);
    1918      141370 :     return;
    1919             :   }
    1920             : 
    1921             :   DCHECK(mode == ALLOW_COPIED_DOUBLE_ELEMENTS);
    1922           0 :   if (object->GetElementsKind() == FAST_HOLEY_SMI_ELEMENTS) {
    1923           0 :     TransitionElementsKind(object, FAST_HOLEY_DOUBLE_ELEMENTS);
    1924           0 :   } else if (object->GetElementsKind() == FAST_SMI_ELEMENTS) {
    1925             :     Handle<FixedDoubleArray> double_array =
    1926             :         Handle<FixedDoubleArray>::cast(elements);
    1927           0 :     for (uint32_t i = 0; i < length; ++i) {
    1928           0 :       if (double_array->is_the_hole(i)) {
    1929           0 :         TransitionElementsKind(object, FAST_HOLEY_DOUBLE_ELEMENTS);
    1930             :         return;
    1931             :       }
    1932             :     }
    1933           0 :     TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS);
    1934             :   }
    1935             : }
    1936             : 
    1937             : 
    1938     1283344 : void JSObject::SetMapAndElements(Handle<JSObject> object,
    1939             :                                  Handle<Map> new_map,
    1940             :                                  Handle<FixedArrayBase> value) {
    1941     1283344 :   JSObject::MigrateToMap(object, new_map);
    1942             :   DCHECK((object->map()->has_fast_smi_or_object_elements() ||
    1943             :           (*value == object->GetHeap()->empty_fixed_array()) ||
    1944             :           object->map()->has_fast_string_wrapper_elements()) ==
    1945             :          (value->map() == object->GetHeap()->fixed_array_map() ||
    1946             :           value->map() == object->GetHeap()->fixed_cow_array_map()));
    1947             :   DCHECK((*value == object->GetHeap()->empty_fixed_array()) ||
    1948             :          (object->map()->has_fast_double_elements() ==
    1949             :           value->IsFixedDoubleArray()));
    1950     1283344 :   object->set_elements(*value);
    1951     1283344 : }
    1952             : 
    1953             : 
    1954    31042230 : void JSObject::set_elements(FixedArrayBase* value, WriteBarrierMode mode) {
    1955    31042230 :   WRITE_FIELD(this, kElementsOffset, value);
    1956    86521890 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kElementsOffset, value, mode);
    1957    31042230 : }
    1958             : 
    1959             : 
    1960    75706868 : void JSObject::initialize_elements() {
    1961    75706868 :   FixedArrayBase* elements = map()->GetInitialElements();
    1962    75706868 :   WRITE_FIELD(this, kElementsOffset, elements);
    1963    75706868 : }
    1964             : 
    1965             : 
    1966      723347 : InterceptorInfo* JSObject::GetIndexedInterceptor() {
    1967      723347 :   return map()->GetIndexedInterceptor();
    1968             : }
    1969             : 
    1970     1764738 : InterceptorInfo* JSObject::GetNamedInterceptor() {
    1971     1764738 :   return map()->GetNamedInterceptor();
    1972             : }
    1973             : 
    1974             : InterceptorInfo* Map::GetNamedInterceptor() {
    1975             :   DCHECK(has_named_interceptor());
    1976     1764738 :   FunctionTemplateInfo* info = GetFunctionTemplateInfo();
    1977             :   return InterceptorInfo::cast(info->named_property_handler());
    1978             : }
    1979             : 
    1980             : InterceptorInfo* Map::GetIndexedInterceptor() {
    1981             :   DCHECK(has_indexed_interceptor());
    1982      723569 :   FunctionTemplateInfo* info = GetFunctionTemplateInfo();
    1983             :   return InterceptorInfo::cast(info->indexed_property_handler());
    1984             : }
    1985             : 
    1986             : double Oddball::to_number_raw() const {
    1987             :   return READ_DOUBLE_FIELD(this, kToNumberRawOffset);
    1988             : }
    1989             : 
    1990             : void Oddball::set_to_number_raw(double value) {
    1991             :   WRITE_DOUBLE_FIELD(this, kToNumberRawOffset, value);
    1992             : }
    1993             : 
    1994             : void Oddball::set_to_number_raw_as_bits(uint64_t bits) {
    1995          86 :   WRITE_UINT64_FIELD(this, kToNumberRawOffset, bits);
    1996             : }
    1997             : 
    1998     2565356 : ACCESSORS(Oddball, to_string, String, kToStringOffset)
    1999     3357489 : ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
    2000        3572 : ACCESSORS(Oddball, type_of, String, kTypeOfOffset)
    2001             : 
    2002             : 
    2003    17932109 : byte Oddball::kind() const {
    2004    68018514 :   return Smi::cast(READ_FIELD(this, kKindOffset))->value();
    2005             : }
    2006             : 
    2007             : 
    2008             : void Oddball::set_kind(byte value) {
    2009         688 :   WRITE_FIELD(this, kKindOffset, Smi::FromInt(value));
    2010             : }
    2011             : 
    2012             : 
    2013             : // static
    2014     3356070 : Handle<Object> Oddball::ToNumber(Handle<Oddball> input) {
    2015     3356070 :   return handle(input->to_number(), input->GetIsolate());
    2016             : }
    2017             : 
    2018             : 
    2019    92343886 : ACCESSORS(Cell, value, Object, kValueOffset)
    2020    12667515 : ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset)
    2021   285351334 : ACCESSORS(PropertyCell, property_details_raw, Object, kDetailsOffset)
    2022   122616896 : ACCESSORS(PropertyCell, value, Object, kValueOffset)
    2023             : 
    2024             : 
    2025             : PropertyDetails PropertyCell::property_details() {
    2026             :   return PropertyDetails(Smi::cast(property_details_raw()));
    2027             : }
    2028             : 
    2029             : 
    2030             : void PropertyCell::set_property_details(PropertyDetails details) {
    2031    29650174 :   set_property_details_raw(details.AsSmi());
    2032             : }
    2033             : 
    2034             : 
    2035   539046374 : Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); }
    2036             : 
    2037             : 
    2038             : void WeakCell::clear() {
    2039             :   // Either the garbage collector is clearing the cell or we are simply
    2040             :   // initializing the root empty weak cell.
    2041             :   DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT ||
    2042             :          this == GetHeap()->empty_weak_cell());
    2043     2590526 :   WRITE_FIELD(this, kValueOffset, Smi::kZero);
    2044             : }
    2045             : 
    2046             : 
    2047    39341904 : void WeakCell::initialize(HeapObject* val) {
    2048    39341904 :   WRITE_FIELD(this, kValueOffset, val);
    2049             :   // We just have to execute the generational barrier here because we never
    2050             :   // mark through a weak cell and collect evacuation candidates when we process
    2051             :   // all weak cells.
    2052             :   WriteBarrierMode mode =
    2053             :       ObjectMarking::IsBlack(this, MarkingState::Internal(this))
    2054             :           ? UPDATE_WRITE_BARRIER
    2055    39341897 :           : UPDATE_WEAK_WRITE_BARRIER;
    2056    78804486 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kValueOffset, val, mode);
    2057    39341890 : }
    2058             : 
    2059   180745518 : bool WeakCell::cleared() const { return value() == Smi::kZero; }
    2060             : 
    2061   146847990 : Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); }
    2062             : 
    2063             : 
    2064   149206189 : void WeakCell::set_next(Object* val, WriteBarrierMode mode) {
    2065   149206189 :   WRITE_FIELD(this, kNextOffset, val);
    2066   149206189 :   if (mode == UPDATE_WRITE_BARRIER) {
    2067     3044292 :     WRITE_BARRIER(GetHeap(), this, kNextOffset, val);
    2068             :   }
    2069   149206189 : }
    2070             : 
    2071             : 
    2072             : void WeakCell::clear_next(Object* the_hole_value) {
    2073             :   DCHECK_EQ(GetHeap()->the_hole_value(), the_hole_value);
    2074    93766422 :   set_next(the_hole_value, SKIP_WRITE_BARRIER);
    2075             : }
    2076             : 
    2077   180745511 : bool WeakCell::next_cleared() { return next()->IsTheHole(GetIsolate()); }
    2078             : 
    2079    38484440 : int JSObject::GetHeaderSize() { return GetHeaderSize(map()->instance_type()); }
    2080             : 
    2081             : 
    2082    22460232 : int JSObject::GetHeaderSize(InstanceType type) {
    2083             :   // Check for the most common kind of JavaScript object before
    2084             :   // falling into the generic switch. This speeds up the internal
    2085             :   // field operations considerably on average.
    2086    22460232 :   if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize;
    2087     3534512 :   switch (type) {
    2088             :     case JS_API_OBJECT_TYPE:
    2089             :     case JS_SPECIAL_API_OBJECT_TYPE:
    2090             :       return JSObject::kHeaderSize;
    2091             :     case JS_GENERATOR_OBJECT_TYPE:
    2092       18006 :       return JSGeneratorObject::kSize;
    2093             :     case JS_ASYNC_GENERATOR_OBJECT_TYPE:
    2094        1736 :       return JSAsyncGeneratorObject::kSize;
    2095             :     case JS_GLOBAL_PROXY_TYPE:
    2096          12 :       return JSGlobalProxy::kSize;
    2097             :     case JS_GLOBAL_OBJECT_TYPE:
    2098         661 :       return JSGlobalObject::kSize;
    2099             :     case JS_BOUND_FUNCTION_TYPE:
    2100          18 :       return JSBoundFunction::kSize;
    2101             :     case JS_FUNCTION_TYPE:
    2102     1298305 :       return JSFunction::kSize;
    2103             :     case JS_VALUE_TYPE:
    2104        6832 :       return JSValue::kSize;
    2105             :     case JS_DATE_TYPE:
    2106        1456 :       return JSDate::kSize;
    2107             :     case JS_ARRAY_TYPE:
    2108      100240 :       return JSArray::kSize;
    2109             :     case JS_ARRAY_BUFFER_TYPE:
    2110      266974 :       return JSArrayBuffer::kSize;
    2111             :     case JS_TYPED_ARRAY_TYPE:
    2112        9942 :       return JSTypedArray::kSize;
    2113             :     case JS_DATA_VIEW_TYPE:
    2114       11442 :       return JSDataView::kSize;
    2115             :     case JS_SET_TYPE:
    2116        1473 :       return JSSet::kSize;
    2117             :     case JS_MAP_TYPE:
    2118        1787 :       return JSMap::kSize;
    2119             :     case JS_SET_ITERATOR_TYPE:
    2120           0 :       return JSSetIterator::kSize;
    2121             :     case JS_MAP_ITERATOR_TYPE:
    2122           0 :       return JSMapIterator::kSize;
    2123             :     case JS_WEAK_MAP_TYPE:
    2124        1208 :       return JSWeakMap::kSize;
    2125             :     case JS_WEAK_SET_TYPE:
    2126         974 :       return JSWeakSet::kSize;
    2127             :     case JS_PROMISE_CAPABILITY_TYPE:
    2128           0 :       return JSPromiseCapability::kSize;
    2129             :     case JS_PROMISE_TYPE:
    2130         320 :       return JSPromise::kSize;
    2131             :     case JS_REGEXP_TYPE:
    2132      121406 :       return JSRegExp::kSize;
    2133             :     case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
    2134             :       return JSObject::kHeaderSize;
    2135             :     case JS_MESSAGE_OBJECT_TYPE:
    2136           0 :       return JSMessageObject::kSize;
    2137             :     case JS_ARGUMENTS_TYPE:
    2138        3152 :       return JSArgumentsObject::kHeaderSize;
    2139             :     case JS_ERROR_TYPE:
    2140             :       return JSObject::kHeaderSize;
    2141             :     case JS_STRING_ITERATOR_TYPE:
    2142           0 :       return JSStringIterator::kSize;
    2143             :     case JS_MODULE_NAMESPACE_TYPE:
    2144         172 :       return JSModuleNamespace::kHeaderSize;
    2145             :     default:
    2146          30 :       if (type >= FIRST_ARRAY_ITERATOR_TYPE &&
    2147             :           type <= LAST_ARRAY_ITERATOR_TYPE) {
    2148             :         return JSArrayIterator::kSize;
    2149             :       }
    2150           0 :       UNREACHABLE();
    2151             :       return 0;
    2152             :   }
    2153             : }
    2154             : 
    2155             : inline bool IsSpecialReceiverInstanceType(InstanceType instance_type) {
    2156   833204397 :   return instance_type <= LAST_SPECIAL_RECEIVER_TYPE;
    2157             : }
    2158             : 
    2159     2508527 : int JSObject::GetEmbedderFieldCount(Map* map) {
    2160             :   int instance_size = map->instance_size();
    2161     2508527 :   if (instance_size == kVariableSizeSentinel) return 0;
    2162             :   InstanceType instance_type = map->instance_type();
    2163     2508527 :   return ((instance_size - GetHeaderSize(instance_type)) >> kPointerSizeLog2) -
    2164     2508527 :          map->GetInObjectProperties();
    2165             : }
    2166             : 
    2167     1562638 : int JSObject::GetEmbedderFieldCount() { return GetEmbedderFieldCount(map()); }
    2168             : 
    2169             : int JSObject::GetEmbedderFieldOffset(int index) {
    2170             :   DCHECK(index < GetEmbedderFieldCount() && index >= 0);
    2171         120 :   return GetHeaderSize() + (kPointerSize * index);
    2172             : }
    2173             : 
    2174             : Object* JSObject::GetEmbedderField(int index) {
    2175             :   DCHECK(index < GetEmbedderFieldCount() && index >= 0);
    2176             :   // Internal objects do follow immediately after the header, whereas in-object
    2177             :   // properties are at the end of the object. Therefore there is no need
    2178             :   // to adjust the index here.
    2179    18232623 :   return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index));
    2180             : }
    2181             : 
    2182      460376 : void JSObject::SetEmbedderField(int index, Object* value) {
    2183             :   DCHECK(index < GetEmbedderFieldCount() && index >= 0);
    2184             :   // Internal objects do follow immediately after the header, whereas in-object
    2185             :   // properties are at the end of the object. Therefore there is no need
    2186             :   // to adjust the index here.
    2187      460376 :   int offset = GetHeaderSize() + (kPointerSize * index);
    2188      460376 :   WRITE_FIELD(this, offset, value);
    2189      920752 :   WRITE_BARRIER(GetHeap(), this, offset, value);
    2190      460376 : }
    2191             : 
    2192             : void JSObject::SetEmbedderField(int index, Smi* value) {
    2193             :   DCHECK(index < GetEmbedderFieldCount() && index >= 0);
    2194             :   // Internal objects do follow immediately after the header, whereas in-object
    2195             :   // properties are at the end of the object. Therefore there is no need
    2196             :   // to adjust the index here.
    2197      549101 :   int offset = GetHeaderSize() + (kPointerSize * index);
    2198      549101 :   WRITE_FIELD(this, offset, value);
    2199             : }
    2200             : 
    2201             : 
    2202   159496630 : bool JSObject::IsUnboxedDoubleField(FieldIndex index) {
    2203             :   if (!FLAG_unbox_double_fields) return false;
    2204   159496630 :   return map()->IsUnboxedDoubleField(index);
    2205             : }
    2206             : 
    2207             : 
    2208   193931656 : bool Map::IsUnboxedDoubleField(FieldIndex index) {
    2209             :   if (!FLAG_unbox_double_fields) return false;
    2210   387863319 :   if (index.is_hidden_field() || !index.is_inobject()) return false;
    2211   117025391 :   return !layout_descriptor()->IsTagged(index.property_index());
    2212             : }
    2213             : 
    2214             : 
    2215             : // Access fast-case object properties at index. The use of these routines
    2216             : // is needed to correctly distinguish between properties stored in-object and
    2217             : // properties stored in the properties array.
    2218   143133464 : Object* JSObject::RawFastPropertyAt(FieldIndex index) {
    2219             :   DCHECK(!IsUnboxedDoubleField(index));
    2220   143133464 :   if (index.is_inobject()) {
    2221    65564867 :     return READ_FIELD(this, index.offset());
    2222             :   } else {
    2223    77568597 :     return properties()->get(index.outobject_array_index());
    2224             :   }
    2225             : }
    2226             : 
    2227             : 
    2228             : double JSObject::RawFastDoublePropertyAt(FieldIndex index) {
    2229             :   DCHECK(IsUnboxedDoubleField(index));
    2230       79342 :   return READ_DOUBLE_FIELD(this, index.offset());
    2231             : }
    2232             : 
    2233             : uint64_t JSObject::RawFastDoublePropertyAsBitsAt(FieldIndex index) {
    2234             :   DCHECK(IsUnboxedDoubleField(index));
    2235      154584 :   return READ_UINT64_FIELD(this, index.offset());
    2236             : }
    2237             : 
    2238   131163945 : void JSObject::RawFastPropertyAtPut(FieldIndex index, Object* value) {
    2239   131163945 :   if (index.is_inobject()) {
    2240             :     int offset = index.offset();
    2241   105199559 :     WRITE_FIELD(this, offset, value);
    2242   210399118 :     WRITE_BARRIER(GetHeap(), this, offset, value);
    2243             :   } else {
    2244    25964386 :     properties()->set(index.outobject_array_index(), value);
    2245             :   }
    2246   131163945 : }
    2247             : 
    2248             : void JSObject::RawFastDoublePropertyAsBitsAtPut(FieldIndex index,
    2249             :                                                 uint64_t bits) {
    2250      255343 :   WRITE_UINT64_FIELD(this, index.offset(), bits);
    2251             : }
    2252             : 
    2253    16390021 : void JSObject::FastPropertyAtPut(FieldIndex index, Object* value) {
    2254    16390021 :   if (IsUnboxedDoubleField(index)) {
    2255             :     DCHECK(value->IsMutableHeapNumber());
    2256             :     // Ensure that all bits of the double value are preserved.
    2257             :     RawFastDoublePropertyAsBitsAtPut(index,
    2258             :                                      HeapNumber::cast(value)->value_as_bits());
    2259             :   } else {
    2260    16390021 :     RawFastPropertyAtPut(index, value);
    2261             :   }
    2262    16390021 : }
    2263             : 
    2264    76617773 : void JSObject::WriteToField(int descriptor, PropertyDetails details,
    2265             :                             Object* value) {
    2266             :   DCHECK_EQ(kField, details.location());
    2267             :   DCHECK_EQ(kData, details.kind());
    2268             :   DisallowHeapAllocation no_gc;
    2269    76617773 :   FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor);
    2270    76617775 :   if (details.representation().IsDouble()) {
    2271             :     // Nothing more to be done.
    2272       79132 :     if (value->IsUninitialized(this->GetIsolate())) {
    2273         850 :       return;
    2274             :     }
    2275             :     // Manipulating the signaling NaN used for the hole and uninitialized
    2276             :     // double field sentinel in C++, e.g. with bit_cast or value()/set_value(),
    2277             :     // will change its value on ia32 (the x87 stack is used to return values
    2278             :     // and stores to the stack silently clear the signalling bit).
    2279             :     uint64_t bits;
    2280       78282 :     if (value->IsSmi()) {
    2281        9319 :       bits = bit_cast<uint64_t>(static_cast<double>(Smi::cast(value)->value()));
    2282             :     } else {
    2283             :       DCHECK(value->IsHeapNumber());
    2284             :       bits = HeapNumber::cast(value)->value_as_bits();
    2285             :     }
    2286       78282 :     if (IsUnboxedDoubleField(index)) {
    2287             :       RawFastDoublePropertyAsBitsAtPut(index, bits);
    2288             :     } else {
    2289       12127 :       HeapNumber* box = HeapNumber::cast(RawFastPropertyAt(index));
    2290             :       DCHECK(box->IsMutableHeapNumber());
    2291             :       box->set_value_as_bits(bits);
    2292             :     }
    2293             :   } else {
    2294    76538643 :     RawFastPropertyAtPut(index, value);
    2295             :   }
    2296             : }
    2297             : 
    2298    15576547 : int JSObject::GetInObjectPropertyOffset(int index) {
    2299    15576547 :   return map()->GetInObjectPropertyOffset(index);
    2300             : }
    2301             : 
    2302             : 
    2303             : Object* JSObject::InObjectPropertyAt(int index) {
    2304      420363 :   int offset = GetInObjectPropertyOffset(index);
    2305      420363 :   return READ_FIELD(this, offset);
    2306             : }
    2307             : 
    2308             : 
    2309    15152709 : Object* JSObject::InObjectPropertyAtPut(int index,
    2310             :                                         Object* value,
    2311             :                                         WriteBarrierMode mode) {
    2312             :   // Adjust for the number of properties stored in the object.
    2313    15152709 :   int offset = GetInObjectPropertyOffset(index);
    2314    15152709 :   WRITE_FIELD(this, offset, value);
    2315    44025895 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode);
    2316    15152709 :   return value;
    2317             : }
    2318             : 
    2319             : 
    2320    45699325 : void JSObject::InitializeBody(Map* map, int start_offset,
    2321             :                               Object* pre_allocated_value,
    2322             :                               Object* filler_value) {
    2323             :   DCHECK(!filler_value->IsHeapObject() ||
    2324             :          !GetHeap()->InNewSpace(filler_value));
    2325             :   DCHECK(!pre_allocated_value->IsHeapObject() ||
    2326             :          !GetHeap()->InNewSpace(pre_allocated_value));
    2327             :   int size = map->instance_size();
    2328             :   int offset = start_offset;
    2329    45699325 :   if (filler_value != pre_allocated_value) {
    2330             :     int end_of_pre_allocated_offset =
    2331      407608 :         size - (map->unused_property_fields() * kPointerSize);
    2332             :     DCHECK_LE(kHeaderSize, end_of_pre_allocated_offset);
    2333     1058692 :     while (offset < end_of_pre_allocated_offset) {
    2334      243476 :       WRITE_FIELD(this, offset, pre_allocated_value);
    2335      243476 :       offset += kPointerSize;
    2336             :     }
    2337             :   }
    2338   159691552 :   while (offset < size) {
    2339   113992227 :     WRITE_FIELD(this, offset, filler_value);
    2340   113992227 :     offset += kPointerSize;
    2341             :   }
    2342    45699325 : }
    2343             : 
    2344             : 
    2345     9123605 : bool Map::TooManyFastProperties(StoreFromKeyed store_mode) {
    2346     9123605 :   if (unused_property_fields() != 0) return false;
    2347     2656458 :   if (is_prototype_map()) return false;
    2348     1839041 :   int minimum = store_mode == CERTAINLY_NOT_STORE_FROM_KEYED ? 128 : 12;
    2349             :   int limit = Max(minimum, GetInObjectProperties());
    2350     3678082 :   int external = NumberOfFields() - GetInObjectProperties();
    2351     1839041 :   return external > limit;
    2352             : }
    2353             : 
    2354             : 
    2355             : void Struct::InitializeBody(int object_size) {
    2356    16519068 :   Object* value = GetHeap()->undefined_value();
    2357   138687475 :   for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
    2358   138687475 :     WRITE_FIELD(this, offset, value);
    2359             :   }
    2360             : }
    2361             : 
    2362     7367482 : bool Object::ToArrayLength(uint32_t* index) { return Object::ToUint32(index); }
    2363             : 
    2364             : 
    2365      114897 : bool Object::ToArrayIndex(uint32_t* index) {
    2366   139533885 :   return Object::ToUint32(index) && *index != kMaxUInt32;
    2367             : }
    2368             : 
    2369             : 
    2370             : void Object::VerifyApiCallResultType() {
    2371             : #if DEBUG
    2372             :   if (IsSmi()) return;
    2373             :   DCHECK(IsHeapObject());
    2374             :   Isolate* isolate = HeapObject::cast(this)->GetIsolate();
    2375             :   if (!(IsString() || IsSymbol() || IsJSReceiver() || IsHeapNumber() ||
    2376             :         IsUndefined(isolate) || IsTrue(isolate) || IsFalse(isolate) ||
    2377             :         IsNull(isolate))) {
    2378             :     FATAL("API call returned invalid object");
    2379             :   }
    2380             : #endif  // DEBUG
    2381             : }
    2382             : 
    2383             : 
    2384   135370567 : Object* FixedArray::get(int index) const {
    2385             :   SLOW_DCHECK(index >= 0 && index < this->length());
    2386 23413319165 :   return NOBARRIER_READ_FIELD(this, kHeaderSize + index * kPointerSize);
    2387             : }
    2388             : 
    2389    13129720 : Handle<Object> FixedArray::get(FixedArray* array, int index, Isolate* isolate) {
    2390    13129721 :   return handle(array->get(index), isolate);
    2391             : }
    2392             : 
    2393             : template <class T>
    2394     4878651 : MaybeHandle<T> FixedArray::GetValue(Isolate* isolate, int index) const {
    2395             :   Object* obj = get(index);
    2396     4878651 :   if (obj->IsUndefined(isolate)) return MaybeHandle<T>();
    2397             :   return Handle<T>(T::cast(obj), isolate);
    2398             : }
    2399             : 
    2400             : template <class T>
    2401      331737 : Handle<T> FixedArray::GetValueChecked(Isolate* isolate, int index) const {
    2402             :   Object* obj = get(index);
    2403      331737 :   CHECK(!obj->IsUndefined(isolate));
    2404      331737 :   return Handle<T>(T::cast(obj), isolate);
    2405             : }
    2406   635985774 : bool FixedArray::is_the_hole(Isolate* isolate, int index) {
    2407   635985774 :   return get(index)->IsTheHole(isolate);
    2408             : }
    2409             : 
    2410     6293703 : void FixedArray::set(int index, Smi* value) {
    2411             :   DCHECK(map() != GetHeap()->fixed_cow_array_map());
    2412             :   DCHECK(index >= 0 && index < this->length());
    2413             :   DCHECK(reinterpret_cast<Object*>(value)->IsSmi());
    2414   926935852 :   int offset = kHeaderSize + index * kPointerSize;
    2415  1209555347 :   NOBARRIER_WRITE_FIELD(this, offset, value);
    2416     6293703 : }
    2417             : 
    2418             : 
    2419  1267228955 : void FixedArray::set(int index, Object* value) {
    2420             :   DCHECK_NE(GetHeap()->fixed_cow_array_map(), map());
    2421             :   DCHECK(IsFixedArray());
    2422             :   DCHECK_GE(index, 0);
    2423             :   DCHECK_LT(index, this->length());
    2424  1267228955 :   int offset = kHeaderSize + index * kPointerSize;
    2425  1267228955 :   NOBARRIER_WRITE_FIELD(this, offset, value);
    2426  2534457931 :   WRITE_BARRIER(GetHeap(), this, offset, value);
    2427  1267228955 : }
    2428             : 
    2429             : 
    2430      891154 : double FixedDoubleArray::get_scalar(int index) {
    2431             :   DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
    2432             :          map() != GetHeap()->fixed_array_map());
    2433             :   DCHECK(index >= 0 && index < this->length());
    2434             :   DCHECK(!is_the_hole(index));
    2435    15068739 :   return READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize);
    2436             : }
    2437             : 
    2438             : 
    2439             : uint64_t FixedDoubleArray::get_representation(int index) {
    2440             :   DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
    2441             :          map() != GetHeap()->fixed_array_map());
    2442             :   DCHECK(index >= 0 && index < this->length());
    2443    29074287 :   int offset = kHeaderSize + index * kDoubleSize;
    2444    29074287 :   return READ_UINT64_FIELD(this, offset);
    2445             : }
    2446             : 
    2447    14560631 : Handle<Object> FixedDoubleArray::get(FixedDoubleArray* array, int index,
    2448             :                                      Isolate* isolate) {
    2449    14560631 :   if (array->is_the_hole(index)) {
    2450     1306236 :     return isolate->factory()->the_hole_value();
    2451             :   } else {
    2452    13254395 :     return isolate->factory()->NewNumber(array->get_scalar(index));
    2453             :   }
    2454             : }
    2455             : 
    2456             : 
    2457    28598720 : void FixedDoubleArray::set(int index, double value) {
    2458             :   DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
    2459             :          map() != GetHeap()->fixed_array_map());
    2460    40041476 :   int offset = kHeaderSize + index * kDoubleSize;
    2461    40041476 :   if (std::isnan(value)) {
    2462      183413 :     WRITE_DOUBLE_FIELD(this, offset, std::numeric_limits<double>::quiet_NaN());
    2463             :   } else {
    2464    39858063 :     WRITE_DOUBLE_FIELD(this, offset, value);
    2465             :   }
    2466             :   DCHECK(!is_the_hole(index));
    2467    28598720 : }
    2468             : 
    2469             : void FixedDoubleArray::set_the_hole(Isolate* isolate, int index) {
    2470             :   set_the_hole(index);
    2471             : }
    2472             : 
    2473             : void FixedDoubleArray::set_the_hole(int index) {
    2474             :   DCHECK(map() != GetHeap()->fixed_cow_array_map() &&
    2475             :          map() != GetHeap()->fixed_array_map());
    2476    47263815 :   int offset = kHeaderSize + index * kDoubleSize;
    2477    47263815 :   WRITE_UINT64_FIELD(this, offset, kHoleNanInt64);
    2478             : }
    2479             : 
    2480             : bool FixedDoubleArray::is_the_hole(Isolate* isolate, int index) {
    2481             :   return is_the_hole(index);
    2482             : }
    2483             : 
    2484             : bool FixedDoubleArray::is_the_hole(int index) {
    2485             :   return get_representation(index) == kHoleNanInt64;
    2486             : }
    2487             : 
    2488             : 
    2489             : double* FixedDoubleArray::data_start() {
    2490             :   return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize));
    2491             : }
    2492             : 
    2493             : 
    2494             : void FixedDoubleArray::FillWithHoles(int from, int to) {
    2495     1089686 :   for (int i = from; i < to; i++) {
    2496             :     set_the_hole(i);
    2497             :   }
    2498             : }
    2499             : 
    2500             : 
    2501    81413014 : Object* WeakFixedArray::Get(int index) const {
    2502    81413014 :   Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
    2503    81413014 :   if (raw->IsSmi()) return raw;
    2504             :   DCHECK(raw->IsWeakCell());
    2505    67369043 :   return WeakCell::cast(raw)->value();
    2506             : }
    2507             : 
    2508             : 
    2509             : bool WeakFixedArray::IsEmptySlot(int index) const {
    2510             :   DCHECK(index < Length());
    2511    57546250 :   return Get(index)->IsSmi();
    2512             : }
    2513             : 
    2514             : 
    2515             : void WeakFixedArray::Clear(int index) {
    2516             :   FixedArray::cast(this)->set(index + kFirstIndex, Smi::kZero);
    2517             : }
    2518             : 
    2519             : 
    2520             : int WeakFixedArray::Length() const {
    2521    31104037 :   return FixedArray::cast(this)->length() - kFirstIndex;
    2522             : }
    2523             : 
    2524             : 
    2525             : int WeakFixedArray::last_used_index() const {
    2526             :   return Smi::cast(FixedArray::cast(this)->get(kLastUsedIndexIndex))->value();
    2527             : }
    2528             : 
    2529             : 
    2530             : void WeakFixedArray::set_last_used_index(int index) {
    2531             :   FixedArray::cast(this)->set(kLastUsedIndexIndex, Smi::FromInt(index));
    2532             : }
    2533             : 
    2534             : 
    2535             : template <class T>
    2536    23759209 : T* WeakFixedArray::Iterator::Next() {
    2537    23759209 :   if (list_ != NULL) {
    2538             :     // Assert that list did not change during iteration.
    2539             :     DCHECK_EQ(last_used_index_, list_->last_used_index());
    2540    34512090 :     while (index_ < list_->Length()) {
    2541    17035573 :       Object* item = list_->Get(index_++);
    2542    17035573 :       if (item != Empty()) return T::cast(item);
    2543             :     }
    2544      220472 :     list_ = NULL;
    2545             :   }
    2546             :   return NULL;
    2547             : }
    2548             : 
    2549     2071664 : int ArrayList::Length() const {
    2550     2071664 :   if (FixedArray::cast(this)->length() == 0) return 0;
    2551     2053860 :   return Smi::cast(FixedArray::cast(this)->get(kLengthIndex))->value();
    2552             : }
    2553             : 
    2554             : 
    2555             : void ArrayList::SetLength(int length) {
    2556             :   return FixedArray::cast(this)->set(kLengthIndex, Smi::FromInt(length));
    2557             : }
    2558             : 
    2559             : Object* ArrayList::Get(int index) const {
    2560     1984244 :   return FixedArray::cast(this)->get(kFirstIndex + index);
    2561             : }
    2562             : 
    2563             : 
    2564             : Object** ArrayList::Slot(int index) {
    2565     1330690 :   return data_start() + kFirstIndex + index;
    2566             : }
    2567             : 
    2568             : void ArrayList::Set(int index, Object* obj, WriteBarrierMode mode) {
    2569     3260069 :   FixedArray::cast(this)->set(kFirstIndex + index, obj, mode);
    2570             : }
    2571             : 
    2572             : 
    2573             : void ArrayList::Clear(int index, Object* undefined) {
    2574             :   DCHECK(undefined->IsUndefined(GetIsolate()));
    2575             :   FixedArray::cast(this)
    2576       13850 :       ->set(kFirstIndex + index, undefined, SKIP_WRITE_BARRIER);
    2577             : }
    2578             : 
    2579         445 : int RegExpMatchInfo::NumberOfCaptureRegisters() {
    2580             :   DCHECK_GE(length(), kLastMatchOverhead);
    2581             :   Object* obj = get(kNumberOfCapturesIndex);
    2582         445 :   return Smi::cast(obj)->value();
    2583             : }
    2584             : 
    2585             : void RegExpMatchInfo::SetNumberOfCaptureRegisters(int value) {
    2586             :   DCHECK_GE(length(), kLastMatchOverhead);
    2587             :   set(kNumberOfCapturesIndex, Smi::FromInt(value));
    2588             : }
    2589             : 
    2590             : String* RegExpMatchInfo::LastSubject() {
    2591             :   DCHECK_GE(length(), kLastMatchOverhead);
    2592             :   Object* obj = get(kLastSubjectIndex);
    2593             :   return String::cast(obj);
    2594             : }
    2595             : 
    2596             : void RegExpMatchInfo::SetLastSubject(String* value) {
    2597             :   DCHECK_GE(length(), kLastMatchOverhead);
    2598      590125 :   set(kLastSubjectIndex, value);
    2599             : }
    2600             : 
    2601             : Object* RegExpMatchInfo::LastInput() {
    2602             :   DCHECK_GE(length(), kLastMatchOverhead);
    2603             :   return get(kLastInputIndex);
    2604             : }
    2605             : 
    2606             : void RegExpMatchInfo::SetLastInput(Object* value) {
    2607             :   DCHECK_GE(length(), kLastMatchOverhead);
    2608      590196 :   set(kLastInputIndex, value);
    2609             : }
    2610             : 
    2611         890 : int RegExpMatchInfo::Capture(int i) {
    2612             :   DCHECK_LT(i, NumberOfCaptureRegisters());
    2613      844228 :   Object* obj = get(kFirstCaptureIndex + i);
    2614         890 :   return Smi::cast(obj)->value();
    2615             : }
    2616             : 
    2617             : void RegExpMatchInfo::SetCapture(int i, int value) {
    2618             :   DCHECK_LT(i, NumberOfCaptureRegisters());
    2619             :   set(kFirstCaptureIndex + i, Smi::FromInt(value));
    2620             : }
    2621             : 
    2622    84526923 : WriteBarrierMode HeapObject::GetWriteBarrierMode(
    2623             :     const DisallowHeapAllocation& promise) {
    2624    84526923 :   Heap* heap = GetHeap();
    2625    84526924 :   if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER;
    2626    81731239 :   if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER;
    2627             :   return UPDATE_WRITE_BARRIER;
    2628             : }
    2629             : 
    2630             : 
    2631             : AllocationAlignment HeapObject::RequiredAlignment() {
    2632             : #ifdef V8_HOST_ARCH_32_BIT
    2633             :   if ((IsFixedFloat64Array() || IsFixedDoubleArray()) &&
    2634             :       FixedArrayBase::cast(this)->length() != 0) {
    2635             :     return kDoubleAligned;
    2636             :   }
    2637             :   if (IsHeapNumber()) return kDoubleUnaligned;
    2638             : #endif  // V8_HOST_ARCH_32_BIT
    2639             :   return kWordAligned;
    2640             : }
    2641             : 
    2642             : 
    2643  1464428244 : void FixedArray::set(int index,
    2644             :                      Object* value,
    2645             :                      WriteBarrierMode mode) {
    2646             :   DCHECK_NE(map(), GetHeap()->fixed_cow_array_map());
    2647             :   DCHECK_GE(index, 0);
    2648             :   DCHECK_LT(index, this->length());
    2649  1464428244 :   int offset = kHeaderSize + index * kPointerSize;
    2650  1464428244 :   NOBARRIER_WRITE_FIELD(this, offset, value);
    2651  2339359932 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode);
    2652  1464428243 : }
    2653             : 
    2654             : 
    2655             : void FixedArray::NoWriteBarrierSet(FixedArray* array,
    2656             :                                    int index,
    2657             :                                    Object* value) {
    2658             :   DCHECK_NE(array->map(), array->GetHeap()->fixed_cow_array_map());
    2659             :   DCHECK_GE(index, 0);
    2660             :   DCHECK_LT(index, array->length());
    2661             :   DCHECK(!array->GetHeap()->InNewSpace(value));
    2662   368138304 :   NOBARRIER_WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value);
    2663             : }
    2664             : 
    2665   343592861 : void FixedArray::set_undefined(int index) {
    2666             :   set_undefined(GetIsolate(), index);
    2667   343592861 : }
    2668             : 
    2669             : void FixedArray::set_undefined(Isolate* isolate, int index) {
    2670             :   FixedArray::NoWriteBarrierSet(this, index,
    2671   343595188 :                                 isolate->heap()->undefined_value());
    2672             : }
    2673             : 
    2674        1642 : void FixedArray::set_null(int index) { set_null(GetIsolate(), index); }
    2675             : 
    2676             : void FixedArray::set_null(Isolate* isolate, int index) {
    2677         821 :   FixedArray::NoWriteBarrierSet(this, index, isolate->heap()->null_value());
    2678             : }
    2679             : 
    2680         972 : void FixedArray::set_the_hole(int index) { set_the_hole(GetIsolate(), index); }
    2681             : 
    2682             : void FixedArray::set_the_hole(Isolate* isolate, int index) {
    2683    24528273 :   FixedArray::NoWriteBarrierSet(this, index, isolate->heap()->the_hole_value());
    2684             : }
    2685             : 
    2686     1581360 : void FixedArray::FillWithHoles(int from, int to) {
    2687             :   Isolate* isolate = GetIsolate();
    2688    13269152 :   for (int i = from; i < to; i++) {
    2689             :     set_the_hole(isolate, i);
    2690             :   }
    2691     1581360 : }
    2692             : 
    2693             : 
    2694           0 : Object** FixedArray::data_start() {
    2695           0 :   return HeapObject::RawField(this, kHeaderSize);
    2696             : }
    2697             : 
    2698             : 
    2699             : Object** FixedArray::RawFieldOfElementAt(int index) {
    2700             :   return HeapObject::RawField(this, OffsetOfElementAt(index));
    2701             : }
    2702             : 
    2703             : bool DescriptorArray::IsEmpty() {
    2704             :   DCHECK(length() >= kFirstIndex ||
    2705             :          this == GetHeap()->empty_descriptor_array());
    2706             :   return length() < kFirstIndex;
    2707             : }
    2708             : 
    2709             : 
    2710   125665510 : int DescriptorArray::number_of_descriptors() {
    2711             :   DCHECK(length() >= kFirstIndex || IsEmpty());
    2712             :   int len = length();
    2713   251331020 :   return len == 0 ? 0 : Smi::cast(get(kDescriptorLengthIndex))->value();
    2714             : }
    2715             : 
    2716             : 
    2717             : int DescriptorArray::number_of_descriptors_storage() {
    2718             :   int len = length();
    2719    15368193 :   return len == 0 ? 0 : (len - kFirstIndex) / kEntrySize;
    2720             : }
    2721             : 
    2722             : 
    2723    15353449 : int DescriptorArray::NumberOfSlackDescriptors() {
    2724    15353449 :   return number_of_descriptors_storage() - number_of_descriptors();
    2725             : }
    2726             : 
    2727             : 
    2728             : void DescriptorArray::SetNumberOfDescriptors(int number_of_descriptors) {
    2729             :   WRITE_FIELD(
    2730    14266612 :       this, kDescriptorLengthOffset, Smi::FromInt(number_of_descriptors));
    2731             : }
    2732             : 
    2733             : 
    2734             : inline int DescriptorArray::number_of_entries() {
    2735    32769327 :   return number_of_descriptors();
    2736             : }
    2737             : 
    2738             : 
    2739    22030696 : bool DescriptorArray::HasEnumCache() {
    2740    42619080 :   return !IsEmpty() && !get(kEnumCacheIndex)->IsSmi();
    2741             : }
    2742             : 
    2743             : 
    2744       36785 : void DescriptorArray::CopyEnumCacheFrom(DescriptorArray* array) {
    2745       36785 :   set(kEnumCacheIndex, array->get(kEnumCacheIndex));
    2746       36785 : }
    2747             : 
    2748             : 
    2749    14713841 : FixedArray* DescriptorArray::GetEnumCache() {
    2750             :   DCHECK(HasEnumCache());
    2751             :   FixedArray* bridge = FixedArray::cast(get(kEnumCacheIndex));
    2752    14713841 :   return FixedArray::cast(bridge->get(kEnumCacheBridgeCacheIndex));
    2753             : }
    2754             : 
    2755             : 
    2756       12102 : bool DescriptorArray::HasEnumIndicesCache() {
    2757       12102 :   if (IsEmpty()) return false;
    2758             :   Object* object = get(kEnumCacheIndex);
    2759       12102 :   if (object->IsSmi()) return false;
    2760             :   FixedArray* bridge = FixedArray::cast(object);
    2761       12102 :   return !bridge->get(kEnumCacheBridgeIndicesCacheIndex)->IsSmi();
    2762             : }
    2763             : 
    2764             : 
    2765       12095 : FixedArray* DescriptorArray::GetEnumIndicesCache() {
    2766             :   DCHECK(HasEnumIndicesCache());
    2767             :   FixedArray* bridge = FixedArray::cast(get(kEnumCacheIndex));
    2768       12095 :   return FixedArray::cast(bridge->get(kEnumCacheBridgeIndicesCacheIndex));
    2769             : }
    2770             : 
    2771             : 
    2772             : Object** DescriptorArray::GetEnumCacheSlot() {
    2773             :   DCHECK(HasEnumCache());
    2774             :   return HeapObject::RawField(reinterpret_cast<HeapObject*>(this),
    2775             :                               kEnumCacheOffset);
    2776             : }
    2777             : 
    2778             : // Perform a binary search in a fixed array.
    2779             : template <SearchMode search_mode, typename T>
    2780    43143146 : int BinarySearch(T* array, Name* name, int valid_entries,
    2781             :                  int* out_insertion_index) {
    2782             :   DCHECK(search_mode == ALL_ENTRIES || out_insertion_index == NULL);
    2783             :   int low = 0;
    2784    43143149 :   int high = array->number_of_entries() - 1;
    2785             :   uint32_t hash = name->hash_field();
    2786             :   int limit = high;
    2787             : 
    2788             :   DCHECK(low <= high);
    2789             : 
    2790   272623108 :   while (low != high) {
    2791   186336815 :     int mid = low + (high - low) / 2;
    2792   142520793 :     Name* mid_name = array->GetSortedKey(mid);
    2793             :     uint32_t mid_hash = mid_name->hash_field();
    2794             : 
    2795   186336810 :     if (mid_hash >= hash) {
    2796             :       high = mid;
    2797             :     } else {
    2798    96436612 :       low = mid + 1;
    2799             :     }
    2800             :   }
    2801             : 
    2802           0 :   for (; low <= limit; ++low) {
    2803             :     int sort_index = array->GetSortedKeyIndex(low);
    2804             :     Name* entry = array->GetKey(sort_index);
    2805             :     uint32_t current_hash = entry->hash_field();
    2806    43143143 :     if (current_hash != hash) {
    2807      299805 :       if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
    2808      131783 :         *out_insertion_index = sort_index + (current_hash > hash ? 0 : 1);
    2809             :       }
    2810             :       return T::kNotFound;
    2811             :     }
    2812    26350071 :     if (entry == name) {
    2813    16276057 :       if (search_mode == ALL_ENTRIES || sort_index < valid_entries) {
    2814    15832688 :         return sort_index;
    2815             :       }
    2816             :       return T::kNotFound;
    2817             :     }
    2818             :   }
    2819             : 
    2820           0 :   if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
    2821           0 :     *out_insertion_index = limit + 1;
    2822             :   }
    2823             :   return T::kNotFound;
    2824             : }
    2825             : 
    2826             : 
    2827             : // Perform a linear search in this fixed array. len is the number of entry
    2828             : // indices that are valid.
    2829             : template <SearchMode search_mode, typename T>
    2830    88006941 : int LinearSearch(T* array, Name* name, int valid_entries,
    2831             :                  int* out_insertion_index) {
    2832    14262270 :   if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
    2833             :     uint32_t hash = name->hash_field();
    2834             :     int len = array->number_of_entries();
    2835     1884159 :     for (int number = 0; number < len; number++) {
    2836             :       int sorted_index = array->GetSortedKeyIndex(number);
    2837             :       Name* entry = array->GetKey(sorted_index);
    2838             :       uint32_t current_hash = entry->hash_field();
    2839     1699253 :       if (current_hash > hash) {
    2840      318522 :         *out_insertion_index = sorted_index;
    2841      318522 :         return T::kNotFound;
    2842             :       }
    2843     1380731 :       if (entry == name) return sorted_index;
    2844             :     }
    2845      184906 :     *out_insertion_index = len;
    2846      184906 :     return T::kNotFound;
    2847             :   } else {
    2848             :     DCHECK_LE(valid_entries, array->number_of_entries());
    2849             :     DCHECK_NULL(out_insertion_index);  // Not supported here.
    2850   204931642 :     for (int number = 0; number < valid_entries; number++) {
    2851   252468750 :       if (array->GetKey(number) == name) return number;
    2852             :     }
    2853             :     return T::kNotFound;
    2854             :   }
    2855             : }
    2856             : 
    2857             : 
    2858             : template <SearchMode search_mode, typename T>
    2859   132670738 : int Search(T* array, Name* name, int valid_entries, int* out_insertion_index) {
    2860             :   SLOW_DCHECK(array->IsSortedNoDuplicates());
    2861             : 
    2862   132670738 :   if (valid_entries == 0) {
    2863      191182 :     if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
    2864      187827 :       *out_insertion_index = 0;
    2865             :     }
    2866             :     return T::kNotFound;
    2867             :   }
    2868             : 
    2869             :   // Fast case: do linear search for small arrays.
    2870             :   const int kMaxElementsForLinearSearch = 8;
    2871   132479574 :   if (valid_entries <= kMaxElementsForLinearSearch) {
    2872             :     return LinearSearch<search_mode>(array, name, valid_entries,
    2873    88006941 :                                      out_insertion_index);
    2874             :   }
    2875             : 
    2876             :   // Slow case: perform binary search.
    2877             :   return BinarySearch<search_mode>(array, name, valid_entries,
    2878    44472633 :                                    out_insertion_index);
    2879             : }
    2880             : 
    2881             : 
    2882             : int DescriptorArray::Search(Name* name, int valid_descriptors) {
    2883             :   DCHECK(name->IsUniqueName());
    2884   107843467 :   return internal::Search<VALID_ENTRIES>(this, name, valid_descriptors, NULL);
    2885             : }
    2886             : 
    2887   299860526 : int DescriptorArray::SearchWithCache(Isolate* isolate, Name* name, Map* map) {
    2888             :   DCHECK(name->IsUniqueName());
    2889   327816355 :   int number_of_own_descriptors = map->NumberOfOwnDescriptors();
    2890   327816384 :   if (number_of_own_descriptors == 0) return kNotFound;
    2891             : 
    2892   299860526 :   DescriptorLookupCache* cache = isolate->descriptor_lookup_cache();
    2893   299860522 :   int number = cache->Lookup(map, name);
    2894             : 
    2895   299860519 :   if (number == DescriptorLookupCache::kAbsent) {
    2896             :     number = Search(name, number_of_own_descriptors);
    2897   107843462 :     cache->Update(map, name, number);
    2898             :   }
    2899             : 
    2900             :   return number;
    2901             : }
    2902             : 
    2903             : PropertyDetails Map::GetLastDescriptorDetails() {
    2904   135368643 :   return instance_descriptors()->GetDetails(LastAdded());
    2905             : }
    2906             : 
    2907             : 
    2908             : int Map::LastAdded() {
    2909             :   int number_of_own_descriptors = NumberOfOwnDescriptors();
    2910             :   DCHECK(number_of_own_descriptors > 0);
    2911   237740366 :   return number_of_own_descriptors - 1;
    2912             : }
    2913             : 
    2914             : 
    2915   329480289 : int Map::NumberOfOwnDescriptors() {
    2916   329480289 :   return NumberOfOwnDescriptorsBits::decode(bit_field3());
    2917             : }
    2918             : 
    2919             : 
    2920             : void Map::SetNumberOfOwnDescriptors(int number) {
    2921             :   DCHECK(number <= instance_descriptors()->number_of_descriptors());
    2922             :   set_bit_field3(NumberOfOwnDescriptorsBits::update(bit_field3(), number));
    2923             : }
    2924             : 
    2925             : 
    2926       19870 : int Map::EnumLength() { return EnumLengthBits::decode(bit_field3()); }
    2927             : 
    2928             : 
    2929             : void Map::SetEnumLength(int length) {
    2930             :   if (length != kInvalidEnumCacheSentinel) {
    2931             :     DCHECK(length >= 0);
    2932             :     DCHECK(length == 0 || instance_descriptors()->HasEnumCache());
    2933             :     DCHECK(length <= NumberOfOwnDescriptors());
    2934             :   }
    2935             :   set_bit_field3(EnumLengthBits::update(bit_field3(), length));
    2936             : }
    2937             : 
    2938             : 
    2939    75708870 : FixedArrayBase* Map::GetInitialElements() {
    2940             :   FixedArrayBase* result = nullptr;
    2941    75708870 :   if (has_fast_elements() || has_fast_string_wrapper_elements()) {
    2942    75704984 :     result = GetHeap()->empty_fixed_array();
    2943        3886 :   } else if (has_fast_sloppy_arguments_elements()) {
    2944           0 :     result = GetHeap()->empty_sloppy_arguments_elements();
    2945        3886 :   } else if (has_fixed_typed_array_elements()) {
    2946           0 :     result = GetHeap()->EmptyFixedTypedArrayForMap(this);
    2947             :   } else {
    2948           0 :     UNREACHABLE();
    2949             :   }
    2950             :   DCHECK(!GetHeap()->InNewSpace(result));
    2951    75708870 :   return result;
    2952             : }
    2953             : 
    2954             : Object** DescriptorArray::GetKeySlot(int descriptor_number) {
    2955             :   DCHECK(descriptor_number < number_of_descriptors());
    2956             :   return RawFieldOfElementAt(ToKeyIndex(descriptor_number));
    2957             : }
    2958             : 
    2959             : 
    2960             : Object** DescriptorArray::GetDescriptorStartSlot(int descriptor_number) {
    2961             :   return GetKeySlot(descriptor_number);
    2962             : }
    2963             : 
    2964             : 
    2965             : Object** DescriptorArray::GetDescriptorEndSlot(int descriptor_number) {
    2966    22301676 :   return GetValueSlot(descriptor_number - 1) + 1;
    2967             : }
    2968             : 
    2969             : 
    2970     1138618 : Name* DescriptorArray::GetKey(int descriptor_number) {
    2971             :   DCHECK(descriptor_number < number_of_descriptors());
    2972     1138618 :   return Name::cast(get(ToKeyIndex(descriptor_number)));
    2973             : }
    2974             : 
    2975             : 
    2976             : int DescriptorArray::GetSortedKeyIndex(int descriptor_number) {
    2977  1099015461 :   return GetDetails(descriptor_number).pointer();
    2978             : }
    2979             : 
    2980             : 
    2981   336025075 : Name* DescriptorArray::GetSortedKey(int descriptor_number) {
    2982   336025075 :   return GetKey(GetSortedKeyIndex(descriptor_number));
    2983             : }
    2984             : 
    2985             : 
    2986   201848250 : void DescriptorArray::SetSortedKey(int descriptor_index, int pointer) {
    2987   201848250 :   PropertyDetails details = GetDetails(descriptor_index);
    2988             :   set(ToDetailsIndex(descriptor_index), details.set_pointer(pointer).AsSmi());
    2989   201848250 : }
    2990             : 
    2991             : 
    2992             : Object** DescriptorArray::GetValueSlot(int descriptor_number) {
    2993             :   DCHECK(descriptor_number < number_of_descriptors());
    2994             :   return RawFieldOfElementAt(ToValueIndex(descriptor_number));
    2995             : }
    2996             : 
    2997             : 
    2998             : int DescriptorArray::GetValueOffset(int descriptor_number) {
    2999             :   return OffsetOfElementAt(ToValueIndex(descriptor_number));
    3000             : }
    3001             : 
    3002             : 
    3003             : Object* DescriptorArray::GetValue(int descriptor_number) {
    3004             :   DCHECK(descriptor_number < number_of_descriptors());
    3005             :   return get(ToValueIndex(descriptor_number));
    3006             : }
    3007             : 
    3008             : 
    3009             : void DescriptorArray::SetValue(int descriptor_index, Object* value) {
    3010     5111075 :   set(ToValueIndex(descriptor_index), value);
    3011             : }
    3012             : 
    3013             : 
    3014  2797257184 : PropertyDetails DescriptorArray::GetDetails(int descriptor_number) {
    3015             :   DCHECK(descriptor_number < number_of_descriptors());
    3016             :   Object* details = get(ToDetailsIndex(descriptor_number));
    3017  2797257184 :   return PropertyDetails(Smi::cast(details));
    3018             : }
    3019             : 
    3020             : int DescriptorArray::GetFieldIndex(int descriptor_number) {
    3021             :   DCHECK(GetDetails(descriptor_number).location() == kField);
    3022   219148965 :   return GetDetails(descriptor_number).field_index();
    3023             : }
    3024             : 
    3025    67447709 : FieldType* DescriptorArray::GetFieldType(int descriptor_number) {
    3026             :   DCHECK(GetDetails(descriptor_number).location() == kField);
    3027             :   Object* wrapped_type = GetValue(descriptor_number);
    3028    67447709 :   return Map::UnwrapFieldType(wrapped_type);
    3029             : }
    3030             : 
    3031             : void DescriptorArray::Get(int descriptor_number, Descriptor* desc) {
    3032             :   desc->Init(handle(GetKey(descriptor_number), GetIsolate()),
    3033             :              handle(GetValue(descriptor_number), GetIsolate()),
    3034             :              GetDetails(descriptor_number));
    3035             : }
    3036             : 
    3037   175115865 : void DescriptorArray::Set(int descriptor_number, Name* key, Object* value,
    3038             :                           PropertyDetails details) {
    3039             :   // Range check.
    3040             :   DCHECK(descriptor_number < number_of_descriptors());
    3041   175115865 :   set(ToKeyIndex(descriptor_number), key);
    3042   175115869 :   set(ToValueIndex(descriptor_number), value);
    3043             :   set(ToDetailsIndex(descriptor_number), details.AsSmi());
    3044   175115879 : }
    3045             : 
    3046    20345772 : void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
    3047             :   Name* key = *desc->GetKey();
    3048             :   Object* value = *desc->GetValue();
    3049    20345772 :   Set(descriptor_number, key, value, desc->GetDetails());
    3050    20345769 : }
    3051             : 
    3052             : 
    3053    14252048 : void DescriptorArray::Append(Descriptor* desc) {
    3054             :   DisallowHeapAllocation no_gc;
    3055    14252048 :   int descriptor_number = number_of_descriptors();
    3056    14252049 :   SetNumberOfDescriptors(descriptor_number + 1);
    3057    14252049 :   Set(descriptor_number, desc);
    3058             : 
    3059             :   uint32_t hash = desc->GetKey()->Hash();
    3060             : 
    3061             :   int insertion;
    3062             : 
    3063   190054300 :   for (insertion = descriptor_number; insertion > 0; --insertion) {
    3064   171168148 :     Name* key = GetSortedKey(insertion - 1);
    3065   171168152 :     if (key->Hash() <= hash) break;
    3066   161550211 :     SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1));
    3067             :   }
    3068             : 
    3069    14252049 :   SetSortedKey(insertion, descriptor_number);
    3070    14252049 : }
    3071             : 
    3072             : 
    3073    11111177 : void DescriptorArray::SwapSortedKeys(int first, int second) {
    3074             :   int first_key = GetSortedKeyIndex(first);
    3075    11111177 :   SetSortedKey(first, GetSortedKeyIndex(second));
    3076    11111177 :   SetSortedKey(second, first_key);
    3077    11111177 : }
    3078             : 
    3079             : 
    3080        1444 : int HashTableBase::NumberOfElements() {
    3081        1444 :   return Smi::cast(get(kNumberOfElementsIndex))->value();
    3082             : }
    3083             : 
    3084             : 
    3085             : int HashTableBase::NumberOfDeletedElements() {
    3086             :   return Smi::cast(get(kNumberOfDeletedElementsIndex))->value();
    3087             : }
    3088             : 
    3089             : 
    3090             : int HashTableBase::Capacity() {
    3091             :   return Smi::cast(get(kCapacityIndex))->value();
    3092             : }
    3093             : 
    3094             : 
    3095    69330736 : void HashTableBase::ElementAdded() {
    3096    69330736 :   SetNumberOfElements(NumberOfElements() + 1);
    3097    69330736 : }
    3098             : 
    3099             : 
    3100     6190492 : void HashTableBase::ElementRemoved() {
    3101     6190492 :   SetNumberOfElements(NumberOfElements() - 1);
    3102     6190492 :   SetNumberOfDeletedElements(NumberOfDeletedElements() + 1);
    3103     6190492 : }
    3104             : 
    3105             : 
    3106       53559 : void HashTableBase::ElementsRemoved(int n) {
    3107       53559 :   SetNumberOfElements(NumberOfElements() - n);
    3108       53559 :   SetNumberOfDeletedElements(NumberOfDeletedElements() + n);
    3109       53559 : }
    3110             : 
    3111             : 
    3112             : // static
    3113             : int HashTableBase::ComputeCapacity(int at_least_space_for) {
    3114             :   // Add 50% slack to make slot collisions sufficiently unlikely.
    3115             :   // See matching computation in HashTable::HasSufficientCapacityToAdd().
    3116             :   // Must be kept in sync with CodeStubAssembler::HashTableComputeCapacity().
    3117     8170003 :   int raw_cap = at_least_space_for + (at_least_space_for >> 1);
    3118     8170003 :   int capacity = base::bits::RoundUpToPowerOfTwo32(raw_cap);
    3119             :   return Max(capacity, kMinCapacity);
    3120             : }
    3121             : 
    3122        4531 : bool HashTableBase::IsKey(Isolate* isolate, Object* k) {
    3123   494634781 :   Heap* heap = isolate->heap();
    3124   494634781 :   return k != heap->the_hole_value() && k != heap->undefined_value();
    3125             : }
    3126             : 
    3127             : void HashTableBase::SetNumberOfElements(int nof) {
    3128             :   set(kNumberOfElementsIndex, Smi::FromInt(nof));
    3129             : }
    3130             : 
    3131             : 
    3132             : void HashTableBase::SetNumberOfDeletedElements(int nod) {
    3133             :   set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod));
    3134             : }
    3135             : 
    3136             : template <typename Key>
    3137             : Map* BaseShape<Key>::GetMap(Isolate* isolate) {
    3138     7049191 :   return isolate->heap()->hash_table_map();
    3139             : }
    3140             : 
    3141             : template <typename Derived, typename Shape, typename Key>
    3142           0 : int HashTable<Derived, Shape, Key>::FindEntry(Key key) {
    3143   114341526 :   return FindEntry(GetIsolate(), key);
    3144             : }
    3145             : 
    3146             : 
    3147             : template<typename Derived, typename Shape, typename Key>
    3148   262460575 : int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) {
    3149   262460589 :   return FindEntry(isolate, key, HashTable::Hash(key));
    3150             : }
    3151             : 
    3152             : // Find entry for key otherwise return kNotFound.
    3153             : template <typename Derived, typename Shape, typename Key>
    3154   278543519 : int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key,
    3155             :                                               int32_t hash) {
    3156   278543519 :   uint32_t capacity = Capacity();
    3157   278543519 :   uint32_t entry = FirstProbe(hash, capacity);
    3158             :   uint32_t count = 1;
    3159             :   // EnsureCapacity will guarantee the hash table is never full.
    3160   278543519 :   Object* undefined = isolate->heap()->undefined_value();
    3161   278543519 :   Object* the_hole = isolate->heap()->the_hole_value();
    3162             :   while (true) {
    3163   478631170 :     Object* element = KeyAt(entry);
    3164             :     // Empty entry. Uses raw unchecked accessors because it is called by the
    3165             :     // string table during bootstrapping.
    3166   478631170 :     if (element == undefined) break;
    3167   585688165 :     if (element != the_hole && Shape::IsMatch(key, element)) return entry;
    3168   200087651 :     entry = NextProbe(entry, count++, capacity);
    3169             :   }
    3170   200087651 :   return kNotFound;
    3171             : }
    3172             : 
    3173             : template <typename Derived, typename Shape, typename Key>
    3174        1818 : bool HashTable<Derived, Shape, Key>::Has(Key key) {
    3175        1818 :   return FindEntry(key) != kNotFound;
    3176             : }
    3177             : 
    3178             : template <typename Derived, typename Shape, typename Key>
    3179           0 : bool HashTable<Derived, Shape, Key>::Has(Isolate* isolate, Key key) {
    3180           0 :   return FindEntry(isolate, key) != kNotFound;
    3181             : }
    3182             : 
    3183             : bool ObjectHashSet::Has(Isolate* isolate, Handle<Object> key, int32_t hash) {
    3184    16025435 :   return FindEntry(isolate, key, hash) != kNotFound;
    3185             : }
    3186             : 
    3187       16135 : bool ObjectHashSet::Has(Isolate* isolate, Handle<Object> key) {
    3188       16135 :   Object* hash = key->GetHash();
    3189       16135 :   if (!hash->IsSmi()) return false;
    3190       16135 :   return FindEntry(isolate, key, Smi::cast(hash)->value()) != kNotFound;
    3191             : }
    3192             : 
    3193     2511675 : bool StringSetShape::IsMatch(String* key, Object* value) {
    3194     2511675 :   return value->IsString() && key->Equals(String::cast(value));
    3195             : }
    3196             : 
    3197             : uint32_t StringSetShape::Hash(String* key) { return key->Hash(); }
    3198             : 
    3199       24106 : uint32_t StringSetShape::HashForObject(String* key, Object* object) {
    3200       48212 :   return object->IsString() ? String::cast(object)->Hash() : 0;
    3201             : }
    3202             : 
    3203     8246521 : bool SeededNumberDictionary::requires_slow_elements() {
    3204             :   Object* max_index_object = get(kMaxNumberKeyIndex);
    3205     8246521 :   if (!max_index_object->IsSmi()) return false;
    3206             :   return 0 !=
    3207     7772356 :       (Smi::cast(max_index_object)->value() & kRequiresSlowElementsMask);
    3208             : }
    3209             : 
    3210             : 
    3211     6616098 : uint32_t SeededNumberDictionary::max_number_key() {
    3212             :   DCHECK(!requires_slow_elements());
    3213             :   Object* max_index_object = get(kMaxNumberKeyIndex);
    3214     6616098 :   if (!max_index_object->IsSmi()) return 0;
    3215     6612428 :   uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value());
    3216     6612428 :   return value >> kRequiresSlowElementsTagSize;
    3217             : }
    3218             : 
    3219             : 
    3220             : void SeededNumberDictionary::set_requires_slow_elements() {
    3221             :   set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask));
    3222             : }
    3223             : 
    3224             : 
    3225             : template <class T>
    3226             : PodArray<T>* PodArray<T>::cast(Object* object) {
    3227             :   SLOW_DCHECK(object->IsByteArray());
    3228             :   return reinterpret_cast<PodArray<T>*>(object);
    3229             : }
    3230             : template <class T>
    3231             : const PodArray<T>* PodArray<T>::cast(const Object* object) {
    3232             :   SLOW_DCHECK(object->IsByteArray());
    3233             :   return reinterpret_cast<const PodArray<T>*>(object);
    3234             : }
    3235             : 
    3236             : // static
    3237             : template <class T>
    3238             : Handle<PodArray<T>> PodArray<T>::New(Isolate* isolate, int length,
    3239             :                                      PretenureFlag pretenure) {
    3240             :   return Handle<PodArray<T>>::cast(
    3241       27484 :       isolate->factory()->NewByteArray(length * sizeof(T), pretenure));
    3242             : }
    3243             : 
    3244             : // static
    3245             : template <class Traits>
    3246             : STATIC_CONST_MEMBER_DEFINITION const InstanceType
    3247             :     FixedTypedArray<Traits>::kInstanceType;
    3248             : 
    3249             : 
    3250             : template <class Traits>
    3251             : FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) {
    3252             :   SLOW_DCHECK(object->IsHeapObject() &&
    3253             :               HeapObject::cast(object)->map()->instance_type() ==
    3254             :               Traits::kInstanceType);
    3255             :   return reinterpret_cast<FixedTypedArray<Traits>*>(object);
    3256             : }
    3257             : 
    3258             : 
    3259             : template <class Traits>
    3260             : const FixedTypedArray<Traits>*
    3261             : FixedTypedArray<Traits>::cast(const Object* object) {
    3262             :   SLOW_DCHECK(object->IsHeapObject() &&
    3263             :               HeapObject::cast(object)->map()->instance_type() ==
    3264             :               Traits::kInstanceType);
    3265             :   return reinterpret_cast<FixedTypedArray<Traits>*>(object);
    3266             : }
    3267             : 
    3268             : 
    3269             : #define DEFINE_DEOPT_ELEMENT_ACCESSORS(name, type)       \
    3270             :   type* DeoptimizationInputData::name() {                \
    3271             :     return type::cast(get(k##name##Index));              \
    3272             :   }                                                      \
    3273             :   void DeoptimizationInputData::Set##name(type* value) { \
    3274             :     set(k##name##Index, value);                          \
    3275             :   }
    3276             : 
    3277      670321 : DEFINE_DEOPT_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray)
    3278             : DEFINE_DEOPT_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi)
    3279      670321 : DEFINE_DEOPT_ELEMENT_ACCESSORS(LiteralArray, FixedArray)
    3280             : DEFINE_DEOPT_ELEMENT_ACCESSORS(OsrAstId, Smi)
    3281       16786 : DEFINE_DEOPT_ELEMENT_ACCESSORS(OsrPcOffset, Smi)
    3282             : DEFINE_DEOPT_ELEMENT_ACCESSORS(OptimizationId, Smi)
    3283     1083620 : DEFINE_DEOPT_ELEMENT_ACCESSORS(SharedFunctionInfo, Object)
    3284      612450 : DEFINE_DEOPT_ELEMENT_ACCESSORS(WeakCellCache, Object)
    3285      670321 : DEFINE_DEOPT_ELEMENT_ACCESSORS(InliningPositions, PodArray<InliningPosition>)
    3286             : 
    3287             : #undef DEFINE_DEOPT_ELEMENT_ACCESSORS
    3288             : 
    3289             : 
    3290             : #define DEFINE_DEOPT_ENTRY_ACCESSORS(name, type)                \
    3291             :   type* DeoptimizationInputData::name(int i) {                  \
    3292             :     return type::cast(get(IndexForEntry(i) + k##name##Offset)); \
    3293             :   }                                                             \
    3294             :   void DeoptimizationInputData::Set##name(int i, type* value) { \
    3295             :     set(IndexForEntry(i) + k##name##Offset, value);             \
    3296             :   }
    3297             : 
    3298    13477722 : DEFINE_DEOPT_ENTRY_ACCESSORS(AstIdRaw, Smi)
    3299    18847661 : DEFINE_DEOPT_ENTRY_ACCESSORS(TranslationIndex, Smi)
    3300    13851350 : DEFINE_DEOPT_ENTRY_ACCESSORS(ArgumentsStackHeight, Smi)
    3301    36440524 : DEFINE_DEOPT_ENTRY_ACCESSORS(Pc, Smi)
    3302             : 
    3303             : #undef DEFINE_DEOPT_ENTRY_ACCESSORS
    3304             : 
    3305             : 
    3306      155539 : BailoutId DeoptimizationInputData::AstId(int i) {
    3307      155539 :   return BailoutId(AstIdRaw(i)->value());
    3308             : }
    3309             : 
    3310             : 
    3311             : void DeoptimizationInputData::SetAstId(int i, BailoutId value) {
    3312     6738862 :   SetAstIdRaw(i, Smi::FromInt(value.ToInt()));
    3313             : }
    3314             : 
    3315             : 
    3316             : int DeoptimizationInputData::DeoptCount() {
    3317     5098782 :   return (length() - kFirstDeoptEntryIndex) / kDeoptEntrySize;
    3318             : }
    3319             : 
    3320             : 
    3321      568987 : int DeoptimizationOutputData::DeoptPoints() { return length() / 2; }
    3322             : 
    3323             : 
    3324    24828029 : BailoutId DeoptimizationOutputData::AstId(int index) {
    3325    49656058 :   return BailoutId(Smi::cast(get(index * 2))->value());
    3326             : }
    3327             : 
    3328             : 
    3329     8411054 : void DeoptimizationOutputData::SetAstId(int index, BailoutId id) {
    3330     8411054 :   set(index * 2, Smi::FromInt(id.ToInt()));
    3331     8411054 : }
    3332             : 
    3333             : 
    3334             : Smi* DeoptimizationOutputData::PcAndState(int index) {
    3335      568987 :   return Smi::cast(get(1 + index * 2));
    3336             : }
    3337             : 
    3338             : 
    3339             : void DeoptimizationOutputData::SetPcAndState(int index, Smi* offset) {
    3340     8411055 :   set(1 + index * 2, offset);
    3341             : }
    3342             : 
    3343             : int HandlerTable::GetRangeStart(int index) const {
    3344     1526645 :   return Smi::cast(get(index * kRangeEntrySize + kRangeStartIndex))->value();
    3345             : }
    3346             : 
    3347       38808 : int HandlerTable::GetRangeEnd(int index) const {
    3348       77616 :   return Smi::cast(get(index * kRangeEntrySize + kRangeEndIndex))->value();
    3349             : }
    3350             : 
    3351       38808 : int HandlerTable::GetRangeHandler(int index) const {
    3352             :   return HandlerOffsetField::decode(
    3353      116424 :       Smi::cast(get(index * kRangeEntrySize + kRangeHandlerIndex))->value());
    3354             : }
    3355             : 
    3356       38808 : int HandlerTable::GetRangeData(int index) const {
    3357       77616 :   return Smi::cast(get(index * kRangeEntrySize + kRangeDataIndex))->value();
    3358             : }
    3359             : 
    3360      176197 : void HandlerTable::SetRangeStart(int index, int value) {
    3361      176197 :   set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value));
    3362      176197 : }
    3363             : 
    3364             : 
    3365      176197 : void HandlerTable::SetRangeEnd(int index, int value) {
    3366      176197 :   set(index * kRangeEntrySize + kRangeEndIndex, Smi::FromInt(value));
    3367      176197 : }
    3368             : 
    3369             : 
    3370      176197 : void HandlerTable::SetRangeHandler(int index, int offset,
    3371             :                                    CatchPrediction prediction) {
    3372      176197 :   int value = HandlerOffsetField::encode(offset) |
    3373      176197 :               HandlerPredictionField::encode(prediction);
    3374      176197 :   set(index * kRangeEntrySize + kRangeHandlerIndex, Smi::FromInt(value));
    3375      176197 : }
    3376             : 
    3377      176197 : void HandlerTable::SetRangeData(int index, int value) {
    3378      176197 :   set(index * kRangeEntrySize + kRangeDataIndex, Smi::FromInt(value));
    3379      176197 : }
    3380             : 
    3381             : 
    3382      230004 : void HandlerTable::SetReturnOffset(int index, int value) {
    3383      230004 :   set(index * kReturnEntrySize + kReturnOffsetIndex, Smi::FromInt(value));
    3384      230004 : }
    3385             : 
    3386      230004 : void HandlerTable::SetReturnHandler(int index, int offset) {
    3387      230004 :   int value = HandlerOffsetField::encode(offset);
    3388      230004 :   set(index * kReturnEntrySize + kReturnHandlerIndex, Smi::FromInt(value));
    3389      230004 : }
    3390             : 
    3391             : int HandlerTable::NumberOfRangeEntries() const {
    3392    14338899 :   return length() / kRangeEntrySize;
    3393             : }
    3394             : 
    3395             : template <typename Derived, typename Shape, typename Key>
    3396             : HashTable<Derived, Shape, Key>*
    3397           0 : HashTable<Derived, Shape, Key>::cast(Object* obj) {
    3398             :   SLOW_DCHECK(obj->IsHashTable());
    3399           0 :   return reinterpret_cast<HashTable*>(obj);
    3400             : }
    3401             : 
    3402             : 
    3403             : template <typename Derived, typename Shape, typename Key>
    3404             : const HashTable<Derived, Shape, Key>*
    3405           0 : HashTable<Derived, Shape, Key>::cast(const Object* obj) {
    3406             :   SLOW_DCHECK(obj->IsHashTable());
    3407           0 :   return reinterpret_cast<const HashTable*>(obj);
    3408             : }
    3409             : 
    3410             : 
    3411  2044012630 : SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
    3412   372160932 : SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
    3413             : 
    3414     2264978 : SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
    3415   146347276 : NOBARRIER_SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
    3416             : 
    3417 25747696765 : SMI_ACCESSORS(String, length, kLengthOffset)
    3418   466254896 : SYNCHRONIZED_SMI_ACCESSORS(String, length, kLengthOffset)
    3419             : 
    3420             : 
    3421             : int FreeSpace::Size() { return size(); }
    3422             : 
    3423             : 
    3424             : FreeSpace* FreeSpace::next() {
    3425             :   DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
    3426             :          (!GetHeap()->deserialization_complete() && map() == NULL));
    3427             :   DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size());
    3428             :   return reinterpret_cast<FreeSpace*>(
    3429     2378000 :       Memory::Address_at(address() + kNextOffset));
    3430             : }
    3431             : 
    3432             : 
    3433             : void FreeSpace::set_next(FreeSpace* next) {
    3434             :   DCHECK(map() == GetHeap()->root(Heap::kFreeSpaceMapRootIndex) ||
    3435             :          (!GetHeap()->deserialization_complete() && map() == NULL));
    3436             :   DCHECK_LE(kNextOffset + kPointerSize, nobarrier_size());
    3437             :   base::NoBarrier_Store(
    3438             :       reinterpret_cast<base::AtomicWord*>(address() + kNextOffset),
    3439    35109659 :       reinterpret_cast<base::AtomicWord>(next));
    3440             : }
    3441             : 
    3442             : 
    3443        4195 : FreeSpace* FreeSpace::cast(HeapObject* o) {
    3444             :   SLOW_DCHECK(!o->GetHeap()->deserialization_complete() || o->IsFreeSpace());
    3445        4195 :   return reinterpret_cast<FreeSpace*>(o);
    3446             : }
    3447             : 
    3448             : 
    3449       66201 : uint32_t Name::hash_field() {
    3450  1544264571 :   return READ_UINT32_FIELD(this, kHashFieldOffset);
    3451             : }
    3452             : 
    3453             : 
    3454             : void Name::set_hash_field(uint32_t value) {
    3455   258623759 :   WRITE_UINT32_FIELD(this, kHashFieldOffset, value);
    3456             : #if V8_HOST_ARCH_64_BIT
    3457             : #if V8_TARGET_LITTLE_ENDIAN
    3458   258623759 :   WRITE_UINT32_FIELD(this, kHashFieldSlot + kIntSize, 0);
    3459             : #else
    3460             :   WRITE_UINT32_FIELD(this, kHashFieldSlot, 0);
    3461             : #endif
    3462             : #endif
    3463             : }
    3464             : 
    3465             : 
    3466      143631 : bool Name::Equals(Name* other) {
    3467      143631 :   if (other == this) return true;
    3468      188309 :   if ((this->IsInternalizedString() && other->IsInternalizedString()) ||
    3469       94486 :       this->IsSymbol() || other->IsSymbol()) {
    3470             :     return false;
    3471             :   }
    3472          15 :   return String::cast(this)->SlowEquals(String::cast(other));
    3473             : }
    3474             : 
    3475             : 
    3476     1399285 : bool Name::Equals(Handle<Name> one, Handle<Name> two) {
    3477     1399285 :   if (one.is_identical_to(two)) return true;
    3478     2283368 :   if ((one->IsInternalizedString() && two->IsInternalizedString()) ||
    3479     1141714 :       one->IsSymbol() || two->IsSymbol()) {
    3480             :     return false;
    3481             :   }
    3482             :   return String::SlowEquals(Handle<String>::cast(one),
    3483          30 :                             Handle<String>::cast(two));
    3484             : }
    3485             : 
    3486             : 
    3487     1504091 : ACCESSORS(Symbol, name, Object, kNameOffset)
    3488    42915495 : SMI_ACCESSORS(Symbol, flags, kFlagsOffset)
    3489        2240 : BOOL_ACCESSORS(Symbol, flags, is_private, kPrivateBit)
    3490             : BOOL_ACCESSORS(Symbol, flags, is_well_known_symbol, kWellKnownSymbolBit)
    3491             : BOOL_ACCESSORS(Symbol, flags, is_public, kPublicBit)
    3492             : 
    3493   132146043 : bool String::Equals(String* other) {
    3494   132146043 :   if (other == this) return true;
    3495   217701682 :   if (this->IsInternalizedString() && other->IsInternalizedString()) {
    3496             :     return false;
    3497             :   }
    3498    35264923 :   return SlowEquals(other);
    3499             : }
    3500             : 
    3501             : 
    3502     7222234 : bool String::Equals(Handle<String> one, Handle<String> two) {
    3503     7222234 :   if (one.is_identical_to(two)) return true;
    3504     7766586 :   if (one->IsInternalizedString() && two->IsInternalizedString()) {
    3505             :     return false;
    3506             :   }
    3507     6240854 :   return SlowEquals(one, two);
    3508             : }
    3509             : 
    3510             : 
    3511    81635361 : Handle<String> String::Flatten(Handle<String> string, PretenureFlag pretenure) {
    3512    81635360 :   if (string->IsConsString()) {
    3513             :     Handle<ConsString> cons = Handle<ConsString>::cast(string);
    3514     6155360 :     if (cons->IsFlat()) {
    3515             :       string = handle(cons->first());
    3516             :     } else {
    3517     5838564 :       return SlowFlatten(cons, pretenure);
    3518             :     }
    3519             :   }
    3520    75796793 :   if (string->IsThinString()) {
    3521             :     string = handle(Handle<ThinString>::cast(string)->actual());
    3522             :     DCHECK(!string->IsConsString());
    3523             :   }
    3524    75796793 :   return string;
    3525             : }
    3526             : 
    3527             : 
    3528             : uint16_t String::Get(int index) {
    3529             :   DCHECK(index >= 0 && index < length());
    3530   712184029 :   switch (StringShape(this).full_representation_tag()) {
    3531             :     case kSeqStringTag | kOneByteStringTag:
    3532   669355331 :       return SeqOneByteString::cast(this)->SeqOneByteStringGet(index);
    3533             :     case kSeqStringTag | kTwoByteStringTag:
    3534    32117939 :       return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index);
    3535             :     case kConsStringTag | kOneByteStringTag:
    3536             :     case kConsStringTag | kTwoByteStringTag:
    3537     4314957 :       return ConsString::cast(this)->ConsStringGet(index);
    3538             :     case kExternalStringTag | kOneByteStringTag:
    3539     4569799 :       return ExternalOneByteString::cast(this)->ExternalOneByteStringGet(index);
    3540             :     case kExternalStringTag | kTwoByteStringTag:
    3541        8878 :       return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index);
    3542             :     case kSlicedStringTag | kOneByteStringTag:
    3543             :     case kSlicedStringTag | kTwoByteStringTag:
    3544     1816864 :       return SlicedString::cast(this)->SlicedStringGet(index);
    3545             :     case kThinStringTag | kOneByteStringTag:
    3546             :     case kThinStringTag | kTwoByteStringTag:
    3547         258 :       return ThinString::cast(this)->ThinStringGet(index);
    3548             :     default:
    3549             :       break;
    3550             :   }
    3551             : 
    3552           0 :   UNREACHABLE();
    3553             :   return 0;
    3554             : }
    3555             : 
    3556             : 
    3557           0 : void String::Set(int index, uint16_t value) {
    3558             :   DCHECK(index >= 0 && index < length());
    3559             :   DCHECK(StringShape(this).IsSequential());
    3560             : 
    3561             :   return this->IsOneByteRepresentation()
    3562             :       ? SeqOneByteString::cast(this)->SeqOneByteStringSet(index, value)
    3563           0 :       : SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value);
    3564             : }
    3565             : 
    3566             : 
    3567     6663528 : bool String::IsFlat() {
    3568     6663528 :   if (!StringShape(this).IsCons()) return true;
    3569     6632491 :   return ConsString::cast(this)->second()->length() == 0;
    3570             : }
    3571             : 
    3572             : 
    3573             : String* String::GetUnderlying() {
    3574             :   // Giving direct access to underlying string only makes sense if the
    3575             :   // wrapping string is already flattened.
    3576             :   DCHECK(this->IsFlat());
    3577             :   DCHECK(StringShape(this).IsIndirect());
    3578             :   STATIC_ASSERT(ConsString::kFirstOffset == SlicedString::kParentOffset);
    3579             :   STATIC_ASSERT(ConsString::kFirstOffset == ThinString::kActualOffset);
    3580             :   const int kUnderlyingOffset = SlicedString::kParentOffset;
    3581        2781 :   return String::cast(READ_FIELD(this, kUnderlyingOffset));
    3582             : }
    3583             : 
    3584             : 
    3585             : template<class Visitor>
    3586   134732421 : ConsString* String::VisitFlat(Visitor* visitor,
    3587             :                               String* string,
    3588             :                               const int offset) {
    3589             :   int slice_offset = offset;
    3590             :   const int length = string->length();
    3591             :   DCHECK(offset <= length);
    3592             :   while (true) {
    3593             :     int32_t type = string->map()->instance_type();
    3594   134918815 :     switch (type & (kStringRepresentationMask | kStringEncodingMask)) {
    3595             :       case kSeqStringTag | kOneByteStringTag:
    3596   227680654 :         visitor->VisitOneByteString(
    3597   113840327 :             SeqOneByteString::cast(string)->GetChars() + slice_offset,
    3598             :             length - offset);
    3599   113840330 :         return NULL;
    3600             : 
    3601             :       case kSeqStringTag | kTwoByteStringTag:
    3602    25574300 :         visitor->VisitTwoByteString(
    3603    12787150 :             SeqTwoByteString::cast(string)->GetChars() + slice_offset,
    3604             :             length - offset);
    3605    12787150 :         return NULL;
    3606             : 
    3607             :       case kExternalStringTag | kOneByteStringTag:
    3608        3836 :         visitor->VisitOneByteString(
    3609             :             ExternalOneByteString::cast(string)->GetChars() + slice_offset,
    3610             :             length - offset);
    3611        1918 :         return NULL;
    3612             : 
    3613             :       case kExternalStringTag | kTwoByteStringTag:
    3614       43114 :         visitor->VisitTwoByteString(
    3615             :             ExternalTwoByteString::cast(string)->GetChars() + slice_offset,
    3616             :             length - offset);
    3617       21557 :         return NULL;
    3618             : 
    3619             :       case kSlicedStringTag | kOneByteStringTag:
    3620             :       case kSlicedStringTag | kTwoByteStringTag: {
    3621             :         SlicedString* slicedString = SlicedString::cast(string);
    3622      179639 :         slice_offset += slicedString->offset();
    3623             :         string = slicedString->parent();
    3624      179639 :         continue;
    3625             :       }
    3626             : 
    3627             :       case kConsStringTag | kOneByteStringTag:
    3628             :       case kConsStringTag | kTwoByteStringTag:
    3629       47532 :         return ConsString::cast(string);
    3630             : 
    3631             :       case kThinStringTag | kOneByteStringTag:
    3632             :       case kThinStringTag | kTwoByteStringTag:
    3633             :         string = ThinString::cast(string)->actual();
    3634        6755 :         continue;
    3635             : 
    3636             :       default:
    3637           0 :         UNREACHABLE();
    3638             :         return NULL;
    3639             :     }
    3640             :   }
    3641             : }
    3642             : 
    3643             : 
    3644             : template <>
    3645             : inline Vector<const uint8_t> String::GetCharVector() {
    3646     2598391 :   String::FlatContent flat = GetFlatContent();
    3647             :   DCHECK(flat.IsOneByte());
    3648     2598391 :   return flat.ToOneByteVector();
    3649             : }
    3650             : 
    3651             : 
    3652             : template <>
    3653             : inline Vector<const uc16> String::GetCharVector() {
    3654     1320415 :   String::FlatContent flat = GetFlatContent();
    3655             :   DCHECK(flat.IsTwoByte());
    3656     1320415 :   return flat.ToUC16Vector();
    3657             : }
    3658             : 
    3659             : uint32_t String::ToValidIndex(Object* number) {
    3660        9854 :   uint32_t index = PositiveNumberToUint32(number);
    3661        9854 :   uint32_t length_value = static_cast<uint32_t>(length());
    3662        9854 :   if (index > length_value) return length_value;
    3663             :   return index;
    3664             : }
    3665             : 
    3666  2424991124 : uint16_t SeqOneByteString::SeqOneByteStringGet(int index) {
    3667             :   DCHECK(index >= 0 && index < length());
    3668  2514994356 :   return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
    3669             : }
    3670             : 
    3671             : 
    3672   303538318 : void SeqOneByteString::SeqOneByteStringSet(int index, uint16_t value) {
    3673             :   DCHECK(index >= 0 && index < length() && value <= kMaxOneByteCharCode);
    3674  1472839088 :   WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize,
    3675  1472839088 :                    static_cast<byte>(value));
    3676   303538318 : }
    3677             : 
    3678             : 
    3679             : Address SeqOneByteString::GetCharsAddress() {
    3680             :   return FIELD_ADDR(this, kHeaderSize);
    3681             : }
    3682             : 
    3683             : 
    3684       49538 : uint8_t* SeqOneByteString::GetChars() {
    3685       49538 :   return reinterpret_cast<uint8_t*>(GetCharsAddress());
    3686             : }
    3687             : 
    3688             : 
    3689             : Address SeqTwoByteString::GetCharsAddress() {
    3690             :   return FIELD_ADDR(this, kHeaderSize);
    3691             : }
    3692             : 
    3693             : 
    3694       91378 : uc16* SeqTwoByteString::GetChars() {
    3695       91378 :   return reinterpret_cast<uc16*>(FIELD_ADDR(this, kHeaderSize));
    3696             : }
    3697             : 
    3698             : 
    3699    32117939 : uint16_t SeqTwoByteString::SeqTwoByteStringGet(int index) {
    3700             :   DCHECK(index >= 0 && index < length());
    3701    32117939 :   return READ_UINT16_FIELD(this, kHeaderSize + index * kShortSize);
    3702             : }
    3703             : 
    3704             : 
    3705     2279171 : void SeqTwoByteString::SeqTwoByteStringSet(int index, uint16_t value) {
    3706             :   DCHECK(index >= 0 && index < length());
    3707    26023691 :   WRITE_UINT16_FIELD(this, kHeaderSize + index * kShortSize, value);
    3708     2279171 : }
    3709             : 
    3710             : 
    3711     6559374 : int SeqTwoByteString::SeqTwoByteStringSize(InstanceType instance_type) {
    3712     6559374 :   return SizeFor(length());
    3713             : }
    3714             : 
    3715             : 
    3716     8441518 : int SeqOneByteString::SeqOneByteStringSize(InstanceType instance_type) {
    3717     8441518 :   return SizeFor(length());
    3718             : }
    3719             : 
    3720             : 
    3721             : String* SlicedString::parent() {
    3722     5854526 :   return String::cast(READ_FIELD(this, kParentOffset));
    3723             : }
    3724             : 
    3725             : 
    3726     3593170 : void SlicedString::set_parent(String* parent, WriteBarrierMode mode) {
    3727             :   DCHECK(parent->IsSeqString() || parent->IsExternalString());
    3728     3593170 :   WRITE_FIELD(this, kParentOffset, parent);
    3729    10779510 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kParentOffset, parent, mode);
    3730     3593170 : }
    3731             : 
    3732             : 
    3733     9447690 : SMI_ACCESSORS(SlicedString, offset, kOffsetOffset)
    3734             : 
    3735             : 
    3736             : String* ConsString::first() {
    3737 23870949865 :   return String::cast(READ_FIELD(this, kFirstOffset));
    3738             : }
    3739             : 
    3740             : 
    3741             : Object* ConsString::unchecked_first() {
    3742      919422 :   return READ_FIELD(this, kFirstOffset);
    3743             : }
    3744             : 
    3745             : 
    3746    30766384 : void ConsString::set_first(String* value, WriteBarrierMode mode) {
    3747    30766384 :   WRITE_FIELD(this, kFirstOffset, value);
    3748    44544938 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kFirstOffset, value, mode);
    3749    30766384 : }
    3750             : 
    3751             : 
    3752             : String* ConsString::second() {
    3753   210741594 :   return String::cast(READ_FIELD(this, kSecondOffset));
    3754             : }
    3755             : 
    3756             : 
    3757             : Object* ConsString::unchecked_second() {
    3758    54644547 :   return READ_FIELD(this, kSecondOffset);
    3759             : }
    3760             : 
    3761             : 
    3762    30766384 : void ConsString::set_second(String* value, WriteBarrierMode mode) {
    3763    30766384 :   WRITE_FIELD(this, kSecondOffset, value);
    3764    44544938 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kSecondOffset, value, mode);
    3765    30766384 : }
    3766             : 
    3767    30089174 : ACCESSORS(ThinString, actual, String, kActualOffset);
    3768             : 
    3769             : bool ExternalString::is_short() {
    3770             :   InstanceType type = map()->instance_type();
    3771     1024632 :   return (type & kShortExternalStringMask) == kShortExternalStringTag;
    3772             : }
    3773             : 
    3774             : 
    3775             : const ExternalOneByteString::Resource* ExternalOneByteString::resource() {
    3776     6576449 :   return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset));
    3777             : }
    3778             : 
    3779             : 
    3780     1001462 : void ExternalOneByteString::update_data_cache() {
    3781     2002924 :   if (is_short()) return;
    3782             :   const char** data_field =
    3783             :       reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset));
    3784        8452 :   *data_field = resource()->data();
    3785             : }
    3786             : 
    3787             : 
    3788             : void ExternalOneByteString::set_resource(
    3789             :     const ExternalOneByteString::Resource* resource) {
    3790             :   DCHECK(IsAligned(reinterpret_cast<intptr_t>(resource), kPointerSize));
    3791             :   *reinterpret_cast<const Resource**>(
    3792     1001477 :       FIELD_ADDR(this, kResourceOffset)) = resource;
    3793     1001465 :   if (resource != NULL) update_data_cache();
    3794             : }
    3795             : 
    3796             : 
    3797             : const uint8_t* ExternalOneByteString::GetChars() {
    3798     5539364 :   return reinterpret_cast<const uint8_t*>(resource()->data());
    3799             : }
    3800             : 
    3801             : 
    3802     4569799 : uint16_t ExternalOneByteString::ExternalOneByteStringGet(int index) {
    3803             :   DCHECK(index >= 0 && index < length());
    3804     4569799 :   return GetChars()[index];
    3805             : }
    3806             : 
    3807             : 
    3808             : const ExternalTwoByteString::Resource* ExternalTwoByteString::resource() {
    3809      397390 :   return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset));
    3810             : }
    3811             : 
    3812             : 
    3813       23170 : void ExternalTwoByteString::update_data_cache() {
    3814       46340 :   if (is_short()) return;
    3815             :   const uint16_t** data_field =
    3816             :       reinterpret_cast<const uint16_t**>(FIELD_ADDR(this, kResourceDataOffset));
    3817       22993 :   *data_field = resource()->data();
    3818             : }
    3819             : 
    3820             : 
    3821             : void ExternalTwoByteString::set_resource(
    3822             :     const ExternalTwoByteString::Resource* resource) {
    3823             :   *reinterpret_cast<const Resource**>(
    3824       23170 :       FIELD_ADDR(this, kResourceOffset)) = resource;
    3825       23170 :   if (resource != NULL) update_data_cache();
    3826             : }
    3827             : 
    3828             : 
    3829             : const uint16_t* ExternalTwoByteString::GetChars() {
    3830      374345 :   return resource()->data();
    3831             : }
    3832             : 
    3833             : 
    3834        8878 : uint16_t ExternalTwoByteString::ExternalTwoByteStringGet(int index) {
    3835             :   DCHECK(index >= 0 && index < length());
    3836        8878 :   return GetChars()[index];
    3837             : }
    3838             : 
    3839             : 
    3840             : const uint16_t* ExternalTwoByteString::ExternalTwoByteStringGetData(
    3841             :       unsigned start) {
    3842          82 :   return GetChars() + start;
    3843             : }
    3844             : 
    3845             : 
    3846    69529831 : int ConsStringIterator::OffsetForDepth(int depth) { return depth & kDepthMask; }
    3847             : 
    3848             : 
    3849             : void ConsStringIterator::PushLeft(ConsString* string) {
    3850 23687727276 :   frames_[depth_++ & kDepthMask] = string;
    3851             : }
    3852             : 
    3853             : 
    3854             : void ConsStringIterator::PushRight(ConsString* string) {
    3855             :   // Inplace update.
    3856    15956645 :   frames_[(depth_-1) & kDepthMask] = string;
    3857             : }
    3858             : 
    3859             : 
    3860             : void ConsStringIterator::AdjustMaximumDepth() {
    3861    21192098 :   if (depth_ > maximum_depth_) maximum_depth_ = depth_;
    3862             : }
    3863             : 
    3864             : 
    3865             : void ConsStringIterator::Pop() {
    3866             :   DCHECK(depth_ > 0);
    3867             :   DCHECK(depth_ <= maximum_depth_);
    3868    55948146 :   depth_--;
    3869             : }
    3870             : 
    3871             : 
    3872    72194792 : uint16_t StringCharacterStream::GetNext() {
    3873             :   DCHECK(buffer8_ != NULL && end_ != NULL);
    3874             :   // Advance cursor if needed.
    3875    72194792 :   if (buffer8_ == end_) HasMore();
    3876             :   DCHECK(buffer8_ < end_);
    3877    72194792 :   return is_one_byte_ ? *buffer8_++ : *buffer16_++;
    3878             : }
    3879             : 
    3880             : 
    3881         162 : StringCharacterStream::StringCharacterStream(String* string, int offset)
    3882     5575993 :     : is_one_byte_(false) {
    3883     5575993 :   Reset(string, offset);
    3884         162 : }
    3885             : 
    3886             : 
    3887     3384890 : void StringCharacterStream::Reset(String* string, int offset) {
    3888     3384890 :   buffer8_ = NULL;
    3889     3384890 :   end_ = NULL;
    3890     3384890 :   ConsString* cons_string = String::VisitFlat(this, string, offset);
    3891     3384888 :   iter_.Reset(cons_string, offset);
    3892     3384888 :   if (cons_string != NULL) {
    3893       44756 :     string = iter_.Next(&offset);
    3894       44756 :     if (string != NULL) String::VisitFlat(this, string, offset);
    3895             :   }
    3896     3384888 : }
    3897             : 
    3898             : 
    3899    77992301 : bool StringCharacterStream::HasMore() {
    3900    77992301 :   if (buffer8_ != end_) return true;
    3901             :   int offset;
    3902     7561828 :   String* string = iter_.Next(&offset);
    3903             :   DCHECK_EQ(offset, 0);
    3904     7561828 :   if (string == NULL) return false;
    3905       98962 :   String::VisitFlat(this, string);
    3906             :   DCHECK(buffer8_ != end_);
    3907       98962 :   return true;
    3908             : }
    3909             : 
    3910             : 
    3911             : void StringCharacterStream::VisitOneByteString(
    3912             :     const uint8_t* chars, int length) {
    3913     3483805 :   is_one_byte_ = true;
    3914     3483805 :   buffer8_ = chars;
    3915     3483805 :   end_ = chars + length;
    3916             : }
    3917             : 
    3918             : 
    3919             : void StringCharacterStream::VisitTwoByteString(
    3920             :     const uint16_t* chars, int length) {
    3921          45 :   is_one_byte_ = false;
    3922          45 :   buffer16_ = chars;
    3923          45 :   end_ = reinterpret_cast<const uint8_t*>(chars + length);
    3924             : }
    3925             : 
    3926             : 
    3927     3772688 : int ByteArray::Size() { return RoundUp(length() + kHeaderSize, kPointerSize); }
    3928             : 
    3929             : byte ByteArray::get(int index) {
    3930             :   DCHECK(index >= 0 && index < this->length());
    3931   480071996 :   return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
    3932             : }
    3933             : 
    3934             : void ByteArray::set(int index, byte value) {
    3935             :   DCHECK(index >= 0 && index < this->length());
    3936     1698845 :   WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value);
    3937             : }
    3938             : 
    3939             : void ByteArray::copy_in(int index, const byte* buffer, int length) {
    3940             :   DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index &&
    3941             :          index + length <= this->length());
    3942      147479 :   byte* dst_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize);
    3943        3609 :   memcpy(dst_addr, buffer, length);
    3944             : }
    3945             : 
    3946             : void ByteArray::copy_out(int index, byte* buffer, int length) {
    3947             :   DCHECK(index >= 0 && length >= 0 && length <= kMaxInt - index &&
    3948             :          index + length <= this->length());
    3949        3310 :   const byte* src_addr = FIELD_ADDR(this, kHeaderSize + index * kCharSize);
    3950             :   memcpy(buffer, src_addr, length);
    3951             : }
    3952             : 
    3953             : int ByteArray::get_int(int index) {
    3954             :   DCHECK(index >= 0 && index < this->length() / kIntSize);
    3955        4829 :   return READ_INT_FIELD(this, kHeaderSize + index * kIntSize);
    3956             : }
    3957             : 
    3958             : void ByteArray::set_int(int index, int value) {
    3959             :   DCHECK(index >= 0 && index < this->length() / kIntSize);
    3960         951 :   WRITE_INT_FIELD(this, kHeaderSize + index * kIntSize, value);
    3961             : }
    3962             : 
    3963             : ByteArray* ByteArray::FromDataStartAddress(Address address) {
    3964             :   DCHECK_TAG_ALIGNED(address);
    3965             :   return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag);
    3966             : }
    3967             : 
    3968             : 
    3969       48428 : int ByteArray::ByteArraySize() { return SizeFor(this->length()); }
    3970             : 
    3971             : 
    3972             : Address ByteArray::GetDataStartAddress() {
    3973             :   return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize;
    3974             : }
    3975             : 
    3976             : 
    3977       65505 : byte BytecodeArray::get(int index) {
    3978             :   DCHECK(index >= 0 && index < this->length());
    3979   232346138 :   return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
    3980             : }
    3981             : 
    3982             : 
    3983             : void BytecodeArray::set(int index, byte value) {
    3984             :   DCHECK(index >= 0 && index < this->length());
    3985    14670655 :   WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value);
    3986             : }
    3987             : 
    3988             : 
    3989             : void BytecodeArray::set_frame_size(int frame_size) {
    3990             :   DCHECK_GE(frame_size, 0);
    3991             :   DCHECK(IsAligned(frame_size, static_cast<unsigned>(kPointerSize)));
    3992     2111983 :   WRITE_INT_FIELD(this, kFrameSizeOffset, frame_size);
    3993             : }
    3994             : 
    3995             : 
    3996             : int BytecodeArray::frame_size() const {
    3997    19724412 :   return READ_INT_FIELD(this, kFrameSizeOffset);
    3998             : }
    3999             : 
    4000             : 
    4001       37547 : int BytecodeArray::register_count() const {
    4002    19714942 :   return frame_size() / kPointerSize;
    4003             : }
    4004             : 
    4005             : 
    4006             : void BytecodeArray::set_parameter_count(int number_of_parameters) {
    4007             :   DCHECK_GE(number_of_parameters, 0);
    4008             :   // Parameter count is stored as the size on stack of the parameters to allow
    4009             :   // it to be used directly by generated code.
    4010     2111983 :   WRITE_INT_FIELD(this, kParameterSizeOffset,
    4011     2111983 :                   (number_of_parameters << kPointerSizeLog2));
    4012             : }
    4013             : 
    4014             : int BytecodeArray::interrupt_budget() const {
    4015        9470 :   return READ_INT_FIELD(this, kInterruptBudgetOffset);
    4016             : }
    4017             : 
    4018             : void BytecodeArray::set_interrupt_budget(int interrupt_budget) {
    4019             :   DCHECK_GE(interrupt_budget, 0);
    4020     2111981 :   WRITE_INT_FIELD(this, kInterruptBudgetOffset, interrupt_budget);
    4021             : }
    4022             : 
    4023             : int BytecodeArray::osr_loop_nesting_level() const {
    4024       17899 :   return READ_INT8_FIELD(this, kOSRNestingLevelOffset);
    4025             : }
    4026             : 
    4027             : void BytecodeArray::set_osr_loop_nesting_level(int depth) {
    4028             :   DCHECK(0 <= depth && depth <= AbstractCode::kMaxLoopNestingMarker);
    4029             :   STATIC_ASSERT(AbstractCode::kMaxLoopNestingMarker < kMaxInt8);
    4030     2126246 :   WRITE_INT8_FIELD(this, kOSRNestingLevelOffset, depth);
    4031             : }
    4032             : 
    4033             : BytecodeArray::Age BytecodeArray::bytecode_age() const {
    4034     2205517 :   return static_cast<Age>(READ_INT8_FIELD(this, kBytecodeAgeOffset));
    4035             : }
    4036             : 
    4037             : void BytecodeArray::set_bytecode_age(BytecodeArray::Age age) {
    4038             :   DCHECK_GE(age, kFirstBytecodeAge);
    4039             :   DCHECK_LE(age, kLastBytecodeAge);
    4040             :   STATIC_ASSERT(kLastBytecodeAge <= kMaxInt8);
    4041     3519146 :   WRITE_INT8_FIELD(this, kBytecodeAgeOffset, static_cast<int8_t>(age));
    4042             : }
    4043             : 
    4044           0 : int BytecodeArray::parameter_count() const {
    4045             :   // Parameter count is stored as the size on stack of the parameters to allow
    4046             :   // it to be used directly by generated code.
    4047     1812802 :   return READ_INT_FIELD(this, kParameterSizeOffset) >> kPointerSizeLog2;
    4048             : }
    4049             : 
    4050    10698684 : ACCESSORS(BytecodeArray, constant_pool, FixedArray, kConstantPoolOffset)
    4051    25802205 : ACCESSORS(BytecodeArray, handler_table, FixedArray, kHandlerTableOffset)
    4052    18945968 : ACCESSORS(BytecodeArray, source_position_table, Object,
    4053             :           kSourcePositionTableOffset)
    4054             : 
    4055           0 : Address BytecodeArray::GetFirstBytecodeAddress() {
    4056           0 :   return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize;
    4057             : }
    4058             : 
    4059     6221226 : ByteArray* BytecodeArray::SourcePositionTable() {
    4060             :   Object* maybe_table = source_position_table();
    4061     6221227 :   if (maybe_table->IsByteArray()) return ByteArray::cast(maybe_table);
    4062             :   DCHECK(maybe_table->IsSourcePositionTableWithFrameCache());
    4063             :   return SourcePositionTableWithFrameCache::cast(maybe_table)
    4064      218742 :       ->source_position_table();
    4065             : }
    4066             : 
    4067             : int BytecodeArray::BytecodeArraySize() { return SizeFor(this->length()); }
    4068             : 
    4069     2076107 : int BytecodeArray::SizeIncludingMetadata() {
    4070             :   int size = BytecodeArraySize();
    4071     2076107 :   size += constant_pool()->Size();
    4072     2076107 :   size += handler_table()->Size();
    4073     4152213 :   size += SourcePositionTable()->Size();
    4074     2076107 :   return size;
    4075             : }
    4076             : 
    4077     6934142 : ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset)
    4078             : 
    4079             : 
    4080             : void* FixedTypedArrayBase::external_pointer() const {
    4081     4243271 :   intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset);
    4082             :   return reinterpret_cast<void*>(ptr);
    4083             : }
    4084             : 
    4085             : 
    4086             : void FixedTypedArrayBase::set_external_pointer(void* value,
    4087             :                                                WriteBarrierMode mode) {
    4088       16833 :   intptr_t ptr = reinterpret_cast<intptr_t>(value);
    4089       16833 :   WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr);
    4090             : }
    4091             : 
    4092             : 
    4093         421 : void* FixedTypedArrayBase::DataPtr() {
    4094             :   return reinterpret_cast<void*>(
    4095     8458864 :       reinterpret_cast<intptr_t>(base_pointer()) +
    4096     4229432 :       reinterpret_cast<intptr_t>(external_pointer()));
    4097             : }
    4098             : 
    4099             : 
    4100     1999817 : int FixedTypedArrayBase::ElementSize(InstanceType type) {
    4101             :   int element_size;
    4102     1999817 :   switch (type) {
    4103             : #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size)                       \
    4104             :     case FIXED_##TYPE##_ARRAY_TYPE:                                           \
    4105             :       element_size = size;                                                    \
    4106             :       break;
    4107             : 
    4108      219998 :     TYPED_ARRAYS(TYPED_ARRAY_CASE)
    4109             : #undef TYPED_ARRAY_CASE
    4110             :     default:
    4111           0 :       UNREACHABLE();
    4112             :       return 0;
    4113             :   }
    4114             :   return element_size;
    4115             : }
    4116             : 
    4117             : 
    4118             : int FixedTypedArrayBase::DataSize(InstanceType type) {
    4119     2687877 :   if (base_pointer() == Smi::kZero) return 0;
    4120     2220722 :   return length() * ElementSize(type);
    4121             : }
    4122             : 
    4123             : 
    4124      926223 : int FixedTypedArrayBase::DataSize() {
    4125      926223 :   return DataSize(map()->instance_type());
    4126             : }
    4127             : 
    4128             : 
    4129             : int FixedTypedArrayBase::size() {
    4130      894584 :   return OBJECT_POINTER_ALIGN(kDataOffset + DataSize());
    4131             : }
    4132             : 
    4133             : 
    4134     1761654 : int FixedTypedArrayBase::TypedArraySize(InstanceType type) {
    4135     1761654 :   return OBJECT_POINTER_ALIGN(kDataOffset + DataSize(type));
    4136             : }
    4137             : 
    4138             : 
    4139             : int FixedTypedArrayBase::TypedArraySize(InstanceType type, int length) {
    4140         146 :   return OBJECT_POINTER_ALIGN(kDataOffset + length * ElementSize(type));
    4141             : }
    4142             : 
    4143             : 
    4144             : uint8_t Uint8ArrayTraits::defaultValue() { return 0; }
    4145             : 
    4146             : 
    4147             : uint8_t Uint8ClampedArrayTraits::defaultValue() { return 0; }
    4148             : 
    4149             : 
    4150             : int8_t Int8ArrayTraits::defaultValue() { return 0; }
    4151             : 
    4152             : 
    4153             : uint16_t Uint16ArrayTraits::defaultValue() { return 0; }
    4154             : 
    4155             : 
    4156             : int16_t Int16ArrayTraits::defaultValue() { return 0; }
    4157             : 
    4158             : 
    4159             : uint32_t Uint32ArrayTraits::defaultValue() { return 0; }
    4160             : 
    4161             : 
    4162             : int32_t Int32ArrayTraits::defaultValue() { return 0; }
    4163             : 
    4164             : 
    4165             : float Float32ArrayTraits::defaultValue() {
    4166             :   return std::numeric_limits<float>::quiet_NaN();
    4167             : }
    4168             : 
    4169             : 
    4170             : double Float64ArrayTraits::defaultValue() {
    4171             :   return std::numeric_limits<double>::quiet_NaN();
    4172             : }
    4173             : 
    4174             : 
    4175             : template <class Traits>
    4176      444734 : typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) {
    4177             :   DCHECK((index >= 0) && (index < this->length()));
    4178             :   ElementType* ptr = reinterpret_cast<ElementType*>(DataPtr());
    4179     1818748 :   return ptr[index];
    4180             : }
    4181             : 
    4182             : 
    4183             : template <class Traits>
    4184      209253 : void FixedTypedArray<Traits>::set(int index, ElementType value) {
    4185             :   DCHECK((index >= 0) && (index < this->length()));
    4186             :   ElementType* ptr = reinterpret_cast<ElementType*>(DataPtr());
    4187     2373780 :   ptr[index] = value;
    4188      209253 : }
    4189             : 
    4190             : template <class Traits>
    4191             : typename Traits::ElementType FixedTypedArray<Traits>::from(int value) {
    4192     1162807 :   return static_cast<ElementType>(value);
    4193             : }
    4194             : 
    4195             : template <>
    4196             : inline uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from(int value) {
    4197       30115 :   if (value < 0) return 0;
    4198       29926 :   if (value > 0xFF) return 0xFF;
    4199       29393 :   return static_cast<uint8_t>(value);
    4200             : }
    4201             : 
    4202             : template <class Traits>
    4203             : typename Traits::ElementType FixedTypedArray<Traits>::from(uint32_t value) {
    4204         672 :   return static_cast<ElementType>(value);
    4205             : }
    4206             : 
    4207             : template <>
    4208             : inline uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from(uint32_t value) {
    4209             :   // We need this special case for Uint32 -> Uint8Clamped, because the highest
    4210             :   // Uint32 values will be negative as an int, clamping to 0, rather than 255.
    4211         112 :   if (value > 0xFF) return 0xFF;
    4212          70 :   return static_cast<uint8_t>(value);
    4213             : }
    4214             : 
    4215             : template <class Traits>
    4216             : typename Traits::ElementType FixedTypedArray<Traits>::from(double value) {
    4217      433777 :   return static_cast<ElementType>(DoubleToInt32(value));
    4218             : }
    4219             : 
    4220             : template <>
    4221             : inline uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from(double value) {
    4222             :   // Handle NaNs and less than zero values which clamp to zero.
    4223      145031 :   if (!(value > 0)) return 0;
    4224      143603 :   if (value > 0xFF) return 0xFF;
    4225      142474 :   return static_cast<uint8_t>(lrint(value));
    4226             : }
    4227             : 
    4228             : template <>
    4229             : inline float FixedTypedArray<Float32ArrayTraits>::from(double value) {
    4230      152204 :   return static_cast<float>(value);
    4231             : }
    4232             : 
    4233             : template <>
    4234             : inline double FixedTypedArray<Float64ArrayTraits>::from(double value) {
    4235             :   return value;
    4236             : }
    4237             : 
    4238             : template <class Traits>
    4239      630941 : Handle<Object> FixedTypedArray<Traits>::get(FixedTypedArray<Traits>* array,
    4240             :                                             int index) {
    4241      899612 :   return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index));
    4242             : }
    4243             : 
    4244             : 
    4245             : template <class Traits>
    4246     2046283 : void FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) {
    4247             :   ElementType cast_value = Traits::defaultValue();
    4248     2046283 :   if (value->IsSmi()) {
    4249             :     int int_value = Smi::cast(value)->value();
    4250             :     cast_value = from(int_value);
    4251      860644 :   } else if (value->IsHeapNumber()) {
    4252             :     double double_value = HeapNumber::cast(value)->value();
    4253             :     cast_value = from(double_value);
    4254             :   } else {
    4255             :     // Clamp undefined to the default value. All other types have been
    4256             :     // converted to a number type further up in the call chain.
    4257             :     DCHECK(value->IsUndefined(GetIsolate()));
    4258             :   }
    4259     2046283 :   set(index, cast_value);
    4260     2046283 : }
    4261             : 
    4262             : 
    4263      134951 : Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) {
    4264      134951 :   return handle(Smi::FromInt(scalar), isolate);
    4265             : }
    4266             : 
    4267             : 
    4268        3378 : Handle<Object> Uint8ClampedArrayTraits::ToHandle(Isolate* isolate,
    4269             :                                                  uint8_t scalar) {
    4270        3378 :   return handle(Smi::FromInt(scalar), isolate);
    4271             : }
    4272             : 
    4273             : 
    4274        7181 : Handle<Object> Int8ArrayTraits::ToHandle(Isolate* isolate, int8_t scalar) {
    4275        7181 :   return handle(Smi::FromInt(scalar), isolate);
    4276             : }
    4277             : 
    4278             : 
    4279      117564 : Handle<Object> Uint16ArrayTraits::ToHandle(Isolate* isolate, uint16_t scalar) {
    4280      117564 :   return handle(Smi::FromInt(scalar), isolate);
    4281             : }
    4282             : 
    4283             : 
    4284        5597 : Handle<Object> Int16ArrayTraits::ToHandle(Isolate* isolate, int16_t scalar) {
    4285        5597 :   return handle(Smi::FromInt(scalar), isolate);
    4286             : }
    4287             : 
    4288             : 
    4289             : Handle<Object> Uint32ArrayTraits::ToHandle(Isolate* isolate, uint32_t scalar) {
    4290      116641 :   return isolate->factory()->NewNumberFromUint(scalar);
    4291             : }
    4292             : 
    4293             : 
    4294             : Handle<Object> Int32ArrayTraits::ToHandle(Isolate* isolate, int32_t scalar) {
    4295       12615 :   return isolate->factory()->NewNumberFromInt(scalar);
    4296             : }
    4297             : 
    4298             : 
    4299             : Handle<Object> Float32ArrayTraits::ToHandle(Isolate* isolate, float scalar) {
    4300      117173 :   return isolate->factory()->NewNumber(scalar);
    4301             : }
    4302             : 
    4303             : 
    4304             : Handle<Object> Float64ArrayTraits::ToHandle(Isolate* isolate, double scalar) {
    4305      115841 :   return isolate->factory()->NewNumber(scalar);
    4306             : }
    4307             : 
    4308             : 
    4309             : int Map::visitor_id() {
    4310   884870403 :   return READ_BYTE_FIELD(this, kVisitorIdOffset);
    4311             : }
    4312             : 
    4313             : 
    4314             : void Map::set_visitor_id(int id) {
    4315             :   DCHECK(0 <= id && id < 256);
    4316    61057485 :   WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id));
    4317             : }
    4318             : 
    4319             : 
    4320     2691290 : int Map::instance_size() {
    4321  3391829480 :   return NOBARRIER_READ_BYTE_FIELD(
    4322  3392172657 :       this, kInstanceSizeOffset) << kPointerSizeLog2;
    4323             : }
    4324             : 
    4325             : 
    4326             : int Map::inobject_properties_or_constructor_function_index() {
    4327   559686863 :   return READ_BYTE_FIELD(this,
    4328             :                          kInObjectPropertiesOrConstructorFunctionIndexOffset);
    4329             : }
    4330             : 
    4331             : 
    4332             : void Map::set_inobject_properties_or_constructor_function_index(int value) {
    4333             :   DCHECK(0 <= value && value < 256);
    4334             :   WRITE_BYTE_FIELD(this, kInObjectPropertiesOrConstructorFunctionIndexOffset,
    4335    58579545 :                    static_cast<byte>(value));
    4336             : }
    4337             : 
    4338             : 
    4339    10312813 : int Map::GetInObjectProperties() {
    4340             :   DCHECK(IsJSObjectMap());
    4341    10312813 :   return inobject_properties_or_constructor_function_index();
    4342             : }
    4343             : 
    4344             : 
    4345             : void Map::SetInObjectProperties(int value) {
    4346             :   DCHECK(IsJSObjectMap());
    4347             :   set_inobject_properties_or_constructor_function_index(value);
    4348             : }
    4349             : 
    4350             : 
    4351             : int Map::GetConstructorFunctionIndex() {
    4352             :   DCHECK(IsPrimitiveMap());
    4353             :   return inobject_properties_or_constructor_function_index();
    4354             : }
    4355             : 
    4356             : 
    4357             : void Map::SetConstructorFunctionIndex(int value) {
    4358             :   DCHECK(IsPrimitiveMap());
    4359             :   set_inobject_properties_or_constructor_function_index(value);
    4360             : }
    4361             : 
    4362             : 
    4363   174724334 : int Map::GetInObjectPropertyOffset(int index) {
    4364             :   // Adjust for the number of properties stored in the object.
    4365   174724334 :   index -= GetInObjectProperties();
    4366             :   DCHECK(index <= 0);
    4367   174724334 :   return instance_size() + (index * kPointerSize);
    4368             : }
    4369             : 
    4370             : 
    4371             : Handle<Map> Map::AddMissingTransitionsForTesting(
    4372             :     Handle<Map> split_map, Handle<DescriptorArray> descriptors,
    4373             :     Handle<LayoutDescriptor> full_layout_descriptor) {
    4374             :   return AddMissingTransitions(split_map, descriptors, full_layout_descriptor);
    4375             : }
    4376             : 
    4377             : 
    4378  2698461163 : int HeapObject::SizeFromMap(Map* map) {
    4379             :   int instance_size = map->instance_size();
    4380  2698461163 :   if (instance_size != kVariableSizeSentinel) return instance_size;
    4381             :   // Only inline the most frequent cases.
    4382             :   InstanceType instance_type = map->instance_type();
    4383  1389737244 :   if (instance_type == FIXED_ARRAY_TYPE ||
    4384             :       instance_type == TRANSITION_ARRAY_TYPE) {
    4385             :     return FixedArray::SizeFor(
    4386   341324666 :         reinterpret_cast<FixedArray*>(this)->synchronized_length());
    4387             :   }
    4388  2096825156 :   if (instance_type == ONE_BYTE_STRING_TYPE ||
    4389  1048412578 :       instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) {
    4390             :     // Strings may get concurrently truncated, hence we have to access its
    4391             :     // length synchronized.
    4392             :     return SeqOneByteString::SizeFor(
    4393   364673784 :         reinterpret_cast<SeqOneByteString*>(this)->synchronized_length());
    4394             :   }
    4395   683738794 :   if (instance_type == BYTE_ARRAY_TYPE) {
    4396   289201187 :     return reinterpret_cast<ByteArray*>(this)->ByteArraySize();
    4397             :   }
    4398   394537607 :   if (instance_type == BYTECODE_ARRAY_TYPE) {
    4399     7831479 :     return reinterpret_cast<BytecodeArray*>(this)->BytecodeArraySize();
    4400             :   }
    4401   386706128 :   if (instance_type == FREE_SPACE_TYPE) {
    4402    21188108 :     return reinterpret_cast<FreeSpace*>(this)->nobarrier_size();
    4403             :   }
    4404   731036040 :   if (instance_type == STRING_TYPE ||
    4405   365518020 :       instance_type == INTERNALIZED_STRING_TYPE) {
    4406             :     // Strings may get concurrently truncated, hence we have to access its
    4407             :     // length synchronized.
    4408             :     return SeqTwoByteString::SizeFor(
    4409    74316914 :         reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length());
    4410             :   }
    4411   291201106 :   if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
    4412             :     return FixedDoubleArray::SizeFor(
    4413      208269 :         reinterpret_cast<FixedDoubleArray*>(this)->length());
    4414             :   }
    4415   290992837 :   if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE &&
    4416             :       instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) {
    4417             :     return reinterpret_cast<FixedTypedArrayBase*>(
    4418     1761654 :         this)->TypedArraySize(instance_type);
    4419             :   }
    4420             :   DCHECK(instance_type == CODE_TYPE);
    4421   289246328 :   return reinterpret_cast<Code*>(this)->CodeSize();
    4422             : }
    4423             : 
    4424             : 
    4425             : void Map::set_instance_size(int value) {
    4426             :   DCHECK_EQ(0, value & (kPointerSize - 1));
    4427    32293083 :   value >>= kPointerSizeLog2;
    4428             :   DCHECK(0 <= value && value < 256);
    4429    31956076 :   NOBARRIER_WRITE_BYTE_FIELD(
    4430             :       this, kInstanceSizeOffset, static_cast<byte>(value));
    4431             : }
    4432             : 
    4433             : 
    4434    31705563 : void Map::clear_unused() { WRITE_BYTE_FIELD(this, kUnusedOffset, 0); }
    4435             : 
    4436             : 
    4437 10878496313 : InstanceType Map::instance_type() {
    4438 40857740743 :   return static_cast<InstanceType>(READ_BYTE_FIELD(this, kInstanceTypeOffset));
    4439             : }
    4440             : 
    4441             : 
    4442             : void Map::set_instance_type(InstanceType value) {
    4443    32776312 :   WRITE_BYTE_FIELD(this, kInstanceTypeOffset, value);
    4444             : }
    4445             : 
    4446             : 
    4447             : int Map::unused_property_fields() {
    4448   105638113 :   return READ_BYTE_FIELD(this, kUnusedPropertyFieldsOffset);
    4449             : }
    4450             : 
    4451             : 
    4452             : void Map::set_unused_property_fields(int value) {
    4453    69786215 :   WRITE_BYTE_FIELD(this, kUnusedPropertyFieldsOffset, Min(value, 255));
    4454             : }
    4455             : 
    4456             : 
    4457   257386758 : byte Map::bit_field() const { return READ_BYTE_FIELD(this, kBitFieldOffset); }
    4458             : 
    4459             : 
    4460             : void Map::set_bit_field(byte value) {
    4461    57836006 :   WRITE_BYTE_FIELD(this, kBitFieldOffset, value);
    4462             : }
    4463             : 
    4464             : 
    4465  1124759362 : byte Map::bit_field2() const { return READ_BYTE_FIELD(this, kBitField2Offset); }
    4466             : 
    4467             : 
    4468             : void Map::set_bit_field2(byte value) {
    4469    96810542 :   WRITE_BYTE_FIELD(this, kBitField2Offset, value);
    4470             : }
    4471             : 
    4472             : 
    4473             : void Map::set_non_instance_prototype(bool value) {
    4474             :   if (value) {
    4475        6597 :     set_bit_field(bit_field() | (1 << kHasNonInstancePrototype));
    4476             :   } else {
    4477         108 :     set_bit_field(bit_field() & ~(1 << kHasNonInstancePrototype));
    4478             :   }
    4479             : }
    4480             : 
    4481             : 
    4482             : bool Map::has_non_instance_prototype() {
    4483     5854045 :   return ((1 << kHasNonInstancePrototype) & bit_field()) != 0;
    4484             : }
    4485             : 
    4486             : 
    4487             : void Map::set_is_constructor(bool value) {
    4488         565 :   if (value) {
    4489         931 :     set_bit_field(bit_field() | (1 << kIsConstructor));
    4490             :   } else {
    4491         474 :     set_bit_field(bit_field() & ~(1 << kIsConstructor));
    4492             :   }
    4493             : }
    4494             : 
    4495             : 
    4496      166085 : bool Map::is_constructor() const {
    4497      773381 :   return ((1 << kIsConstructor) & bit_field()) != 0;
    4498             : }
    4499             : 
    4500             : void Map::set_has_hidden_prototype(bool value) {
    4501             :   set_bit_field3(HasHiddenPrototype::update(bit_field3(), value));
    4502             : }
    4503             : 
    4504         790 : bool Map::has_hidden_prototype() const {
    4505         790 :   return HasHiddenPrototype::decode(bit_field3());
    4506             : }
    4507             : 
    4508             : 
    4509             : void Map::set_has_indexed_interceptor() {
    4510         209 :   set_bit_field(bit_field() | (1 << kHasIndexedInterceptor));
    4511             : }
    4512             : 
    4513             : 
    4514         240 : bool Map::has_indexed_interceptor() {
    4515    16275491 :   return ((1 << kHasIndexedInterceptor) & bit_field()) != 0;
    4516             : }
    4517             : 
    4518             : 
    4519             : void Map::set_is_undetectable() {
    4520         309 :   set_bit_field(bit_field() | (1 << kIsUndetectable));
    4521             : }
    4522             : 
    4523             : 
    4524     4710001 : bool Map::is_undetectable() {
    4525    10100447 :   return ((1 << kIsUndetectable) & bit_field()) != 0;
    4526             : }
    4527             : 
    4528             : 
    4529             : void Map::set_has_named_interceptor() {
    4530        1268 :   set_bit_field(bit_field() | (1 << kHasNamedInterceptor));
    4531             : }
    4532             : 
    4533             : 
    4534         342 : bool Map::has_named_interceptor() {
    4535    46147660 :   return ((1 << kHasNamedInterceptor) & bit_field()) != 0;
    4536             : }
    4537             : 
    4538             : 
    4539             : void Map::set_is_access_check_needed(bool access_check_needed) {
    4540             :   if (access_check_needed) {
    4541      214430 :     set_bit_field(bit_field() | (1 << kIsAccessCheckNeeded));
    4542             :   } else {
    4543         293 :     set_bit_field(bit_field() & ~(1 << kIsAccessCheckNeeded));
    4544             :   }
    4545             : }
    4546             : 
    4547             : 
    4548    65670421 : bool Map::is_access_check_needed() {
    4549   120415255 :   return ((1 << kIsAccessCheckNeeded) & bit_field()) != 0;
    4550             : }
    4551             : 
    4552             : 
    4553             : void Map::set_is_extensible(bool value) {
    4554             :   if (value) {
    4555             :     set_bit_field2(bit_field2() | (1 << kIsExtensible));
    4556             :   } else {
    4557       52327 :     set_bit_field2(bit_field2() & ~(1 << kIsExtensible));
    4558             :   }
    4559             : }
    4560             : 
    4561             : bool Map::is_extensible() {
    4562    69998009 :   return ((1 << kIsExtensible) & bit_field2()) != 0;
    4563             : }
    4564             : 
    4565             : 
    4566             : void Map::set_is_prototype_map(bool value) {
    4567             :   set_bit_field2(IsPrototypeMapBits::update(bit_field2(), value));
    4568             : }
    4569             : 
    4570             : bool Map::is_prototype_map() const {
    4571             :   return IsPrototypeMapBits::decode(bit_field2());
    4572             : }
    4573             : 
    4574    34180003 : bool Map::should_be_fast_prototype_map() const {
    4575    34180007 :   if (!prototype_info()->IsPrototypeInfo()) return false;
    4576    28527973 :   return PrototypeInfo::cast(prototype_info())->should_be_fast_map();
    4577             : }
    4578             : 
    4579             : void Map::set_elements_kind(ElementsKind elements_kind) {
    4580             :   DCHECK(static_cast<int>(elements_kind) < kElementsKindCount);
    4581             :   DCHECK(kElementsKindCount <= (1 << Map::ElementsKindBits::kSize));
    4582     2273314 :   set_bit_field2(Map::ElementsKindBits::update(bit_field2(), elements_kind));
    4583             :   DCHECK(this->elements_kind() == elements_kind);
    4584             : }
    4585             : 
    4586             : 
    4587        7366 : ElementsKind Map::elements_kind() {
    4588        7366 :   return Map::ElementsKindBits::decode(bit_field2());
    4589             : }
    4590             : 
    4591             : 
    4592             : bool Map::has_fast_smi_elements() {
    4593             :   return IsFastSmiElementsKind(elements_kind());
    4594             : }
    4595             : 
    4596             : bool Map::has_fast_object_elements() {
    4597             :   return IsFastObjectElementsKind(elements_kind());
    4598             : }
    4599             : 
    4600             : bool Map::has_fast_smi_or_object_elements() {
    4601             :   return IsFastSmiOrObjectElementsKind(elements_kind());
    4602             : }
    4603             : 
    4604             : bool Map::has_fast_double_elements() {
    4605             :   return IsFastDoubleElementsKind(elements_kind());
    4606             : }
    4607             : 
    4608             : bool Map::has_fast_elements() { return IsFastElementsKind(elements_kind()); }
    4609             : 
    4610             : bool Map::has_sloppy_arguments_elements() {
    4611             :   return IsSloppyArgumentsElementsKind(elements_kind());
    4612             : }
    4613             : 
    4614             : bool Map::has_fast_sloppy_arguments_elements() {
    4615             :   return elements_kind() == FAST_SLOPPY_ARGUMENTS_ELEMENTS;
    4616             : }
    4617             : 
    4618             : bool Map::has_fast_string_wrapper_elements() {
    4619             :   return elements_kind() == FAST_STRING_WRAPPER_ELEMENTS;
    4620             : }
    4621             : 
    4622             : bool Map::has_fixed_typed_array_elements() {
    4623             :   return IsFixedTypedArrayElementsKind(elements_kind());
    4624             : }
    4625             : 
    4626             : bool Map::has_dictionary_elements() {
    4627             :   return IsDictionaryElementsKind(elements_kind());
    4628             : }
    4629             : 
    4630             : 
    4631             : void Map::set_dictionary_map(bool value) {
    4632             :   uint32_t new_bit_field3 = DictionaryMap::update(bit_field3(), value);
    4633             :   new_bit_field3 = IsUnstable::update(new_bit_field3, value);
    4634             :   set_bit_field3(new_bit_field3);
    4635             : }
    4636             : 
    4637             : 
    4638      189387 : bool Map::is_dictionary_map() {
    4639      189387 :   return DictionaryMap::decode(bit_field3());
    4640             : }
    4641             : 
    4642             : 
    4643             : Code::Flags Code::flags() {
    4644   356100036 :   return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset));
    4645             : }
    4646             : 
    4647             : 
    4648             : void Map::set_owns_descriptors(bool owns_descriptors) {
    4649             :   set_bit_field3(OwnsDescriptors::update(bit_field3(), owns_descriptors));
    4650             : }
    4651             : 
    4652             : 
    4653             : bool Map::owns_descriptors() {
    4654             :   return OwnsDescriptors::decode(bit_field3());
    4655             : }
    4656             : 
    4657             : 
    4658        1089 : void Map::set_is_callable() { set_bit_field(bit_field() | (1 << kIsCallable)); }
    4659             : 
    4660             : 
    4661    26150311 : bool Map::is_callable() const {
    4662    31518464 :   return ((1 << kIsCallable) & bit_field()) != 0;
    4663             : }
    4664             : 
    4665             : 
    4666             : void Map::deprecate() {
    4667             :   set_bit_field3(Deprecated::update(bit_field3(), true));
    4668             : }
    4669             : 
    4670             : 
    4671     1500028 : bool Map::is_deprecated() {
    4672     1500028 :   return Deprecated::decode(bit_field3());
    4673             : }
    4674             : 
    4675             : 
    4676             : void Map::set_migration_target(bool value) {
    4677             :   set_bit_field3(IsMigrationTarget::update(bit_field3(), value));
    4678             : }
    4679             : 
    4680             : 
    4681             : bool Map::is_migration_target() {
    4682             :   return IsMigrationTarget::decode(bit_field3());
    4683             : }
    4684             : 
    4685             : void Map::set_immutable_proto(bool value) {
    4686             :   set_bit_field3(ImmutablePrototype::update(bit_field3(), value));
    4687             : }
    4688             : 
    4689             : bool Map::is_immutable_proto() {
    4690             :   return ImmutablePrototype::decode(bit_field3());
    4691             : }
    4692             : 
    4693             : void Map::set_new_target_is_base(bool value) {
    4694             :   set_bit_field3(NewTargetIsBase::update(bit_field3(), value));
    4695             : }
    4696             : 
    4697             : 
    4698             : bool Map::new_target_is_base() { return NewTargetIsBase::decode(bit_field3()); }
    4699             : 
    4700             : 
    4701             : void Map::set_construction_counter(int value) {
    4702             :   set_bit_field3(ConstructionCounter::update(bit_field3(), value));
    4703             : }
    4704             : 
    4705             : 
    4706             : int Map::construction_counter() {
    4707             :   return ConstructionCounter::decode(bit_field3());
    4708             : }
    4709             : 
    4710             : 
    4711             : void Map::mark_unstable() {
    4712             :   set_bit_field3(IsUnstable::update(bit_field3(), true));
    4713             : }
    4714             : 
    4715             : 
    4716             : bool Map::is_stable() {
    4717       21582 :   return !IsUnstable::decode(bit_field3());
    4718             : }
    4719             : 
    4720             : 
    4721             : bool Map::has_code_cache() {
    4722             :   // Code caches are always fixed arrays. The empty fixed array is used as a
    4723             :   // sentinel for an absent code cache.
    4724             :   return code_cache()->length() != 0;
    4725             : }
    4726             : 
    4727             : 
    4728       13732 : bool Map::CanBeDeprecated() {
    4729             :   int descriptor = LastAdded();
    4730       16938 :   for (int i = 0; i <= descriptor; i++) {
    4731       16725 :     PropertyDetails details = instance_descriptors()->GetDetails(i);
    4732       16725 :     if (details.representation().IsNone()) return true;
    4733       16725 :     if (details.representation().IsSmi()) return true;
    4734       12470 :     if (details.representation().IsDouble()) return true;
    4735       12266 :     if (details.representation().IsHeapObject()) return true;
    4736        6313 :     if (details.kind() == kData && details.location() == kDescriptor) {
    4737             :       return true;
    4738             :     }
    4739             :   }
    4740             :   return false;
    4741             : }
    4742             : 
    4743             : 
    4744    27675894 : void Map::NotifyLeafMapLayoutChange() {
    4745    27675894 :   if (is_stable()) {
    4746             :     mark_unstable();
    4747             :     dependent_code()->DeoptimizeDependentCodeGroup(
    4748             :         GetIsolate(),
    4749    17345956 :         DependentCode::kPrototypeCheckGroup);
    4750             :   }
    4751    27675898 : }
    4752             : 
    4753             : 
    4754    44568885 : bool Map::CanTransition() {
    4755             :   // Only JSObject and subtypes have map transitions and back pointers.
    4756             :   STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE);
    4757    45126155 :   return instance_type() >= FIRST_JS_OBJECT_TYPE;
    4758             : }
    4759             : 
    4760             : 
    4761      121752 : bool Map::IsBooleanMap() { return this == GetHeap()->boolean_map(); }
    4762    14931958 : bool Map::IsPrimitiveMap() {
    4763             :   STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE);
    4764    19445377 :   return instance_type() <= LAST_PRIMITIVE_TYPE;
    4765             : }
    4766             : bool Map::IsJSReceiverMap() {
    4767             :   STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
    4768    13497424 :   return instance_type() >= FIRST_JS_RECEIVER_TYPE;
    4769             : }
    4770   407014263 : bool Map::IsJSObjectMap() {
    4771             :   STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
    4772   435373127 :   return instance_type() >= FIRST_JS_OBJECT_TYPE;
    4773             : }
    4774             : bool Map::IsJSArrayMap() { return instance_type() == JS_ARRAY_TYPE; }
    4775             : bool Map::IsJSFunctionMap() { return instance_type() == JS_FUNCTION_TYPE; }
    4776      573951 : bool Map::IsStringMap() { return instance_type() < FIRST_NONSTRING_TYPE; }
    4777   217848658 : bool Map::IsJSProxyMap() { return instance_type() == JS_PROXY_TYPE; }
    4778             : bool Map::IsJSGlobalProxyMap() {
    4779             :   return instance_type() == JS_GLOBAL_PROXY_TYPE;
    4780             : }
    4781             : bool Map::IsJSGlobalObjectMap() {
    4782             :   return instance_type() == JS_GLOBAL_OBJECT_TYPE;
    4783             : }
    4784             : bool Map::IsJSTypedArrayMap() { return instance_type() == JS_TYPED_ARRAY_TYPE; }
    4785             : bool Map::IsJSDataViewMap() { return instance_type() == JS_DATA_VIEW_TYPE; }
    4786             : 
    4787       15150 : bool Map::IsSpecialReceiverMap() {
    4788             :   bool result = IsSpecialReceiverInstanceType(instance_type());
    4789             :   DCHECK_IMPLIES(!result,
    4790             :                  !has_named_interceptor() && !is_access_check_needed());
    4791       15150 :   return result;
    4792             : }
    4793             : 
    4794             : bool Map::CanOmitMapChecks() {
    4795             :   return is_stable() && FLAG_omit_map_checks_for_leaf_maps;
    4796             : }
    4797             : 
    4798             : 
    4799             : DependentCode* DependentCode::next_link() {
    4800             :   return DependentCode::cast(get(kNextLinkIndex));
    4801             : }
    4802             : 
    4803             : 
    4804             : void DependentCode::set_next_link(DependentCode* next) {
    4805      416856 :   set(kNextLinkIndex, next);
    4806             : }
    4807             : 
    4808             : 
    4809             : int DependentCode::flags() { return Smi::cast(get(kFlagsIndex))->value(); }
    4810             : 
    4811             : 
    4812             : void DependentCode::set_flags(int flags) {
    4813             :   set(kFlagsIndex, Smi::FromInt(flags));
    4814             : }
    4815             : 
    4816             : 
    4817     3793016 : int DependentCode::count() { return CountField::decode(flags()); }
    4818             : 
    4819     1026597 : void DependentCode::set_count(int value) {
    4820     2053194 :   set_flags(CountField::update(flags(), value));
    4821     1026597 : }
    4822             : 
    4823             : 
    4824             : DependentCode::DependencyGroup DependentCode::group() {
    4825       17312 :   return static_cast<DependencyGroup>(GroupField::decode(flags()));
    4826             : }
    4827             : 
    4828             : 
    4829             : void DependentCode::set_group(DependentCode::DependencyGroup group) {
    4830             :   set_flags(GroupField::update(flags(), static_cast<int>(group)));
    4831             : }
    4832             : 
    4833             : 
    4834             : void DependentCode::set_object_at(int i, Object* object) {
    4835     1578051 :   set(kCodesStartIndex + i, object);
    4836             : }
    4837             : 
    4838             : 
    4839             : Object* DependentCode::object_at(int i) {
    4840   258539345 :   return get(kCodesStartIndex + i);
    4841             : }
    4842             : 
    4843             : 
    4844             : void DependentCode::clear_at(int i) {
    4845      140961 :   set_undefined(kCodesStartIndex + i);
    4846             : }
    4847             : 
    4848             : 
    4849       13643 : void DependentCode::copy(int from, int to) {
    4850       27286 :   set(kCodesStartIndex + to, get(kCodesStartIndex + from));
    4851       13643 : }
    4852             : 
    4853             : 
    4854             : void Code::set_flags(Code::Flags flags) {
    4855             :   STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1);
    4856     2554083 :   WRITE_INT_FIELD(this, kFlagsOffset, flags);
    4857             : }
    4858             : 
    4859             : 
    4860      541025 : Code::Kind Code::kind() {
    4861      541025 :   return ExtractKindFromFlags(flags());
    4862             : }
    4863             : 
    4864             : bool Code::IsCodeStubOrIC() {
    4865             :   switch (kind()) {
    4866             :     case STUB:
    4867             :     case HANDLER:
    4868             : #define CASE_KIND(kind) case kind:
    4869             :       IC_KIND_LIST(CASE_KIND)
    4870             : #undef CASE_KIND
    4871             :       return true;
    4872             :     default:
    4873             :       return false;
    4874             :   }
    4875             : }
    4876             : 
    4877             : ExtraICState Code::extra_ic_state() {
    4878             :   DCHECK(is_binary_op_stub() || is_compare_ic_stub() ||
    4879             :          is_to_boolean_ic_stub() || is_debug_stub());
    4880             :   return ExtractExtraICStateFromFlags(flags());
    4881             : }
    4882             : 
    4883             : 
    4884             : // For initialization.
    4885             : void Code::set_raw_kind_specific_flags1(int value) {
    4886     2554083 :   WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value);
    4887             : }
    4888             : 
    4889             : 
    4890             : void Code::set_raw_kind_specific_flags2(int value) {
    4891     2554083 :   WRITE_INT_FIELD(this, kKindSpecificFlags2Offset, value);
    4892             : }
    4893             : 
    4894             : 
    4895             : inline bool Code::is_crankshafted() {
    4896             :   return IsCrankshaftedField::decode(
    4897       26618 :       READ_UINT32_FIELD(this, kKindSpecificFlags2Offset));
    4898             : }
    4899             : 
    4900             : 
    4901             : inline bool Code::is_hydrogen_stub() {
    4902       53236 :   return is_crankshafted() && kind() != OPTIMIZED_FUNCTION;
    4903             : }
    4904             : 
    4905    42894633 : inline bool Code::is_interpreter_trampoline_builtin() {
    4906    42894633 :   Builtins* builtins = GetIsolate()->builtins();
    4907    93882972 :   return this == *builtins->InterpreterEntryTrampoline() ||
    4908    93686168 :          this == *builtins->InterpreterEnterBytecodeAdvance() ||
    4909    93686165 :          this == *builtins->InterpreterEnterBytecodeDispatch();
    4910             : }
    4911             : 
    4912             : inline bool Code::has_unwinding_info() const {
    4913   365337260 :   return HasUnwindingInfoField::decode(READ_UINT32_FIELD(this, kFlagsOffset));
    4914             : }
    4915             : 
    4916             : inline void Code::set_has_unwinding_info(bool state) {
    4917             :   uint32_t previous = READ_UINT32_FIELD(this, kFlagsOffset);
    4918             :   uint32_t updated_value = HasUnwindingInfoField::update(previous, state);
    4919     2554083 :   WRITE_UINT32_FIELD(this, kFlagsOffset, updated_value);
    4920             : }
    4921             : 
    4922             : inline void Code::set_is_crankshafted(bool value) {
    4923      278783 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
    4924             :   int updated = IsCrankshaftedField::update(previous, value);
    4925     2832866 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
    4926             : }
    4927             : 
    4928             : inline bool Code::has_tagged_params() {
    4929     1847088 :   int flags = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
    4930             :   return HasTaggedStackField::decode(flags);
    4931             : }
    4932             : 
    4933             : inline void Code::set_has_tagged_params(bool value) {
    4934       98996 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
    4935             :   int updated = HasTaggedStackField::update(previous, value);
    4936     2653079 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
    4937             : }
    4938             : 
    4939      266471 : inline bool Code::is_turbofanned() {
    4940             :   return IsTurbofannedField::decode(
    4941    12549145 :       READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
    4942             : }
    4943             : 
    4944             : 
    4945             : inline void Code::set_is_turbofanned(bool value) {
    4946      912010 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
    4947             :   int updated = IsTurbofannedField::update(previous, value);
    4948      912010 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
    4949             : }
    4950             : 
    4951             : 
    4952             : inline bool Code::can_have_weak_objects() {
    4953             :   DCHECK(kind() == OPTIMIZED_FUNCTION);
    4954             :   return CanHaveWeakObjectsField::decode(
    4955     4059666 :       READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
    4956             : }
    4957             : 
    4958             : 
    4959             : inline void Code::set_can_have_weak_objects(bool value) {
    4960             :   DCHECK(kind() == OPTIMIZED_FUNCTION);
    4961      639874 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
    4962             :   int updated = CanHaveWeakObjectsField::update(previous, value);
    4963      639874 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
    4964             : }
    4965             : 
    4966             : inline bool Code::is_construct_stub() {
    4967             :   DCHECK(kind() == BUILTIN);
    4968             :   return IsConstructStubField::decode(
    4969        4099 :       READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
    4970             : }
    4971             : 
    4972             : inline void Code::set_is_construct_stub(bool value) {
    4973             :   DCHECK(kind() == BUILTIN);
    4974    14896067 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
    4975             :   int updated = IsConstructStubField::update(previous, value);
    4976    14896067 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
    4977             : }
    4978             : 
    4979             : inline bool Code::is_promise_rejection() {
    4980             :   DCHECK(kind() == BUILTIN);
    4981             :   return IsPromiseRejectionField::decode(
    4982        2288 :       READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
    4983             : }
    4984             : 
    4985             : inline void Code::set_is_promise_rejection(bool value) {
    4986             :   DCHECK(kind() == BUILTIN);
    4987         688 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
    4988             :   int updated = IsPromiseRejectionField::update(previous, value);
    4989         688 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
    4990             : }
    4991             : 
    4992             : inline bool Code::is_exception_caught() {
    4993             :   DCHECK(kind() == BUILTIN);
    4994             :   return IsExceptionCaughtField::decode(
    4995             :       READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
    4996             : }
    4997             : 
    4998             : inline void Code::set_is_exception_caught(bool value) {
    4999             :   DCHECK(kind() == BUILTIN);
    5000          43 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
    5001             :   int updated = IsExceptionCaughtField::update(previous, value);
    5002          43 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
    5003             : }
    5004             : 
    5005             : bool Code::has_deoptimization_support() {
    5006             :   DCHECK_EQ(FUNCTION, kind());
    5007      587970 :   unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
    5008             :   return FullCodeFlagsHasDeoptimizationSupportField::decode(flags);
    5009             : }
    5010             : 
    5011             : 
    5012             : void Code::set_has_deoptimization_support(bool value) {
    5013             :   DCHECK_EQ(FUNCTION, kind());
    5014     1308351 :   unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
    5015             :   flags = FullCodeFlagsHasDeoptimizationSupportField::update(flags, value);
    5016     1308351 :   WRITE_UINT32_FIELD(this, kFullCodeFlags, flags);
    5017             : }
    5018             : 
    5019             : 
    5020             : bool Code::has_debug_break_slots() {
    5021             :   DCHECK_EQ(FUNCTION, kind());
    5022     4675601 :   unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
    5023             :   return FullCodeFlagsHasDebugBreakSlotsField::decode(flags);
    5024             : }
    5025             : 
    5026             : 
    5027             : void Code::set_has_debug_break_slots(bool value) {
    5028             :   DCHECK_EQ(FUNCTION, kind());
    5029        3431 :   unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
    5030             :   flags = FullCodeFlagsHasDebugBreakSlotsField::update(flags, value);
    5031        3431 :   WRITE_UINT32_FIELD(this, kFullCodeFlags, flags);
    5032             : }
    5033             : 
    5034             : 
    5035             : bool Code::has_reloc_info_for_serialization() {
    5036             :   DCHECK_EQ(FUNCTION, kind());
    5037      228494 :   unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
    5038             :   return FullCodeFlagsHasRelocInfoForSerialization::decode(flags);
    5039             : }
    5040             : 
    5041             : 
    5042             : void Code::set_has_reloc_info_for_serialization(bool value) {
    5043             :   DCHECK_EQ(FUNCTION, kind());
    5044             :   unsigned flags = READ_UINT32_FIELD(this, kFullCodeFlags);
    5045             :   flags = FullCodeFlagsHasRelocInfoForSerialization::update(flags, value);
    5046     1079857 :   WRITE_UINT32_FIELD(this, kFullCodeFlags, flags);
    5047             : }
    5048             : 
    5049             : 
    5050             : int Code::allow_osr_at_loop_nesting_level() {
    5051             :   DCHECK_EQ(FUNCTION, kind());
    5052       13199 :   int fields = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
    5053             :   return AllowOSRAtLoopNestingLevelField::decode(fields);
    5054             : }
    5055             : 
    5056             : 
    5057             : void Code::set_allow_osr_at_loop_nesting_level(int level) {
    5058             :   DCHECK_EQ(FUNCTION, kind());
    5059             :   DCHECK(level >= 0 && level <= AbstractCode::kMaxLoopNestingMarker);
    5060     1091937 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
    5061             :   int updated = AllowOSRAtLoopNestingLevelField::update(previous, level);
    5062     1091937 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
    5063             : }
    5064             : 
    5065             : 
    5066             : int Code::profiler_ticks() {
    5067             :   DCHECK_EQ(FUNCTION, kind());
    5068             :   return ProfilerTicksField::decode(
    5069      234741 :       READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
    5070             : }
    5071             : 
    5072             : 
    5073             : void Code::set_profiler_ticks(int ticks) {
    5074     5575738 :   if (kind() == FUNCTION) {
    5075     4427345 :     unsigned previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
    5076             :     unsigned updated = ProfilerTicksField::update(previous, ticks);
    5077     5575735 :     WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
    5078             :   }
    5079             : }
    5080             : 
    5081     1255155 : int Code::builtin_index() { return READ_INT_FIELD(this, kBuiltinIndexOffset); }
    5082             : 
    5083             : void Code::set_builtin_index(int index) {
    5084     2581603 :   WRITE_INT_FIELD(this, kBuiltinIndexOffset, index);
    5085             : }
    5086             : 
    5087             : 
    5088             : unsigned Code::stack_slots() {
    5089             :   DCHECK(is_crankshafted());
    5090             :   return StackSlotsField::decode(
    5091     5582259 :       READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
    5092             : }
    5093             : 
    5094             : 
    5095     1190793 : void Code::set_stack_slots(unsigned slots) {
    5096     1190793 :   CHECK(slots <= (1 << kStackSlotsBitCount));
    5097             :   DCHECK(is_crankshafted());
    5098     1190793 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
    5099             :   int updated = StackSlotsField::update(previous, slots);
    5100     1190793 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
    5101     1190793 : }
    5102             : 
    5103             : 
    5104             : unsigned Code::safepoint_table_offset() {
    5105             :   DCHECK(is_crankshafted());
    5106             :   return SafepointTableOffsetField::decode(
    5107     1736619 :       READ_UINT32_FIELD(this, kKindSpecificFlags2Offset));
    5108             : }
    5109             : 
    5110             : 
    5111     1190793 : void Code::set_safepoint_table_offset(unsigned offset) {
    5112     1190793 :   CHECK(offset <= (1 << kSafepointTableOffsetBitCount));
    5113             :   DCHECK(is_crankshafted());
    5114             :   DCHECK(IsAligned(offset, static_cast<unsigned>(kIntSize)));
    5115     1190793 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
    5116             :   int updated = SafepointTableOffsetField::update(previous, offset);
    5117     1190793 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
    5118     1190793 : }
    5119             : 
    5120             : 
    5121             : unsigned Code::back_edge_table_offset() {
    5122             :   DCHECK_EQ(FUNCTION, kind());
    5123             :   return BackEdgeTableOffsetField::decode(
    5124       17358 :       READ_UINT32_FIELD(this, kKindSpecificFlags2Offset)) << kPointerSizeLog2;
    5125             : }
    5126             : 
    5127             : 
    5128             : void Code::set_back_edge_table_offset(unsigned offset) {
    5129             :   DCHECK_EQ(FUNCTION, kind());
    5130             :   DCHECK(IsAligned(offset, static_cast<unsigned>(kPointerSize)));
    5131     1079857 :   offset = offset >> kPointerSizeLog2;
    5132     1079857 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset);
    5133             :   int updated = BackEdgeTableOffsetField::update(previous, offset);
    5134     1079857 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated);
    5135             : }
    5136             : 
    5137             : 
    5138             : bool Code::back_edges_patched_for_osr() {
    5139             :   DCHECK_EQ(FUNCTION, kind());
    5140             :   return allow_osr_at_loop_nesting_level() > 0;
    5141             : }
    5142             : 
    5143             : 
    5144      208427 : uint16_t Code::to_boolean_state() { return extra_ic_state(); }
    5145             : 
    5146             : 
    5147             : bool Code::marked_for_deoptimization() {
    5148             :   DCHECK(kind() == OPTIMIZED_FUNCTION);
    5149             :   return MarkedForDeoptimizationField::decode(
    5150     2082143 :       READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
    5151             : }
    5152             : 
    5153             : 
    5154             : void Code::set_marked_for_deoptimization(bool flag) {
    5155             :   DCHECK(kind() == OPTIMIZED_FUNCTION);
    5156             :   DCHECK_IMPLIES(flag, AllowDeoptimization::IsAllowed(GetIsolate()));
    5157     1062344 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
    5158             :   int updated = MarkedForDeoptimizationField::update(previous, flag);
    5159     1062344 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
    5160             : }
    5161             : 
    5162             : bool Code::deopt_already_counted() {
    5163             :   DCHECK(kind() == OPTIMIZED_FUNCTION);
    5164             :   return DeoptAlreadyCountedField::decode(
    5165       24319 :       READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
    5166             : }
    5167             : 
    5168             : void Code::set_deopt_already_counted(bool flag) {
    5169             :   DCHECK(kind() == OPTIMIZED_FUNCTION);
    5170             :   DCHECK_IMPLIES(flag, AllowDeoptimization::IsAllowed(GetIsolate()));
    5171      356330 :   int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
    5172             :   int updated = DeoptAlreadyCountedField::update(previous, flag);
    5173      356330 :   WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
    5174             : }
    5175             : 
    5176             : bool Code::is_inline_cache_stub() {
    5177             :   Kind kind = this->kind();
    5178    15194533 :   switch (kind) {
    5179             : #define CASE(name) case name: return true;
    5180             :     IC_KIND_LIST(CASE)
    5181             : #undef CASE
    5182             :     default: return false;
    5183             :   }
    5184             : }
    5185             : 
    5186             : bool Code::is_debug_stub() {
    5187      132284 :   if (kind() != BUILTIN) return false;
    5188           0 :   switch (builtin_index()) {
    5189             : #define CASE_DEBUG_BUILTIN(name) case Builtins::k##name:
    5190             :     BUILTIN_LIST_DBG(CASE_DEBUG_BUILTIN)
    5191             : #undef CASE_DEBUG_BUILTIN
    5192             :       return true;
    5193             :     default:
    5194             :       return false;
    5195             :   }
    5196             :   return false;
    5197             : }
    5198             : bool Code::is_handler() { return kind() == HANDLER; }
    5199             : bool Code::is_stub() { return kind() == STUB; }
    5200             : bool Code::is_binary_op_stub() { return kind() == BINARY_OP_IC; }
    5201             : bool Code::is_compare_ic_stub() { return kind() == COMPARE_IC; }
    5202             : bool Code::is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; }
    5203             : bool Code::is_optimized_code() { return kind() == OPTIMIZED_FUNCTION; }
    5204             : bool Code::is_wasm_code() { return kind() == WASM_FUNCTION; }
    5205             : 
    5206             : Address Code::constant_pool() {
    5207             :   Address constant_pool = NULL;
    5208             :   if (FLAG_enable_embedded_constant_pool) {
    5209             :     int offset = constant_pool_offset();
    5210             :     if (offset < instruction_size()) {
    5211             :       constant_pool = FIELD_ADDR(this, kHeaderSize + offset);
    5212             :     }
    5213             :   }
    5214             :   return constant_pool;
    5215             : }
    5216             : 
    5217             : Code::Flags Code::ComputeFlags(Kind kind, ExtraICState extra_ic_state) {
    5218             :   // Compute the bit mask.
    5219             :   unsigned int bits =
    5220      319577 :       KindField::encode(kind) | ExtraICStateField::encode(extra_ic_state);
    5221             :   return static_cast<Flags>(bits);
    5222             : }
    5223             : 
    5224             : Code::Flags Code::ComputeHandlerFlags(Kind handler_kind) {
    5225             :   return ComputeFlags(Code::HANDLER, handler_kind);
    5226             : }
    5227             : 
    5228             : 
    5229             : Code::Kind Code::ExtractKindFromFlags(Flags flags) {
    5230             :   return KindField::decode(flags);
    5231             : }
    5232             : 
    5233             : 
    5234             : ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) {
    5235             :   return ExtraICStateField::decode(flags);
    5236             : }
    5237             : 
    5238             : 
    5239   314044179 : Code* Code::GetCodeFromTargetAddress(Address address) {
    5240             :   HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize);
    5241             :   // GetCodeFromTargetAddress might be called when marking objects during mark
    5242             :   // sweep. reinterpret_cast is therefore used instead of the more appropriate
    5243             :   // Code::cast. Code::cast does not work when the object's map is
    5244             :   // marked.
    5245             :   Code* result = reinterpret_cast<Code*>(code);
    5246   314044179 :   return result;
    5247             : }
    5248             : 
    5249             : 
    5250    61619880 : Object* Code::GetObjectFromEntryAddress(Address location_of_address) {
    5251             :   return HeapObject::
    5252   265346297 :       FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize);
    5253             : }
    5254             : 
    5255             : 
    5256             : bool Code::CanContainWeakObjects() {
    5257    34905135 :   return is_optimized_code() && can_have_weak_objects();
    5258             : }
    5259             : 
    5260             : 
    5261    30845469 : bool Code::IsWeakObject(Object* object) {
    5262    30845469 :   return (CanContainWeakObjects() && IsWeakObjectInOptimizedCode(object));
    5263             : }
    5264             : 
    5265             : 
    5266    10088968 : bool Code::IsWeakObjectInOptimizedCode(Object* object) {
    5267    10088971 :   if (object->IsMap()) {
    5268      334810 :     return Map::cast(object)->CanTransition();
    5269             :   }
    5270     9754161 :   if (object->IsCell()) {
    5271             :     object = Cell::cast(object)->value();
    5272     9754161 :   } else if (object->IsPropertyCell()) {
    5273             :     object = PropertyCell::cast(object)->value();
    5274             :   }
    5275    17870252 :   if (object->IsJSReceiver() || object->IsContext()) {
    5276             :     return true;
    5277             :   }
    5278     6752129 :   return false;
    5279             : }
    5280             : 
    5281             : 
    5282        9160 : int AbstractCode::instruction_size() {
    5283        9160 :   if (IsCode()) {
    5284        8694 :     return GetCode()->instruction_size();
    5285             :   } else {
    5286         466 :     return GetBytecodeArray()->length();
    5287             :   }
    5288             : }
    5289             : 
    5290     2267851 : ByteArray* AbstractCode::source_position_table() {
    5291     2267851 :   if (IsCode()) {
    5292      603514 :     return GetCode()->SourcePositionTable();
    5293             :   } else {
    5294     1664337 :     return GetBytecodeArray()->SourcePositionTable();
    5295             :   }
    5296             : }
    5297             : 
    5298        1300 : void AbstractCode::set_source_position_table(ByteArray* source_position_table) {
    5299        1300 :   if (IsCode()) {
    5300         184 :     GetCode()->set_source_position_table(source_position_table);
    5301             :   } else {
    5302        1116 :     GetBytecodeArray()->set_source_position_table(source_position_table);
    5303             :   }
    5304        1300 : }
    5305             : 
    5306       46982 : Object* AbstractCode::stack_frame_cache() {
    5307             :   Object* maybe_table;
    5308       46982 :   if (IsCode()) {
    5309             :     maybe_table = GetCode()->source_position_table();
    5310             :   } else {
    5311             :     maybe_table = GetBytecodeArray()->source_position_table();
    5312             :   }
    5313       46982 :   if (maybe_table->IsSourcePositionTableWithFrameCache()) {
    5314             :     return SourcePositionTableWithFrameCache::cast(maybe_table)
    5315       38041 :         ->stack_frame_cache();
    5316             :   }
    5317             :   return Smi::kZero;
    5318             : }
    5319             : 
    5320           0 : int AbstractCode::SizeIncludingMetadata() {
    5321           0 :   if (IsCode()) {
    5322           0 :     return GetCode()->SizeIncludingMetadata();
    5323             :   } else {
    5324           0 :     return GetBytecodeArray()->SizeIncludingMetadata();
    5325             :   }
    5326             : }
    5327      211548 : int AbstractCode::ExecutableSize() {
    5328      211548 :   if (IsCode()) {
    5329      209625 :     return GetCode()->ExecutableSize();
    5330             :   } else {
    5331        1923 :     return GetBytecodeArray()->BytecodeArraySize();
    5332             :   }
    5333             : }
    5334             : 
    5335      172545 : Address AbstractCode::instruction_start() {
    5336      172545 :   if (IsCode()) {
    5337      169897 :     return GetCode()->instruction_start();
    5338             :   } else {
    5339        2648 :     return GetBytecodeArray()->GetFirstBytecodeAddress();
    5340             :   }
    5341             : }
    5342             : 
    5343             : Address AbstractCode::instruction_end() {
    5344             :   if (IsCode()) {
    5345             :     return GetCode()->instruction_end();
    5346             :   } else {
    5347             :     return GetBytecodeArray()->GetFirstBytecodeAddress() +
    5348             :            GetBytecodeArray()->length();
    5349             :   }
    5350             : }
    5351             : 
    5352             : bool AbstractCode::contains(byte* inner_pointer) {
    5353             :   return (address() <= inner_pointer) && (inner_pointer <= address() + Size());
    5354             : }
    5355             : 
    5356      162411 : AbstractCode::Kind AbstractCode::kind() {
    5357      162411 :   if (IsCode()) {
    5358             :     STATIC_ASSERT(AbstractCode::FUNCTION ==
    5359             :                   static_cast<AbstractCode::Kind>(Code::FUNCTION));
    5360      157421 :     return static_cast<AbstractCode::Kind>(GetCode()->kind());
    5361             :   } else {
    5362             :     return INTERPRETED_FUNCTION;
    5363             :   }
    5364             : }
    5365             : 
    5366             : Code* AbstractCode::GetCode() { return Code::cast(this); }
    5367             : 
    5368             : BytecodeArray* AbstractCode::GetBytecodeArray() {
    5369             :   return BytecodeArray::cast(this);
    5370             : }
    5371             : 
    5372          49 : Object* Map::prototype() const {
    5373   661830765 :   return READ_FIELD(this, kPrototypeOffset);
    5374             : }
    5375             : 
    5376             : 
    5377    63479064 : void Map::set_prototype(Object* value, WriteBarrierMode mode) {
    5378             :   DCHECK(value->IsNull(GetIsolate()) || value->IsJSReceiver());
    5379    63479064 :   WRITE_FIELD(this, kPrototypeOffset, value);
    5380   116678018 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode);
    5381    63479067 : }
    5382             : 
    5383             : 
    5384      239397 : LayoutDescriptor* Map::layout_descriptor_gc_safe() {
    5385      239397 :   Object* layout_desc = READ_FIELD(this, kLayoutDescriptorOffset);
    5386      239397 :   return LayoutDescriptor::cast_gc_safe(layout_desc);
    5387             : }
    5388             : 
    5389             : 
    5390             : bool Map::HasFastPointerLayout() const {
    5391   146271943 :   Object* layout_desc = READ_FIELD(this, kLayoutDescriptorOffset);
    5392             :   return LayoutDescriptor::IsFastPointerLayout(layout_desc);
    5393             : }
    5394             : 
    5395             : 
    5396    44210356 : void Map::UpdateDescriptors(DescriptorArray* descriptors,
    5397             :                             LayoutDescriptor* layout_desc) {
    5398    44210356 :   set_instance_descriptors(descriptors);
    5399             :   if (FLAG_unbox_double_fields) {
    5400    44210352 :     if (layout_descriptor()->IsSlowLayout()) {
    5401        3965 :       set_layout_descriptor(layout_desc);
    5402             :     }
    5403             : #ifdef VERIFY_HEAP
    5404             :     // TODO(ishell): remove these checks from VERIFY_HEAP mode.
    5405             :     if (FLAG_verify_heap) {
    5406             :       CHECK(layout_descriptor()->IsConsistentWithMap(this));
    5407             :       CHECK(visitor_id() == Heap::GetStaticVisitorIdForMap(this));
    5408             :     }
    5409             : #else
    5410             :     SLOW_DCHECK(layout_descriptor()->IsConsistentWithMap(this));
    5411             :     DCHECK(visitor_id() == Heap::GetStaticVisitorIdForMap(this));
    5412             : #endif
    5413             :   }
    5414    44210352 : }
    5415             : 
    5416             : 
    5417    28515717 : void Map::InitializeDescriptors(DescriptorArray* descriptors,
    5418             :                                 LayoutDescriptor* layout_desc) {
    5419    28515717 :   int len = descriptors->number_of_descriptors();
    5420    28515720 :   set_instance_descriptors(descriptors);
    5421             :   SetNumberOfOwnDescriptors(len);
    5422             : 
    5423             :   if (FLAG_unbox_double_fields) {
    5424    28515714 :     set_layout_descriptor(layout_desc);
    5425             : #ifdef VERIFY_HEAP
    5426             :     // TODO(ishell): remove these checks from VERIFY_HEAP mode.
    5427             :     if (FLAG_verify_heap) {
    5428             :       CHECK(layout_descriptor()->IsConsistentWithMap(this));
    5429             :     }
    5430             : #else
    5431             :     SLOW_DCHECK(layout_descriptor()->IsConsistentWithMap(this));
    5432             : #endif
    5433    28515712 :     set_visitor_id(Heap::GetStaticVisitorIdForMap(this));
    5434             :   }
    5435    28515714 : }
    5436             : 
    5437             : 
    5438  1493830338 : ACCESSORS(Map, instance_descriptors, DescriptorArray, kDescriptorsOffset)
    5439   365067435 : ACCESSORS(Map, layout_descriptor, LayoutDescriptor, kLayoutDescriptorOffset)
    5440             : 
    5441             : void Map::set_bit_field3(uint32_t bits) {
    5442             :   if (kInt32Size != kPointerSize) {
    5443   164688641 :     WRITE_UINT32_FIELD(this, kBitField3Offset + kInt32Size, 0);
    5444             :   }
    5445   197531646 :   WRITE_UINT32_FIELD(this, kBitField3Offset, bits);
    5446             : }
    5447             : 
    5448             : 
    5449             : uint32_t Map::bit_field3() const {
    5450  2230620309 :   return READ_UINT32_FIELD(this, kBitField3Offset);
    5451             : }
    5452             : 
    5453             : 
    5454             : LayoutDescriptor* Map::GetLayoutDescriptor() {
    5455             :   return FLAG_unbox_double_fields ? layout_descriptor()
    5456             :                                   : LayoutDescriptor::FastPointerLayout();
    5457             : }
    5458             : 
    5459             : 
    5460        6588 : void Map::AppendDescriptor(Descriptor* desc) {
    5461             :   DescriptorArray* descriptors = instance_descriptors();
    5462             :   int number_of_own_descriptors = NumberOfOwnDescriptors();
    5463             :   DCHECK(descriptors->number_of_descriptors() == number_of_own_descriptors);
    5464        6588 :   descriptors->Append(desc);
    5465        6588 :   SetNumberOfOwnDescriptors(number_of_own_descriptors + 1);
    5466             : 
    5467             : // This function does not support appending double field descriptors and
    5468             : // it should never try to (otherwise, layout descriptor must be updated too).
    5469             : #ifdef DEBUG
    5470             :   PropertyDetails details = desc->GetDetails();
    5471             :   CHECK(details.location() != kField || !details.representation().IsDouble());
    5472             : #endif
    5473        6588 : }
    5474             : 
    5475             : 
    5476   180984458 : Object* Map::GetBackPointer() {
    5477             :   Object* object = constructor_or_backpointer();
    5478   180984434 :   if (object->IsMap()) {
    5479             :     return object;
    5480             :   }
    5481    45696133 :   return GetIsolate()->heap()->undefined_value();
    5482             : }
    5483             : 
    5484             : 
    5485             : Map* Map::ElementsTransitionMap() {
    5486             :   return TransitionArray::SearchSpecial(
    5487     3088583 :       this, GetHeap()->elements_transition_symbol());
    5488             : }
    5489             : 
    5490             : 
    5491   297265683 : ACCESSORS(Map, raw_transitions, Object, kTransitionsOrPrototypeInfoOffset)
    5492             : 
    5493             : 
    5494             : Object* Map::prototype_info() const {
    5495             :   DCHECK(is_prototype_map());
    5496    88677944 :   return READ_FIELD(this, Map::kTransitionsOrPrototypeInfoOffset);
    5497             : }
    5498             : 
    5499             : 
    5500    11494401 : void Map::set_prototype_info(Object* value, WriteBarrierMode mode) {
    5501             :   DCHECK(is_prototype_map());
    5502    11494401 :   WRITE_FIELD(this, Map::kTransitionsOrPrototypeInfoOffset, value);
    5503    34483205 :   CONDITIONAL_WRITE_BARRIER(
    5504             :       GetHeap(), this, Map::kTransitionsOrPrototypeInfoOffset, value, mode);
    5505    11494401 : }
    5506             : 
    5507             : 
    5508             : void Map::SetBackPointer(Object* value, WriteBarrierMode mode) {
    5509             :   DCHECK(instance_type() >= FIRST_JS_RECEIVER_TYPE);
    5510             :   DCHECK(value->IsMap());
    5511             :   DCHECK(GetBackPointer()->IsUndefined(GetIsolate()));
    5512             :   DCHECK(!value->IsMap() ||
    5513             :          Map::cast(value)->GetConstructor() == constructor_or_backpointer());
    5514    11747470 :   set_constructor_or_backpointer(value, mode);
    5515             : }
    5516             : 
    5517             : ACCESSORS(JSArgumentsObject, length, Object, kLengthOffset);
    5518             : ACCESSORS(JSSloppyArgumentsObject, callee, Object, kCalleeOffset);
    5519             : 
    5520    32128290 : ACCESSORS(Map, code_cache, FixedArray, kCodeCacheOffset)
    5521    52682104 : ACCESSORS(Map, dependent_code, DependentCode, kDependentCodeOffset)
    5522   161206992 : ACCESSORS(Map, weak_cell_cache, Object, kWeakCellCacheOffset)
    5523   871406625 : ACCESSORS(Map, constructor_or_backpointer, Object,
    5524             :           kConstructorOrBackPointerOffset)
    5525             : 
    5526   109685069 : Object* Map::GetConstructor() const {
    5527             :   Object* maybe_constructor = constructor_or_backpointer();
    5528             :   // Follow any back pointers.
    5529   625593125 :   while (maybe_constructor->IsMap()) {
    5530             :     maybe_constructor =
    5531             :         Map::cast(maybe_constructor)->constructor_or_backpointer();
    5532             :   }
    5533   109685017 :   return maybe_constructor;
    5534             : }
    5535             : 
    5536     2488307 : FunctionTemplateInfo* Map::GetFunctionTemplateInfo() const {
    5537     2488307 :   Object* constructor = GetConstructor();
    5538     2488307 :   if (constructor->IsJSFunction()) {
    5539             :     DCHECK(JSFunction::cast(constructor)->shared()->IsApiFunction());
    5540     2488307 :     return JSFunction::cast(constructor)->shared()->get_api_func_data();
    5541             :   }
    5542             :   DCHECK(constructor->IsFunctionTemplateInfo());
    5543             :   return FunctionTemplateInfo::cast(constructor);
    5544             : }
    5545             : 
    5546             : void Map::SetConstructor(Object* constructor, WriteBarrierMode mode) {
    5547             :   // Never overwrite a back pointer with a constructor.
    5548             :   DCHECK(!constructor_or_backpointer()->IsMap());
    5549     9426854 :   set_constructor_or_backpointer(constructor, mode);
    5550             : }
    5551             : 
    5552             : 
    5553      190364 : Handle<Map> Map::CopyInitialMap(Handle<Map> map) {
    5554             :   return CopyInitialMap(map, map->instance_size(), map->GetInObjectProperties(),
    5555      190364 :                         map->unused_property_fields());
    5556             : }
    5557             : 
    5558             : 
    5559        5182 : ACCESSORS(JSBoundFunction, bound_target_function, JSReceiver,
    5560             :           kBoundTargetFunctionOffset)
    5561        3426 : ACCESSORS(JSBoundFunction, bound_this, Object, kBoundThisOffset)
    5562        3959 : ACCESSORS(JSBoundFunction, bound_arguments, FixedArray, kBoundArgumentsOffset)
    5563             : 
    5564   582781624 : ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
    5565   202261201 : ACCESSORS(JSFunction, feedback_vector_cell, Cell, kFeedbackVectorOffset)
    5566    47568958 : ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset)
    5567             : 
    5568    18512496 : ACCESSORS(JSGlobalObject, native_context, Context, kNativeContextOffset)
    5569      388793 : ACCESSORS(JSGlobalObject, global_proxy, JSObject, kGlobalProxyOffset)
    5570             : 
    5571     8994251 : ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset)
    5572      427692 : ACCESSORS(JSGlobalProxy, hash, Object, kHashOffset)
    5573             : 
    5574      930812 : ACCESSORS(AccessorInfo, name, Object, kNameOffset)
    5575     5280668 : SMI_ACCESSORS(AccessorInfo, flag, kFlagOffset)
    5576     2727393 : ACCESSORS(AccessorInfo, expected_receiver_type, Object,
    5577             :           kExpectedReceiverTypeOffset)
    5578             : 
    5579     1438121 : ACCESSORS(AccessorInfo, getter, Object, kGetterOffset)
    5580    40473175 : ACCESSORS(AccessorInfo, setter, Object, kSetterOffset)
    5581      368130 : ACCESSORS(AccessorInfo, js_getter, Object, kJsGetterOffset)
    5582    41178127 : ACCESSORS(AccessorInfo, data, Object, kDataOffset)
    5583             : 
    5584       24510 : ACCESSORS(PromiseResolveThenableJobInfo, thenable, JSReceiver, kThenableOffset)
    5585       24510 : ACCESSORS(PromiseResolveThenableJobInfo, then, JSReceiver, kThenOffset)
    5586       24510 : ACCESSORS(PromiseResolveThenableJobInfo, resolve, JSFunction, kResolveOffset)
    5587       24510 : ACCESSORS(PromiseResolveThenableJobInfo, reject, JSFunction, kRejectOffset)
    5588       24510 : ACCESSORS(PromiseResolveThenableJobInfo, context, Context, kContextOffset);
    5589             : 
    5590      230180 : ACCESSORS(PromiseReactionJobInfo, value, Object, kValueOffset);
    5591      230180 : ACCESSORS(PromiseReactionJobInfo, tasks, Object, kTasksOffset);
    5592      230180 : ACCESSORS(PromiseReactionJobInfo, deferred_promise, Object,
    5593             :           kDeferredPromiseOffset);
    5594      230180 : ACCESSORS(PromiseReactionJobInfo, deferred_on_resolve, Object,
    5595             :           kDeferredOnResolveOffset);
    5596      230180 : ACCESSORS(PromiseReactionJobInfo, deferred_on_reject, Object,
    5597             :           kDeferredOnRejectOffset);
    5598      230180 : ACCESSORS(PromiseReactionJobInfo, context, Context, kContextOffset);
    5599             : 
    5600             : ACCESSORS(AsyncGeneratorRequest, next, Object, kNextOffset)
    5601             : SMI_ACCESSORS(AsyncGeneratorRequest, resume_mode, kResumeModeOffset)
    5602             : ACCESSORS(AsyncGeneratorRequest, value, Object, kValueOffset)
    5603             : ACCESSORS(AsyncGeneratorRequest, promise, Object, kPromiseOffset)
    5604             : 
    5605             : Map* PrototypeInfo::ObjectCreateMap() {
    5606             :   return Map::cast(WeakCell::cast(object_create_map())->value());
    5607             : }
    5608             : 
    5609             : // static
    5610      187630 : void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info,
    5611             :                                        Handle<Map> map) {
    5612      187630 :   Handle<WeakCell> cell = Map::WeakCellForMap(map);
    5613      187630 :   info->set_object_create_map(*cell);
    5614      187630 : }
    5615             : 
    5616      187691 : bool PrototypeInfo::HasObjectCreateMap() {
    5617             :   Object* cache = object_create_map();
    5618      187752 :   return cache->IsWeakCell() && !WeakCell::cast(cache)->cleared();
    5619             : }
    5620             : 
    5621     5482577 : bool FunctionTemplateInfo::instantiated() {
    5622     5482577 :   return shared_function_info()->IsSharedFunctionInfo();
    5623             : }
    5624             : 
    5625     3960023 : FunctionTemplateInfo* FunctionTemplateInfo::GetParent(Isolate* isolate) {
    5626             :   Object* parent = parent_template();
    5627             :   return parent->IsUndefined(isolate) ? nullptr
    5628     3960022 :                                       : FunctionTemplateInfo::cast(parent);
    5629             : }
    5630             : 
    5631      515064 : ObjectTemplateInfo* ObjectTemplateInfo::GetParent(Isolate* isolate) {
    5632             :   Object* maybe_ctor = constructor();
    5633      515064 :   if (maybe_ctor->IsUndefined(isolate)) return nullptr;
    5634             :   FunctionTemplateInfo* constructor = FunctionTemplateInfo::cast(maybe_ctor);
    5635             :   while (true) {
    5636      200040 :     constructor = constructor->GetParent(isolate);
    5637      200040 :     if (constructor == nullptr) return nullptr;
    5638             :     Object* maybe_obj = constructor->instance_template();
    5639         416 :     if (!maybe_obj->IsUndefined(isolate)) {
    5640             :       return ObjectTemplateInfo::cast(maybe_obj);
    5641             :     }
    5642             :   }
    5643             :   return nullptr;
    5644             : }
    5645             : 
    5646     1671685 : ACCESSORS(PrototypeInfo, weak_cell, Object, kWeakCellOffset)
    5647     3519175 : ACCESSORS(PrototypeInfo, prototype_users, Object, kPrototypeUsersOffset)
    5648      750642 : ACCESSORS(PrototypeInfo, object_create_map, Object, kObjectCreateMap)
    5649     4616637 : SMI_ACCESSORS(PrototypeInfo, registry_slot, kRegistrySlotOffset)
    5650     5980635 : ACCESSORS(PrototypeInfo, validity_cell, Object, kValidityCellOffset)
    5651    29688714 : SMI_ACCESSORS(PrototypeInfo, bit_field, kBitFieldOffset)
    5652             : BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map, kShouldBeFastBit)
    5653             : 
    5654     8472948 : ACCESSORS(Tuple2, value1, Object, kValue1Offset)
    5655     8518329 : ACCESSORS(Tuple2, value2, Object, kValue2Offset)
    5656     7726587 : ACCESSORS(Tuple3, value3, Object, kValue3Offset)
    5657             : 
    5658     3668738 : ACCESSORS(ContextExtension, scope_info, ScopeInfo, kScopeInfoOffset)
    5659    11381400 : ACCESSORS(ContextExtension, extension, Object, kExtensionOffset)
    5660             : 
    5661      685191 : SMI_ACCESSORS(ConstantElementsPair, elements_kind, kElementsKindOffset)
    5662     1295756 : ACCESSORS(ConstantElementsPair, constant_values, FixedArrayBase,
    5663             :           kConstantValuesOffset)
    5664             : 
    5665        1753 : ACCESSORS(JSModuleNamespace, module, Module, kModuleOffset)
    5666             : 
    5667       45224 : ACCESSORS(Module, code, Object, kCodeOffset)
    5668       19862 : ACCESSORS(Module, exports, ObjectHashTable, kExportsOffset)
    5669        8063 : ACCESSORS(Module, regular_exports, FixedArray, kRegularExportsOffset)
    5670        6994 : ACCESSORS(Module, regular_imports, FixedArray, kRegularImportsOffset)
    5671        7316 : ACCESSORS(Module, module_namespace, HeapObject, kModuleNamespaceOffset)
    5672       13189 : ACCESSORS(Module, requested_modules, FixedArray, kRequestedModulesOffset)
    5673        6266 : SMI_ACCESSORS(Module, status, kStatusOffset)
    5674        6104 : SMI_ACCESSORS(Module, hash, kHashOffset)
    5675             : 
    5676       14810 : bool Module::evaluated() const { return code()->IsModuleInfo(); }
    5677             : 
    5678        1875 : void Module::set_evaluated() {
    5679             :   DCHECK(instantiated());
    5680             :   DCHECK(!evaluated());
    5681             :   return set_code(
    5682        1875 :       JSFunction::cast(code())->shared()->scope_info()->ModuleDescriptorInfo());
    5683             : }
    5684             : 
    5685       16674 : bool Module::instantiated() const { return !code()->IsSharedFunctionInfo(); }
    5686             : 
    5687        5085 : ModuleInfo* Module::info() const {
    5688        5369 :   if (evaluated()) return ModuleInfo::cast(code());
    5689        4801 :   ScopeInfo* scope_info = instantiated()
    5690             :                               ? JSFunction::cast(code())->shared()->scope_info()
    5691        4801 :                               : SharedFunctionInfo::cast(code())->scope_info();
    5692        4801 :   return scope_info->ModuleDescriptorInfo();
    5693             : }
    5694             : 
    5695    20887331 : ACCESSORS(AccessorPair, getter, Object, kGetterOffset)
    5696     1142444 : ACCESSORS(AccessorPair, setter, Object, kSetterOffset)
    5697             : 
    5698        3672 : ACCESSORS(AccessCheckInfo, callback, Object, kCallbackOffset)
    5699        1232 : ACCESSORS(AccessCheckInfo, named_interceptor, Object, kNamedInterceptorOffset)
    5700        1563 : ACCESSORS(AccessCheckInfo, indexed_interceptor, Object,
    5701             :           kIndexedInterceptorOffset)
    5702        3860 : ACCESSORS(AccessCheckInfo, data, Object, kDataOffset)
    5703             : 
    5704      860318 : ACCESSORS(InterceptorInfo, getter, Object, kGetterOffset)
    5705     1082351 : ACCESSORS(InterceptorInfo, setter, Object, kSetterOffset)
    5706      282121 : ACCESSORS(InterceptorInfo, query, Object, kQueryOffset)
    5707         357 : ACCESSORS(InterceptorInfo, descriptor, Object, kDescriptorOffset)
    5708         452 : ACCESSORS(InterceptorInfo, deleter, Object, kDeleterOffset)
    5709        1152 : ACCESSORS(InterceptorInfo, enumerator, Object, kEnumeratorOffset)
    5710         613 : ACCESSORS(InterceptorInfo, definer, Object, kDefinerOffset)
    5711     1427892 : ACCESSORS(InterceptorInfo, data, Object, kDataOffset)
    5712     1063539 : SMI_ACCESSORS(InterceptorInfo, flags, kFlagsOffset)
    5713             : BOOL_ACCESSORS(InterceptorInfo, flags, can_intercept_symbols,
    5714             :                kCanInterceptSymbolsBit)
    5715             : BOOL_ACCESSORS(InterceptorInfo, flags, all_can_read, kAllCanReadBit)
    5716             : BOOL_ACCESSORS(InterceptorInfo, flags, non_masking, kNonMasking)
    5717             : 
    5718    56669002 : ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset)
    5719    56661662 : ACCESSORS(CallHandlerInfo, data, Object, kDataOffset)
    5720             : 
    5721    12628993 : ACCESSORS(TemplateInfo, tag, Object, kTagOffset)
    5722    18340644 : ACCESSORS(TemplateInfo, serial_number, Object, kSerialNumberOffset)
    5723    11945343 : SMI_ACCESSORS(TemplateInfo, number_of_properties, kNumberOfProperties)
    5724    12848319 : ACCESSORS(TemplateInfo, property_list, Object, kPropertyListOffset)
    5725     4528795 : ACCESSORS(TemplateInfo, property_accessors, Object, kPropertyAccessorsOffset)
    5726             : 
    5727    56700226 : ACCESSORS(FunctionTemplateInfo, call_code, Object, kCallCodeOffset)
    5728     4483161 : ACCESSORS(FunctionTemplateInfo, prototype_template, Object,
    5729             :           kPrototypeTemplateOffset)
    5730     7309716 : ACCESSORS(FunctionTemplateInfo, prototype_provider_template, Object,
    5731             :           kPrototypeProviderTemplateOffset)
    5732             : 
    5733     7679929 : ACCESSORS(FunctionTemplateInfo, parent_template, Object, kParentTemplateOffset)
    5734     9593688 : ACCESSORS(FunctionTemplateInfo, named_property_handler, Object,
    5735             :           kNamedPropertyHandlerOffset)
    5736     8548095 : ACCESSORS(FunctionTemplateInfo, indexed_property_handler, Object,
    5737             :           kIndexedPropertyHandlerOffset)
    5738     5017336 : ACCESSORS(FunctionTemplateInfo, instance_template, Object,
    5739             :           kInstanceTemplateOffset)
    5740     3947365 : ACCESSORS(FunctionTemplateInfo, class_name, Object, kClassNameOffset)
    5741    46282986 : ACCESSORS(FunctionTemplateInfo, signature, Object, kSignatureOffset)
    5742     3849274 : ACCESSORS(FunctionTemplateInfo, instance_call_handler, Object,
    5743             :           kInstanceCallHandlerOffset)
    5744      331088 : ACCESSORS(FunctionTemplateInfo, access_check_info, Object,
    5745             :           kAccessCheckInfoOffset)
    5746    20649643 : ACCESSORS(FunctionTemplateInfo, shared_function_info, Object,
    5747             :           kSharedFunctionInfoOffset)
    5748    11282022 : ACCESSORS(FunctionTemplateInfo, cached_property_name, Object,
    5749             :           kCachedPropertyNameOffset)
    5750             : 
    5751   110749866 : SMI_ACCESSORS(FunctionTemplateInfo, flag, kFlagOffset)
    5752             : 
    5753     2062435 : ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset)
    5754     2818386 : ACCESSORS(ObjectTemplateInfo, data, Object, kDataOffset)
    5755             : 
    5756             : int ObjectTemplateInfo::embedder_field_count() const {
    5757             :   Object* value = data();
    5758             :   DCHECK(value->IsSmi());
    5759      452811 :   return EmbedderFieldCount::decode(Smi::cast(value)->value());
    5760             : }
    5761             : 
    5762      127397 : void ObjectTemplateInfo::set_embedder_field_count(int count) {
    5763             :   return set_data(Smi::FromInt(
    5764      382191 :       EmbedderFieldCount::update(Smi::cast(data())->value(), count)));
    5765             : }
    5766             : 
    5767             : bool ObjectTemplateInfo::immutable_proto() const {
    5768             :   Object* value = data();
    5769             :   DCHECK(value->IsSmi());
    5770      508273 :   return IsImmutablePrototype::decode(Smi::cast(value)->value());
    5771             : }
    5772             : 
    5773          21 : void ObjectTemplateInfo::set_immutable_proto(bool immutable) {
    5774             :   return set_data(Smi::FromInt(
    5775          63 :       IsImmutablePrototype::update(Smi::cast(data())->value(), immutable)));
    5776             : }
    5777             : 
    5778             : int TemplateList::length() const {
    5779             :   return Smi::cast(FixedArray::cast(this)->get(kLengthIndex))->value();
    5780             : }
    5781             : 
    5782             : Object* TemplateList::get(int index) const {
    5783      140057 :   return FixedArray::cast(this)->get(kFirstElementIndex + index);
    5784             : }
    5785             : 
    5786             : void TemplateList::set(int index, Object* value) {
    5787         185 :   FixedArray::cast(this)->set(kFirstElementIndex + index, value);
    5788             : }
    5789             : 
    5790    21417659 : ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset)
    5791     7288592 : ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset)
    5792    13177682 : SMI_ACCESSORS(AllocationSite, pretenure_data, kPretenureDataOffset)
    5793    16519186 : SMI_ACCESSORS(AllocationSite, pretenure_create_count,
    5794             :               kPretenureCreateCountOffset)
    5795     1857672 : ACCESSORS(AllocationSite, dependent_code, DependentCode,
    5796             :           kDependentCodeOffset)
    5797    10500261 : ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset)
    5798    18993803 : ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset)
    5799             : 
    5800    43799458 : ACCESSORS(Script, source, Object, kSourceOffset)
    5801     8803262 : ACCESSORS(Script, name, Object, kNameOffset)
    5802     8534091 : SMI_ACCESSORS(Script, id, kIdOffset)
    5803     3820298 : SMI_ACCESSORS(Script, line_offset, kLineOffsetOffset)
    5804     2581609 : SMI_ACCESSORS(Script, column_offset, kColumnOffsetOffset)
    5805    25026014 : ACCESSORS(Script, context_data, Object, kContextOffset)
    5806    11546914 : ACCESSORS(Script, wrapper, HeapObject, kWrapperOffset)
    5807    39660536 : SMI_ACCESSORS(Script, type, kTypeOffset)
    5808    11338323 : ACCESSORS(Script, line_ends, Object, kLineEndsOffset)
    5809    10212179 : ACCESSORS_CHECKED(Script, eval_from_shared, Object, kEvalFromSharedOffset,
    5810             :                   this->type() != TYPE_WASM)
    5811     3402487 : SMI_ACCESSORS_CHECKED(Script, eval_from_position, kEvalFromPositionOffset,
    5812             :                       this->type() != TYPE_WASM)
    5813    20174051 : ACCESSORS(Script, shared_function_infos, FixedArray, kSharedFunctionInfosOffset)
    5814    15416899 : SMI_ACCESSORS(Script, flags, kFlagsOffset)
    5815      357339 : ACCESSORS(Script, source_url, Object, kSourceUrlOffset)
    5816       77149 : ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset)
    5817       37711 : ACCESSORS_CHECKED(Script, wasm_compiled_module, Object, kEvalFromSharedOffset,
    5818             :                   this->type() == TYPE_WASM)
    5819     6283674 : ACCESSORS(Script, preparsed_scope_data, PodArray<uint32_t>,
    5820             :           kPreParsedScopeDataOffset)
    5821             : 
    5822             : Script::CompilationType Script::compilation_type() {
    5823             :   return BooleanBit::get(flags(), kCompilationTypeBit) ?
    5824     4891153 :       COMPILATION_TYPE_EVAL : COMPILATION_TYPE_HOST;
    5825             : }
    5826             : void Script::set_compilation_type(CompilationType type) {
    5827             :   set_flags(BooleanBit::set(flags(), kCompilationTypeBit,
    5828             :       type == COMPILATION_TYPE_EVAL));
    5829             : }
    5830           0 : Script::CompilationState Script::compilation_state() {
    5831             :   return BooleanBit::get(flags(), kCompilationStateBit) ?
    5832       12088 :       COMPILATION_STATE_COMPILED : COMPILATION_STATE_INITIAL;
    5833             : }
    5834             : void Script::set_compilation_state(CompilationState state) {
    5835             :   set_flags(BooleanBit::set(flags(), kCompilationStateBit,
    5836             :       state == COMPILATION_STATE_COMPILED));
    5837             : }
    5838             : ScriptOriginOptions Script::origin_options() {
    5839      144719 :   return ScriptOriginOptions((flags() & kOriginOptionsMask) >>
    5840      144719 :                              kOriginOptionsShift);
    5841             : }
    5842             : void Script::set_origin_options(ScriptOriginOptions origin_options) {
    5843             :   DCHECK(!(origin_options.Flags() & ~((1 << kOriginOptionsSize) - 1)));
    5844     1501747 :   set_flags((flags() & ~kOriginOptionsMask) |
    5845     1501747 :             (origin_options.Flags() << kOriginOptionsShift));
    5846             : }
    5847             : 
    5848             : 
    5849   125107466 : ACCESSORS(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoIndex)
    5850      328370 : SMI_ACCESSORS(DebugInfo, debugger_hints, kDebuggerHintsIndex)
    5851    18710916 : ACCESSORS(DebugInfo, debug_bytecode_array, Object, kDebugBytecodeArrayIndex)
    5852     3636170 : ACCESSORS(DebugInfo, break_points, FixedArray, kBreakPointsStateIndex)
    5853             : 
    5854     1633703 : bool DebugInfo::HasDebugBytecodeArray() {
    5855     1633703 :   return debug_bytecode_array()->IsBytecodeArray();
    5856             : }
    5857             : 
    5858             : bool DebugInfo::HasDebugCode() {
    5859             :   Code* code = shared()->code();
    5860             :   bool has = code->kind() == Code::FUNCTION;
    5861             :   DCHECK(!has || code->has_debug_break_slots());
    5862             :   return has;
    5863             : }
    5864             : 
    5865             : BytecodeArray* DebugInfo::OriginalBytecodeArray() {
    5866             :   DCHECK(HasDebugBytecodeArray());
    5867             :   return shared()->bytecode_array();
    5868             : }
    5869             : 
    5870             : BytecodeArray* DebugInfo::DebugBytecodeArray() {
    5871             :   DCHECK(HasDebugBytecodeArray());
    5872             :   return BytecodeArray::cast(debug_bytecode_array());
    5873             : }
    5874             : 
    5875             : Code* DebugInfo::DebugCode() {
    5876             :   DCHECK(HasDebugCode());
    5877             :   return shared()->code();
    5878             : }
    5879             : 
    5880      144079 : SMI_ACCESSORS(BreakPointInfo, source_position, kSourcePositionIndex)
    5881      272006 : ACCESSORS(BreakPointInfo, break_point_objects, Object, kBreakPointObjectsIndex)
    5882             : 
    5883       71263 : SMI_ACCESSORS(StackFrameInfo, line_number, kLineNumberIndex)
    5884       71223 : SMI_ACCESSORS(StackFrameInfo, column_number, kColumnNumberIndex)
    5885       70953 : SMI_ACCESSORS(StackFrameInfo, script_id, kScriptIdIndex)
    5886       76847 : ACCESSORS(StackFrameInfo, script_name, Object, kScriptNameIndex)
    5887      121874 : ACCESSORS(StackFrameInfo, script_name_or_source_url, Object,
    5888             :           kScriptNameOrSourceUrlIndex)
    5889      157089 : ACCESSORS(StackFrameInfo, function_name, Object, kFunctionNameIndex)
    5890      134661 : SMI_ACCESSORS(StackFrameInfo, flag, kFlagIndex)
    5891             : BOOL_ACCESSORS(StackFrameInfo, flag, is_eval, kIsEvalBit)
    5892             : BOOL_ACCESSORS(StackFrameInfo, flag, is_constructor, kIsConstructorBit)
    5893             : BOOL_ACCESSORS(StackFrameInfo, flag, is_wasm, kIsWasmBit)
    5894       19268 : SMI_ACCESSORS(StackFrameInfo, id, kIdIndex)
    5895             : 
    5896      285223 : ACCESSORS(SourcePositionTableWithFrameCache, source_position_table, ByteArray,
    5897             :           kSourcePositionTableIndex)
    5898       66778 : ACCESSORS(SourcePositionTableWithFrameCache, stack_frame_cache,
    5899             :           UnseededNumberDictionary, kStackFrameCacheIndex)
    5900             : 
    5901    55574687 : ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset)
    5902    79542979 : ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray,
    5903             :           kOptimizedCodeMapOffset)
    5904    45406410 : ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset)
    5905   114883346 : ACCESSORS(SharedFunctionInfo, feedback_metadata, FeedbackMetadata,
    5906             :           kFeedbackMetadataOffset)
    5907    27170755 : SMI_ACCESSORS(SharedFunctionInfo, function_literal_id, kFunctionLiteralIdOffset)
    5908             : #if TRACE_MAPS
    5909             : SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset)
    5910             : #endif
    5911    67648736 : ACCESSORS(SharedFunctionInfo, instance_class_name, Object,
    5912             :           kInstanceClassNameOffset)
    5913   283990824 : ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset)
    5914   127547894 : ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset)
    5915    60908692 : ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset)
    5916    37280567 : ACCESSORS(SharedFunctionInfo, function_identifier, Object,
    5917             :           kFunctionIdentifierOffset)
    5918             : 
    5919     7519833 : SMI_ACCESSORS(FunctionTemplateInfo, length, kLengthOffset)
    5920             : BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype,
    5921             :                kHiddenPrototypeBit)
    5922             : BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit)
    5923             : BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check,
    5924             :                kNeedsAccessCheckBit)
    5925             : BOOL_ACCESSORS(FunctionTemplateInfo, flag, read_only_prototype,
    5926             :                kReadOnlyPrototypeBit)
    5927             : BOOL_ACCESSORS(FunctionTemplateInfo, flag, remove_prototype,
    5928             :                kRemovePrototypeBit)
    5929             : BOOL_ACCESSORS(FunctionTemplateInfo, flag, do_not_cache,
    5930             :                kDoNotCacheBit)
    5931             : BOOL_ACCESSORS(FunctionTemplateInfo, flag, accept_any_receiver,
    5932             :                kAcceptAnyReceiver)
    5933             : BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_named_expression,
    5934             :                kIsNamedExpressionBit)
    5935      874188 : BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
    5936             :                kIsTopLevelBit)
    5937             : 
    5938             : #if V8_HOST_ARCH_32_BIT
    5939             : SMI_ACCESSORS(SharedFunctionInfo, length, kLengthOffset)
    5940             : SMI_ACCESSORS(SharedFunctionInfo, internal_formal_parameter_count,
    5941             :               kFormalParameterCountOffset)
    5942             : SMI_ACCESSORS(SharedFunctionInfo, expected_nof_properties,
    5943             :               kExpectedNofPropertiesOffset)
    5944             : SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type,
    5945             :               kStartPositionAndTypeOffset)
    5946             : SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset)
    5947             : SMI_ACCESSORS(SharedFunctionInfo, function_token_position,
    5948             :               kFunctionTokenPositionOffset)
    5949             : SMI_ACCESSORS(SharedFunctionInfo, compiler_hints,
    5950             :               kCompilerHintsOffset)
    5951             : SMI_ACCESSORS(SharedFunctionInfo, opt_count_and_bailout_reason,
    5952             :               kOptCountAndBailoutReasonOffset)
    5953             : SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset)
    5954             : SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset)
    5955             : SMI_ACCESSORS(SharedFunctionInfo, profiler_ticks, kProfilerTicksOffset)
    5956             : 
    5957             : #else
    5958             : 
    5959             : #if V8_TARGET_LITTLE_ENDIAN
    5960             : #define PSEUDO_SMI_LO_ALIGN 0
    5961             : #define PSEUDO_SMI_HI_ALIGN kIntSize
    5962             : #else
    5963             : #define PSEUDO_SMI_LO_ALIGN kIntSize
    5964             : #define PSEUDO_SMI_HI_ALIGN 0
    5965             : #endif
    5966             : 
    5967             : #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset)                          \
    5968             :   STATIC_ASSERT(holder::offset % kPointerSize == PSEUDO_SMI_LO_ALIGN);         \
    5969             :   int holder::name() const {                                                   \
    5970             :     int value = READ_INT_FIELD(this, offset);                                  \
    5971             :     DCHECK(kHeapObjectTag == 1);                                               \
    5972             :     DCHECK((value & kHeapObjectTag) == 0);                                     \
    5973             :     return value >> 1;                                                         \
    5974             :   }                                                                            \
    5975             :   void holder::set_##name(int value) {                                         \
    5976             :     DCHECK(kHeapObjectTag == 1);                                               \
    5977             :     DCHECK((value & 0xC0000000) == 0xC0000000 || (value & 0xC0000000) == 0x0); \
    5978             :     WRITE_INT_FIELD(this, offset, (value << 1) & ~kHeapObjectTag);             \
    5979             :   }
    5980             : 
    5981             : #define PSEUDO_SMI_ACCESSORS_HI(holder, name, offset)                  \
    5982             :   STATIC_ASSERT(holder::offset % kPointerSize == PSEUDO_SMI_HI_ALIGN); \
    5983             :   INT_ACCESSORS(holder, name, offset)
    5984             : 
    5985             : 
    5986    26113024 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, length, kLengthOffset)
    5987    36069688 : PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, internal_formal_parameter_count,
    5988             :                         kFormalParameterCountOffset)
    5989             : 
    5990    19983148 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo,
    5991             :                         expected_nof_properties,
    5992             :                         kExpectedNofPropertiesOffset)
    5993             : 
    5994    21447556 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, end_position, kEndPositionOffset)
    5995    60760777 : PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo,
    5996             :                         start_position_and_type,
    5997             :                         kStartPositionAndTypeOffset)
    5998             : 
    5999    16929372 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo,
    6000             :                         function_token_position,
    6001             :                         kFunctionTokenPositionOffset)
    6002   181442088 : PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo,
    6003             :                         compiler_hints,
    6004             :                         kCompilerHintsOffset)
    6005             : 
    6006    12478236 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo,
    6007             :                         opt_count_and_bailout_reason,
    6008             :                         kOptCountAndBailoutReasonOffset)
    6009   103803391 : PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, counters, kCountersOffset)
    6010             : 
    6011    14279928 : PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo,
    6012             :                         ast_node_count,
    6013             :                         kAstNodeCountOffset)
    6014    19356344 : PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo,
    6015             :                         profiler_ticks,
    6016             :                         kProfilerTicksOffset)
    6017             : 
    6018             : #endif
    6019             : 
    6020           0 : AbstractCode* SharedFunctionInfo::abstract_code() {
    6021     1399260 :   if (HasBytecodeArray()) {
    6022           0 :     return AbstractCode::cast(bytecode_array());
    6023             :   } else {
    6024           0 :     return AbstractCode::cast(code());
    6025             :   }
    6026             : }
    6027             : 
    6028     1410530 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, allows_lazy_compilation,
    6029             :                kAllowLazyCompilation)
    6030             : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, uses_arguments,
    6031             :                kUsesArguments)
    6032             : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, has_duplicate_parameters,
    6033             :                kHasDuplicateParameters)
    6034        8306 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, asm_function, kIsAsmFunction)
    6035             : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_declaration,
    6036             :                kIsDeclaration)
    6037             : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, marked_for_tier_up,
    6038             :                kMarkedForTierUp)
    6039             : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
    6040             :                has_concurrent_optimization_job, kHasConcurrentOptimizationJob)
    6041             : 
    6042             : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, needs_home_object,
    6043             :                kNeedsHomeObject)
    6044      104972 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
    6045        2868 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, force_inline, kForceInline)
    6046             : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, must_use_ignition_turbo,
    6047             :                kMustUseIgnitionTurbo)
    6048      274660 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_flush, kDontFlush)
    6049        1028 : BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_asm_wasm_broken,
    6050             :                kIsAsmWasmBroken)
    6051             : 
    6052           0 : BOOL_GETTER(SharedFunctionInfo, compiler_hints, optimization_disabled,
    6053             :             kOptimizationDisabled)
    6054             : 
    6055        2168 : void SharedFunctionInfo::set_optimization_disabled(bool disable) {
    6056             :   set_compiler_hints(BooleanBit::set(compiler_hints(),
    6057             :                                      kOptimizationDisabled,
    6058             :                                      disable));
    6059        2168 : }
    6060             : 
    6061             : LanguageMode SharedFunctionInfo::language_mode() {
    6062             :   STATIC_ASSERT(LANGUAGE_END == 2);
    6063             :   return construct_language_mode(
    6064             :       BooleanBit::get(compiler_hints(), kStrictModeFunction));
    6065             : }
    6066             : 
    6067             : void SharedFunctionInfo::set_language_mode(LanguageMode language_mode) {
    6068             :   STATIC_ASSERT(LANGUAGE_END == 2);
    6069             :   // We only allow language mode transitions that set the same language mode
    6070             :   // again or go up in the chain:
    6071             :   DCHECK(is_sloppy(this->language_mode()) || is_strict(language_mode));
    6072             :   int hints = compiler_hints();
    6073             :   hints = BooleanBit::set(hints, kStrictModeFunction, is_strict(language_mode));
    6074             :   set_compiler_hints(hints);
    6075             : }
    6076             : 
    6077      474641 : FunctionKind SharedFunctionInfo::kind() const {
    6078    32942265 :   return FunctionKindBits::decode(compiler_hints());
    6079             : }
    6080             : 
    6081             : void SharedFunctionInfo::set_kind(FunctionKind kind) {
    6082             :   DCHECK(IsValidFunctionKind(kind));
    6083             :   int hints = compiler_hints();
    6084    24930278 :   hints = FunctionKindBits::update(hints, kind);
    6085             :   set_compiler_hints(hints);
    6086             : }
    6087             : 
    6088     3587062 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints,
    6089             :                name_should_print_as_anonymous, kNameShouldPrintAsAnonymous)
    6090    12462144 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, is_anonymous_expression,
    6091             :                kIsAnonymousExpression)
    6092         546 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, deserialized, kDeserialized)
    6093       22148 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, has_no_side_effect,
    6094             :                kHasNoSideEffect)
    6095       22148 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, computed_has_no_side_effect,
    6096             :                kComputedHasNoSideEffect)
    6097       43352 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, debug_is_blackboxed,
    6098             :                kDebugIsBlackboxed)
    6099     2153192 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, computed_debug_is_blackboxed,
    6100             :                kComputedDebugIsBlackboxed)
    6101      115502 : BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, has_reported_binary_coverage,
    6102             :                kHasReportedBinaryCoverage)
    6103             : 
    6104       92770 : bool Script::HasValidSource() {
    6105             :   Object* src = this->source();
    6106       92770 :   if (!src->IsString()) return true;
    6107             :   String* src_str = String::cast(src);
    6108       92770 :   if (!StringShape(src_str).IsExternal()) return true;
    6109       56026 :   if (src_str->IsOneByteRepresentation()) {
    6110       55998 :     return ExternalOneByteString::cast(src)->resource() != NULL;
    6111          28 :   } else if (src_str->IsTwoByteRepresentation()) {
    6112          28 :     return ExternalTwoByteString::cast(src)->resource() != NULL;
    6113             :   }
    6114             :   return true;
    6115             : }
    6116             : 
    6117             : 
    6118             : void SharedFunctionInfo::DontAdaptArguments() {
    6119             :   DCHECK(code()->kind() == Code::BUILTIN || code()->kind() == Code::STUB);
    6120             :   set_internal_formal_parameter_count(kDontAdaptArgumentsSentinel);
    6121             : }
    6122             : 
    6123             : 
    6124      196003 : int SharedFunctionInfo::start_position() const {
    6125     7931350 :   return start_position_and_type() >> kStartPositionShift;
    6126             : }
    6127             : 
    6128             : 
    6129             : void SharedFunctionInfo::set_start_position(int start_position) {
    6130     6233100 :   set_start_position_and_type((start_position << kStartPositionShift)
    6131     6233179 :     | (start_position_and_type() & ~kStartPositionMask));
    6132             : }
    6133             : 
    6134             : 
    6135   189108625 : Code* SharedFunctionInfo::code() const {
    6136   324787938 :   return Code::cast(READ_FIELD(this, kCodeOffset));
    6137             : }
    6138             : 
    6139             : 
    6140    13585396 : void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) {
    6141             :   DCHECK(value->kind() != Code::OPTIMIZED_FUNCTION);
    6142             :   // If the SharedFunctionInfo has bytecode we should never mark it for lazy
    6143             :   // compile, since the bytecode is never flushed.
    6144             :   DCHECK(value != GetIsolate()->builtins()->builtin(Builtins::kCompileLazy) ||
    6145             :          !HasBytecodeArray());
    6146    13585396 :   WRITE_FIELD(this, kCodeOffset, value);
    6147    40756192 :   CONDITIONAL_WRITE_BARRIER(value->GetHeap(), this, kCodeOffset, value, mode);
    6148    13585394 : }
    6149             : 
    6150             : 
    6151     2933271 : void SharedFunctionInfo::ReplaceCode(Code* value) {
    6152             :   // If the GC metadata field is already used then the function was
    6153             :   // enqueued as a code flushing candidate and we remove it now.
    6154     2933271 :   if (code()->gc_metadata() != NULL) {
    6155           0 :     CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher();
    6156           0 :     flusher->EvictCandidate(this);
    6157             :   }
    6158             : 
    6159             :   DCHECK(code()->gc_metadata() == NULL && value->gc_metadata() == NULL);
    6160             : #ifdef DEBUG
    6161             :   Code::VerifyRecompiledCode(code(), value);
    6162             : #endif  // DEBUG
    6163             : 
    6164     2933271 :   set_code(value);
    6165     2933270 : }
    6166             : 
    6167             : bool SharedFunctionInfo::IsInterpreted() const {
    6168     6024506 :   return code()->is_interpreter_trampoline_builtin();
    6169             : }
    6170             : 
    6171             : bool SharedFunctionInfo::HasBaselineCode() const {
    6172       11691 :   return code()->kind() == Code::FUNCTION;
    6173             : }
    6174             : 
    6175      230721 : ScopeInfo* SharedFunctionInfo::scope_info() const {
    6176     7908595 :   return reinterpret_cast<ScopeInfo*>(READ_FIELD(this, kScopeInfoOffset));
    6177             : }
    6178             : 
    6179             : 
    6180    19814562 : void SharedFunctionInfo::set_scope_info(ScopeInfo* value,
    6181             :                                         WriteBarrierMode mode) {
    6182    19814562 :   WRITE_FIELD(this, kScopeInfoOffset, reinterpret_cast<Object*>(value));
    6183    59443685 :   CONDITIONAL_WRITE_BARRIER(GetHeap(),
    6184             :                             this,
    6185             :                             kScopeInfoOffset,
    6186             :                             reinterpret_cast<Object*>(value),
    6187             :                             mode);
    6188    19814564 : }
    6189             : 
    6190    73876854 : ACCESSORS(SharedFunctionInfo, outer_scope_info, HeapObject,
    6191             :           kOuterScopeInfoOffset)
    6192             : 
    6193     1030622 : bool SharedFunctionInfo::is_compiled() const {
    6194             :   Builtins* builtins = GetIsolate()->builtins();
    6195             :   DCHECK(code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent));
    6196             :   DCHECK(code() != builtins->builtin(Builtins::kCompileOptimized));
    6197     1030622 :   return code() != builtins->builtin(Builtins::kCompileLazy);
    6198             : }
    6199             : 
    6200        1659 : int SharedFunctionInfo::GetLength() const {
    6201             :   DCHECK(is_compiled());
    6202             :   DCHECK(HasLength());
    6203        1659 :   return length();
    6204             : }
    6205             : 
    6206             : bool SharedFunctionInfo::HasLength() const {
    6207             :   DCHECK_IMPLIES(length() < 0, length() == kInvalidLength);
    6208             :   return length() != kInvalidLength;
    6209             : }
    6210             : 
    6211             : bool SharedFunctionInfo::has_simple_parameters() {
    6212             :   return scope_info()->HasSimpleParameters();
    6213             : }
    6214             : 
    6215             : bool SharedFunctionInfo::HasDebugInfo() const {
    6216             :   bool has_debug_info = !debug_info()->IsSmi();
    6217             :   DCHECK_EQ(debug_info()->IsStruct(), has_debug_info);
    6218             :   DCHECK(!has_debug_info || HasDebugCode());
    6219             :   return has_debug_info;
    6220             : }
    6221             : 
    6222             : DebugInfo* SharedFunctionInfo::GetDebugInfo() const {
    6223             :   DCHECK(HasDebugInfo());
    6224             :   return DebugInfo::cast(debug_info());
    6225             : }
    6226             : 
    6227      148448 : bool SharedFunctionInfo::HasDebugCode() const {
    6228      291261 :   if (HasBaselineCode()) return code()->has_debug_break_slots();
    6229        5635 :   return HasBytecodeArray();
    6230             : }
    6231             : 
    6232             : int SharedFunctionInfo::debugger_hints() const {
    6233    11890251 :   if (HasDebugInfo()) return GetDebugInfo()->debugger_hints();
    6234             :   return Smi::cast(debug_info())->value();
    6235             : }
    6236             : 
    6237     9203045 : void SharedFunctionInfo::set_debugger_hints(int value) {
    6238     9203045 :   if (HasDebugInfo()) {
    6239             :     GetDebugInfo()->set_debugger_hints(value);
    6240             :   } else {
    6241     9201644 :     set_debug_info(Smi::FromInt(value));
    6242             :   }
    6243     9203047 : }
    6244             : 
    6245    62596405 : bool SharedFunctionInfo::IsApiFunction() {
    6246    62596402 :   return function_data()->IsFunctionTemplateInfo();
    6247             : }
    6248             : 
    6249             : 
    6250             : FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() {
    6251             :   DCHECK(IsApiFunction());
    6252             :   return FunctionTemplateInfo::cast(function_data());
    6253             : }
    6254             : 
    6255             : void SharedFunctionInfo::set_api_func_data(FunctionTemplateInfo* data) {
    6256             :   DCHECK(function_data()->IsUndefined(GetIsolate()));
    6257     3759364 :   set_function_data(data);
    6258             : }
    6259             : 
    6260     3105589 : bool SharedFunctionInfo::HasBytecodeArray() const {
    6261     3105588 :   return function_data()->IsBytecodeArray();
    6262             : }
    6263             : 
    6264      104633 : BytecodeArray* SharedFunctionInfo::bytecode_array() const {
    6265             :   DCHECK(HasBytecodeArray());
    6266      104633 :   return BytecodeArray::cast(function_data());
    6267             : }
    6268             : 
    6269        1581 : void SharedFunctionInfo::set_bytecode_array(BytecodeArray* bytecode) {
    6270             :   DCHECK(function_data()->IsUndefined(GetIsolate()));
    6271     2078102 :   set_function_data(bytecode);
    6272        1581 : }
    6273             : 
    6274             : void SharedFunctionInfo::ClearBytecodeArray() {
    6275             :   DCHECK(function_data()->IsUndefined(GetIsolate()) || HasBytecodeArray());
    6276        7340 :   set_function_data(GetHeap()->undefined_value());
    6277             : }
    6278             : 
    6279    20589486 : bool SharedFunctionInfo::HasAsmWasmData() const {
    6280    20589486 :   return function_data()->IsFixedArray();
    6281             : }
    6282             : 
    6283       13469 : FixedArray* SharedFunctionInfo::asm_wasm_data() const {
    6284             :   DCHECK(HasAsmWasmData());
    6285       13469 :   return FixedArray::cast(function_data());
    6286             : }
    6287             : 
    6288             : void SharedFunctionInfo::set_asm_wasm_data(FixedArray* data) {
    6289             :   DCHECK(function_data()->IsUndefined(GetIsolate()) || HasAsmWasmData());
    6290        3609 :   set_function_data(data);
    6291             : }
    6292             : 
    6293         507 : void SharedFunctionInfo::ClearAsmWasmData() {
    6294             :   DCHECK(function_data()->IsUndefined(GetIsolate()) || HasAsmWasmData());
    6295         507 :   set_function_data(GetHeap()->undefined_value());
    6296         507 : }
    6297             : 
    6298             : bool SharedFunctionInfo::HasBuiltinFunctionId() {
    6299             :   return function_identifier()->IsSmi();
    6300             : }
    6301             : 
    6302             : BuiltinFunctionId SharedFunctionInfo::builtin_function_id() {
    6303             :   DCHECK(HasBuiltinFunctionId());
    6304             :   return static_cast<BuiltinFunctionId>(
    6305      275350 :       Smi::cast(function_identifier())->value());
    6306             : }
    6307             : 
    6308             : void SharedFunctionInfo::set_builtin_function_id(BuiltinFunctionId id) {
    6309       24539 :   set_function_identifier(Smi::FromInt(id));
    6310             : }
    6311             : 
    6312     3672079 : bool SharedFunctionInfo::HasInferredName() {
    6313     3672079 :   return function_identifier()->IsString();
    6314             : }
    6315             : 
    6316     3672079 : String* SharedFunctionInfo::inferred_name() {
    6317     3672079 :   if (HasInferredName()) {
    6318     2815735 :     return String::cast(function_identifier());
    6319             :   }
    6320             :   Isolate* isolate = GetIsolate();
    6321             :   DCHECK(function_identifier()->IsUndefined(isolate) || HasBuiltinFunctionId());
    6322      856345 :   return isolate->heap()->empty_string();
    6323             : }
    6324             : 
    6325             : void SharedFunctionInfo::set_inferred_name(String* inferred_name) {
    6326             :   DCHECK(function_identifier()->IsUndefined(GetIsolate()) || HasInferredName());
    6327     6231074 :   set_function_identifier(inferred_name);
    6328             : }
    6329             : 
    6330    56362034 : int SharedFunctionInfo::ic_age() {
    6331   138808534 :   return ICAgeBits::decode(counters());
    6332             : }
    6333             : 
    6334             : 
    6335             : void SharedFunctionInfo::set_ic_age(int ic_age) {
    6336     9002502 :   set_counters(ICAgeBits::update(counters(), ic_age));
    6337             : }
    6338             : 
    6339             : 
    6340          91 : int SharedFunctionInfo::deopt_count() {
    6341          91 :   return DeoptCountBits::decode(counters());
    6342             : }
    6343             : 
    6344             : 
    6345             : void SharedFunctionInfo::set_deopt_count(int deopt_count) {
    6346       74566 :   set_counters(DeoptCountBits::update(counters(), deopt_count));
    6347             : }
    6348             : 
    6349             : 
    6350             : void SharedFunctionInfo::increment_deopt_count() {
    6351             :   int value = counters();
    6352             :   int deopt_count = DeoptCountBits::decode(value);
    6353             :   // Saturate the deopt count when incrementing, rather than overflowing.
    6354      254493 :   if (deopt_count < DeoptCountBits::kMax) {
    6355      506768 :     set_counters(DeoptCountBits::update(value, deopt_count + 1));
    6356             :   }
    6357             : }
    6358             : 
    6359             : 
    6360             : int SharedFunctionInfo::opt_reenable_tries() {
    6361          41 :   return OptReenableTriesBits::decode(counters());
    6362             : }
    6363             : 
    6364             : 
    6365             : void SharedFunctionInfo::set_opt_reenable_tries(int tries) {
    6366          41 :   set_counters(OptReenableTriesBits::update(counters(), tries));
    6367             : }
    6368             : 
    6369             : 
    6370      167208 : int SharedFunctionInfo::opt_count() {
    6371      167208 :   return OptCountBits::decode(opt_count_and_bailout_reason());
    6372             : }
    6373             : 
    6374             : 
    6375             : void SharedFunctionInfo::set_opt_count(int opt_count) {
    6376             :   set_opt_count_and_bailout_reason(
    6377     1358112 :       OptCountBits::update(opt_count_and_bailout_reason(), opt_count));
    6378             : }
    6379             : 
    6380             : 
    6381             : BailoutReason SharedFunctionInfo::disable_optimization_reason() {
    6382             :   return static_cast<BailoutReason>(
    6383      183925 :       DisabledOptimizationReasonBits::decode(opt_count_and_bailout_reason()));
    6384             : }
    6385             : 
    6386             : 
    6387             : bool SharedFunctionInfo::has_deoptimization_support() {
    6388             :   Code* code = this->code();
    6389     1179834 :   return code->kind() == Code::FUNCTION && code->has_deoptimization_support();
    6390             : }
    6391             : 
    6392             : 
    6393          41 : void SharedFunctionInfo::TryReenableOptimization() {
    6394             :   int tries = opt_reenable_tries();
    6395          41 :   set_opt_reenable_tries((tries + 1) & OptReenableTriesBits::kMax);
    6396             :   // We reenable optimization whenever the number of tries is a large
    6397             :   // enough power of 2.
    6398          41 :   if (tries >= 16 && (((tries - 1) & tries) == 0)) {
    6399             :     set_optimization_disabled(false);
    6400             :     set_deopt_count(0);
    6401             :   }
    6402          41 : }
    6403             : 
    6404             : 
    6405        2168 : void SharedFunctionInfo::set_disable_optimization_reason(BailoutReason reason) {
    6406             :   set_opt_count_and_bailout_reason(DisabledOptimizationReasonBits::update(
    6407      118500 :       opt_count_and_bailout_reason(), reason));
    6408        2168 : }
    6409             : 
    6410    29763181 : bool SharedFunctionInfo::IsUserJavaScript() {
    6411             :   Object* script_obj = script();
    6412    29763181 :   if (script_obj->IsUndefined(GetIsolate())) return false;
    6413             :   Script* script = Script::cast(script_obj);
    6414    27894567 :   return script->IsUserJavaScript();
    6415             : }
    6416             : 
    6417    20866762 : bool SharedFunctionInfo::IsSubjectToDebugging() {
    6418    20866762 :   return IsUserJavaScript() && !HasAsmWasmData();
    6419             : }
    6420             : 
    6421             : bool SharedFunctionInfo::OptimizedCodeMapIsCleared() const {
    6422    45283489 :   return optimized_code_map() == GetHeap()->empty_fixed_array();
    6423             : }
    6424             : 
    6425     7693055 : FeedbackVector* JSFunction::feedback_vector() const {
    6426             :   DCHECK(feedback_vector_cell()->value()->IsFeedbackVector());
    6427     7693055 :   return FeedbackVector::cast(feedback_vector_cell()->value());
    6428             : }
    6429             : 
    6430     1920058 : bool JSFunction::IsOptimized() {
    6431     4634697 :   return code()->kind() == Code::OPTIMIZED_FUNCTION;
    6432             : }
    6433             : 
    6434        4578 : bool JSFunction::IsInterpreted() {
    6435     7169864 :   return code()->is_interpreter_trampoline_builtin();
    6436             : }
    6437             : 
    6438             : bool JSFunction::IsMarkedForOptimization() {
    6439      349163 :   return code() == GetIsolate()->builtins()->builtin(
    6440             :       Builtins::kCompileOptimized);
    6441             : }
    6442             : 
    6443             : 
    6444        5907 : bool JSFunction::IsMarkedForConcurrentOptimization() {
    6445        5907 :   return code() == GetIsolate()->builtins()->builtin(
    6446        5907 :       Builtins::kCompileOptimizedConcurrent);
    6447             : }
    6448             : 
    6449             : 
    6450        4268 : bool JSFunction::IsInOptimizationQueue() {
    6451      604806 :   return code() == GetIsolate()->builtins()->builtin(
    6452        4268 :       Builtins::kInOptimizationQueue);
    6453             : }
    6454             : 
    6455             : 
    6456      194677 : void JSFunction::CompleteInobjectSlackTrackingIfActive() {
    6457      251046 :   if (has_initial_map() && initial_map()->IsInobjectSlackTrackingInProgress()) {
    6458       40898 :     initial_map()->CompleteInobjectSlackTracking();
    6459             :   }
    6460      194677 : }
    6461             : 
    6462             : 
    6463             : bool Map::IsInobjectSlackTrackingInProgress() {
    6464    45699328 :   return construction_counter() != Map::kNoSlackTracking;
    6465             : }
    6466             : 
    6467             : 
    6468      407608 : void Map::InobjectSlackTrackingStep() {
    6469      815216 :   if (!IsInobjectSlackTrackingInProgress()) return;
    6470             :   int counter = construction_counter();
    6471      407608 :   set_construction_counter(counter - 1);
    6472      407608 :   if (counter == kSlackTrackingCounterEnd) {
    6473        2177 :     CompleteInobjectSlackTracking();
    6474             :   }
    6475             : }
    6476             : 
    6477             : AbstractCode* JSFunction::abstract_code() {
    6478         844 :   if (IsInterpreted()) {
    6479             :     return AbstractCode::cast(shared()->bytecode_array());
    6480             :   } else {
    6481         844 :     return AbstractCode::cast(code());
    6482             :   }
    6483             : }
    6484             : 
    6485   139001889 : Code* JSFunction::code() {
    6486             :   return Code::cast(
    6487   139001889 :       Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset)));
    6488             : }
    6489             : 
    6490             : 
    6491    29708412 : void JSFunction::set_code(Code* value) {
    6492             :   DCHECK(!GetHeap()->InNewSpace(value));
    6493    29708412 :   Address entry = value->entry();
    6494    29708412 :   WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry));
    6495             :   GetHeap()->incremental_marking()->RecordWriteOfCodeEntry(
    6496             :       this,
    6497             :       HeapObject::RawField(this, kCodeEntryOffset),
    6498    59416824 :       value);
    6499    29708414 : }
    6500             : 
    6501             : 
    6502             : void JSFunction::set_code_no_write_barrier(Code* value) {
    6503             :   DCHECK(!GetHeap()->InNewSpace(value));
    6504     1357586 :   Address entry = value->entry();
    6505     1357586 :   WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry));
    6506             : }
    6507             : 
    6508             : 
    6509     2714639 : void JSFunction::ReplaceCode(Code* code) {
    6510             :   bool was_optimized = IsOptimized();
    6511     2714639 :   bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION;
    6512             : 
    6513     2714639 :   if (was_optimized && is_optimized) {
    6514             :     shared()->EvictFromOptimizedCodeMap(this->code(),
    6515          80 :         "Replacing with another optimized code");
    6516             :   }
    6517             : 
    6518     2714639 :   set_code(code);
    6519             : 
    6520             :   // Add/remove the function from the list of optimized functions for this
    6521             :   // context based on the state change.
    6522     2714640 :   if (!was_optimized && is_optimized) {
    6523     1472907 :     context()->native_context()->AddOptimizedFunction(this);
    6524             :   }
    6525     2714642 :   if (was_optimized && !is_optimized) {
    6526             :     // TODO(titzer): linear in the number of optimized functions; fix!
    6527           6 :     context()->native_context()->RemoveOptimizedFunction(this);
    6528             :   }
    6529     2714642 : }
    6530             : 
    6531    10232574 : bool JSFunction::has_feedback_vector() const {
    6532    10232575 :   return !feedback_vector_cell()->value()->IsUndefined(GetIsolate());
    6533             : }
    6534             : 
    6535    18752915 : JSFunction::FeedbackVectorState JSFunction::GetFeedbackVectorState(
    6536             :     Isolate* isolate) const {
    6537             :   Cell* cell = feedback_vector_cell();
    6538    18752915 :   if (cell == isolate->heap()->undefined_cell()) {
    6539             :     return TOP_LEVEL_SCRIPT_NEEDS_VECTOR;
    6540    22863898 :   } else if (cell->value() == isolate->heap()->undefined_value() ||
    6541    10232454 :              !has_feedback_vector()) {
    6542             :     return NEEDS_VECTOR;
    6543             :   }
    6544    10232454 :   return HAS_VECTOR;
    6545             : }
    6546             : 
    6547       38555 : Context* JSFunction::context() {
    6548    55414660 :   return Context::cast(READ_FIELD(this, kContextOffset));
    6549             : }
    6550             : 
    6551         489 : bool JSFunction::has_context() const {
    6552         978 :   return READ_FIELD(this, kContextOffset)->IsContext();
    6553             : }
    6554             : 
    6555          86 : JSObject* JSFunction::global_proxy() {
    6556     1809453 :   return context()->global_proxy();
    6557             : }
    6558             : 
    6559             : 
    6560      597478 : Context* JSFunction::native_context() { return context()->native_context(); }
    6561             : 
    6562             : 
    6563    26507823 : void JSFunction::set_context(Object* value) {
    6564             :   DCHECK(value->IsUndefined(GetIsolate()) || value->IsContext());
    6565    26507823 :   WRITE_FIELD(this, kContextOffset, value);
    6566    79523466 :   WRITE_BARRIER(GetHeap(), this, kContextOffset, value);
    6567    26507821 : }
    6568             : 
    6569   154985331 : ACCESSORS(JSFunction, prototype_or_initial_map, Object,
    6570             :           kPrototypeOrInitialMapOffset)
    6571             : 
    6572             : 
    6573        5997 : Map* JSFunction::initial_map() {
    6574        5997 :   return Map::cast(prototype_or_initial_map());
    6575             : }
    6576             : 
    6577             : 
    6578    27769854 : bool JSFunction::has_initial_map() {
    6579    27769854 :   return prototype_or_initial_map()->IsMap();
    6580             : }
    6581             : 
    6582             : 
    6583      681570 : bool JSFunction::has_instance_prototype() {
    6584     1334422 :   return has_initial_map() ||
    6585      681570 :          !prototype_or_initial_map()->IsTheHole(GetIsolate());
    6586             : }
    6587             : 
    6588             : 
    6589      210229 : bool JSFunction::has_prototype() {
    6590      210229 :   return map()->has_non_instance_prototype() || has_instance_prototype();
    6591             : }
    6592             : 
    6593             : 
    6594             : Object* JSFunction::instance_prototype() {
    6595             :   DCHECK(has_instance_prototype());
    6596     5250621 :   if (has_initial_map()) return initial_map()->prototype();
    6597             :   // When there is no initial map and the prototype is a JSObject, the
    6598             :   // initial map field is used for the prototype field.
    6599             :   return prototype_or_initial_map();
    6600             : }
    6601             : 
    6602             : 
    6603     4871182 : Object* JSFunction::prototype() {
    6604             :   DCHECK(has_prototype());
    6605             :   // If the function's prototype property has been set to a non-JSObject
    6606             :   // value, that value is stored in the constructor field of the map.
    6607     4871182 :   if (map()->has_non_instance_prototype()) {
    6608       21542 :     Object* prototype = map()->GetConstructor();
    6609             :     // The map must have a prototype in that field, not a back pointer.
    6610             :     DCHECK(!prototype->IsMap());
    6611             :     DCHECK(!prototype->IsFunctionTemplateInfo());
    6612       21542 :     return prototype;
    6613             :   }
    6614     4849640 :   return instance_prototype();
    6615             : }
    6616             : 
    6617             : 
    6618             : bool JSFunction::is_compiled() {
    6619             :   Builtins* builtins = GetIsolate()->builtins();
    6620     1950725 :   return code() != builtins->builtin(Builtins::kCompileLazy) &&
    6621     1896805 :          code() != builtins->builtin(Builtins::kCompileOptimized) &&
    6622             :          code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent);
    6623             : }
    6624             : 
    6625     7629180 : ACCESSORS(JSProxy, target, JSReceiver, kTargetOffset)
    6626    15136266 : ACCESSORS(JSProxy, handler, Object, kHandlerOffset)
    6627       50074 : ACCESSORS(JSProxy, hash, Object, kHashOffset)
    6628             : 
    6629     7508028 : bool JSProxy::IsRevoked() const { return !handler()->IsJSReceiver(); }
    6630             : 
    6631     2516170 : ACCESSORS(JSCollection, table, Object, kTableOffset)
    6632             : 
    6633             : 
    6634             : #define ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(name, type, offset)    \
    6635             :   template<class Derived, class TableType>                           \
    6636             :   type* OrderedHashTableIterator<Derived, TableType>::name() const { \
    6637             :     return type::cast(READ_FIELD(this, offset));                     \
    6638             :   }                                                                  \
    6639             :   template<class Derived, class TableType>                           \
    6640             :   void OrderedHashTableIterator<Derived, TableType>::set_##name(     \
    6641             :       type* value, WriteBarrierMode mode) {                          \
    6642             :     WRITE_FIELD(this, offset, value);                                \
    6643             :     CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \
    6644             :   }
    6645             : 
    6646       95489 : ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(table, Object, kTableOffset)
    6647      143376 : ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(index, Object, kIndexOffset)
    6648       49457 : ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(kind, Object, kKindOffset)
    6649             : 
    6650             : #undef ORDERED_HASH_TABLE_ITERATOR_ACCESSORS
    6651             : 
    6652             : 
    6653      420506 : ACCESSORS(JSWeakCollection, table, Object, kTableOffset)
    6654       22259 : ACCESSORS(JSWeakCollection, next, Object, kNextOffset)
    6655             : 
    6656             : 
    6657      153282 : Address Foreign::foreign_address() {
    6658   106218501 :   return AddressFrom<Address>(READ_INTPTR_FIELD(this, kForeignAddressOffset));
    6659             : }
    6660             : 
    6661             : 
    6662             : void Foreign::set_foreign_address(Address value) {
    6663     4375837 :   WRITE_INTPTR_FIELD(this, kForeignAddressOffset, OffsetFrom(value));
    6664             : }
    6665             : 
    6666             : 
    6667      118205 : ACCESSORS(JSGeneratorObject, function, JSFunction, kFunctionOffset)
    6668      184575 : ACCESSORS(JSGeneratorObject, context, Context, kContextOffset)
    6669      112695 : ACCESSORS(JSGeneratorObject, receiver, Object, kReceiverOffset)
    6670       74600 : ACCESSORS(JSGeneratorObject, input_or_debug_pos, Object, kInputOrDebugPosOffset)
    6671      139324 : SMI_ACCESSORS(JSGeneratorObject, resume_mode, kResumeModeOffset)
    6672      108042 : SMI_ACCESSORS(JSGeneratorObject, continuation, kContinuationOffset)
    6673      112641 : ACCESSORS(JSGeneratorObject, register_file, FixedArray, kRegisterFileOffset)
    6674             : 
    6675           0 : bool JSGeneratorObject::is_suspended() const {
    6676             :   DCHECK_LT(kGeneratorExecuting, 0);
    6677             :   DCHECK_LT(kGeneratorClosed, 0);
    6678          54 :   return continuation() >= 0;
    6679             : }
    6680             : 
    6681             : bool JSGeneratorObject::is_closed() const {
    6682             :   return continuation() == kGeneratorClosed;
    6683             : }
    6684             : 
    6685             : bool JSGeneratorObject::is_executing() const {
    6686             :   return continuation() == kGeneratorExecuting;
    6687             : }
    6688             : 
    6689             : ACCESSORS(JSAsyncGeneratorObject, queue, HeapObject, kQueueOffset)
    6690           0 : ACCESSORS(JSAsyncGeneratorObject, await_input_or_debug_pos, Object,
    6691             :           kAwaitInputOrDebugPosOffset)
    6692           0 : ACCESSORS(JSAsyncGeneratorObject, awaited_promise, HeapObject,
    6693             :           kAwaitedPromiseOffset)
    6694             : 
    6695     5317371 : ACCESSORS(JSValue, value, Object, kValueOffset)
    6696             : 
    6697             : 
    6698             : HeapNumber* HeapNumber::cast(Object* object) {
    6699             :   SLOW_DCHECK(object->IsHeapNumber() || object->IsMutableHeapNumber());
    6700             :   return reinterpret_cast<HeapNumber*>(object);
    6701             : }
    6702             : 
    6703             : 
    6704             : const HeapNumber* HeapNumber::cast(const Object* object) {
    6705             :   SLOW_DCHECK(object->IsHeapNumber() || object->IsMutableHeapNumber());
    6706             :   return reinterpret_cast<const HeapNumber*>(object);
    6707             : }
    6708             : 
    6709             : 
    6710      856058 : ACCESSORS(JSDate, value, Object, kValueOffset)
    6711      256713 : ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset)
    6712       19349 : ACCESSORS(JSDate, year, Object, kYearOffset)
    6713       18339 : ACCESSORS(JSDate, month, Object, kMonthOffset)
    6714       18072 : ACCESSORS(JSDate, day, Object, kDayOffset)
    6715       17959 : ACCESSORS(JSDate, weekday, Object, kWeekdayOffset)
    6716       22846 : ACCESSORS(JSDate, hour, Object, kHourOffset)
    6717       19281 : ACCESSORS(JSDate, min, Object, kMinOffset)
    6718       18310 : ACCESSORS(JSDate, sec, Object, kSecOffset)
    6719             : 
    6720             : 
    6721     1410786 : SMI_ACCESSORS(JSMessageObject, type, kTypeOffset)
    6722     4246698 : ACCESSORS(JSMessageObject, argument, Object, kArgumentsOffset)
    6723     4303347 : ACCESSORS(JSMessageObject, script, Object, kScriptOffset)
    6724     4215435 : ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset)
    6725     1519151 : SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset)
    6726     1429872 : SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset)
    6727     1457727 : SMI_ACCESSORS(JSMessageObject, error_level, kErrorLevelOffset)
    6728             : 
    6729   374945452 : INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset)
    6730   180203358 : INT_ACCESSORS(Code, prologue_offset, kPrologueOffset)
    6731     2554083 : INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset)
    6732             : #define CODE_ACCESSORS(name, type, offset)           \
    6733             :   ACCESSORS_CHECKED2(Code, name, type, offset, true, \
    6734             :                      !GetHeap()->InNewSpace(value))
    6735    11236890 : CODE_ACCESSORS(relocation_info, ByteArray, kRelocationInfoOffset)
    6736     6255519 : CODE_ACCESSORS(handler_table, FixedArray, kHandlerTableOffset)
    6737    15155630 : CODE_ACCESSORS(deoptimization_data, FixedArray, kDeoptimizationDataOffset)
    6738    21269850 : CODE_ACCESSORS(source_position_table, Object, kSourcePositionTableOffset)
    6739     7680664 : CODE_ACCESSORS(trap_handler_index, Smi, kTrapHandlerIndex)
    6740    18640314 : CODE_ACCESSORS(raw_type_feedback_info, Object, kTypeFeedbackInfoOffset)
    6741     7949424 : CODE_ACCESSORS(next_code_link, Object, kNextCodeLinkOffset)
    6742             : #undef CODE_ACCESSORS
    6743             : 
    6744             : void Code::WipeOutHeader() {
    6745        1366 :   WRITE_FIELD(this, kRelocationInfoOffset, NULL);
    6746        1366 :   WRITE_FIELD(this, kHandlerTableOffset, NULL);
    6747        1366 :   WRITE_FIELD(this, kDeoptimizationDataOffset, NULL);
    6748        1366 :   WRITE_FIELD(this, kSourcePositionTableOffset, NULL);
    6749             :   // Do not wipe out major/minor keys on a code stub or IC
    6750        2732 :   if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) {
    6751           0 :     WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL);
    6752             :   }
    6753        1366 :   WRITE_FIELD(this, kNextCodeLinkOffset, NULL);
    6754        1366 :   WRITE_FIELD(this, kGCMetadataOffset, NULL);
    6755             : }
    6756             : 
    6757             : 
    6758             : Object* Code::type_feedback_info() {
    6759             :   DCHECK(kind() == FUNCTION);
    6760             :   return raw_type_feedback_info();
    6761             : }
    6762             : 
    6763             : 
    6764     1079855 : void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) {
    6765             :   DCHECK(kind() == FUNCTION);
    6766     1079855 :   set_raw_type_feedback_info(value, mode);
    6767     3239561 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset,
    6768             :                             value, mode);
    6769     1079857 : }
    6770             : 
    6771     1958619 : ByteArray* Code::SourcePositionTable() {
    6772             :   Object* maybe_table = source_position_table();
    6773     1958623 :   if (maybe_table->IsByteArray()) return ByteArray::cast(maybe_table);
    6774             :   DCHECK(maybe_table->IsSourcePositionTableWithFrameCache());
    6775             :   return SourcePositionTableWithFrameCache::cast(maybe_table)
    6776       39658 :       ->source_position_table();
    6777             : }
    6778             : 
    6779             : uint32_t Code::stub_key() {
    6780             :   DCHECK(IsCodeStubOrIC());
    6781             :   Smi* smi_key = Smi::cast(raw_type_feedback_info());
    6782      877239 :   return static_cast<uint32_t>(smi_key->value());
    6783             : }
    6784             : 
    6785             : 
    6786             : void Code::set_stub_key(uint32_t key) {
    6787             :   DCHECK(IsCodeStubOrIC());
    6788      517570 :   set_raw_type_feedback_info(Smi::FromInt(key));
    6789             : }
    6790             : 
    6791             : 
    6792    18809151 : ACCESSORS(Code, gc_metadata, Object, kGCMetadataOffset)
    6793     5108160 : INT_ACCESSORS(Code, ic_age, kICAgeOffset)
    6794             : 
    6795             : 
    6796          14 : byte* Code::instruction_start()  {
    6797          14 :   return FIELD_ADDR(this, kHeaderSize);
    6798             : }
    6799             : 
    6800             : 
    6801             : byte* Code::instruction_end()  {
    6802      941185 :   return instruction_start() + instruction_size();
    6803             : }
    6804             : 
    6805             : int Code::GetUnwindingInfoSizeOffset() const {
    6806             :   DCHECK(has_unwinding_info());
    6807          31 :   return RoundUp(kHeaderSize + instruction_size(), kInt64Size);
    6808             : }
    6809             : 
    6810             : int Code::unwinding_info_size() const {
    6811             :   DCHECK(has_unwinding_info());
    6812             :   return static_cast<int>(
    6813           6 :       READ_UINT64_FIELD(this, GetUnwindingInfoSizeOffset()));
    6814             : }
    6815             : 
    6816             : void Code::set_unwinding_info_size(int value) {
    6817             :   DCHECK(has_unwinding_info());
    6818          25 :   WRITE_UINT64_FIELD(this, GetUnwindingInfoSizeOffset(), value);
    6819             : }
    6820             : 
    6821             : byte* Code::unwinding_info_start() {
    6822             :   DCHECK(has_unwinding_info());
    6823          31 :   return FIELD_ADDR(this, GetUnwindingInfoSizeOffset()) + kInt64Size;
    6824             : }
    6825             : 
    6826             : byte* Code::unwinding_info_end() {
    6827             :   DCHECK(has_unwinding_info());
    6828           6 :   return unwinding_info_start() + unwinding_info_size();
    6829             : }
    6830             : 
    6831   365337260 : int Code::body_size() {
    6832             :   int unpadded_body_size =
    6833             :       has_unwinding_info()
    6834           6 :           ? static_cast<int>(unwinding_info_end() - instruction_start())
    6835   365337266 :           : instruction_size();
    6836   365337260 :   return RoundUp(unpadded_body_size, kObjectAlignment);
    6837             : }
    6838             : 
    6839      848289 : int Code::SizeIncludingMetadata() {
    6840             :   int size = CodeSize();
    6841      848289 :   size += relocation_info()->Size();
    6842      848289 :   size += deoptimization_data()->Size();
    6843      848290 :   size += handler_table()->Size();
    6844      848290 :   if (kind() == FUNCTION) {
    6845     1696581 :     size += SourcePositionTable()->Size();
    6846             :   }
    6847      848293 :   return size;
    6848             : }
    6849             : 
    6850             : ByteArray* Code::unchecked_relocation_info() {
    6851   180229230 :   return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset));
    6852             : }
    6853             : 
    6854             : 
    6855             : byte* Code::relocation_start() {
    6856             :   return unchecked_relocation_info()->GetDataStartAddress();
    6857             : }
    6858             : 
    6859             : 
    6860             : int Code::relocation_size() {
    6861             :   return unchecked_relocation_info()->length();
    6862             : }
    6863             : 
    6864             : 
    6865             : byte* Code::entry() {
    6866             :   return instruction_start();
    6867             : }
    6868             : 
    6869             : 
    6870             : bool Code::contains(byte* inner_pointer) {
    6871     1979476 :   return (address() <= inner_pointer) && (inner_pointer <= address() + Size());
    6872             : }
    6873             : 
    6874             : 
    6875             : int Code::ExecutableSize() {
    6876             :   // Check that the assumptions about the layout of the code object holds.
    6877             :   DCHECK_EQ(static_cast<int>(instruction_start() - address()),
    6878             :             Code::kHeaderSize);
    6879      209625 :   return instruction_size() + Code::kHeaderSize;
    6880             : }
    6881             : 
    6882             : 
    6883   365056333 : int Code::CodeSize() { return SizeFor(body_size()); }
    6884             : 
    6885             : 
    6886   260484235 : ACCESSORS(JSArray, length, Object, kLengthOffset)
    6887             : 
    6888             : 
    6889       16661 : void* JSArrayBuffer::backing_store() const {
    6890    57206069 :   intptr_t ptr = READ_INTPTR_FIELD(this, kBackingStoreOffset);
    6891    57206069 :   return reinterpret_cast<void*>(ptr);
    6892             : }
    6893             : 
    6894             : 
    6895             : void JSArrayBuffer::set_backing_store(void* value, WriteBarrierMode mode) {
    6896      147962 :   intptr_t ptr = reinterpret_cast<intptr_t>(value);
    6897      151230 :   WRITE_INTPTR_FIELD(this, kBackingStoreOffset, ptr);
    6898             : }
    6899             : 
    6900             : 
    6901      737932 : ACCESSORS(JSArrayBuffer, byte_length, Object, kByteLengthOffset)
    6902             : 
    6903             : 
    6904             : void JSArrayBuffer::set_bit_field(uint32_t bits) {
    6905             :   if (kInt32Size != kPointerSize) {
    6906             : #if V8_TARGET_LITTLE_ENDIAN
    6907      182471 :     WRITE_UINT32_FIELD(this, kBitFieldSlot + kInt32Size, 0);
    6908             : #else
    6909             :     WRITE_UINT32_FIELD(this, kBitFieldSlot, 0);
    6910             : #endif
    6911             :   }
    6912      591804 :   WRITE_UINT32_FIELD(this, kBitFieldOffset, bits);
    6913             : }
    6914             : 
    6915             : 
    6916             : uint32_t JSArrayBuffer::bit_field() const {
    6917    98172495 :   return READ_UINT32_FIELD(this, kBitFieldOffset);
    6918             : }
    6919             : 
    6920             : 
    6921         210 : bool JSArrayBuffer::is_external() { return IsExternal::decode(bit_field()); }
    6922             : 
    6923             : 
    6924        3020 : void JSArrayBuffer::set_is_external(bool value) {
    6925             :   DCHECK(!value || !has_guard_region());
    6926             :   set_bit_field(IsExternal::update(bit_field(), value));
    6927        3020 : }
    6928             : 
    6929             : 
    6930             : bool JSArrayBuffer::is_neuterable() {
    6931             :   return IsNeuterable::decode(bit_field());
    6932             : }
    6933             : 
    6934             : 
    6935             : void JSArrayBuffer::set_is_neuterable(bool value) {
    6936             :   set_bit_field(IsNeuterable::update(bit_field(), value));
    6937             : }
    6938             : 
    6939             : 
    6940             : bool JSArrayBuffer::was_neutered() { return WasNeutered::decode(bit_field()); }
    6941             : 
    6942             : 
    6943             : void JSArrayBuffer::set_was_neutered(bool value) {
    6944             :   set_bit_field(WasNeutered::update(bit_field(), value));
    6945             : }
    6946             : 
    6947             : 
    6948    37829512 : bool JSArrayBuffer::is_shared() { return IsShared::decode(bit_field()); }
    6949             : 
    6950             : 
    6951             : void JSArrayBuffer::set_is_shared(bool value) {
    6952             :   set_bit_field(IsShared::update(bit_field(), value));
    6953             : }
    6954             : 
    6955             : bool JSArrayBuffer::has_guard_region() {
    6956             :   return HasGuardRegion::decode(bit_field());
    6957             : }
    6958             : 
    6959             : void JSArrayBuffer::set_has_guard_region(bool value) {
    6960             :   set_bit_field(HasGuardRegion::update(bit_field(), value));
    6961             : }
    6962             : 
    6963    18939974 : Object* JSArrayBufferView::byte_offset() const {
    6964    18955078 :   if (WasNeutered()) return Smi::kZero;
    6965    18954901 :   return Object::cast(READ_FIELD(this, kByteOffsetOffset));
    6966             : }
    6967             : 
    6968             : 
    6969        5943 : void JSArrayBufferView::set_byte_offset(Object* value, WriteBarrierMode mode) {
    6970        5943 :   WRITE_FIELD(this, kByteOffsetOffset, value);
    6971       17829 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteOffsetOffset, value, mode);
    6972        5943 : }
    6973             : 
    6974             : 
    6975       15606 : Object* JSArrayBufferView::byte_length() const {
    6976       49448 :   if (WasNeutered()) return Smi::kZero;
    6977       49271 :   return Object::cast(READ_FIELD(this, kByteLengthOffset));
    6978             : }
    6979             : 
    6980             : 
    6981        5943 : void JSArrayBufferView::set_byte_length(Object* value, WriteBarrierMode mode) {
    6982        5943 :   WRITE_FIELD(this, kByteLengthOffset, value);
    6983       17829 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kByteLengthOffset, value, mode);
    6984        5943 : }
    6985             : 
    6986             : 
    6987    79103142 : ACCESSORS(JSArrayBufferView, buffer, Object, kBufferOffset)
    6988             : #ifdef VERIFY_HEAP
    6989             : ACCESSORS(JSArrayBufferView, raw_byte_offset, Object, kByteOffsetOffset)
    6990             : ACCESSORS(JSArrayBufferView, raw_byte_length, Object, kByteLengthOffset)
    6991             : #endif
    6992             : 
    6993             : 
    6994       41794 : bool JSArrayBufferView::WasNeutered() const {
    6995       41794 :   return JSArrayBuffer::cast(buffer())->was_neutered();
    6996             : }
    6997             : 
    6998             : 
    6999    18962743 : Object* JSTypedArray::length() const {
    7000    18962976 :   if (WasNeutered()) return Smi::kZero;
    7001    18962931 :   return Object::cast(READ_FIELD(this, kLengthOffset));
    7002             : }
    7003             : 
    7004             : 
    7005       59730 : uint32_t JSTypedArray::length_value() const {
    7006       59730 :   if (WasNeutered()) return 0;
    7007       59604 :   uint32_t index = 0;
    7008      119208 :   CHECK(Object::cast(READ_FIELD(this, kLengthOffset))->ToArrayLength(&index));
    7009       59604 :   return index;
    7010             : }
    7011             : 
    7012             : 
    7013         372 : void JSTypedArray::set_length(Object* value, WriteBarrierMode mode) {
    7014         372 :   WRITE_FIELD(this, kLengthOffset, value);
    7015        1116 :   CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kLengthOffset, value, mode);
    7016         372 : }
    7017             : 
    7018             : // static
    7019       43779 : MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate,
    7020             :                                                  Handle<Object> receiver,
    7021             :                                                  const char* method_name) {
    7022       43779 :   if (V8_UNLIKELY(!receiver->IsJSTypedArray())) {
    7023             :     const MessageTemplate::Template message = MessageTemplate::kNotTypedArray;
    7024        3388 :     THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray);
    7025             :   }
    7026             : 
    7027             :   Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver);
    7028       42085 :   if (V8_UNLIKELY(array->WasNeutered())) {
    7029             :     const MessageTemplate::Template message =
    7030             :         MessageTemplate::kDetachedOperation;
    7031             :     Handle<String> operation =
    7032         756 :         isolate->factory()->NewStringFromAsciiChecked(method_name);
    7033        1512 :     THROW_NEW_ERROR(isolate, NewTypeError(message, operation), JSTypedArray);
    7034             :   }
    7035             : 
    7036             :   // spec describes to return `buffer`, but it may disrupt current
    7037             :   // implementations, and it's much useful to return array for now.
    7038             :   return array;
    7039             : }
    7040             : 
    7041             : #ifdef VERIFY_HEAP
    7042             : ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset)
    7043             : #endif
    7044             : 
    7045             : ACCESSORS(JSPromiseCapability, promise, Object, kPromiseOffset)
    7046             : ACCESSORS(JSPromiseCapability, resolve, Object, kResolveOffset)
    7047             : ACCESSORS(JSPromiseCapability, reject, Object, kRejectOffset)
    7048             : 
    7049         508 : SMI_ACCESSORS(JSPromise, status, kStatusOffset)
    7050          42 : ACCESSORS(JSPromise, result, Object, kResultOffset)
    7051        5642 : ACCESSORS(JSPromise, deferred_promise, Object, kDeferredPromiseOffset)
    7052             : ACCESSORS(JSPromise, deferred_on_resolve, Object, kDeferredOnResolveOffset)
    7053             : ACCESSORS(JSPromise, deferred_on_reject, Object, kDeferredOnRejectOffset)
    7054             : ACCESSORS(JSPromise, fulfill_reactions, Object, kFulfillReactionsOffset)
    7055        5642 : ACCESSORS(JSPromise, reject_reactions, Object, kRejectReactionsOffset)
    7056       18672 : SMI_ACCESSORS(JSPromise, flags, kFlagsOffset)
    7057       15424 : BOOL_ACCESSORS(JSPromise, flags, has_handler, kHasHandlerBit)
    7058             : BOOL_ACCESSORS(JSPromise, flags, handled_hint, kHandledHintBit)
    7059             : 
    7060    13817891 : ACCESSORS(JSRegExp, data, Object, kDataOffset)
    7061     2149242 : ACCESSORS(JSRegExp, flags, Object, kFlagsOffset)
    7062     2149302 : ACCESSORS(JSRegExp, source, Object, kSourceOffset)
    7063             : 
    7064             : 
    7065     3959438 : JSRegExp::Type JSRegExp::TypeTag() {
    7066             :   Object* data = this->data();
    7067     3959438 :   if (data->IsUndefined(GetIsolate())) return JSRegExp::NOT_COMPILED;
    7068             :   Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex));
    7069     3959438 :   return static_cast<JSRegExp::Type>(smi->value());
    7070             : }
    7071             : 
    7072             : 
    7073      368276 : int JSRegExp::CaptureCount() {
    7074      368276 :   switch (TypeTag()) {
    7075             :     case ATOM:
    7076             :       return 0;
    7077             :     case IRREGEXP:
    7078       15492 :       return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value();
    7079             :     default:
    7080           0 :       UNREACHABLE();
    7081             :       return -1;
    7082             :   }
    7083             : }
    7084             : 
    7085             : 
    7086      156112 : JSRegExp::Flags JSRegExp::GetFlags() {
    7087             :   DCHECK(this->data()->IsFixedArray());
    7088             :   Object* data = this->data();
    7089             :   Smi* smi = Smi::cast(FixedArray::cast(data)->get(kFlagsIndex));
    7090      156112 :   return Flags(smi->value());
    7091             : }
    7092             : 
    7093             : 
    7094             : String* JSRegExp::Pattern() {
    7095             :   DCHECK(this->data()->IsFixedArray());
    7096             :   Object* data = this->data();
    7097             :   String* pattern = String::cast(FixedArray::cast(data)->get(kSourceIndex));
    7098             :   return pattern;
    7099             : }
    7100             : 
    7101         173 : Object* JSRegExp::CaptureNameMap() {
    7102             :   DCHECK(this->data()->IsFixedArray());
    7103             :   DCHECK_EQ(TypeTag(), IRREGEXP);
    7104             :   Object* value = DataAt(kIrregexpCaptureNameMapIndex);
    7105             :   DCHECK_NE(value, Smi::FromInt(JSRegExp::kUninitializedValue));
    7106         173 :   return value;
    7107             : }
    7108             : 
    7109             : Object* JSRegExp::DataAt(int index) {
    7110             :   DCHECK(TypeTag() != NOT_COMPILED);
    7111             :   return FixedArray::cast(data())->get(index);
    7112             : }
    7113             : 
    7114             : 
    7115             : void JSRegExp::SetDataAt(int index, Object* value) {
    7116             :   DCHECK(TypeTag() != NOT_COMPILED);
    7117             :   DCHECK(index >= kDataIndex);  // Only implementation data can be set this way.
    7118        3557 :   FixedArray::cast(data())->set(index, value);
    7119             : }
    7120             : 
    7121           0 : void JSRegExp::SetLastIndex(int index) {
    7122             :   static const int offset =
    7123             :       kSize + JSRegExp::kLastIndexFieldIndex * kPointerSize;
    7124             :   Smi* value = Smi::FromInt(index);
    7125        4048 :   WRITE_FIELD(this, offset, value);
    7126           0 : }
    7127             : 
    7128           0 : Object* JSRegExp::LastIndex() {
    7129             :   static const int offset =
    7130             :       kSize + JSRegExp::kLastIndexFieldIndex * kPointerSize;
    7131        8997 :   return READ_FIELD(this, offset);
    7132             : }
    7133             : 
    7134      678025 : ElementsKind JSObject::GetElementsKind() {
    7135             :   ElementsKind kind = map()->elements_kind();
    7136             : #if VERIFY_HEAP && DEBUG
    7137             :   FixedArrayBase* fixed_array =
    7138             :       reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset));
    7139             : 
    7140             :   // If a GC was caused while constructing this object, the elements
    7141             :   // pointer may point to a one pointer filler map.
    7142             :   if (ElementsAreSafeToExamine()) {
    7143             :     Map* map = fixed_array->map();
    7144             :     if (IsFastSmiOrObjectElementsKind(kind)) {
    7145             :       DCHECK(map == GetHeap()->fixed_array_map() ||
    7146             :              map == GetHeap()->fixed_cow_array_map());
    7147             :     } else if (IsFastDoubleElementsKind(kind)) {
    7148             :       DCHECK(fixed_array->IsFixedDoubleArray() ||
    7149             :              fixed_array == GetHeap()->empty_fixed_array());
    7150             :     } else if (kind == DICTIONARY_ELEMENTS) {
    7151             :       DCHECK(fixed_array->IsFixedArray());
    7152             :       DCHECK(fixed_array->IsDictionary());
    7153             :     } else {
    7154             :       DCHECK(kind > DICTIONARY_ELEMENTS);
    7155             :     }
    7156             :     DCHECK(!IsSloppyArgumentsElementsKind(kind) ||
    7157             :            (elements()->IsFixedArray() && elements()->length() >= 2));
    7158             :   }
    7159             : #endif
    7160      678025 :   return kind;
    7161             : }
    7162             : 
    7163             : 
    7164     3185972 : bool JSObject::HasFastObjectElements() {
    7165     3185972 :   return IsFastObjectElementsKind(GetElementsKind());
    7166             : }
    7167             : 
    7168             : 
    7169     1912842 : bool JSObject::HasFastSmiElements() {
    7170     1912842 :   return IsFastSmiElementsKind(GetElementsKind());
    7171             : }
    7172             : 
    7173             : 
    7174     2255026 : bool JSObject::HasFastSmiOrObjectElements() {
    7175     2255026 :   return IsFastSmiOrObjectElementsKind(GetElementsKind());
    7176             : }
    7177             : 
    7178             : 
    7179     3908809 : bool JSObject::HasFastDoubleElements() {
    7180     3908809 :   return IsFastDoubleElementsKind(GetElementsKind());
    7181             : }
    7182             : 
    7183             : 
    7184     8250813 : bool JSObject::HasFastHoleyElements() {
    7185     8250813 :   return IsFastHoleyElementsKind(GetElementsKind());
    7186             : }
    7187             : 
    7188             : 
    7189     5330040 : bool JSObject::HasFastElements() {
    7190     5330040 :   return IsFastElementsKind(GetElementsKind());
    7191             : }
    7192             : 
    7193             : 
    7194      956833 : bool JSObject::HasDictionaryElements() {
    7195      956833 :   return GetElementsKind() == DICTIONARY_ELEMENTS;
    7196             : }
    7197             : 
    7198             : 
    7199             : bool JSObject::HasFastArgumentsElements() {
    7200             :   return GetElementsKind() == FAST_SLOPPY_ARGUMENTS_ELEMENTS;
    7201             : }
    7202             : 
    7203             : 
    7204      627817 : bool JSObject::HasSlowArgumentsElements() {
    7205      627817 :   return GetElementsKind() == SLOW_SLOPPY_ARGUMENTS_ELEMENTS;
    7206             : }
    7207             : 
    7208             : 
    7209     1228700 : bool JSObject::HasSloppyArgumentsElements() {
    7210     1228700 :   return IsSloppyArgumentsElementsKind(GetElementsKind());
    7211             : }
    7212             : 
    7213      129458 : bool JSObject::HasStringWrapperElements() {
    7214      129458 :   return IsStringWrapperElementsKind(GetElementsKind());
    7215             : }
    7216             : 
    7217     2200824 : bool JSObject::HasFastStringWrapperElements() {
    7218     2200824 :   return GetElementsKind() == FAST_STRING_WRAPPER_ELEMENTS;
    7219             : }
    7220             : 
    7221      211591 : bool JSObject::HasSlowStringWrapperElements() {
    7222      211591 :   return GetElementsKind() == SLOW_STRING_WRAPPER_ELEMENTS;
    7223             : }
    7224             : 
    7225     1952354 : bool JSObject::HasFixedTypedArrayElements() {
    7226             :   DCHECK_NOT_NULL(elements());
    7227     1952354 :   return map()->has_fixed_typed_array_elements();
    7228             : }
    7229             : 
    7230             : #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size)      \
    7231             :   bool JSObject::HasFixed##Type##Elements() {                          \
    7232             :     HeapObject* array = elements();                                    \
    7233             :     DCHECK(array != NULL);                                             \
    7234             :     if (!array->IsHeapObject()) return false;                          \
    7235             :     return array->map()->instance_type() == FIXED_##TYPE##_ARRAY_TYPE; \
    7236             :   }
    7237             : 
    7238        1890 : TYPED_ARRAYS(FIXED_TYPED_ELEMENTS_CHECK)
    7239             : 
    7240             : #undef FIXED_TYPED_ELEMENTS_CHECK
    7241             : 
    7242             : 
    7243           0 : bool JSObject::HasNamedInterceptor() {
    7244           0 :   return map()->has_named_interceptor();
    7245             : }
    7246             : 
    7247             : 
    7248       24606 : bool JSObject::HasIndexedInterceptor() {
    7249       24606 :   return map()->has_indexed_interceptor();
    7250             : }
    7251             : 
    7252             : 
    7253             : GlobalDictionary* JSObject::global_dictionary() {
    7254             :   DCHECK(!HasFastProperties());
    7255             :   DCHECK(IsJSGlobalObject());
    7256             :   return GlobalDictionary::cast(properties());
    7257             : }
    7258             : 
    7259             : 
    7260        4562 : SeededNumberDictionary* JSObject::element_dictionary() {
    7261             :   DCHECK(HasDictionaryElements() || HasSlowStringWrapperElements());
    7262        4562 :   return SeededNumberDictionary::cast(elements());
    7263             : }
    7264             : 
    7265             : 
    7266             : bool Name::IsHashFieldComputed(uint32_t field) {
    7267   838076966 :   return (field & kHashNotComputedMask) == 0;
    7268             : }
    7269             : 
    7270             : 
    7271             : bool Name::HasHashCode() {
    7272             :   return IsHashFieldComputed(hash_field());
    7273             : }
    7274             : 
    7275             : 
    7276    19583063 : uint32_t Name::Hash() {
    7277             :   // Fast case: has hash code already been computed?
    7278             :   uint32_t field = hash_field();
    7279   620695854 :   if (IsHashFieldComputed(field)) return field >> kHashShift;
    7280             :   // Slow case: compute hash code and set it. Has to be a string.
    7281    29105217 :   return String::cast(this)->ComputeAndSetHash();
    7282             : }
    7283             : 
    7284             : 
    7285   357012006 : bool Name::IsPrivate() {
    7286   398534437 :   return this->IsSymbol() && Symbol::cast(this)->is_private();
    7287             : }
    7288             : 
    7289             : 
    7290             : StringHasher::StringHasher(int length, uint32_t seed)
    7291             :   : length_(length),
    7292             :     raw_running_hash_(seed),
    7293             :     array_index_(0),
    7294   188371591 :     is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize),
    7295   401220215 :     is_first_char_(true) {
    7296             :   DCHECK(FLAG_randomize_hashes || raw_running_hash_ == 0);
    7297             : }
    7298             : 
    7299             : 
    7300             : bool StringHasher::has_trivial_hash() {
    7301             :   return length_ > String::kMaxHashCalcLength;
    7302             : }
    7303             : 
    7304             : 
    7305             : uint32_t StringHasher::AddCharacterCore(uint32_t running_hash, uint16_t c) {
    7306  2644452588 :   running_hash += c;
    7307  2644452588 :   running_hash += (running_hash << 10);
    7308  2644452588 :   running_hash ^= (running_hash >> 6);
    7309             :   return running_hash;
    7310             : }
    7311             : 
    7312             : 
    7313             : uint32_t StringHasher::GetHashCore(uint32_t running_hash) {
    7314   217265958 :   running_hash += (running_hash << 3);
    7315   217265958 :   running_hash ^= (running_hash >> 11);
    7316   217265958 :   running_hash += (running_hash << 15);
    7317   217265958 :   if ((running_hash & String::kHashBitMask) == 0) {
    7318             :     return kZeroHash;
    7319             :   }
    7320             :   return running_hash;
    7321             : }
    7322             : 
    7323             : 
    7324             : uint32_t StringHasher::ComputeRunningHash(uint32_t running_hash,
    7325             :                                           const uc16* chars, int length) {
    7326             :   DCHECK_NOT_NULL(chars);
    7327             :   DCHECK(length >= 0);
    7328         175 :   for (int i = 0; i < length; ++i) {
    7329         175 :     running_hash = AddCharacterCore(running_hash, *chars++);
    7330             :   }
    7331             :   return running_hash;
    7332             : }
    7333             : 
    7334             : 
    7335             : uint32_t StringHasher::ComputeRunningHashOneByte(uint32_t running_hash,
    7336             :                                                  const char* chars,
    7337             :                                                  int length) {
    7338             :   DCHECK_NOT_NULL(chars);
    7339             :   DCHECK(length >= 0);
    7340       85696 :   for (int i = 0; i < length; ++i) {
    7341       85696 :     uint16_t c = static_cast<uint16_t>(*chars++);
    7342             :     running_hash = AddCharacterCore(running_hash, c);
    7343             :   }
    7344             :   return running_hash;
    7345             : }
    7346             : 
    7347             : 
    7348             : void StringHasher::AddCharacter(uint16_t c) {
    7349             :   // Use the Jenkins one-at-a-time hash function to update the hash
    7350             :   // for the given character.
    7351  5108726926 :   raw_running_hash_ = AddCharacterCore(raw_running_hash_, c);
    7352             : }
    7353             : 
    7354             : 
    7355   182300734 : bool StringHasher::UpdateIndex(uint16_t c) {
    7356             :   DCHECK(is_array_index_);
    7357   182300734 :   if (c < '0' || c > '9') {
    7358   145474339 :     is_array_index_ = false;
    7359   145474339 :     return false;
    7360             :   }
    7361    36826395 :   int d = c - '0';
    7362    36826395 :   if (is_first_char_) {
    7363    10679943 :     is_first_char_ = false;
    7364    10679943 :     if (c == '0' && length_ > 1) {
    7365       18089 :       is_array_index_ = false;
    7366       18089 :       return false;
    7367             :     }
    7368             :   }
    7369    36808306 :   if (array_index_ > 429496729U - ((d + 3) >> 3)) {
    7370        4579 :     is_array_index_ = false;
    7371        4579 :     return false;
    7372             :   }
    7373    36803727 :   array_index_ = array_index_ * 10 + d;
    7374    36803727 :   return true;
    7375             : }
    7376             : 
    7377             : 
    7378             : template<typename Char>
    7379   198948644 : inline void StringHasher::AddCharacters(const Char* chars, int length) {
    7380             :   DCHECK(sizeof(Char) == 1 || sizeof(Char) == 2);
    7381             :   int i = 0;
    7382   198948644 :   if (is_array_index_) {
    7383    36797230 :     for (; i < length; i++) {
    7384   157819622 :       AddCharacter(chars[i]);
    7385   157819622 :       if (!UpdateIndex(chars[i])) {
    7386   121022377 :         i++;
    7387   121022377 :         break;
    7388             :       }
    7389             :     }
    7390             :   }
    7391  1869074118 :   for (; i < length; i++) {
    7392             :     DCHECK(!is_array_index_);
    7393  1869074118 :     AddCharacter(chars[i]);
    7394             :   }
    7395   198948629 : }
    7396             : 
    7397             : 
    7398             : template <typename schar>
    7399   159265194 : uint32_t StringHasher::HashSequentialString(const schar* chars,
    7400             :                                             int length,
    7401             :                                             uint32_t seed) {
    7402             :   StringHasher hasher(length, seed);
    7403   159265194 :   if (!hasher.has_trivial_hash()) hasher.AddCharacters(chars, length);
    7404   159265313 :   return hasher.GetHashField();
    7405             : }
    7406             : 
    7407             : 
    7408             : IteratingStringHasher::IteratingStringHasher(int len, uint32_t seed)
    7409             :     : StringHasher(len, seed) {}
    7410             : 
    7411             : 
    7412    29106397 : uint32_t IteratingStringHasher::Hash(String* string, uint32_t seed) {
    7413             :   IteratingStringHasher hasher(string->length(), seed);
    7414             :   // Nothing to do.
    7415    29106397 :   if (hasher.has_trivial_hash()) return hasher.GetHashField();
    7416    29045595 :   ConsString* cons_string = String::VisitFlat(&hasher, string);
    7417    29045597 :   if (cons_string == nullptr) return hasher.GetHashField();
    7418     2502457 :   hasher.VisitConsString(cons_string);
    7419     2502457 :   return hasher.GetHashField();
    7420             : }
    7421             : 
    7422             : 
    7423             : void IteratingStringHasher::VisitOneByteString(const uint8_t* chars,
    7424             :                                                int length) {
    7425    35058480 :   AddCharacters(chars, length);
    7426             : }
    7427             : 
    7428             : 
    7429             : void IteratingStringHasher::VisitTwoByteString(const uint16_t* chars,
    7430             :                                                int length) {
    7431     4310103 :   AddCharacters(chars, length);
    7432             : }
    7433             : 
    7434             : 
    7435   175728705 : bool Name::AsArrayIndex(uint32_t* index) {
    7436   175728703 :   return IsString() && String::cast(this)->AsArrayIndex(index);
    7437             : }
    7438             : 
    7439             : 
    7440   184847868 : bool String::AsArrayIndex(uint32_t* index) {
    7441             :   uint32_t field = hash_field();
    7442   184847868 :   if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) {
    7443             :     return false;
    7444             :   }
    7445    23891680 :   return SlowAsArrayIndex(index);
    7446             : }
    7447             : 
    7448             : 
    7449             : void String::SetForwardedInternalizedString(String* canonical) {
    7450             :   DCHECK(IsInternalizedString());
    7451             :   DCHECK(HasHashCode());
    7452        2756 :   if (canonical == this) return;  // No need to forward.
    7453             :   DCHECK(SlowEquals(canonical));
    7454             :   DCHECK(canonical->IsInternalizedString());
    7455             :   DCHECK(canonical->HasHashCode());
    7456        2756 :   WRITE_FIELD(this, kHashFieldSlot, canonical);
    7457             :   // Setting the hash field to a tagged value sets the LSB, causing the hash
    7458             :   // code to be interpreted as uninitialized.  We use this fact to recognize
    7459             :   // that we have a forwarded string.
    7460             :   DCHECK(!HasHashCode());
    7461             : }
    7462             : 
    7463             : 
    7464             : String* String::GetForwardedInternalizedString() {
    7465             :   DCHECK(IsInternalizedString());
    7466        8177 :   if (HasHashCode()) return this;
    7467        2426 :   String* canonical = String::cast(READ_FIELD(this, kHashFieldSlot));
    7468             :   DCHECK(canonical->IsInternalizedString());
    7469             :   DCHECK(SlowEquals(canonical));
    7470             :   DCHECK(canonical->HasHashCode());
    7471             :   return canonical;
    7472             : }
    7473             : 
    7474             : 
    7475             : // static
    7476           0 : Maybe<bool> Object::GreaterThan(Handle<Object> x, Handle<Object> y) {
    7477           0 :   Maybe<ComparisonResult> result = Compare(x, y);
    7478           0 :   if (result.IsJust()) {
    7479           0 :     switch (result.FromJust()) {
    7480             :       case ComparisonResult::kGreaterThan:
    7481             :         return Just(true);
    7482             :       case ComparisonResult::kLessThan:
    7483             :       case ComparisonResult::kEqual:
    7484             :       case ComparisonResult::kUndefined:
    7485             :         return Just(false);
    7486             :     }
    7487             :   }
    7488             :   return Nothing<bool>();
    7489             : }
    7490             : 
    7491             : 
    7492             : // static
    7493           0 : Maybe<bool> Object::GreaterThanOrEqual(Handle<Object> x, Handle<Object> y) {
    7494           0 :   Maybe<ComparisonResult> result = Compare(x, y);
    7495           0 :   if (result.IsJust()) {
    7496           0 :     switch (result.FromJust()) {
    7497             :       case ComparisonResult::kEqual:
    7498             :       case ComparisonResult::kGreaterThan:
    7499             :         return Just(true);
    7500             :       case ComparisonResult::kLessThan:
    7501             :       case ComparisonResult::kUndefined:
    7502             :         return Just(false);
    7503             :     }
    7504             :   }
    7505             :   return Nothing<bool>();
    7506             : }
    7507             : 
    7508             : 
    7509             : // static
    7510           0 : Maybe<bool> Object::LessThan(Handle<Object> x, Handle<Object> y) {
    7511           0 :   Maybe<ComparisonResult> result = Compare(x, y);
    7512           0 :   if (result.IsJust()) {
    7513           0 :     switch (result.FromJust()) {
    7514             :       case ComparisonResult::kLessThan:
    7515             :         return Just(true);
    7516             :       case ComparisonResult::kEqual:
    7517             :       case ComparisonResult::kGreaterThan:
    7518             :       case ComparisonResult::kUndefined:
    7519             :         return Just(false);
    7520             :     }
    7521             :   }
    7522             :   return Nothing<bool>();
    7523             : }
    7524             : 
    7525             : 
    7526             : // static
    7527           0 : Maybe<bool> Object::LessThanOrEqual(Handle<Object> x, Handle<Object> y) {
    7528           0 :   Maybe<ComparisonResult> result = Compare(x, y);
    7529           0 :   if (result.IsJust()) {
    7530           0 :     switch (result.FromJust()) {
    7531             :       case ComparisonResult::kEqual:
    7532             :       case ComparisonResult::kLessThan:
    7533             :         return Just(true);
    7534             :       case ComparisonResult::kGreaterThan:
    7535             :       case ComparisonResult::kUndefined:
    7536             :         return Just(false);
    7537             :     }
    7538             :   }
    7539             :   return Nothing<bool>();
    7540             : }
    7541             : 
    7542      206902 : MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object,
    7543             :                                                  Handle<Name> name) {
    7544             :   LookupIterator it =
    7545      206902 :       LookupIterator::PropertyOrElement(name->GetIsolate(), object, name);
    7546      206902 :   return GetProperty(&it);
    7547             : }
    7548             : 
    7549             : MaybeHandle<Object> Object::SetPropertyOrElement(Handle<Object> object,
    7550             :                                                  Handle<Name> name,
    7551             :                                                  Handle<Object> value,
    7552             :                                                  LanguageMode language_mode,
    7553             :                                                  StoreFromKeyed store_mode) {
    7554             :   LookupIterator it =
    7555             :       LookupIterator::PropertyOrElement(name->GetIsolate(), object, name);
    7556             :   MAYBE_RETURN_NULL(SetProperty(&it, value, language_mode, store_mode));
    7557             :   return value;
    7558             : }
    7559             : 
    7560       15375 : MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> receiver,
    7561             :                                                  Handle<Name> name,
    7562             :                                                  Handle<JSReceiver> holder) {
    7563             :   LookupIterator it = LookupIterator::PropertyOrElement(
    7564       15375 :       name->GetIsolate(), receiver, name, holder);
    7565       15375 :   return GetProperty(&it);
    7566             : }
    7567             : 
    7568             : 
    7569    26550906 : void JSReceiver::initialize_properties() {
    7570             :   DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
    7571             :   DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_properties_dictionary()));
    7572    26550906 :   if (map()->is_dictionary_map()) {
    7573       44740 :     WRITE_FIELD(this, kPropertiesOffset,
    7574       44740 :                 GetHeap()->empty_properties_dictionary());
    7575             :   } else {
    7576    26506166 :     WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array());
    7577             :   }
    7578    26550906 : }
    7579             : 
    7580             : 
    7581   296149858 : bool JSReceiver::HasFastProperties() {
    7582             :   DCHECK_EQ(properties()->IsDictionary(), map()->is_dictionary_map());
    7583   296149806 :   return !properties()->IsDictionary();
    7584             : }
    7585             : 
    7586             : 
    7587     2880880 : NameDictionary* JSReceiver::property_dictionary() {
    7588             :   DCHECK(!HasFastProperties());
    7589             :   DCHECK(!IsJSGlobalObject());
    7590     2880880 :   return NameDictionary::cast(properties());
    7591             : }
    7592             : 
    7593      452282 : Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
    7594             :                                     Handle<Name> name) {
    7595             :   LookupIterator it = LookupIterator::PropertyOrElement(object->GetIsolate(),
    7596      452282 :                                                         object, name, object);
    7597      452282 :   return HasProperty(&it);
    7598             : }
    7599             : 
    7600             : 
    7601    10406712 : Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
    7602             :                                        Handle<Name> name) {
    7603    10406712 :   if (object->IsJSObject()) {  // Shortcut
    7604             :     LookupIterator it = LookupIterator::PropertyOrElement(
    7605    10404821 :         object->GetIsolate(), object, name, object, LookupIterator::OWN);
    7606    10404821 :     return HasProperty(&it);
    7607             :   }
    7608             : 
    7609             :   Maybe<PropertyAttributes> attributes =
    7610        1891 :       JSReceiver::GetOwnPropertyAttributes(object, name);
    7611        1891 :   MAYBE_RETURN(attributes, Nothing<bool>());
    7612        1751 :   return Just(attributes.FromJust() != ABSENT);
    7613             : }
    7614             : 
    7615          30 : Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
    7616             :                                        uint32_t index) {
    7617          30 :   if (object->IsJSObject()) {  // Shortcut
    7618             :     LookupIterator it(object->GetIsolate(), object, index, object,
    7619             :                       LookupIterator::OWN);
    7620          30 :     return HasProperty(&it);
    7621             :   }
    7622             : 
    7623             :   Maybe<PropertyAttributes> attributes =
    7624           0 :       JSReceiver::GetOwnPropertyAttributes(object, index);
    7625           0 :   MAYBE_RETURN(attributes, Nothing<bool>());
    7626           0 :   return Just(attributes.FromJust() != ABSENT);
    7627             : }
    7628             : 
    7629     1838990 : Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
    7630             :     Handle<JSReceiver> object, Handle<Name> name) {
    7631             :   LookupIterator it = LookupIterator::PropertyOrElement(name->GetIsolate(),
    7632     1838990 :                                                         object, name, object);
    7633     1838990 :   return GetPropertyAttributes(&it);
    7634             : }
    7635             : 
    7636             : 
    7637     1228577 : Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
    7638             :     Handle<JSReceiver> object, Handle<Name> name) {
    7639             :   LookupIterator it = LookupIterator::PropertyOrElement(
    7640     1228577 :       name->GetIsolate(), object, name, object, LookupIterator::OWN);
    7641     1228577 :   return GetPropertyAttributes(&it);
    7642             : }
    7643             : 
    7644           0 : Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
    7645             :     Handle<JSReceiver> object, uint32_t index) {
    7646             :   LookupIterator it(object->GetIsolate(), object, index, object,
    7647             :                     LookupIterator::OWN);
    7648           0 :   return GetPropertyAttributes(&it);
    7649             : }
    7650             : 
    7651     1812033 : Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
    7652             :   LookupIterator it(object->GetIsolate(), object, index, object);
    7653     1812033 :   return HasProperty(&it);
    7654             : }
    7655             : 
    7656             : 
    7657             : Maybe<PropertyAttributes> JSReceiver::GetElementAttributes(
    7658             :     Handle<JSReceiver> object, uint32_t index) {
    7659             :   Isolate* isolate = object->GetIsolate();
    7660             :   LookupIterator it(isolate, object, index, object);
    7661             :   return GetPropertyAttributes(&it);
    7662             : }
    7663             : 
    7664             : 
    7665             : Maybe<PropertyAttributes> JSReceiver::GetOwnElementAttributes(
    7666             :     Handle<JSReceiver> object, uint32_t index) {
    7667             :   Isolate* isolate = object->GetIsolate();
    7668             :   LookupIterator it(isolate, object, index, object, LookupIterator::OWN);
    7669             :   return GetPropertyAttributes(&it);
    7670             : }
    7671             : 
    7672             : 
    7673             : bool JSGlobalObject::IsDetached() {
    7674             :   return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this);
    7675             : }
    7676             : 
    7677             : 
    7678      977074 : bool JSGlobalProxy::IsDetachedFrom(JSGlobalObject* global) const {
    7679             :   const PrototypeIterator iter(this->GetIsolate(),
    7680             :                                const_cast<JSGlobalProxy*>(this));
    7681      977074 :   return iter.GetCurrent() != global;
    7682             : }
    7683             : 
    7684             : inline int JSGlobalProxy::SizeWithEmbedderFields(int embedder_field_count) {
    7685             :   DCHECK_GE(embedder_field_count, 0);
    7686      106771 :   return kSize + embedder_field_count * kPointerSize;
    7687             : }
    7688             : 
    7689        5646 : Smi* JSReceiver::GetOrCreateIdentityHash(Isolate* isolate,
    7690             :                                          Handle<JSReceiver> object) {
    7691             :   return object->IsJSProxy() ? JSProxy::GetOrCreateIdentityHash(
    7692             :                                    isolate, Handle<JSProxy>::cast(object))
    7693             :                              : JSObject::GetOrCreateIdentityHash(
    7694        8074 :                                    isolate, Handle<JSObject>::cast(object));
    7695             : }
    7696             : 
    7697       16991 : Object* JSReceiver::GetIdentityHash(Isolate* isolate,
    7698             :                                     Handle<JSReceiver> receiver) {
    7699             :   return receiver->IsJSProxy()
    7700             :              ? JSProxy::GetIdentityHash(Handle<JSProxy>::cast(receiver))
    7701             :              : JSObject::GetIdentityHash(isolate,
    7702       33716 :                                          Handle<JSObject>::cast(receiver));
    7703             : }
    7704             : 
    7705             : 
    7706             : bool AccessorInfo::all_can_read() {
    7707             :   return BooleanBit::get(flag(), kAllCanReadBit);
    7708             : }
    7709             : 
    7710             : 
    7711             : void AccessorInfo::set_all_can_read(bool value) {
    7712             :   set_flag(BooleanBit::set(flag(), kAllCanReadBit, value));
    7713             : }
    7714             : 
    7715             : 
    7716             : bool AccessorInfo::all_can_write() {
    7717             :   return BooleanBit::get(flag(), kAllCanWriteBit);
    7718             : }
    7719             : 
    7720             : 
    7721             : void AccessorInfo::set_all_can_write(bool value) {
    7722             :   set_flag(BooleanBit::set(flag(), kAllCanWriteBit, value));
    7723             : }
    7724             : 
    7725             : 
    7726             : bool AccessorInfo::is_special_data_property() {
    7727             :   return BooleanBit::get(flag(), kSpecialDataProperty);
    7728             : }
    7729             : 
    7730             : 
    7731             : void AccessorInfo::set_is_special_data_property(bool value) {
    7732             :   set_flag(BooleanBit::set(flag(), kSpecialDataProperty, value));
    7733             : }
    7734             : 
    7735             : bool AccessorInfo::replace_on_access() {
    7736             :   return BooleanBit::get(flag(), kReplaceOnAccess);
    7737             : }
    7738             : 
    7739             : void AccessorInfo::set_replace_on_access(bool value) {
    7740             :   set_flag(BooleanBit::set(flag(), kReplaceOnAccess, value));
    7741             : }
    7742             : 
    7743             : bool AccessorInfo::is_sloppy() { return BooleanBit::get(flag(), kIsSloppy); }
    7744             : 
    7745             : void AccessorInfo::set_is_sloppy(bool value) {
    7746             :   set_flag(BooleanBit::set(flag(), kIsSloppy, value));
    7747             : }
    7748             : 
    7749             : PropertyAttributes AccessorInfo::property_attributes() {
    7750      118115 :   return AttributesField::decode(static_cast<uint32_t>(flag()));
    7751             : }
    7752             : 
    7753             : 
    7754             : void AccessorInfo::set_property_attributes(PropertyAttributes attributes) {
    7755      248218 :   set_flag(AttributesField::update(flag(), attributes));
    7756             : }
    7757             : 
    7758       17493 : bool FunctionTemplateInfo::IsTemplateFor(JSObject* object) {
    7759       17493 :   return IsTemplateFor(object->map());
    7760             : }
    7761             : 
    7762     2666629 : bool AccessorInfo::IsCompatibleReceiver(Object* receiver) {
    7763     2666629 :   if (!HasExpectedReceiverType()) return true;
    7764         406 :   if (!receiver->IsJSObject()) return false;
    7765             :   return FunctionTemplateInfo::cast(expected_receiver_type())
    7766         406 :       ->IsTemplateFor(JSObject::cast(receiver)->map());
    7767             : }
    7768             : 
    7769             : 
    7770     2706389 : bool AccessorInfo::HasExpectedReceiverType() {
    7771     2706388 :   return expected_receiver_type()->IsFunctionTemplateInfo();
    7772             : }
    7773             : 
    7774             : 
    7775             : Object* AccessorPair::get(AccessorComponent component) {
    7776       71561 :   return component == ACCESSOR_GETTER ? getter() : setter();
    7777             : }
    7778             : 
    7779             : 
    7780             : void AccessorPair::set(AccessorComponent component, Object* value) {
    7781             :   if (component == ACCESSOR_GETTER) {
    7782             :     set_getter(value);
    7783             :   } else {
    7784             :     set_setter(value);
    7785             :   }
    7786             : }
    7787             : 
    7788             : 
    7789      506991 : void AccessorPair::SetComponents(Object* getter, Object* setter) {
    7790             :   Isolate* isolate = GetIsolate();
    7791      506991 :   if (!getter->IsNull(isolate)) set_getter(getter);
    7792      506991 :   if (!setter->IsNull(isolate)) set_setter(setter);
    7793      506991 : }
    7794             : 
    7795             : 
    7796             : bool AccessorPair::Equals(AccessorPair* pair) {
    7797             :   return (this == pair) || pair->Equals(getter(), setter());
    7798             : }
    7799             : 
    7800             : 
    7801             : bool AccessorPair::Equals(Object* getter_value, Object* setter_value) {
    7802       51468 :   return (getter() == getter_value) && (setter() == setter_value);
    7803             : }
    7804             : 
    7805             : 
    7806             : bool AccessorPair::ContainsAccessor() {
    7807             :   return IsJSAccessor(getter()) || IsJSAccessor(setter());
    7808             : }
    7809             : 
    7810             : 
    7811             : bool AccessorPair::IsJSAccessor(Object* obj) {
    7812             :   return obj->IsCallable() || obj->IsUndefined(GetIsolate());
    7813             : }
    7814             : 
    7815             : 
    7816             : template<typename Derived, typename Shape, typename Key>
    7817     6169770 : void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
    7818             :                                                Handle<Object> key,
    7819             :                                                Handle<Object> value) {
    7820             :   this->SetEntry(entry, key, value, PropertyDetails(Smi::kZero));
    7821     6169770 : }
    7822             : 
    7823             : 
    7824             : template<typename Derived, typename Shape, typename Key>
    7825           0 : void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
    7826             :                                                Handle<Object> key,
    7827             :                                                Handle<Object> value,
    7828             :                                                PropertyDetails details) {
    7829    45008138 :   Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details);
    7830           0 : }
    7831             : 
    7832             : 
    7833             : template <typename Key>
    7834             : template <typename Dictionary>
    7835    36182194 : void BaseDictionaryShape<Key>::SetEntry(Dictionary* dict, int entry,
    7836             :                                         Handle<Object> key,
    7837             :                                         Handle<Object> value,
    7838             :                                         PropertyDetails details) {
    7839             :   STATIC_ASSERT(Dictionary::kEntrySize == 2 || Dictionary::kEntrySize == 3);
    7840             :   DCHECK(!key->IsName() || details.dictionary_index() > 0);
    7841             :   int index = dict->EntryToIndex(entry);
    7842             :   DisallowHeapAllocation no_gc;
    7843    36182194 :   WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc);
    7844    36182194 :   dict->set(index + Dictionary::kEntryKeyIndex, *key, mode);
    7845    36182194 :   dict->set(index + Dictionary::kEntryValueIndex, *value, mode);
    7846             :   if (Dictionary::kEntrySize == 3) {
    7847             :     dict->set(index + Dictionary::kEntryDetailsIndex, details.AsSmi());
    7848             :   }
    7849    36182194 : }
    7850             : 
    7851             : 
    7852             : template <typename Dictionary>
    7853     8825944 : void GlobalDictionaryShape::SetEntry(Dictionary* dict, int entry,
    7854             :                                      Handle<Object> key, Handle<Object> value,
    7855             :                                      PropertyDetails details) {
    7856             :   STATIC_ASSERT(Dictionary::kEntrySize == 2);
    7857             :   DCHECK(!key->IsName() || details.dictionary_index() > 0);
    7858             :   DCHECK(value->IsPropertyCell());
    7859             :   int index = dict->EntryToIndex(entry);
    7860             :   DisallowHeapAllocation no_gc;
    7861     8825944 :   WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc);
    7862     8825943 :   dict->set(index + Dictionary::kEntryKeyIndex, *key, mode);
    7863     8825945 :   dict->set(index + Dictionary::kEntryValueIndex, *value, mode);
    7864             :   PropertyCell::cast(*value)->set_property_details(details);
    7865     8825942 : }
    7866             : 
    7867             : 
    7868             : bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
    7869             :   DCHECK(other->IsNumber());
    7870   107665843 :   return key == static_cast<uint32_t>(other->Number());
    7871             : }
    7872             : 
    7873             : 
    7874             : uint32_t UnseededNumberDictionaryShape::Hash(uint32_t key) {
    7875             :   return ComputeIntegerHash(key, 0);
    7876             : }
    7877             : 
    7878             : 
    7879      181703 : uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key,
    7880             :                                                       Object* other) {
    7881             :   DCHECK(other->IsNumber());
    7882      363406 :   return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0);
    7883             : }
    7884             : 
    7885             : Map* UnseededNumberDictionaryShape::GetMap(Isolate* isolate) {
    7886      381546 :   return isolate->heap()->unseeded_number_dictionary_map();
    7887             : }
    7888             : 
    7889             : uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) {
    7890             :   return ComputeIntegerHash(key, seed);
    7891             : }
    7892             : 
    7893             : 
    7894     3607223 : uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key,
    7895             :                                                           uint32_t seed,
    7896             :                                                           Object* other) {
    7897             :   DCHECK(other->IsNumber());
    7898     7214446 :   return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed);
    7899             : }
    7900             : 
    7901             : 
    7902             : Handle<Object> NumberDictionaryShape::AsHandle(Isolate* isolate, uint32_t key) {
    7903     7692641 :   return isolate->factory()->NewNumberFromUint(key);
    7904             : }
    7905             : 
    7906             : 
    7907             : bool NameDictionaryShape::IsMatch(Handle<Name> key, Object* other) {
    7908             :   DCHECK(Name::cast(other)->IsUniqueName());
    7909             :   DCHECK(key->IsUniqueName());
    7910             :   return *key == other;
    7911             : }
    7912             : 
    7913             : 
    7914    30893401 : uint32_t NameDictionaryShape::Hash(Handle<Name> key) {
    7915    30893401 :   return key->Hash();
    7916             : }
    7917             : 
    7918             : 
    7919             : uint32_t NameDictionaryShape::HashForObject(Handle<Name> key, Object* other) {
    7920             :   return Name::cast(other)->Hash();
    7921             : }
    7922             : 
    7923             : 
    7924             : Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate,
    7925             :                                              Handle<Name> key) {
    7926             :   DCHECK(key->IsUniqueName());
    7927             :   return key;
    7928             : }
    7929             : 
    7930             : 
    7931             : template <typename Dictionary>
    7932             : PropertyDetails GlobalDictionaryShape::DetailsAt(Dictionary* dict, int entry) {
    7933             :   DCHECK(entry >= 0);  // Not found is -1, which is not caught by get().
    7934   167617605 :   Object* raw_value = dict->ValueAt(entry);
    7935             :   DCHECK(raw_value->IsPropertyCell());
    7936             :   PropertyCell* cell = PropertyCell::cast(raw_value);
    7937             :   return cell->property_details();
    7938             : }
    7939             : 
    7940             : 
    7941             : template <typename Dictionary>
    7942           0 : void GlobalDictionaryShape::DetailsAtPut(Dictionary* dict, int entry,
    7943             :                                          PropertyDetails value) {
    7944             :   DCHECK(entry >= 0);  // Not found is -1, which is not caught by get().
    7945           0 :   Object* raw_value = dict->ValueAt(entry);
    7946             :   DCHECK(raw_value->IsPropertyCell());
    7947             :   PropertyCell* cell = PropertyCell::cast(raw_value);
    7948             :   cell->set_property_details(value);
    7949           0 : }
    7950             : 
    7951             : 
    7952             : template <typename Dictionary>
    7953    13619194 : bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) {
    7954             :   DCHECK(dict->ValueAt(entry)->IsPropertyCell());
    7955             :   Isolate* isolate = dict->GetIsolate();
    7956    27238388 :   return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole(isolate);
    7957             : }
    7958             : 
    7959             : 
    7960             : bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) {
    7961     1455038 :   return key->SameValue(other);
    7962             : }
    7963             : 
    7964             : 
    7965             : uint32_t ObjectHashTableShape::Hash(Handle<Object> key) {
    7966           0 :   return Smi::cast(key->GetHash())->value();
    7967             : }
    7968             : 
    7969             : 
    7970             : uint32_t ObjectHashTableShape::HashForObject(Handle<Object> key,
    7971             :                                              Object* other) {
    7972      629056 :   return Smi::cast(other->GetHash())->value();
    7973             : }
    7974             : 
    7975             : 
    7976             : Handle<Object> ObjectHashTableShape::AsHandle(Isolate* isolate,
    7977             :                                               Handle<Object> key) {
    7978             :   return key;
    7979             : }
    7980             : 
    7981             : 
    7982             : Handle<ObjectHashTable> ObjectHashTable::Shrink(
    7983             :     Handle<ObjectHashTable> table, Handle<Object> key) {
    7984         125 :   return DerivedHashTable::Shrink(table, key);
    7985             : }
    7986             : 
    7987             : 
    7988        9807 : Object* OrderedHashMap::ValueAt(int entry) {
    7989       19614 :   return get(EntryToIndex(entry) + kValueOffset);
    7990             : }
    7991             : 
    7992             : 
    7993             : template <int entrysize>
    7994     5456166 : bool WeakHashTableShape<entrysize>::IsMatch(Handle<Object> key, Object* other) {
    7995     5456166 :   if (other->IsWeakCell()) other = WeakCell::cast(other)->value();
    7996             :   return key->IsWeakCell() ? WeakCell::cast(*key)->value() == other
    7997    10912332 :                            : *key == other;
    7998             : }
    7999             : 
    8000             : 
    8001             : template <int entrysize>
    8002     2250191 : uint32_t WeakHashTableShape<entrysize>::Hash(Handle<Object> key) {
    8003             :   intptr_t hash =
    8004             :       key->IsWeakCell()
    8005             :           ? reinterpret_cast<intptr_t>(WeakCell::cast(*key)->value())
    8006     4500384 :           : reinterpret_cast<intptr_t>(*key);
    8007     2250192 :   return (uint32_t)(hash & 0xFFFFFFFF);
    8008             : }
    8009             : 
    8010             : 
    8011             : template <int entrysize>
    8012     1269141 : uint32_t WeakHashTableShape<entrysize>::HashForObject(Handle<Object> key,
    8013             :                                                       Object* other) {
    8014     1269141 :   if (other->IsWeakCell()) other = WeakCell::cast(other)->value();
    8015     1269141 :   intptr_t hash = reinterpret_cast<intptr_t>(other);
    8016     1269141 :   return (uint32_t)(hash & 0xFFFFFFFF);
    8017             : }
    8018             : 
    8019             : 
    8020             : template <int entrysize>
    8021             : Handle<Object> WeakHashTableShape<entrysize>::AsHandle(Isolate* isolate,
    8022             :                                                        Handle<Object> key) {
    8023             :   return key;
    8024             : }
    8025             : 
    8026             : 
    8027        6746 : ACCESSORS(ModuleInfoEntry, export_name, Object, kExportNameOffset)
    8028        5584 : ACCESSORS(ModuleInfoEntry, local_name, Object, kLocalNameOffset)
    8029        6661 : ACCESSORS(ModuleInfoEntry, import_name, Object, kImportNameOffset)
    8030        5102 : SMI_ACCESSORS(ModuleInfoEntry, module_request, kModuleRequestOffset)
    8031        4655 : SMI_ACCESSORS(ModuleInfoEntry, cell_index, kCellIndexOffset)
    8032        2313 : SMI_ACCESSORS(ModuleInfoEntry, beg_pos, kBegPosOffset)
    8033        2313 : SMI_ACCESSORS(ModuleInfoEntry, end_pos, kEndPosOffset)
    8034             : 
    8035    69469122 : void Map::ClearCodeCache(Heap* heap) {
    8036             :   // No write barrier is needed since empty_fixed_array is not in new space.
    8037             :   // Please note this function is used during marking:
    8038             :   //  - MarkCompactCollector::MarkUnmarkedObject
    8039             :   //  - IncrementalMarking::Step
    8040    69469122 :   WRITE_FIELD(this, kCodeCacheOffset, heap->empty_fixed_array());
    8041    44538903 : }
    8042             : 
    8043             : 
    8044     6126512 : int Map::SlackForArraySize(int old_size, int size_limit) {
    8045     6126512 :   const int max_slack = size_limit - old_size;
    8046     6126512 :   CHECK_LE(0, max_slack);
    8047     6126512 :   if (old_size < 4) {
    8048             :     DCHECK_LE(1, max_slack);
    8049             :     return 1;
    8050             :   }
    8051     6408146 :   return Min(max_slack, old_size / 4);
    8052             : }
    8053             : 
    8054             : 
    8055        2438 : void JSArray::set_length(Smi* length) {
    8056             :   // Don't need a write barrier for a Smi.
    8057    28321410 :   set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER);
    8058        2438 : }
    8059             : 
    8060             : 
    8061     1718160 : bool JSArray::SetLengthWouldNormalize(Heap* heap, uint32_t new_length) {
    8062             :   // This constant is somewhat arbitrary. Any large enough value would work.
    8063             :   const uint32_t kMaxFastArrayLength = 32 * 1024 * 1024;
    8064             :   // If the new array won't fit in a some non-trivial fraction of the max old
    8065             :   // space size, then force it to go dictionary mode.
    8066             :   uint32_t heap_based_upper_bound =
    8067     1718160 :       static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4);
    8068             :   return new_length >= Min(kMaxFastArrayLength, heap_based_upper_bound);
    8069             : }
    8070             : 
    8071             : 
    8072             : bool JSArray::AllowsSetLength() {
    8073             :   bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray();
    8074             :   DCHECK(result == !HasFixedTypedArrayElements());
    8075             :   return result;
    8076             : }
    8077             : 
    8078             : 
    8079      141370 : void JSArray::SetContent(Handle<JSArray> array,
    8080             :                          Handle<FixedArrayBase> storage) {
    8081             :   EnsureCanContainElements(array, storage, storage->length(),
    8082      282740 :                            ALLOW_COPIED_DOUBLE_ELEMENTS);
    8083             : 
    8084             :   DCHECK((storage->map() == array->GetHeap()->fixed_double_array_map() &&
    8085             :           IsFastDoubleElementsKind(array->GetElementsKind())) ||
    8086             :          ((storage->map() != array->GetHeap()->fixed_double_array_map()) &&
    8087             :           (IsFastObjectElementsKind(array->GetElementsKind()) ||
    8088             :            (IsFastSmiElementsKind(array->GetElementsKind()) &&
    8089             :             Handle<FixedArray>::cast(storage)->ContainsOnlySmisOrHoles()))));
    8090      141370 :   array->set_elements(*storage);
    8091             :   array->set_length(Smi::FromInt(storage->length()));
    8092      141370 : }
    8093             : 
    8094             : 
    8095      876353 : bool JSArray::HasArrayPrototype(Isolate* isolate) {
    8096     1752706 :   return map()->prototype() == *isolate->initial_array_prototype();
    8097             : }
    8098             : 
    8099             : 
    8100             : int TypeFeedbackInfo::ic_total_count() {
    8101      161709 :   int current = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
    8102             :   return ICTotalCountField::decode(current);
    8103             : }
    8104             : 
    8105             : 
    8106             : void TypeFeedbackInfo::set_ic_total_count(int count) {
    8107     1079855 :   int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
    8108             :   value = ICTotalCountField::update(value,
    8109     2159710 :                                     ICTotalCountField::decode(count));
    8110     1079855 :   WRITE_FIELD(this, kStorage1Offset, Smi::FromInt(value));
    8111             : }
    8112             : 
    8113             : 
    8114             : int TypeFeedbackInfo::ic_with_type_info_count() {
    8115      161709 :   int current = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
    8116             :   return ICsWithTypeInfoCountField::decode(current);
    8117             : }
    8118             : 
    8119             : 
    8120             : void TypeFeedbackInfo::change_ic_with_type_info_count(int delta) {
    8121      762962 :   if (delta == 0) return;
    8122      724750 :   int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
    8123      724750 :   int new_count = ICsWithTypeInfoCountField::decode(value) + delta;
    8124             :   // We can get negative count here when the type-feedback info is
    8125             :   // shared between two code objects. The can only happen when
    8126             :   // the debugger made a shallow copy of code object (see Heap::CopyCode).
    8127             :   // Since we do not optimize when the debugger is active, we can skip
    8128             :   // this counter update.
    8129      724750 :   if (new_count >= 0) {
    8130      724750 :     new_count &= ICsWithTypeInfoCountField::kMask;
    8131     1449500 :     value = ICsWithTypeInfoCountField::update(value, new_count);
    8132      724750 :     WRITE_FIELD(this, kStorage2Offset, Smi::FromInt(value));
    8133             :   }
    8134             : }
    8135             : 
    8136             : 
    8137             : int TypeFeedbackInfo::ic_generic_count() {
    8138      186257 :   return Smi::cast(READ_FIELD(this, kStorage3Offset))->value();
    8139             : }
    8140             : 
    8141             : 
    8142             : void TypeFeedbackInfo::change_ic_generic_count(int delta) {
    8143      762962 :   if (delta == 0) return;
    8144       24548 :   int new_count = ic_generic_count() + delta;
    8145       24548 :   if (new_count >= 0) {
    8146       24548 :     new_count &= ~Smi::kMinValue;
    8147       24548 :     WRITE_FIELD(this, kStorage3Offset, Smi::FromInt(new_count));
    8148             :   }
    8149             : }
    8150             : 
    8151             : 
    8152             : void TypeFeedbackInfo::initialize_storage() {
    8153     1079855 :   WRITE_FIELD(this, kStorage1Offset, Smi::kZero);
    8154     1079855 :   WRITE_FIELD(this, kStorage2Offset, Smi::kZero);
    8155     1079855 :   WRITE_FIELD(this, kStorage3Offset, Smi::kZero);
    8156             : }
    8157             : 
    8158             : 
    8159             : void TypeFeedbackInfo::change_own_type_change_checksum() {
    8160     3971526 :   int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
    8161     3971526 :   int checksum = OwnTypeChangeChecksum::decode(value);
    8162     3971526 :   checksum = (checksum + 1) % (1 << kTypeChangeChecksumBits);
    8163     3971526 :   value = OwnTypeChangeChecksum::update(value, checksum);
    8164             :   // Ensure packed bit field is in Smi range.
    8165             :   if (value > Smi::kMaxValue) value |= Smi::kMinValue;
    8166             :   if (value < Smi::kMinValue) value &= ~Smi::kMinValue;
    8167     3971526 :   WRITE_FIELD(this, kStorage1Offset, Smi::FromInt(value));
    8168             : }
    8169             : 
    8170             : 
    8171             : void TypeFeedbackInfo::set_inlined_type_change_checksum(int checksum) {
    8172             :   int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
    8173             :   int mask = (1 << kTypeChangeChecksumBits) - 1;
    8174      259782 :   value = InlinedTypeChangeChecksum::update(value, checksum & mask);
    8175             :   // Ensure packed bit field is in Smi range.
    8176             :   if (value > Smi::kMaxValue) value |= Smi::kMinValue;
    8177             :   if (value < Smi::kMinValue) value &= ~Smi::kMinValue;
    8178      259782 :   WRITE_FIELD(this, kStorage2Offset, Smi::FromInt(value));
    8179             : }
    8180             : 
    8181             : 
    8182             : int TypeFeedbackInfo::own_type_change_checksum() {
    8183      367182 :   int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
    8184      367182 :   return OwnTypeChangeChecksum::decode(value);
    8185             : }
    8186             : 
    8187             : 
    8188             : bool TypeFeedbackInfo::matches_inlined_type_change_checksum(int checksum) {
    8189      259782 :   int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
    8190             :   int mask = (1 << kTypeChangeChecksumBits) - 1;
    8191      519564 :   return InlinedTypeChangeChecksum::decode(value) == (checksum & mask);
    8192             : }
    8193             : 
    8194             : 
    8195         235 : SMI_ACCESSORS(AliasedArgumentsEntry, aliased_context_slot, kAliasedContextSlot)
    8196             : 
    8197             : 
    8198   179204060 : Relocatable::Relocatable(Isolate* isolate) {
    8199    89602030 :   isolate_ = isolate;
    8200    89602030 :   prev_ = isolate->relocatable_top();
    8201             :   isolate->set_relocatable_top(this);
    8202             : }
    8203             : 
    8204             : 
    8205    89598447 : Relocatable::~Relocatable() {
    8206             :   DCHECK_EQ(isolate_->relocatable_top(), this);
    8207    89598447 :   isolate_->set_relocatable_top(prev_);
    8208           0 : }
    8209             : 
    8210             : 
    8211             : template<class Derived, class TableType>
    8212           0 : Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() {
    8213             :   TableType* table(TableType::cast(this->table()));
    8214             :   int index = Smi::cast(this->index())->value();
    8215       10193 :   Object* key = table->KeyAt(index);
    8216             :   DCHECK(!key->IsTheHole(table->GetIsolate()));
    8217           0 :   return key;
    8218             : }
    8219             : 
    8220             : 
    8221        6608 : void JSSetIterator::PopulateValueArray(FixedArray* array) {
    8222        6608 :   array->set(0, CurrentKey());
    8223        6608 : }
    8224             : 
    8225             : 
    8226        3585 : void JSMapIterator::PopulateValueArray(FixedArray* array) {
    8227        3585 :   array->set(0, CurrentKey());
    8228        3585 :   array->set(1, CurrentValue());
    8229        3585 : }
    8230             : 
    8231             : 
    8232             : Object* JSMapIterator::CurrentValue() {
    8233             :   OrderedHashMap* table(OrderedHashMap::cast(this->table()));
    8234             :   int index = Smi::cast(this->index())->value();
    8235        3585 :   Object* value = table->ValueAt(index);
    8236             :   DCHECK(!value->IsTheHole(table->GetIsolate()));
    8237             :   return value;
    8238             : }
    8239             : 
    8240             : 
    8241             : String::SubStringRange::SubStringRange(String* string, int first, int length)
    8242             :     : string_(string),
    8243             :       first_(first),
    8244           0 :       length_(length == -1 ? string->length() : length) {}
    8245             : 
    8246             : 
    8247             : class String::SubStringRange::iterator final {
    8248             :  public:
    8249             :   typedef std::forward_iterator_tag iterator_category;
    8250             :   typedef int difference_type;
    8251             :   typedef uc16 value_type;
    8252             :   typedef uc16* pointer;
    8253             :   typedef uc16& reference;
    8254             : 
    8255             :   iterator(const iterator& other)
    8256             :       : content_(other.content_), offset_(other.offset_) {}
    8257             : 
    8258           0 :   uc16 operator*() { return content_.Get(offset_); }
    8259             :   bool operator==(const iterator& other) const {
    8260             :     return content_.UsesSameString(other.content_) && offset_ == other.offset_;
    8261             :   }
    8262             :   bool operator!=(const iterator& other) const {
    8263           0 :     return !content_.UsesSameString(other.content_) || offset_ != other.offset_;
    8264             :   }
    8265             :   iterator& operator++() {
    8266           0 :     ++offset_;
    8267             :     return *this;
    8268             :   }
    8269             :   iterator operator++(int);
    8270             : 
    8271             :  private:
    8272             :   friend class String;
    8273             :   iterator(String* from, int offset)
    8274           0 :       : content_(from->GetFlatContent()), offset_(offset) {}
    8275             :   String::FlatContent content_;
    8276             :   int offset_;
    8277             : };
    8278             : 
    8279             : 
    8280             : String::SubStringRange::iterator String::SubStringRange::begin() {
    8281             :   return String::SubStringRange::iterator(string_, first_);
    8282             : }
    8283             : 
    8284             : 
    8285             : String::SubStringRange::iterator String::SubStringRange::end() {
    8286           0 :   return String::SubStringRange::iterator(string_, first_ + length_);
    8287             : }
    8288             : 
    8289             : 
    8290             : // Predictably converts HeapObject* or Address to uint32 by calculating
    8291             : // offset of the address in respective MemoryChunk.
    8292             : static inline uint32_t ObjectAddressForHashing(void* object) {
    8293   120717740 :   uint32_t value = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(object));
    8294   120717740 :   return value & MemoryChunk::kAlignmentMask;
    8295             : }
    8296             : 
    8297         392 : static inline Handle<Object> MakeEntryPair(Isolate* isolate, uint32_t index,
    8298             :                                            Handle<Object> value) {
    8299         392 :   Handle<Object> key = isolate->factory()->Uint32ToString(index);
    8300             :   Handle<FixedArray> entry_storage =
    8301         392 :       isolate->factory()->NewUninitializedFixedArray(2);
    8302             :   {
    8303         392 :     entry_storage->set(0, *key, SKIP_WRITE_BARRIER);
    8304         392 :     entry_storage->set(1, *value, SKIP_WRITE_BARRIER);
    8305             :   }
    8306             :   return isolate->factory()->NewJSArrayWithElements(entry_storage,
    8307         392 :                                                     FAST_ELEMENTS, 2);
    8308             : }
    8309             : 
    8310         560 : static inline Handle<Object> MakeEntryPair(Isolate* isolate, Handle<Name> key,
    8311             :                                            Handle<Object> value) {
    8312             :   Handle<FixedArray> entry_storage =
    8313         560 :       isolate->factory()->NewUninitializedFixedArray(2);
    8314             :   {
    8315         560 :     entry_storage->set(0, *key, SKIP_WRITE_BARRIER);
    8316         560 :     entry_storage->set(1, *value, SKIP_WRITE_BARRIER);
    8317             :   }
    8318             :   return isolate->factory()->NewJSArrayWithElements(entry_storage,
    8319         560 :                                                     FAST_ELEMENTS, 2);
    8320             : }
    8321             : 
    8322        1847 : ACCESSORS(JSIteratorResult, value, Object, kValueOffset)
    8323           0 : ACCESSORS(JSIteratorResult, done, Object, kDoneOffset)
    8324             : 
    8325          45 : ACCESSORS(JSArrayIterator, object, Object, kIteratedObjectOffset)
    8326          90 : ACCESSORS(JSArrayIterator, index, Object, kNextIndexOffset)
    8327          45 : ACCESSORS(JSArrayIterator, object_map, Object, kIteratedObjectMapOffset)
    8328             : 
    8329         996 : ACCESSORS(JSAsyncFromSyncIterator, sync_iterator, JSReceiver,
    8330             :           kSyncIteratorOffset)
    8331             : 
    8332          24 : ACCESSORS(JSStringIterator, string, String, kStringOffset)
    8333          16 : SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
    8334             : 
    8335             : #undef INT_ACCESSORS
    8336             : #undef ACCESSORS
    8337             : #undef ACCESSORS_CHECKED
    8338             : #undef ACCESSORS_CHECKED2
    8339             : #undef SMI_ACCESSORS
    8340             : #undef SYNCHRONIZED_SMI_ACCESSORS
    8341             : #undef NOBARRIER_SMI_ACCESSORS
    8342             : #undef BOOL_GETTER
    8343             : #undef BOOL_ACCESSORS
    8344             : #undef NOBARRIER_READ_FIELD
    8345             : #undef NOBARRIER_WRITE_FIELD
    8346             : #undef WRITE_BARRIER
    8347             : #undef CONDITIONAL_WRITE_BARRIER
    8348             : #undef READ_DOUBLE_FIELD
    8349             : #undef WRITE_DOUBLE_FIELD
    8350             : #undef READ_INT_FIELD
    8351             : #undef WRITE_INT_FIELD
    8352             : #undef READ_INTPTR_FIELD
    8353             : #undef WRITE_INTPTR_FIELD
    8354             : #undef READ_UINT8_FIELD
    8355             : #undef WRITE_UINT8_FIELD
    8356             : #undef READ_INT8_FIELD
    8357             : #undef WRITE_INT8_FIELD
    8358             : #undef READ_UINT16_FIELD
    8359             : #undef WRITE_UINT16_FIELD
    8360             : #undef READ_INT16_FIELD
    8361             : #undef WRITE_INT16_FIELD
    8362             : #undef READ_UINT32_FIELD
    8363             : #undef WRITE_UINT32_FIELD
    8364             : #undef READ_INT32_FIELD
    8365             : #undef WRITE_INT32_FIELD
    8366             : #undef READ_FLOAT_FIELD
    8367             : #undef WRITE_FLOAT_FIELD
    8368             : #undef READ_UINT64_FIELD
    8369             : #undef WRITE_UINT64_FIELD
    8370             : #undef READ_INT64_FIELD
    8371             : #undef WRITE_INT64_FIELD
    8372             : #undef READ_BYTE_FIELD
    8373             : #undef WRITE_BYTE_FIELD
    8374             : #undef NOBARRIER_READ_BYTE_FIELD
    8375             : #undef NOBARRIER_WRITE_BYTE_FIELD
    8376             : 
    8377             : }  // namespace internal
    8378             : }  // namespace v8
    8379             : 
    8380             : #include "src/objects/object-macros-undef.h"
    8381             : 
    8382             : #endif  // V8_OBJECTS_INL_H_

Generated by: LCOV version 1.10