LCOV - code coverage report
Current view: top level - src/heap - setup-heap-internal.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 454 456 99.6 %
Date: 2019-03-21 Functions: 13 13 100.0 %

          Line data    Source code
       1             : // Copyright 2017 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             : #include "src/setup-isolate.h"
       6             : 
       7             : #include "src/accessors.h"
       8             : #include "src/compilation-cache.h"
       9             : #include "src/contexts.h"
      10             : #include "src/heap-symbols.h"
      11             : #include "src/heap/factory.h"
      12             : #include "src/heap/heap-inl.h"
      13             : #include "src/ic/handler-configuration.h"
      14             : #include "src/interpreter/interpreter.h"
      15             : #include "src/isolate.h"
      16             : #include "src/layout-descriptor.h"
      17             : #include "src/lookup-cache.h"
      18             : #include "src/objects-inl.h"
      19             : #include "src/objects/arguments.h"
      20             : #include "src/objects/cell-inl.h"
      21             : #include "src/objects/data-handler.h"
      22             : #include "src/objects/debug-objects.h"
      23             : #include "src/objects/descriptor-array.h"
      24             : #include "src/objects/dictionary.h"
      25             : #include "src/objects/foreign.h"
      26             : #include "src/objects/heap-number.h"
      27             : #include "src/objects/instance-type-inl.h"
      28             : #include "src/objects/js-generator.h"
      29             : #include "src/objects/js-weak-refs.h"
      30             : #include "src/objects/literal-objects-inl.h"
      31             : #include "src/objects/map.h"
      32             : #include "src/objects/microtask.h"
      33             : #include "src/objects/module.h"
      34             : #include "src/objects/oddball-inl.h"
      35             : #include "src/objects/promise.h"
      36             : #include "src/objects/script.h"
      37             : #include "src/objects/shared-function-info.h"
      38             : #include "src/objects/smi.h"
      39             : #include "src/objects/stack-frame-info.h"
      40             : #include "src/objects/string.h"
      41             : #include "src/regexp/jsregexp.h"
      42             : #include "src/wasm/wasm-objects.h"
      43             : 
      44             : namespace v8 {
      45             : namespace internal {
      46             : 
      47          56 : bool SetupIsolateDelegate::SetupHeapInternal(Heap* heap) {
      48          56 :   return heap->CreateHeapObjects();
      49             : }
      50             : 
      51          56 : bool Heap::CreateHeapObjects() {
      52             :   // Create initial maps.
      53          56 :   if (!CreateInitialMaps()) return false;
      54          56 :   CreateApiObjects();
      55             : 
      56             :   // Create initial objects
      57          56 :   CreateInitialObjects();
      58          56 :   CreateInternalAccessorInfoObjects();
      59         112 :   CHECK_EQ(0u, gc_count_);
      60             : 
      61          56 :   set_native_contexts_list(ReadOnlyRoots(this).undefined_value());
      62          56 :   set_allocation_sites_list(ReadOnlyRoots(this).undefined_value());
      63             : 
      64          56 :   return true;
      65             : }
      66             : 
      67             : const Heap::StringTypeTable Heap::string_type_table[] = {
      68             : #define STRING_TYPE_ELEMENT(type, size, name, CamelName) \
      69             :   {type, size, RootIndex::k##CamelName##Map},
      70             :     STRING_TYPE_LIST(STRING_TYPE_ELEMENT)
      71             : #undef STRING_TYPE_ELEMENT
      72             : };
      73             : 
      74             : const Heap::ConstantStringTable Heap::constant_string_table[] = {
      75             :     {"", RootIndex::kempty_string},
      76             : #define CONSTANT_STRING_ELEMENT(_, name, contents) \
      77             :   {contents, RootIndex::k##name},
      78             :     INTERNALIZED_STRING_LIST_GENERATOR(CONSTANT_STRING_ELEMENT, /* not used */)
      79             : #undef CONSTANT_STRING_ELEMENT
      80             : };
      81             : 
      82             : const Heap::StructTable Heap::struct_table[] = {
      83             : #define STRUCT_TABLE_ELEMENT(TYPE, Name, name) \
      84             :   {TYPE, Name::kSize, RootIndex::k##Name##Map},
      85             :     STRUCT_LIST(STRUCT_TABLE_ELEMENT)
      86             : #undef STRUCT_TABLE_ELEMENT
      87             : 
      88             : #define ALLOCATION_SITE_ELEMENT(_, TYPE, Name, Size, name) \
      89             :   {TYPE, Name::kSize##Size, RootIndex::k##Name##Size##Map},
      90             :         ALLOCATION_SITE_LIST(ALLOCATION_SITE_ELEMENT, /* not used */)
      91             : #undef ALLOCATION_SITE_ELEMENT
      92             : 
      93             : #define DATA_HANDLER_ELEMENT(_, TYPE, Name, Size, name) \
      94             :   {TYPE, Name::kSizeWithData##Size, RootIndex::k##Name##Size##Map},
      95             :             DATA_HANDLER_LIST(DATA_HANDLER_ELEMENT, /* not used */)
      96             : #undef DATA_HANDLER_ELEMENT
      97             : };
      98             : 
      99        5656 : AllocationResult Heap::AllocateMap(InstanceType instance_type,
     100             :                                    int instance_size,
     101             :                                    ElementsKind elements_kind,
     102             :                                    int inobject_properties) {
     103             :   STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
     104       11312 :   bool is_js_object = InstanceTypeChecker::IsJSObject(instance_type);
     105             :   DCHECK_IMPLIES(is_js_object &&
     106             :                      !Map::CanHaveFastTransitionableElementsKind(instance_type),
     107             :                  IsDictionaryElementsKind(elements_kind) ||
     108             :                      IsTerminalElementsKind(elements_kind));
     109        5656 :   HeapObject result;
     110             :   // JSObjects have maps with a mutable prototype_validity_cell, so they cannot
     111             :   // go in RO_SPACE.
     112             :   AllocationResult allocation =
     113             :       AllocateRaw(Map::kSize, is_js_object ? AllocationType::kMap
     114        5656 :                                            : AllocationType::kReadOnly);
     115        5656 :   if (!allocation.To(&result)) return allocation;
     116             : 
     117       11312 :   result->set_map_after_allocation(ReadOnlyRoots(this).meta_map(),
     118        5656 :                                    SKIP_WRITE_BARRIER);
     119             :   Map map = isolate()->factory()->InitializeMap(
     120             :       Map::cast(result), instance_type, instance_size, elements_kind,
     121       11312 :       inobject_properties);
     122             : 
     123        5656 :   return map;
     124             : }
     125             : 
     126        2912 : AllocationResult Heap::AllocatePartialMap(InstanceType instance_type,
     127             :                                           int instance_size) {
     128        2912 :   Object result;
     129             :   AllocationResult allocation =
     130        2912 :       AllocateRaw(Map::kSize, AllocationType::kReadOnly);
     131        2912 :   if (!allocation.To(&result)) return allocation;
     132             :   // Map::cast cannot be used due to uninitialized map field.
     133        2912 :   Map map = Map::unchecked_cast(result);
     134        5824 :   map->set_map_after_allocation(
     135             :       Map::unchecked_cast(isolate()->root(RootIndex::kMetaMap)),
     136        2912 :       SKIP_WRITE_BARRIER);
     137        2912 :   map->set_instance_type(instance_type);
     138        2912 :   map->set_instance_size(instance_size);
     139             :   // Initialize to only containing tagged fields.
     140             :   if (FLAG_unbox_double_fields) {
     141             :     map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
     142             :   }
     143             :   // GetVisitorId requires a properly initialized LayoutDescriptor.
     144        2912 :   map->set_visitor_id(Map::GetVisitorId(map));
     145        2912 :   map->set_inobject_properties_start_or_constructor_function_index(0);
     146             :   DCHECK(!map->IsJSObjectMap());
     147        2912 :   map->set_prototype_validity_cell(Smi::FromInt(Map::kPrototypeChainValid));
     148        2912 :   map->SetInObjectUnusedPropertyFields(0);
     149        2912 :   map->set_bit_field(0);
     150        2912 :   map->set_bit_field2(0);
     151             :   DCHECK(!map->is_in_retained_map_list());
     152        5824 :   int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) |
     153        5824 :                    Map::OwnsDescriptorsBit::encode(true) |
     154        5824 :                    Map::ConstructionCounterBits::encode(Map::kNoSlackTracking);
     155        2912 :   map->set_bit_field3(bit_field3);
     156        2912 :   map->clear_padding();
     157        2912 :   map->set_elements_kind(TERMINAL_FAST_ELEMENTS_KIND);
     158        2912 :   return map;
     159             : }
     160             : 
     161        2912 : void Heap::FinalizePartialMap(Map map) {
     162             :   ReadOnlyRoots roots(this);
     163        5824 :   map->set_dependent_code(DependentCode::cast(roots.empty_weak_fixed_array()));
     164        2912 :   map->set_raw_transitions(MaybeObject::FromSmi(Smi::zero()));
     165        2912 :   map->SetInstanceDescriptors(isolate(), roots.empty_descriptor_array(), 0);
     166             :   if (FLAG_unbox_double_fields) {
     167             :     map->set_layout_descriptor(LayoutDescriptor::FastPointerLayout());
     168             :   }
     169        2912 :   map->set_prototype(roots.null_value());
     170        2912 :   map->set_constructor_or_backpointer(roots.null_value());
     171        2912 : }
     172             : 
     173         392 : AllocationResult Heap::Allocate(Map map, AllocationType allocation_type) {
     174             :   DCHECK(map->instance_type() != MAP_TYPE);
     175         392 :   int size = map->instance_size();
     176         392 :   HeapObject result;
     177         392 :   AllocationResult allocation = AllocateRaw(size, allocation_type);
     178         392 :   if (!allocation.To(&result)) return allocation;
     179             :   // New space objects are allocated white.
     180             :   WriteBarrierMode write_barrier_mode =
     181             :       allocation_type == AllocationType::kYoung ? SKIP_WRITE_BARRIER
     182         392 :                                                 : UPDATE_WRITE_BARRIER;
     183         392 :   result->set_map_after_allocation(map, write_barrier_mode);
     184         392 :   return result;
     185             : }
     186             : 
     187         616 : AllocationResult Heap::AllocateEmptyFixedTypedArray(
     188             :     ExternalArrayType array_type) {
     189         616 :   int size = OBJECT_POINTER_ALIGN(FixedTypedArrayBase::kDataOffset);
     190             : 
     191         616 :   HeapObject object;
     192             :   AllocationResult allocation = AllocateRaw(
     193             :       size, AllocationType::kReadOnly,
     194         616 :       array_type == kExternalFloat64Array ? kDoubleAligned : kWordAligned);
     195         616 :   if (!allocation.To(&object)) return allocation;
     196             : 
     197        1232 :   object->set_map_after_allocation(
     198             :       ReadOnlyRoots(this).MapForFixedTypedArray(array_type),
     199         616 :       SKIP_WRITE_BARRIER);
     200         616 :   FixedTypedArrayBase elements = FixedTypedArrayBase::cast(object);
     201         616 :   elements->set_base_pointer(elements, SKIP_WRITE_BARRIER);
     202         616 :   elements->set_external_pointer(
     203         616 :       FixedTypedArrayBase::ExternalPointerPtrForOnHeapArray());
     204         616 :   elements->set_length(0);
     205         616 :   return elements;
     206             : }
     207             : 
     208          56 : bool Heap::CreateInitialMaps() {
     209          56 :   HeapObject obj;
     210             :   {
     211          56 :     AllocationResult allocation = AllocatePartialMap(MAP_TYPE, Map::kSize);
     212          56 :     if (!allocation.To(&obj)) return false;
     213             :   }
     214             :   // Map::cast cannot be used due to uninitialized map field.
     215          56 :   Map new_meta_map = Map::unchecked_cast(obj);
     216          56 :   set_meta_map(new_meta_map);
     217          56 :   new_meta_map->set_map_after_allocation(new_meta_map);
     218             : 
     219             :   ReadOnlyRoots roots(this);
     220             :   {  // Partial map allocation
     221             : #define ALLOCATE_PARTIAL_MAP(instance_type, size, field_name)                \
     222             :   {                                                                          \
     223             :     Map map;                                                                 \
     224             :     if (!AllocatePartialMap((instance_type), (size)).To(&map)) return false; \
     225             :     set_##field_name##_map(map);                                             \
     226             :   }
     227             : 
     228          56 :     ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel, fixed_array);
     229          56 :     ALLOCATE_PARTIAL_MAP(WEAK_FIXED_ARRAY_TYPE, kVariableSizeSentinel,
     230             :                          weak_fixed_array);
     231          56 :     ALLOCATE_PARTIAL_MAP(WEAK_ARRAY_LIST_TYPE, kVariableSizeSentinel,
     232             :                          weak_array_list);
     233          56 :     ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel,
     234             :                          fixed_cow_array)
     235             :     DCHECK_NE(roots.fixed_array_map(), roots.fixed_cow_array_map());
     236             : 
     237          56 :     ALLOCATE_PARTIAL_MAP(DESCRIPTOR_ARRAY_TYPE, kVariableSizeSentinel,
     238             :                          descriptor_array)
     239             : 
     240          56 :     ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, undefined);
     241          56 :     ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, null);
     242          56 :     ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, the_hole);
     243             : 
     244             : #undef ALLOCATE_PARTIAL_MAP
     245             :   }
     246             : 
     247             :   // Allocate the empty array.
     248             :   {
     249             :     AllocationResult alloc =
     250          56 :         AllocateRaw(FixedArray::SizeFor(0), AllocationType::kReadOnly);
     251          56 :     if (!alloc.To(&obj)) return false;
     252          56 :     obj->set_map_after_allocation(roots.fixed_array_map(), SKIP_WRITE_BARRIER);
     253          56 :     FixedArray::cast(obj)->set_length(0);
     254             :   }
     255          56 :   set_empty_fixed_array(FixedArray::cast(obj));
     256             : 
     257             :   {
     258             :     AllocationResult alloc =
     259          56 :         AllocateRaw(WeakFixedArray::SizeFor(0), AllocationType::kReadOnly);
     260          56 :     if (!alloc.To(&obj)) return false;
     261          56 :     obj->set_map_after_allocation(roots.weak_fixed_array_map(),
     262          56 :                                   SKIP_WRITE_BARRIER);
     263          56 :     WeakFixedArray::cast(obj)->set_length(0);
     264             :   }
     265          56 :   set_empty_weak_fixed_array(WeakFixedArray::cast(obj));
     266             : 
     267             :   {
     268             :     AllocationResult allocation = AllocateRaw(WeakArrayList::SizeForCapacity(0),
     269          56 :                                               AllocationType::kReadOnly);
     270          56 :     if (!allocation.To(&obj)) return false;
     271          56 :     obj->set_map_after_allocation(roots.weak_array_list_map(),
     272          56 :                                   SKIP_WRITE_BARRIER);
     273          56 :     WeakArrayList::cast(obj)->set_capacity(0);
     274          56 :     WeakArrayList::cast(obj)->set_length(0);
     275             :   }
     276          56 :   set_empty_weak_array_list(WeakArrayList::cast(obj));
     277             : 
     278             :   {
     279             :     AllocationResult allocation =
     280          56 :         Allocate(roots.null_map(), AllocationType::kReadOnly);
     281          56 :     if (!allocation.To(&obj)) return false;
     282             :   }
     283          56 :   set_null_value(Oddball::cast(obj));
     284          56 :   Oddball::cast(obj)->set_kind(Oddball::kNull);
     285             : 
     286             :   {
     287             :     AllocationResult allocation =
     288          56 :         Allocate(roots.undefined_map(), AllocationType::kReadOnly);
     289          56 :     if (!allocation.To(&obj)) return false;
     290             :   }
     291          56 :   set_undefined_value(Oddball::cast(obj));
     292          56 :   Oddball::cast(obj)->set_kind(Oddball::kUndefined);
     293             :   DCHECK(!InYoungGeneration(roots.undefined_value()));
     294             :   {
     295             :     AllocationResult allocation =
     296          56 :         Allocate(roots.the_hole_map(), AllocationType::kReadOnly);
     297          56 :     if (!allocation.To(&obj)) return false;
     298             :   }
     299          56 :   set_the_hole_value(Oddball::cast(obj));
     300          56 :   Oddball::cast(obj)->set_kind(Oddball::kTheHole);
     301             : 
     302             :   // Set preliminary exception sentinel value before actually initializing it.
     303          56 :   set_exception(roots.null_value());
     304             : 
     305             :   // Setup the struct maps first (needed for the EnumCache).
     306        2464 :   for (unsigned i = 0; i < arraysize(struct_table); i++) {
     307        2408 :     const StructTable& entry = struct_table[i];
     308        2408 :     Map map;
     309        2408 :     if (!AllocatePartialMap(entry.type, entry.size).To(&map)) return false;
     310        4816 :     roots_table()[entry.index] = map->ptr();
     311             :   }
     312             : 
     313             :   // Allocate the empty enum cache.
     314             :   {
     315             :     AllocationResult allocation =
     316          56 :         Allocate(roots.tuple2_map(), AllocationType::kReadOnly);
     317          56 :     if (!allocation.To(&obj)) return false;
     318             :   }
     319          56 :   set_empty_enum_cache(EnumCache::cast(obj));
     320          56 :   EnumCache::cast(obj)->set_keys(roots.empty_fixed_array());
     321          56 :   EnumCache::cast(obj)->set_indices(roots.empty_fixed_array());
     322             : 
     323             :   // Allocate the empty descriptor array.
     324             :   {
     325          56 :     int size = DescriptorArray::SizeFor(0);
     326          56 :     if (!AllocateRaw(size, AllocationType::kReadOnly).To(&obj)) return false;
     327          56 :     obj->set_map_after_allocation(roots.descriptor_array_map(),
     328          56 :                                   SKIP_WRITE_BARRIER);
     329          56 :     DescriptorArray array = DescriptorArray::cast(obj);
     330         112 :     array->Initialize(roots.empty_enum_cache(), roots.undefined_value(), 0, 0);
     331             :   }
     332          56 :   set_empty_descriptor_array(DescriptorArray::cast(obj));
     333             : 
     334             :   // Fix the instance_descriptors for the existing maps.
     335          56 :   FinalizePartialMap(roots.meta_map());
     336          56 :   FinalizePartialMap(roots.fixed_array_map());
     337          56 :   FinalizePartialMap(roots.weak_fixed_array_map());
     338          56 :   FinalizePartialMap(roots.weak_array_list_map());
     339          56 :   FinalizePartialMap(roots.fixed_cow_array_map());
     340          56 :   FinalizePartialMap(roots.descriptor_array_map());
     341          56 :   FinalizePartialMap(roots.undefined_map());
     342          56 :   roots.undefined_map()->set_is_undetectable(true);
     343          56 :   FinalizePartialMap(roots.null_map());
     344          56 :   roots.null_map()->set_is_undetectable(true);
     345          56 :   FinalizePartialMap(roots.the_hole_map());
     346        2464 :   for (unsigned i = 0; i < arraysize(struct_table); ++i) {
     347        2408 :     const StructTable& entry = struct_table[i];
     348        7224 :     FinalizePartialMap(Map::cast(Object(roots_table()[entry.index])));
     349             :   }
     350             : 
     351             :   {  // Map allocation
     352             : #define ALLOCATE_MAP(instance_type, size, field_name)               \
     353             :   {                                                                 \
     354             :     Map map;                                                        \
     355             :     if (!AllocateMap((instance_type), size).To(&map)) return false; \
     356             :     set_##field_name##_map(map);                                    \
     357             :   }
     358             : 
     359             : #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \
     360             :     ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name)
     361             : 
     362             : #define ALLOCATE_PRIMITIVE_MAP(instance_type, size, field_name, \
     363             :                                constructor_function_index)      \
     364             :   {                                                             \
     365             :     ALLOCATE_MAP((instance_type), (size), field_name);          \
     366             :     roots.field_name##_map()->SetConstructorFunctionIndex(      \
     367             :         (constructor_function_index));                          \
     368             :   }
     369             : 
     370          56 :     ALLOCATE_VARSIZE_MAP(SCOPE_INFO_TYPE, scope_info)
     371          56 :     ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, module_info)
     372          56 :     ALLOCATE_VARSIZE_MAP(FEEDBACK_VECTOR_TYPE, feedback_vector)
     373         112 :     ALLOCATE_PRIMITIVE_MAP(HEAP_NUMBER_TYPE, HeapNumber::kSize, heap_number,
     374             :                            Context::NUMBER_FUNCTION_INDEX)
     375          56 :     ALLOCATE_MAP(MUTABLE_HEAP_NUMBER_TYPE, MutableHeapNumber::kSize,
     376             :                  mutable_heap_number)
     377         112 :     ALLOCATE_PRIMITIVE_MAP(SYMBOL_TYPE, Symbol::kSize, symbol,
     378             :                            Context::SYMBOL_FUNCTION_INDEX)
     379          56 :     ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign)
     380             : 
     381         112 :     ALLOCATE_PRIMITIVE_MAP(ODDBALL_TYPE, Oddball::kSize, boolean,
     382             :                            Context::BOOLEAN_FUNCTION_INDEX);
     383          56 :     ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, uninitialized);
     384          56 :     ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, arguments_marker);
     385          56 :     ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, exception);
     386          56 :     ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, termination_exception);
     387          56 :     ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, optimized_out);
     388          56 :     ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, stale_register);
     389          56 :     ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, self_reference_marker);
     390          56 :     ALLOCATE_VARSIZE_MAP(BIGINT_TYPE, bigint);
     391             : 
     392        1120 :     for (unsigned i = 0; i < arraysize(string_type_table); i++) {
     393        1064 :       const StringTypeTable& entry = string_type_table[i];
     394        1064 :       Map map;
     395        1064 :       if (!AllocateMap(entry.type, entry.size).To(&map)) return false;
     396        1064 :       map->SetConstructorFunctionIndex(Context::STRING_FUNCTION_INDEX);
     397             :       // Mark cons string maps as unstable, because their objects can change
     398             :       // maps during GC.
     399        1064 :       if (StringShape(entry.type).IsCons()) map->mark_unstable();
     400        2128 :       roots_table()[entry.index] = map->ptr();
     401             :     }
     402             : 
     403             :     {  // Create a separate external one byte string map for native sources.
     404          56 :       Map map;
     405             :       AllocationResult allocation =
     406             :           AllocateMap(UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE,
     407          56 :                       ExternalOneByteString::kUncachedSize);
     408          56 :       if (!allocation.To(&map)) return false;
     409          56 :       map->SetConstructorFunctionIndex(Context::STRING_FUNCTION_INDEX);
     410          56 :       set_native_source_string_map(map);
     411             :     }
     412             : 
     413          56 :     ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array)
     414          56 :     roots.fixed_double_array_map()->set_elements_kind(HOLEY_DOUBLE_ELEMENTS);
     415          56 :     ALLOCATE_VARSIZE_MAP(FEEDBACK_METADATA_TYPE, feedback_metadata)
     416          56 :     ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array)
     417          56 :     ALLOCATE_VARSIZE_MAP(BYTECODE_ARRAY_TYPE, bytecode_array)
     418          56 :     ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space)
     419          56 :     ALLOCATE_VARSIZE_MAP(PROPERTY_ARRAY_TYPE, property_array)
     420          56 :     ALLOCATE_VARSIZE_MAP(SMALL_ORDERED_HASH_MAP_TYPE, small_ordered_hash_map)
     421          56 :     ALLOCATE_VARSIZE_MAP(SMALL_ORDERED_HASH_SET_TYPE, small_ordered_hash_set)
     422          56 :     ALLOCATE_VARSIZE_MAP(SMALL_ORDERED_NAME_DICTIONARY_TYPE,
     423             :                          small_ordered_name_dictionary)
     424             : 
     425             : #define ALLOCATE_FIXED_TYPED_ARRAY_MAP(Type, type, TYPE, ctype) \
     426             :   ALLOCATE_VARSIZE_MAP(FIXED_##TYPE##_ARRAY_TYPE, fixed_##type##_array)
     427             : 
     428          56 :     TYPED_ARRAYS(ALLOCATE_FIXED_TYPED_ARRAY_MAP)
     429             : #undef ALLOCATE_FIXED_TYPED_ARRAY_MAP
     430             : 
     431          56 :     ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, sloppy_arguments_elements)
     432             : 
     433          56 :     ALLOCATE_VARSIZE_MAP(CODE_TYPE, code)
     434             : 
     435          56 :     ALLOCATE_MAP(CELL_TYPE, Cell::kSize, cell);
     436             :     {
     437             :       // The invalid_prototype_validity_cell is needed for JSObject maps.
     438          56 :       Smi value = Smi::FromInt(Map::kPrototypeChainInvalid);
     439          56 :       AllocationResult alloc = AllocateRaw(Cell::kSize, AllocationType::kOld);
     440          56 :       if (!alloc.To(&obj)) return false;
     441          56 :       obj->set_map_after_allocation(roots.cell_map(), SKIP_WRITE_BARRIER);
     442          56 :       Cell::cast(obj)->set_value(value);
     443          56 :       set_invalid_prototype_validity_cell(Cell::cast(obj));
     444             :     }
     445             : 
     446          56 :     ALLOCATE_MAP(PROPERTY_CELL_TYPE, PropertyCell::kSize, global_property_cell)
     447          56 :     ALLOCATE_MAP(FILLER_TYPE, kTaggedSize, one_pointer_filler)
     448          56 :     ALLOCATE_MAP(FILLER_TYPE, 2 * kTaggedSize, two_pointer_filler)
     449             : 
     450             :     // The "no closures" and "one closure" FeedbackCell maps need
     451             :     // to be marked unstable because their objects can change maps.
     452          56 :     ALLOCATE_MAP(FEEDBACK_CELL_TYPE, FeedbackCell::kSize, no_closures_cell)
     453          56 :     roots.no_closures_cell_map()->mark_unstable();
     454          56 :     ALLOCATE_MAP(FEEDBACK_CELL_TYPE, FeedbackCell::kSize, one_closure_cell)
     455          56 :     roots.one_closure_cell_map()->mark_unstable();
     456          56 :     ALLOCATE_MAP(FEEDBACK_CELL_TYPE, FeedbackCell::kSize, many_closures_cell)
     457             : 
     458          56 :     ALLOCATE_VARSIZE_MAP(TRANSITION_ARRAY_TYPE, transition_array)
     459             : 
     460          56 :     ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, hash_table)
     461          56 :     ALLOCATE_VARSIZE_MAP(ORDERED_HASH_MAP_TYPE, ordered_hash_map)
     462          56 :     ALLOCATE_VARSIZE_MAP(ORDERED_HASH_SET_TYPE, ordered_hash_set)
     463          56 :     ALLOCATE_VARSIZE_MAP(ORDERED_NAME_DICTIONARY_TYPE, ordered_name_dictionary)
     464          56 :     ALLOCATE_VARSIZE_MAP(NAME_DICTIONARY_TYPE, name_dictionary)
     465          56 :     ALLOCATE_VARSIZE_MAP(GLOBAL_DICTIONARY_TYPE, global_dictionary)
     466          56 :     ALLOCATE_VARSIZE_MAP(NUMBER_DICTIONARY_TYPE, number_dictionary)
     467          56 :     ALLOCATE_VARSIZE_MAP(SIMPLE_NUMBER_DICTIONARY_TYPE,
     468             :                          simple_number_dictionary)
     469          56 :     ALLOCATE_VARSIZE_MAP(STRING_TABLE_TYPE, string_table)
     470             : 
     471          56 :     ALLOCATE_VARSIZE_MAP(EMBEDDER_DATA_ARRAY_TYPE, embedder_data_array)
     472          56 :     ALLOCATE_VARSIZE_MAP(EPHEMERON_HASH_TABLE_TYPE, ephemeron_hash_table)
     473             : 
     474          56 :     ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, array_list)
     475             : 
     476          56 :     ALLOCATE_VARSIZE_MAP(FUNCTION_CONTEXT_TYPE, function_context)
     477          56 :     ALLOCATE_VARSIZE_MAP(CATCH_CONTEXT_TYPE, catch_context)
     478          56 :     ALLOCATE_VARSIZE_MAP(WITH_CONTEXT_TYPE, with_context)
     479          56 :     ALLOCATE_VARSIZE_MAP(DEBUG_EVALUATE_CONTEXT_TYPE, debug_evaluate_context)
     480          56 :     ALLOCATE_VARSIZE_MAP(AWAIT_CONTEXT_TYPE, await_context)
     481          56 :     ALLOCATE_VARSIZE_MAP(BLOCK_CONTEXT_TYPE, block_context)
     482          56 :     ALLOCATE_VARSIZE_MAP(MODULE_CONTEXT_TYPE, module_context)
     483          56 :     ALLOCATE_VARSIZE_MAP(EVAL_CONTEXT_TYPE, eval_context)
     484          56 :     ALLOCATE_VARSIZE_MAP(SCRIPT_CONTEXT_TYPE, script_context)
     485          56 :     ALLOCATE_VARSIZE_MAP(SCRIPT_CONTEXT_TABLE_TYPE, script_context_table)
     486             : 
     487          56 :     ALLOCATE_VARSIZE_MAP(OBJECT_BOILERPLATE_DESCRIPTION_TYPE,
     488             :                          object_boilerplate_description)
     489             : 
     490          56 :     ALLOCATE_MAP(NATIVE_CONTEXT_TYPE, NativeContext::kSize, native_context)
     491             : 
     492          56 :     ALLOCATE_MAP(CALL_HANDLER_INFO_TYPE, CallHandlerInfo::kSize,
     493             :                  side_effect_call_handler_info)
     494          56 :     ALLOCATE_MAP(CALL_HANDLER_INFO_TYPE, CallHandlerInfo::kSize,
     495             :                  side_effect_free_call_handler_info)
     496          56 :     ALLOCATE_MAP(CALL_HANDLER_INFO_TYPE, CallHandlerInfo::kSize,
     497             :                  next_call_side_effect_free_call_handler_info)
     498             : 
     499          56 :     ALLOCATE_VARSIZE_MAP(PREPARSE_DATA_TYPE, preparse_data)
     500          56 :     ALLOCATE_MAP(UNCOMPILED_DATA_WITHOUT_PREPARSE_DATA_TYPE,
     501             :                  UncompiledDataWithoutPreparseData::kSize,
     502             :                  uncompiled_data_without_preparse_data)
     503          56 :     ALLOCATE_MAP(UNCOMPILED_DATA_WITH_PREPARSE_DATA_TYPE,
     504             :                  UncompiledDataWithPreparseData::kSize,
     505             :                  uncompiled_data_with_preparse_data)
     506             : #if V8_SFI_HAS_UNIQUE_ID
     507             :     ALLOCATE_MAP(SHARED_FUNCTION_INFO_TYPE,
     508             :                  SharedFunctionInfoWithID::kAlignedSize, shared_function_info)
     509             : #else
     510          56 :     ALLOCATE_MAP(SHARED_FUNCTION_INFO_TYPE, SharedFunctionInfo::kAlignedSize,
     511             :                  shared_function_info)
     512             : #endif
     513             : 
     514          56 :     ALLOCATE_MAP(CODE_DATA_CONTAINER_TYPE, CodeDataContainer::kSize,
     515             :                  code_data_container)
     516             : 
     517          56 :     ALLOCATE_MAP(WEAK_CELL_TYPE, WeakCell::kSize, weak_cell)
     518             : 
     519          56 :     ALLOCATE_MAP(JS_MESSAGE_OBJECT_TYPE, JSMessageObject::kSize, message_object)
     520          56 :     ALLOCATE_MAP(JS_OBJECT_TYPE, JSObject::kHeaderSize + kEmbedderDataSlotSize,
     521             :                  external)
     522          56 :     external_map()->set_is_extensible(false);
     523             : #undef ALLOCATE_PRIMITIVE_MAP
     524             : #undef ALLOCATE_VARSIZE_MAP
     525             : #undef ALLOCATE_MAP
     526             :   }
     527             : 
     528             :   {
     529             :     AllocationResult alloc =
     530          56 :         AllocateRaw(FixedArray::SizeFor(0), AllocationType::kReadOnly);
     531          56 :     if (!alloc.To(&obj)) return false;
     532          56 :     obj->set_map_after_allocation(roots.scope_info_map(), SKIP_WRITE_BARRIER);
     533          56 :     FixedArray::cast(obj)->set_length(0);
     534             :   }
     535          56 :   set_empty_scope_info(ScopeInfo::cast(obj));
     536             : 
     537             :   {
     538             :     // Empty boilerplate needs a field for literal_flags
     539             :     AllocationResult alloc =
     540          56 :         AllocateRaw(FixedArray::SizeFor(1), AllocationType::kReadOnly);
     541          56 :     if (!alloc.To(&obj)) return false;
     542          56 :     obj->set_map_after_allocation(roots.object_boilerplate_description_map(),
     543          56 :                                   SKIP_WRITE_BARRIER);
     544             : 
     545          56 :     FixedArray::cast(obj)->set_length(1);
     546         112 :     FixedArray::cast(obj)->set(ObjectBoilerplateDescription::kLiteralTypeOffset,
     547          56 :                                Smi::kZero);
     548             :   }
     549             :   set_empty_object_boilerplate_description(
     550          56 :       ObjectBoilerplateDescription::cast(obj));
     551             : 
     552             :   {
     553             :     // Empty array boilerplate description
     554             :     AllocationResult alloc = Allocate(roots.array_boilerplate_description_map(),
     555          56 :                                       AllocationType::kReadOnly);
     556          56 :     if (!alloc.To(&obj)) return false;
     557             : 
     558         112 :     ArrayBoilerplateDescription::cast(obj)->set_constant_elements(
     559         168 :         roots.empty_fixed_array());
     560         112 :     ArrayBoilerplateDescription::cast(obj)->set_elements_kind(
     561          56 :         ElementsKind::PACKED_SMI_ELEMENTS);
     562             :   }
     563             :   set_empty_array_boilerplate_description(
     564          56 :       ArrayBoilerplateDescription::cast(obj));
     565             : 
     566             :   {
     567             :     AllocationResult allocation =
     568          56 :         Allocate(roots.boolean_map(), AllocationType::kReadOnly);
     569          56 :     if (!allocation.To(&obj)) return false;
     570             :   }
     571          56 :   set_true_value(Oddball::cast(obj));
     572          56 :   Oddball::cast(obj)->set_kind(Oddball::kTrue);
     573             : 
     574             :   {
     575             :     AllocationResult allocation =
     576          56 :         Allocate(roots.boolean_map(), AllocationType::kReadOnly);
     577          56 :     if (!allocation.To(&obj)) return false;
     578             :   }
     579          56 :   set_false_value(Oddball::cast(obj));
     580          56 :   Oddball::cast(obj)->set_kind(Oddball::kFalse);
     581             : 
     582             :   // Empty arrays.
     583             :   {
     584          56 :     if (!AllocateRaw(ByteArray::SizeFor(0), AllocationType::kReadOnly).To(&obj))
     585           0 :       return false;
     586          56 :     obj->set_map_after_allocation(roots.byte_array_map(), SKIP_WRITE_BARRIER);
     587          56 :     ByteArray::cast(obj)->set_length(0);
     588          56 :     set_empty_byte_array(ByteArray::cast(obj));
     589             :   }
     590             : 
     591             :   {
     592         112 :     if (!AllocateRaw(FixedArray::SizeFor(0), AllocationType::kReadOnly)
     593          56 :              .To(&obj)) {
     594           0 :       return false;
     595             :     }
     596          56 :     obj->set_map_after_allocation(roots.property_array_map(),
     597          56 :                                   SKIP_WRITE_BARRIER);
     598          56 :     PropertyArray::cast(obj)->initialize_length(0);
     599          56 :     set_empty_property_array(PropertyArray::cast(obj));
     600             :   }
     601             : 
     602             : #define ALLOCATE_EMPTY_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype)         \
     603             :   {                                                                       \
     604             :     FixedTypedArrayBase obj;                                              \
     605             :     if (!AllocateEmptyFixedTypedArray(kExternal##Type##Array).To(&obj)) { \
     606             :       return false;                                                       \
     607             :     }                                                                     \
     608             :     set_empty_fixed_##type##_array(obj);                                  \
     609             :   }
     610             : 
     611          56 :   TYPED_ARRAYS(ALLOCATE_EMPTY_FIXED_TYPED_ARRAY)
     612             : #undef ALLOCATE_EMPTY_FIXED_TYPED_ARRAY
     613             : 
     614             :   DCHECK(!InYoungGeneration(roots.empty_fixed_array()));
     615             : 
     616         112 :   roots.bigint_map()->SetConstructorFunctionIndex(
     617          56 :       Context::BIGINT_FUNCTION_INDEX);
     618             : 
     619          56 :   return true;
     620             : }
     621             : 
     622          56 : void Heap::CreateApiObjects() {
     623          56 :   Isolate* isolate = this->isolate();
     624         112 :   HandleScope scope(isolate);
     625             : 
     626         112 :   set_message_listeners(*TemplateList::New(isolate, 2));
     627             : 
     628             :   Handle<InterceptorInfo> info =
     629             :       Handle<InterceptorInfo>::cast(isolate->factory()->NewStruct(
     630          56 :           INTERCEPTOR_INFO_TYPE, AllocationType::kReadOnly));
     631          56 :   info->set_flags(0);
     632          56 :   set_noop_interceptor_info(*info);
     633          56 : }
     634             : 
     635          56 : void Heap::CreateInitialObjects() {
     636         112 :   HandleScope scope(isolate());
     637          56 :   Factory* factory = isolate()->factory();
     638             :   ReadOnlyRoots roots(this);
     639             : 
     640             :   // The -0 value must be set before NewNumber works.
     641             :   set_minus_zero_value(
     642         112 :       *factory->NewHeapNumber(-0.0, AllocationType::kReadOnly));
     643             :   DCHECK(std::signbit(roots.minus_zero_value()->Number()));
     644             : 
     645         112 :   set_nan_value(*factory->NewHeapNumber(
     646         112 :       std::numeric_limits<double>::quiet_NaN(), AllocationType::kReadOnly));
     647         112 :   set_hole_nan_value(*factory->NewHeapNumberFromBits(
     648          56 :       kHoleNanInt64, AllocationType::kReadOnly));
     649             :   set_infinity_value(
     650         112 :       *factory->NewHeapNumber(V8_INFINITY, AllocationType::kReadOnly));
     651             :   set_minus_infinity_value(
     652         112 :       *factory->NewHeapNumber(-V8_INFINITY, AllocationType::kReadOnly));
     653             : 
     654         112 :   set_hash_seed(*factory->NewByteArray(kInt64Size, AllocationType::kReadOnly));
     655          56 :   InitializeHashSeed();
     656             : 
     657             :   // There's no "current microtask" in the beginning.
     658          56 :   set_current_microtask(roots.undefined_value());
     659             : 
     660          56 :   set_dirty_js_finalization_groups(roots.undefined_value());
     661          56 :   set_weak_refs_keep_during_job(roots.undefined_value());
     662             : 
     663             :   // Allocate cache for single character one byte strings.
     664         112 :   set_single_character_string_cache(*factory->NewFixedArray(
     665          56 :       String::kMaxOneByteCharCode + 1, AllocationType::kOld));
     666             : 
     667             :   // Allocate initial string table.
     668         112 :   set_string_table(*StringTable::New(isolate(), kInitialStringTableSize));
     669             : 
     670       16352 :   for (unsigned i = 0; i < arraysize(constant_string_table); i++) {
     671             :     Handle<String> str =
     672       16296 :         factory->InternalizeUtf8String(constant_string_table[i].contents);
     673       48888 :     roots_table()[constant_string_table[i].index] = str->ptr();
     674             :   }
     675             : 
     676             :   // Allocate
     677             : 
     678             :   // Finish initializing oddballs after creating the string table.
     679         168 :   Oddball::Initialize(isolate(), factory->undefined_value(), "undefined",
     680          56 :                       factory->nan_value(), "undefined", Oddball::kUndefined);
     681             : 
     682             :   // Initialize the null_value.
     683         112 :   Oddball::Initialize(isolate(), factory->null_value(), "null",
     684          56 :                       handle(Smi::kZero, isolate()), "object", Oddball::kNull);
     685             : 
     686             :   // Initialize the_hole_value.
     687         168 :   Oddball::Initialize(isolate(), factory->the_hole_value(), "hole",
     688             :                       factory->hole_nan_value(), "undefined",
     689          56 :                       Oddball::kTheHole);
     690             : 
     691             :   // Initialize the true_value.
     692         168 :   Oddball::Initialize(isolate(), factory->true_value(), "true",
     693             :                       handle(Smi::FromInt(1), isolate()), "boolean",
     694          56 :                       Oddball::kTrue);
     695             : 
     696             :   // Initialize the false_value.
     697         112 :   Oddball::Initialize(isolate(), factory->false_value(), "false",
     698             :                       handle(Smi::kZero, isolate()), "boolean",
     699          56 :                       Oddball::kFalse);
     700             : 
     701             :   set_uninitialized_value(
     702         112 :       *factory->NewOddball(factory->uninitialized_map(), "uninitialized",
     703             :                            handle(Smi::FromInt(-1), isolate()), "undefined",
     704         224 :                            Oddball::kUninitialized));
     705             : 
     706             :   set_arguments_marker(
     707         112 :       *factory->NewOddball(factory->arguments_marker_map(), "arguments_marker",
     708             :                            handle(Smi::FromInt(-4), isolate()), "undefined",
     709         224 :                            Oddball::kArgumentsMarker));
     710             : 
     711         112 :   set_termination_exception(*factory->NewOddball(
     712             :       factory->termination_exception_map(), "termination_exception",
     713         224 :       handle(Smi::FromInt(-3), isolate()), "undefined", Oddball::kOther));
     714             : 
     715         112 :   set_exception(*factory->NewOddball(factory->exception_map(), "exception",
     716             :                                      handle(Smi::FromInt(-5), isolate()),
     717         224 :                                      "undefined", Oddball::kException));
     718             : 
     719         112 :   set_optimized_out(*factory->NewOddball(factory->optimized_out_map(),
     720             :                                          "optimized_out",
     721             :                                          handle(Smi::FromInt(-6), isolate()),
     722         224 :                                          "undefined", Oddball::kOptimizedOut));
     723             : 
     724             :   set_stale_register(
     725         112 :       *factory->NewOddball(factory->stale_register_map(), "stale_register",
     726             :                            handle(Smi::FromInt(-7), isolate()), "undefined",
     727         224 :                            Oddball::kStaleRegister));
     728             : 
     729             :   // Initialize the self-reference marker.
     730         112 :   set_self_reference_marker(
     731         168 :       *factory->NewSelfReferenceMarker(AllocationType::kReadOnly));
     732             : 
     733          56 :   set_interpreter_entry_trampoline_for_profiling(roots.undefined_value());
     734             : 
     735             :   {
     736         112 :     HandleScope scope(isolate());
     737             : #define SYMBOL_INIT(_, name)                                                \
     738             :   {                                                                         \
     739             :     Handle<Symbol> symbol(                                                  \
     740             :         isolate()->factory()->NewPrivateSymbol(AllocationType::kReadOnly)); \
     741             :     roots_table()[RootIndex::k##name] = symbol->ptr();                      \
     742             :   }
     743        3304 :     PRIVATE_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
     744             : #undef SYMBOL_INIT
     745             :   }
     746             : 
     747             :   {
     748         112 :     HandleScope scope(isolate());
     749             : #define SYMBOL_INIT(_, name, description)                                \
     750             :   Handle<Symbol> name = factory->NewSymbol(AllocationType::kReadOnly);   \
     751             :   Handle<String> name##d = factory->InternalizeUtf8String(#description); \
     752             :   name->set_name(*name##d);                                              \
     753             :   roots_table()[RootIndex::k##name] = name->ptr();
     754        2520 :     PUBLIC_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
     755             : #undef SYMBOL_INIT
     756             : 
     757             : #define SYMBOL_INIT(_, name, description)                                \
     758             :   Handle<Symbol> name = factory->NewSymbol(AllocationType::kReadOnly);   \
     759             :   Handle<String> name##d = factory->InternalizeUtf8String(#description); \
     760             :   name->set_is_well_known_symbol(true);                                  \
     761             :   name->set_name(*name##d);                                              \
     762             :   roots_table()[RootIndex::k##name] = name->ptr();
     763         896 :     WELL_KNOWN_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
     764             : #undef SYMBOL_INIT
     765             : 
     766             :     // Mark "Interesting Symbols" appropriately.
     767          56 :     to_string_tag_symbol->set_is_interesting_symbol(true);
     768             :   }
     769             : 
     770             :   Handle<NameDictionary> empty_property_dictionary = NameDictionary::New(
     771          56 :       isolate(), 1, AllocationType::kReadOnly, USE_CUSTOM_MINIMUM_CAPACITY);
     772             :   DCHECK(!empty_property_dictionary->HasSufficientCapacityToAdd(1));
     773          56 :   set_empty_property_dictionary(*empty_property_dictionary);
     774             : 
     775          56 :   set_public_symbol_table(*empty_property_dictionary);
     776          56 :   set_api_symbol_table(*empty_property_dictionary);
     777          56 :   set_api_private_symbol_table(*empty_property_dictionary);
     778             : 
     779         112 :   set_number_string_cache(*factory->NewFixedArray(
     780          56 :       kInitialNumberStringCacheSize * 2, AllocationType::kOld));
     781             : 
     782             :   // Allocate cache for string split and regexp-multiple.
     783         112 :   set_string_split_cache(*factory->NewFixedArray(
     784          56 :       RegExpResultsCache::kRegExpResultsCacheSize, AllocationType::kOld));
     785         112 :   set_regexp_multiple_cache(*factory->NewFixedArray(
     786          56 :       RegExpResultsCache::kRegExpResultsCacheSize, AllocationType::kOld));
     787             : 
     788             :   // Allocate FeedbackCell for builtins.
     789             :   Handle<FeedbackCell> many_closures_cell =
     790         112 :       factory->NewManyClosuresCell(factory->undefined_value());
     791          56 :   set_many_closures_cell(*many_closures_cell);
     792             : 
     793             :   {
     794             :     Handle<FixedArray> empty_sloppy_arguments_elements =
     795          56 :         factory->NewFixedArray(2, AllocationType::kReadOnly);
     796         112 :     empty_sloppy_arguments_elements->set_map_after_allocation(
     797          56 :         roots.sloppy_arguments_elements_map(), SKIP_WRITE_BARRIER);
     798          56 :     set_empty_sloppy_arguments_elements(*empty_sloppy_arguments_elements);
     799             :   }
     800             : 
     801          56 :   set_detached_contexts(roots.empty_weak_array_list());
     802          56 :   set_retained_maps(roots.empty_weak_array_list());
     803          56 :   set_retaining_path_targets(roots.empty_weak_array_list());
     804             : 
     805          56 :   set_feedback_vectors_for_profiling_tools(roots.undefined_value());
     806          56 :   set_pending_optimize_for_test_bytecode(roots.undefined_value());
     807             : 
     808          56 :   set_script_list(roots.empty_weak_array_list());
     809             : 
     810             :   Handle<NumberDictionary> slow_element_dictionary = NumberDictionary::New(
     811          56 :       isolate(), 1, AllocationType::kReadOnly, USE_CUSTOM_MINIMUM_CAPACITY);
     812             :   DCHECK(!slow_element_dictionary->HasSufficientCapacityToAdd(1));
     813          56 :   slow_element_dictionary->set_requires_slow_elements();
     814          56 :   set_empty_slow_element_dictionary(*slow_element_dictionary);
     815             : 
     816         112 :   set_materialized_objects(*factory->NewFixedArray(0, AllocationType::kOld));
     817             : 
     818             :   // Handling of script id generation is in Heap::NextScriptId().
     819          56 :   set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId));
     820          56 :   set_last_debugging_id(Smi::FromInt(DebugInfo::kNoDebuggingId));
     821          56 :   set_next_template_serial_number(Smi::zero());
     822             : 
     823             :   // Allocate the empty OrderedHashMap.
     824             :   Handle<FixedArray> empty_ordered_hash_map = factory->NewFixedArray(
     825          56 :       OrderedHashMap::HashTableStartIndex(), AllocationType::kReadOnly);
     826         112 :   empty_ordered_hash_map->set_map_no_write_barrier(
     827         168 :       *factory->ordered_hash_map_map());
     828         448 :   for (int i = 0; i < empty_ordered_hash_map->length(); ++i) {
     829         168 :     empty_ordered_hash_map->set(i, Smi::kZero);
     830             :   }
     831          56 :   set_empty_ordered_hash_map(*empty_ordered_hash_map);
     832             : 
     833             :   // Allocate the empty OrderedHashSet.
     834             :   Handle<FixedArray> empty_ordered_hash_set = factory->NewFixedArray(
     835          56 :       OrderedHashSet::HashTableStartIndex(), AllocationType::kReadOnly);
     836         112 :   empty_ordered_hash_set->set_map_no_write_barrier(
     837         168 :       *factory->ordered_hash_set_map());
     838         448 :   for (int i = 0; i < empty_ordered_hash_set->length(); ++i) {
     839         168 :     empty_ordered_hash_set->set(i, Smi::kZero);
     840             :   }
     841          56 :   set_empty_ordered_hash_set(*empty_ordered_hash_set);
     842             : 
     843             :   // Allocate the empty FeedbackMetadata.
     844             :   Handle<FeedbackMetadata> empty_feedback_metadata =
     845          56 :       factory->NewFeedbackMetadata(0, 0, AllocationType::kReadOnly);
     846          56 :   set_empty_feedback_metadata(*empty_feedback_metadata);
     847             : 
     848             :   // Allocate the empty script.
     849          56 :   Handle<Script> script = factory->NewScript(factory->empty_string());
     850          56 :   script->set_type(Script::TYPE_NATIVE);
     851             :   // This is used for exceptions thrown with no stack frames. Such exceptions
     852             :   // can be shared everywhere.
     853          56 :   script->set_origin_options(ScriptOriginOptions(true, false));
     854          56 :   set_empty_script(*script);
     855             : 
     856             :   Handle<Cell> array_constructor_cell = factory->NewCell(
     857         112 :       handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
     858          56 :   set_array_constructor_protector(*array_constructor_cell);
     859             : 
     860         112 :   Handle<PropertyCell> cell = factory->NewPropertyCell(factory->empty_string());
     861         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     862          56 :   set_no_elements_protector(*cell);
     863             : 
     864             :   cell = factory->NewPropertyCell(factory->empty_string(),
     865         112 :                                   AllocationType::kReadOnly);
     866         112 :   cell->set_value(roots.the_hole_value());
     867          56 :   set_empty_property_cell(*cell);
     868             : 
     869         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     870         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     871          56 :   set_array_iterator_protector(*cell);
     872             : 
     873         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     874         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     875          56 :   set_map_iterator_protector(*cell);
     876             : 
     877         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     878         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     879          56 :   set_set_iterator_protector(*cell);
     880             : 
     881             :   Handle<Cell> is_concat_spreadable_cell = factory->NewCell(
     882         112 :       handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
     883          56 :   set_is_concat_spreadable_protector(*is_concat_spreadable_cell);
     884             : 
     885         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     886         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     887          56 :   set_array_species_protector(*cell);
     888             : 
     889         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     890         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     891          56 :   set_typed_array_species_protector(*cell);
     892             : 
     893         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     894         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     895          56 :   set_promise_species_protector(*cell);
     896             : 
     897         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     898         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     899          56 :   set_regexp_species_protector(*cell);
     900             : 
     901         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     902         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     903          56 :   set_string_iterator_protector(*cell);
     904             : 
     905             :   Handle<Cell> string_length_overflow_cell = factory->NewCell(
     906         112 :       handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
     907          56 :   set_string_length_protector(*string_length_overflow_cell);
     908             : 
     909         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     910         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     911          56 :   set_array_buffer_detaching_protector(*cell);
     912             : 
     913         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     914         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     915          56 :   set_promise_hook_protector(*cell);
     916             : 
     917             :   Handle<Cell> promise_resolve_cell = factory->NewCell(
     918         112 :       handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
     919          56 :   set_promise_resolve_protector(*promise_resolve_cell);
     920             : 
     921         112 :   cell = factory->NewPropertyCell(factory->empty_string());
     922         112 :   cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
     923          56 :   set_promise_then_protector(*cell);
     924             : 
     925          56 :   set_serialized_objects(roots.empty_fixed_array());
     926          56 :   set_serialized_global_proxy_sizes(roots.empty_fixed_array());
     927             : 
     928          56 :   set_noscript_shared_function_infos(roots.empty_weak_array_list());
     929             : 
     930             :   set_off_heap_trampoline_relocation_info(
     931         112 :       *Builtins::GenerateOffHeapTrampolineRelocInfo(isolate_));
     932             : 
     933             :   // Evaluate the hash values which will then be cached in the strings.
     934         112 :   isolate()->factory()->zero_string()->Hash();
     935         112 :   isolate()->factory()->one_string()->Hash();
     936             : 
     937             :   // Initialize builtins constants table.
     938          56 :   set_builtins_constants_table(roots.empty_fixed_array());
     939             : 
     940             :   // Initialize descriptor cache.
     941          56 :   isolate_->descriptor_lookup_cache()->Clear();
     942             : 
     943             :   // Initialize compilation cache.
     944          56 :   isolate_->compilation_cache()->Clear();
     945          56 : }
     946             : 
     947          56 : void Heap::CreateInternalAccessorInfoObjects() {
     948          56 :   Isolate* isolate = this->isolate();
     949         112 :   HandleScope scope(isolate);
     950             :   Handle<AccessorInfo> accessor_info;
     951             : 
     952             : #define INIT_ACCESSOR_INFO(_, accessor_name, AccessorName, ...) \
     953             :   accessor_info = Accessors::Make##AccessorName##Info(isolate); \
     954             :   roots_table()[RootIndex::k##AccessorName##Accessor] = accessor_info->ptr();
     955        1288 :   ACCESSOR_INFO_LIST_GENERATOR(INIT_ACCESSOR_INFO, /* not used */)
     956             : #undef INIT_ACCESSOR_INFO
     957             : 
     958             : #define INIT_SIDE_EFFECT_FLAG(_, accessor_name, AccessorName, GetterType, \
     959             :                               SetterType)                                 \
     960             :   AccessorInfo::cast(                                                     \
     961             :       Object(roots_table()[RootIndex::k##AccessorName##Accessor]))        \
     962             :       ->set_getter_side_effect_type(SideEffectType::GetterType);          \
     963             :   AccessorInfo::cast(                                                     \
     964             :       Object(roots_table()[RootIndex::k##AccessorName##Accessor]))        \
     965             :       ->set_setter_side_effect_type(SideEffectType::SetterType);
     966        2464 :   ACCESSOR_INFO_LIST_GENERATOR(INIT_SIDE_EFFECT_FLAG, /* not used */)
     967             : #undef INIT_SIDE_EFFECT_FLAG
     968          56 : }
     969             : 
     970             : }  // namespace internal
     971       87414 : }  // namespace v8

Generated by: LCOV version 1.10