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

Generated by: LCOV version 1.10