59#if V8_ENABLE_WEBASSEMBLY
68DirectHandle<SharedFunctionInfo> CreateSharedFunctionInfo(
69 Isolate* isolate,
Builtin builtin,
int len,
71 DirectHandle<SharedFunctionInfo> shared =
72 isolate->factory()->NewSharedFunctionInfoForBuiltin(
73 isolate->factory()->empty_string(), builtin, len,
kAdapt,
kind);
79 bool is_maybe_read_only_js_object =
81 bool is_js_object = InstanceTypeChecker::IsJSObject(instance_type);
82 bool is_always_shared_space_js_object =
83 InstanceTypeChecker::IsAlwaysSharedSpaceJSObject(instance_type);
84 bool is_wasm_object =
false;
85#if V8_ENABLE_WEBASSEMBLY
87 instance_type == WASM_STRUCT_TYPE || instance_type == WASM_ARRAY_TYPE;
93 is_maybe_read_only_js_object ||
94 (is_always_shared_space_js_object &&
98 return (is_js_object && !is_maybe_read_only_js_object &&
99 !is_always_shared_space_js_object) ||
104struct ConstantStringInit {
109constexpr std::initializer_list<ConstantStringInit>
110 kImportantConstantStringTable{
111#define CONSTANT_STRING_ELEMENT(_, name, contents) \
112 {{contents, arraysize(contents) - 1}, RootIndex::k##name},
117#undef CONSTANT_STRING_ELEMENT
120constexpr std::initializer_list<ConstantStringInit>
121 kNotImportantConstantStringTable{
122#define CONSTANT_STRING_ELEMENT(_, name, contents) \
123 {{contents, arraysize(contents) - 1}, RootIndex::k##name},
126#undef CONSTANT_STRING_ELEMENT
129struct StringTypeInit {
135constexpr std::initializer_list<StringTypeInit> kStringTypeTable{
136#define STRING_TYPE_ELEMENT(type, size, name, CamelName) \
137 {type, size, RootIndex::k##CamelName##Map},
139#undef STRING_TYPE_ELEMENT
149 return type == ENUM_CACHE_TYPE || type == CALL_SITE_INFO_TYPE;
152template <
typename StructType>
153constexpr int StructSize() {
154 if constexpr (std::is_base_of_v<StructLayout, StructType>) {
155 return sizeof(StructType);
157 return StructType::kSize;
161using AllocationSiteWithoutWeakNext = AllocationSite;
162constexpr std::initializer_list<StructInit> kStructTable{
163#define STRUCT_TABLE_ELEMENT(TYPE, Name, name) \
164 {TYPE, StructSize<Name>(), RootIndex::k##Name##Map},
166#undef STRUCT_TABLE_ELEMENT
167#define ALLOCATION_SITE_ELEMENT(_, TYPE, Name, Size, name) \
168 {TYPE, sizeof(Name##Size), RootIndex::k##Name##Size##Map},
170#undef ALLOCATION_SITE_ELEMENT
171#define DATA_HANDLER_ELEMENT(_, TYPE, Name, Size, name) \
172 {TYPE, Name::SizeFor(Size), RootIndex::k##Name##Size##Map},
174#undef DATA_HANDLER_ELEMENT
180 auto heap = isolate->heap();
181 if (!isolate->read_only_heap()->roots_init_complete()) {
182 if (!
heap->CreateReadOnlyHeapObjects())
return false;
183 isolate->VerifyStaticRoots();
184 isolate->read_only_heap()->OnCreateRootsComplete(isolate);
188 auto ro_size =
heap->read_only_space()->Size();
191 auto res =
heap->CreateMutableHeapObjects();
197bool Heap::CreateReadOnlyHeapObjects() {
202#if V8_STATIC_ROOTS_BOOL
233bool Heap::CreateMutableHeapObjects() {
260 int inobject_properties) {
261 static_assert(LAST_JS_OBJECT_TYPE ==
LAST_TYPE);
263 DCHECK_EQ(allocation_type, IsMutableMap(instance_type, elements_kind)
267 if (!allocation.To(&
result))
return allocation;
270 result->set_map_after_allocation(
isolate(), roots.meta_map(),
274 inobject_properties, roots);
284 map->set_instance_type(instance_type);
285 map->set_instance_size(instance_size);
287 map->set_inobject_properties_start_or_constructor_function_index(0);
288 DCHECK(!IsJSObjectMap(map));
290 map->SetInObjectUnusedPropertyFields(0);
291 map->set_bit_field(0);
292 map->set_bit_field2(0);
295 Map::Bits3::OwnsDescriptorsBit::encode(
true) |
298 DCHECK(!map->is_in_retained_map_list());
299 map->clear_padding();
309 if (!allocation.To(&
result))
return allocation;
312 InitializePartialMap(
isolate(), map,
314 instance_type, instance_size);
322 map->SetInstanceDescriptors(
isolate(), roots.empty_descriptor_array(), 0,
324 map->init_prototype_and_constructor_or_back_pointer(roots);
329 DCHECK(map->instance_type() != MAP_TYPE);
330 int size = map->instance_size();
333 if (!allocation.To(&
result))
return allocation;
338 result->set_map_after_allocation(
isolate(), *map, write_barrier_mode);
342bool Heap::CreateEarlyReadOnlyMapsAndObjects() {
380#define ALLOCATE_AND_SET_ROOT(Type, name, Size) \
382 AllocationResult alloc = AllocateRaw(Size, AllocationType::kReadOnly); \
383 if (!alloc.To(&obj)) return false; \
385 Tagged<Type> name = UncheckedCast<Type>(obj); \
395 for (
const StringTypeInit& entry : kStringTypeTable) {
399 if (!alloc.
To(&obj))
return false;
418#undef ALLOCATE_AND_SET_ROOT
421 InitializePartialMap(
isolate(), meta_map, meta_map, MAP_TYPE, Map::kSize);
422 InitializePartialMap(
isolate(), undefined_map, meta_map, ODDBALL_TYPE,
424 InitializePartialMap(
isolate(), null_map, meta_map, ODDBALL_TYPE,
426 InitializePartialMap(
isolate(), boolean_map, meta_map, ODDBALL_TYPE,
428 boolean_map->SetConstructorFunctionIndex(Context::BOOLEAN_FUNCTION_INDEX);
429 InitializePartialMap(
isolate(), heap_number_map, meta_map, HEAP_NUMBER_TYPE,
431 heap_number_map->SetConstructorFunctionIndex(
432 Context::NUMBER_FUNCTION_INDEX);
436 for (
const StringTypeInit& entry : kStringTypeTable) {
438 InitializePartialMap(
isolate(), map, meta_map, entry.type, entry.size);
439 map->SetConstructorFunctionIndex(Context::STRING_FUNCTION_INDEX);
442 InitializePartialMap(
isolate(), symbol_map, meta_map, SYMBOL_TYPE,
444 symbol_map->SetConstructorFunctionIndex(Context::SYMBOL_FUNCTION_INDEX);
447 undefined_value->set_map_after_allocation(
isolate(), undefined_map,
451 null_value->set_map_after_allocation(
isolate(), null_map,
455 true_value->set_map_after_allocation(
isolate(), boolean_map,
459 false_value->set_map_after_allocation(
isolate(), boolean_map,
467 empty_string->set_map_after_allocation(
468 isolate(), roots.unchecked_internalized_one_byte_string_map(),
470 empty_string->clear_padding_destructively(0);
471 empty_string->set_length(0);
478#define ALLOCATE_PARTIAL_MAP(instance_type, size, field_name) \
481 if (!AllocatePartialMap((instance_type), (size)).To(&map)) return false; \
482 set_##field_name##_map(map); \
488 trusted_fixed_array);
490 protected_fixed_array);
494 trusted_weak_fixed_array);
496 protected_weak_fixed_array);
501 DCHECK_NE(roots.fixed_array_map(), roots.fixed_cow_array_map());
509 for (
const StructInit& entry : kStructTable) {
510 if (!is_important_struct(entry.type))
continue;
516#undef ALLOCATE_PARTIAL_MAP
521 if (!alloc.
To(&obj))
return false;
522 obj->set_map_after_allocation(
isolate(), roots.fixed_array_map(),
531 if (!alloc.
To(&obj))
return false;
532 obj->set_map_after_allocation(
isolate(), roots.weak_fixed_array_map(),
541 if (!allocation.To(&obj))
return false;
542 obj->set_map_after_allocation(
isolate(), roots.weak_array_list_map(),
553 if (!allocation.To(&obj))
return false;
564 if (!allocation.To(&obj))
return false;
574 obj->set_map_after_allocation(
isolate(), roots.descriptor_array_map(),
577 array->Initialize(roots.empty_enum_cache(), roots.undefined_value(), 0, 0,
594 roots.undefined_map()->set_is_undetectable(
true);
596 roots.null_map()->set_is_undetectable(
true);
602 for (
const StructInit& entry : kStructTable) {
603 if (!is_important_struct(entry.type))
continue;
606 for (
const StringTypeInit& entry : kStringTypeTable) {
610#define ALLOCATE_MAP(instance_type, size, field_name) \
613 if (!AllocateMap(AllocationType::kReadOnly, (instance_type), size) \
617 set_##field_name##_map(map); \
620#define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \
621 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name)
623#define ALLOCATE_PRIMITIVE_MAP(instance_type, size, field_name, \
624 constructor_function_index) \
626 ALLOCATE_MAP((instance_type), (size), field_name); \
627 roots.field_name##_map()->SetConstructorFunctionIndex( \
628 (constructor_function_index)); \
635 closure_feedback_cell_array)
639 ALLOCATE_MAP(TRUSTED_FOREIGN_TYPE, TrustedForeign::kSize, trusted_foreign)
640 ALLOCATE_MAP(MEGA_DOM_HANDLER_TYPE, MegaDomHandler::kSize, mega_dom_handler)
653 small_ordered_name_dictionary)
663 if (!alloc.
To(&obj))
return false;
664 obj->set_map_after_allocation(
isolate(), roots.cell_map(),
667 set_invalid_prototype_validity_cell(
Cast<Cell>(obj));
670 ALLOCATE_MAP(PROPERTY_CELL_TYPE, PropertyCell::kSize, global_property_cell)
678 roots.no_closures_cell_map()->mark_unstable();
681 roots.one_closure_cell_map()->mark_unstable();
698 ALLOCATE_MAP(ACCESSOR_INFO_TYPE, AccessorInfo::kSize, accessor_info)
699 ALLOCATE_MAP(INTERCEPTOR_INFO_TYPE, InterceptorInfo::kSize,
703 ALLOCATE_MAP(SHARED_FUNCTION_INFO_TYPE, SharedFunctionInfo::kSize,
704 shared_function_info)
711bool Heap::CreateLateReadOnlyNonJSReceiverMaps() {
715 for (
const StructInit& entry : kStructTable) {
716 if (is_important_struct(entry.type))
continue;
724#define TORQUE_ALLOCATE_MAP(NAME, Name, name) \
725 ALLOCATE_MAP(NAME, Name::SizeFor(), name)
727#undef TORQUE_ALLOCATE_MAP
729#define TORQUE_ALLOCATE_VARSIZE_MAP(NAME, Name, name) \
731 if (NAME != DESCRIPTOR_ARRAY_TYPE) { \
732 ALLOCATE_VARSIZE_MAP(NAME, name) \
735#undef TORQUE_ALLOCATE_VARSIZE_MAP
741 simple_number_dictionary)
743 name_to_index_hash_table)
751 object_boilerplate_description)
756 ALLOCATE_MAP(REG_EXP_DATA_TYPE, RegExpData::kSize, regexp_data);
757 ALLOCATE_MAP(ATOM_REG_EXP_DATA_TYPE, AtomRegExpData::kSize,
759 ALLOCATE_MAP(IR_REG_EXP_DATA_TYPE, IrRegExpData::kSize, ir_regexp_data);
761 ALLOCATE_MAP(SOURCE_TEXT_MODULE_TYPE, SourceTextModule::kSize,
763 ALLOCATE_MAP(SYNTHETIC_MODULE_TYPE, SyntheticModule::kSize,
767 ContextSidePropertyCell::kSize,
768 global_context_side_property_cell)
773 WasmCapiFunctionData::kSize, wasm_capi_function_data)
775 WasmExportedFunctionData::kSize, wasm_exported_function_data)
777 WasmInternalFunction::kSize, wasm_internal_function)
780 wasm_js_function_data)
784 WasmSuspenderObject::kSize, wasm_suspender_object)
789 WasmTrustedInstanceData::kSize, wasm_trusted_instance_data);
791 wasm_dispatch_table);
793 ALLOCATE_MAP(WEAK_CELL_TYPE, WeakCell::kSize, weak_cell)
794 ALLOCATE_MAP(INTERPRETER_DATA_TYPE, InterpreterData::kSize,
797 SharedFunctionInfoWrapper::kSize, shared_function_info_wrapper)
799 ALLOCATE_MAP(DICTIONARY_TEMPLATE_INFO_TYPE, DictionaryTemplateInfo::kSize,
800 dictionary_template_info)
806bool Heap::CreateLateReadOnlyJSReceiverMaps() {
807#define ALLOCATE_ALWAYS_SHARED_SPACE_JSOBJECT_MAP(instance_type, size, \
811 if (!AllocateMap(AllocationType::kReadOnly, (instance_type), size, \
812 DICTIONARY_ELEMENTS) \
816 AlwaysSharedSpaceJSObject::PrepareMapNoEnumerableProperties(map); \
817 set_##field_name##_map(map); \
829 ALLOCATE_MAP(JS_MESSAGE_OBJECT_TYPE, JSMessageObject::kHeaderSize,
831 roots.message_object_map()->SetEnumLength(0);
832 roots.message_object_map()->set_is_extensible(
false);
834 ALLOCATE_MAP(JS_EXTERNAL_OBJECT_TYPE, JSExternalObject::kHeaderSize,
836 roots.external_map()->SetEnumLength(0);
837 roots.external_map()->set_is_extensible(
false);
846 .To(&shared_array_map)) {
858 shared_array_map->InitializeDescriptors(
isolate(), *descriptors);
859 set_js_shared_array_map(shared_array_map);
863 JS_ATOMICS_MUTEX_TYPE, JSAtomicsMutex::kHeaderSize, js_atomics_mutex)
865 JSAtomicsCondition::kHeaderSize,
866 js_atomics_condition)
868#undef ALLOCATE_ALWAYS_SHARED_SPACE_JSOBJECT_MAP
869#undef ALLOCATE_PRIMITIVE_MAP
870#undef ALLOCATE_VARSIZE_MAP
881 int obj_size = obj->Size();
882 if (required == obj_size)
return;
884 int filler_size = required - obj_size;
898bool Heap::CreateImportantReadOnlyObjects() {
911 for (
const ConstantStringInit& entry : kImportantConstantStringTable) {
912 if (entry.index == RootIndex::kempty_string) {
915 isolate()->string_table()->InsertEmptyStringForBootstrapping(
isolate());
923#define SYMBOL_INIT(_, name) \
925 DirectHandle<Symbol> symbol( \
926 isolate()->factory()->NewPrivateSymbol(AllocationType::kReadOnly)); \
927 roots_table()[RootIndex::k##name] = symbol->ptr(); \
937 DCHECK(!empty_property_dictionary->HasSufficientCapacityToAdd(1));
939 set_empty_property_dictionary(*empty_property_dictionary);
945 set_empty_ordered_property_dictionary(*empty_ordered_property_dictionary);
952 obj->set_map_after_allocation(
isolate(), roots.byte_array_map(),
962 if (!alloc.
To(&obj))
return false;
963 obj->set_map_after_allocation(
isolate(), roots.scope_info_map(),
965 int flags = ScopeInfo::IsEmptyBit::encode(
true);
967 DCHECK_EQ(ScopeInfo::ReceiverVariableBits::decode(flags),
969 DCHECK_EQ(ScopeInfo::FunctionVariableBits::decode(flags),
984 obj->set_map_after_allocation(
isolate(), roots.property_array_map(),
992 set_minus_zero_value(
997 std::numeric_limits<double>::quiet_NaN()));
1002 set_minus_infinity_value(
1004 set_max_safe_integer(
1010 set_smi_max_value_plus_one(
1016bool Heap::CreateReadOnlyObjects() {
1025 if (!alloc.
To(&obj))
return false;
1026 obj->set_map_after_allocation(
isolate(), roots.array_list_map(),
1037 if (!alloc.
To(&obj))
return false;
1038 obj->set_map_after_allocation(
isolate(),
1039 roots.object_boilerplate_description_map(),
1046 set_empty_object_boilerplate_description(
1054 if (!alloc.
To(&obj))
return false;
1057 roots.empty_fixed_array());
1061 set_empty_array_boilerplate_description(
1071 obj->set_map_after_allocation(
1082 set_empty_swiss_property_dictionary(*empty_swiss_property_dictionary);
1086 roots.bigint_map()->SetConstructorFunctionIndex(
1087 Context::BIGINT_FUNCTION_INDEX);
1089 for (
const ConstantStringInit& entry : kNotImportantConstantStringTable) {
1094#define ENSURE_SINGLE_CHAR_STRINGS_ARE_SINGLE_CHAR(_, name, contents) \
1095 static_assert(arraysize(contents) - 1 == 1);
1099#undef ENSURE_SINGLE_CHAR_STRINGS_ARE_SINGLE_CHAR
1103 set_single_character_string_table(
1105 for (
int i = 0;
i < table_size; ++
i) {
1133 factory->hole_nan_value());
1135 set_property_cell_hole_value(*factory->
NewHole());
1136 set_hash_table_hole_value(*factory->
NewHole());
1137 set_promise_hole_value(*factory->
NewHole());
1138 set_uninitialized_value(*factory->
NewHole());
1139 set_arguments_marker(*factory->
NewHole());
1140 set_termination_exception(*factory->
NewHole());
1141 set_exception(*factory->
NewHole());
1142 set_optimized_out(*factory->
NewHole());
1143 set_stale_register(*factory->
NewHole());
1146 set_self_reference_marker(*factory->
NewHole());
1147 set_basic_block_counters_marker(*factory->
NewHole());
1157#define PUBLIC_SYMBOL_INIT(_, name, description) \
1158 DirectHandle<Symbol> name = factory->NewSymbol(AllocationType::kReadOnly); \
1159 DirectHandle<String> name##d = factory->InternalizeUtf8String(#description); \
1160 name->set_description(*name##d); \
1161 roots_table()[RootIndex::k##name] = name->ptr();
1165#define WELL_KNOWN_SYMBOL_INIT(_, name, description) \
1166 DirectHandle<Symbol> name = factory->NewSymbol(AllocationType::kReadOnly); \
1167 DirectHandle<String> name##d = factory->InternalizeUtf8String(#description); \
1168 name->set_is_well_known_symbol(true); \
1169 name->set_description(*name##d); \
1170 roots_table()[RootIndex::k##name] = name->ptr();
1175 to_string_tag_symbol->set_is_interesting_symbol(
true);
1184#define ALLOCATE_SYMBOL_STRING(_, name, description) \
1185 Handle<String> name##symbol_string = \
1186 factory->InternalizeUtf8String(#description); \
1187 USE(name##symbol_string);
1195#undef ALLOCATE_SYMBOL_STRING
1197#define INTERNALIZED_STRING_INIT(_, name, description) \
1198 DirectHandle<String> name = factory->InternalizeUtf8String(description); \
1199 roots_table()[RootIndex::k##name] = name->ptr();
1211 to_primitive_symbol->set_is_interesting_symbol(
true);
1214 roots.VerifyNameForProtectors();
1218#undef INTERNALIZED_STRING_INIT
1219#undef PUBLIC_SYMBOL_INIT
1220#undef WELL_KNOWN_SYMBOL_INIT
1226 DCHECK(!slow_element_dictionary->HasSufficientCapacityToAdd(1));
1227 set_empty_slow_element_dictionary(*slow_element_dictionary);
1232 DCHECK(!empty_symbol_table->HasSufficientCapacityToAdd(1));
1233 set_empty_symbol_table(*empty_symbol_table);
1239 set_empty_ordered_hash_map(*empty_ordered_hash_map);
1245 set_empty_ordered_hash_set(*empty_ordered_hash_set);
1250 set_empty_feedback_metadata(*empty_feedback_metadata);
1255 set_global_this_binding_scope_info(*global_this_binding);
1259 set_empty_function_scope_info(*empty_function);
1263 set_native_scope_info(*native_scope_info);
1267 set_shadow_realm_scope_info(*shadow_realm_scope_info);
1272 set_many_closures_cell(*many_closures_cell);
1276#ifdef V8_ENABLE_WEBASSEMBLY
1287 constexpr size_t kLargestPossibleOSPageSize = 64 *
KB;
1297 kLargestPossibleOSPageSize);
1301 kOffsetAfterMapWord);
1311 set_wasm_null_padding(filler);
1314 set_wasm_null_padding(roots.undefined_value());
1321 .To(&wasm_null_obj));
1325 wasm_null_obj->set_map_after_allocation(
isolate(), roots.wasm_null_map(),
1337void Heap::CreateMutableApiObjects() {
1342void Heap::CreateReadOnlyApiObjects() {
1346 set_noop_interceptor_info(*info);
1353void Heap::CreateInitialMutableObjects() {
1359 set_current_microtask(roots.undefined_value());
1361 set_weak_refs_keep_during_job(roots.undefined_value());
1363 set_public_symbol_table(roots.empty_symbol_table());
1364 set_api_symbol_table(roots.empty_symbol_table());
1365 set_api_private_symbol_table(roots.empty_symbol_table());
1371 set_basic_block_profiling_data(roots.unchecked_empty_array_list());
1381 set_detached_contexts(roots.empty_weak_array_list());
1383 set_feedback_vectors_for_profiling_tools(roots.undefined_value());
1384 set_functions_marked_for_manual_optimization(roots.undefined_value());
1385 set_shared_wasm_memories(roots.empty_weak_array_list());
1386 set_locals_block_list_cache(roots.undefined_value());
1387#ifdef V8_ENABLE_WEBASSEMBLY
1388 set_active_suspender(roots.undefined_value());
1389 set_js_to_wasm_wrappers(roots.empty_weak_fixed_array());
1390 set_wasm_canonical_rtts(roots.empty_weak_fixed_array());
1393 set_script_list(roots.empty_weak_array_list());
1401 set_next_template_serial_number(
1410 set_empty_script(*script);
1413 set_array_buffer_detaching_protector(*factory->
NewProtector());
1414 set_array_constructor_protector(*factory->
NewProtector());
1415 set_array_iterator_protector(*factory->
NewProtector());
1417 set_is_concat_spreadable_protector(*factory->
NewProtector());
1422 set_no_undetectable_objects_protector(*factory->
NewProtector());
1424 set_promise_resolve_protector(*factory->
NewProtector());
1425 set_promise_species_protector(*factory->
NewProtector());
1427 set_regexp_species_protector(*factory->
NewProtector());
1429 set_string_iterator_protector(*factory->
NewProtector());
1431 set_string_wrapper_to_primitive_protector(*factory->
NewProtector());
1432 set_number_string_not_regexp_like_protector(*factory->
NewProtector());
1433 set_typed_array_length_protector(*factory->
NewProtector());
1434 set_typed_array_species_protector(*factory->
NewProtector());
1436 set_serialized_objects(roots.empty_fixed_array());
1437 set_serialized_global_proxy_sizes(roots.empty_fixed_array());
1440 isolate()->factory()->zero_string()->EnsureHash();
1441 isolate()->factory()->one_string()->EnsureHash();
1444 set_builtins_constants_table(roots.empty_fixed_array());
1447 isolate_->descriptor_lookup_cache()->Clear();
1450 isolate_->compilation_cache()->Clear();
1456 isolate_, Accessors::ErrorStackGetter, 0,
1460 set_error_stack_getter_fun_template(*function_template);
1463 isolate_, Accessors::ErrorStackSetter, 1,
1467 set_error_stack_setter_fun_template(*function_template);
1474 isolate(), Builtin::kAsyncFunctionAwaitRejectClosure, 1);
1475 set_async_function_await_reject_closure_shared_fun(*info);
1477 info = CreateSharedFunctionInfo(
1478 isolate(), Builtin::kAsyncFunctionAwaitResolveClosure, 1);
1479 set_async_function_await_resolve_closure_shared_fun(*info);
1485 isolate(), Builtin::kAsyncGeneratorAwaitResolveClosure, 1);
1486 set_async_generator_await_resolve_closure_shared_fun(*info);
1488 info = CreateSharedFunctionInfo(
1489 isolate(), Builtin::kAsyncGeneratorAwaitRejectClosure, 1);
1490 set_async_generator_await_reject_closure_shared_fun(*info);
1492 info = CreateSharedFunctionInfo(
1493 isolate(), Builtin::kAsyncGeneratorYieldWithAwaitResolveClosure, 1);
1494 set_async_generator_yield_with_await_resolve_closure_shared_fun(*info);
1496 info = CreateSharedFunctionInfo(
1497 isolate(), Builtin::kAsyncGeneratorReturnResolveClosure, 1);
1498 set_async_generator_return_resolve_closure_shared_fun(*info);
1500 info = CreateSharedFunctionInfo(
1501 isolate(), Builtin::kAsyncGeneratorReturnClosedResolveClosure, 1);
1502 set_async_generator_return_closed_resolve_closure_shared_fun(*info);
1504 info = CreateSharedFunctionInfo(
1505 isolate(), Builtin::kAsyncGeneratorReturnClosedRejectClosure, 1);
1506 set_async_generator_return_closed_reject_closure_shared_fun(*info);
1512 isolate_, Builtin::kAsyncIteratorValueUnwrap, 1);
1513 set_async_iterator_value_unwrap_shared_fun(*info);
1515 info = CreateSharedFunctionInfo(
1516 isolate_, Builtin::kAsyncIteratorPrototypeAsyncDisposeResolveClosure,
1518 set_async_iterator_prototype_async_dispose_resolve_closure_shared_fun(
1525 isolate_, Builtin::kAsyncFromSyncIteratorCloseSyncAndRethrow, 1);
1526 set_async_from_sync_iterator_close_sync_and_rethrow_shared_fun(*info);
1532 isolate_, Builtin::kPromiseCapabilityDefaultResolve, 1,
1534 info->set_native(
true);
1535 info->set_function_map_index(
1536 Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX);
1537 set_promise_capability_default_resolve_shared_fun(*info);
1539 info = CreateSharedFunctionInfo(
isolate_,
1540 Builtin::kPromiseCapabilityDefaultReject, 1,
1542 info->set_native(
true);
1543 info->set_function_map_index(
1544 Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX);
1545 set_promise_capability_default_reject_shared_fun(*info);
1547 info = CreateSharedFunctionInfo(
1548 isolate_, Builtin::kPromiseGetCapabilitiesExecutor, 2);
1549 set_promise_get_capabilities_executor_shared_fun(*info);
1555 CreateSharedFunctionInfo(
isolate(), Builtin::kPromiseThenFinally, 1);
1556 info->set_native(
true);
1557 set_promise_then_finally_shared_fun(*info);
1560 CreateSharedFunctionInfo(
isolate(), Builtin::kPromiseCatchFinally, 1);
1561 info->set_native(
true);
1562 set_promise_catch_finally_shared_fun(*info);
1564 info = CreateSharedFunctionInfo(
isolate(),
1565 Builtin::kPromiseValueThunkFinally, 0);
1566 set_promise_value_thunk_finally_shared_fun(*info);
1569 CreateSharedFunctionInfo(
isolate(), Builtin::kPromiseThrowerFinally, 0);
1570 set_promise_thrower_finally_shared_fun(*info);
1576 isolate_, Builtin::kPromiseAllResolveElementClosure, 1);
1577 set_promise_all_resolve_element_closure_shared_fun(*info);
1579 info = CreateSharedFunctionInfo(
1580 isolate_, Builtin::kPromiseAllSettledResolveElementClosure, 1);
1581 set_promise_all_settled_resolve_element_closure_shared_fun(*info);
1583 info = CreateSharedFunctionInfo(
1584 isolate_, Builtin::kPromiseAllSettledRejectElementClosure, 1);
1585 set_promise_all_settled_reject_element_closure_shared_fun(*info);
1587 info = CreateSharedFunctionInfo(
1588 isolate_, Builtin::kPromiseAnyRejectElementClosure, 1);
1589 set_promise_any_reject_element_closure_shared_fun(*info);
1595 CreateSharedFunctionInfo(
isolate_, Builtin::kProxyRevoke, 0);
1596 set_proxy_revoke_shared_fun(*info);
1602 isolate_, Builtin::kShadowRealmImportValueFulfilled, 1);
1603 set_shadow_realm_import_value_fulfilled_shared_fun(*info);
1609 isolate_, Builtin::kCallAsyncModuleFulfilled, 0);
1610 set_source_text_module_execute_async_module_fulfilled_sfi(*info);
1612 info = CreateSharedFunctionInfo(
isolate_, Builtin::kCallAsyncModuleRejected,
1614 set_source_text_module_execute_async_module_rejected_sfi(*info);
1620 isolate_, Builtin::kArrayFromAsyncIterableOnFulfilled, 1);
1621 set_array_from_async_iterable_on_fulfilled_shared_fun(*info);
1623 info = CreateSharedFunctionInfo(
1624 isolate_, Builtin::kArrayFromAsyncIterableOnRejected, 1);
1625 set_array_from_async_iterable_on_rejected_shared_fun(*info);
1627 info = CreateSharedFunctionInfo(
1628 isolate_, Builtin::kArrayFromAsyncArrayLikeOnFulfilled, 1);
1629 set_array_from_async_array_like_on_fulfilled_shared_fun(*info);
1631 info = CreateSharedFunctionInfo(
1632 isolate_, Builtin::kArrayFromAsyncArrayLikeOnRejected, 1);
1633 set_array_from_async_array_like_on_rejected_shared_fun(*info);
1639 isolate_, Builtin::kAtomicsMutexAsyncUnlockResolveHandler, 1);
1640 set_atomics_mutex_async_unlock_resolve_handler_sfi(*info);
1641 info = CreateSharedFunctionInfo(
1642 isolate_, Builtin::kAtomicsMutexAsyncUnlockRejectHandler, 1);
1643 set_atomics_mutex_async_unlock_reject_handler_sfi(*info);
1649 isolate_, Builtin::kAtomicsConditionAcquireLock, 0);
1650 set_atomics_condition_acquire_lock_sfi(*info);
1656 isolate_, Builtin::kAsyncDisposableStackOnFulfilled, 0);
1657 set_async_disposable_stack_on_fulfilled_shared_fun(*info);
1659 info = CreateSharedFunctionInfo(
1660 isolate_, Builtin::kAsyncDisposableStackOnRejected, 0);
1661 set_async_disposable_stack_on_rejected_shared_fun(*info);
1663 info = CreateSharedFunctionInfo(
isolate_,
1664 Builtin::kAsyncDisposeFromSyncDispose, 0);
1665 set_async_dispose_from_sync_dispose_shared_fun(*info);
1674 set_empty_trusted_weak_fixed_array(
1677 set_empty_protected_weak_fixed_array(
1682void Heap::CreateInternalAccessorInfoObjects() {
1687#define INIT_ACCESSOR_INFO(_, accessor_name, AccessorName, ...) \
1688 accessor_info = Accessors::Make##AccessorName##Info(isolate); \
1689 roots_table()[RootIndex::k##AccessorName##Accessor] = accessor_info->ptr();
1691#undef INIT_ACCESSOR_INFO
1693#define INIT_SIDE_EFFECT_FLAG(_, accessor_name, AccessorName, GetterType, \
1695 Cast<AccessorInfo>( \
1696 Tagged<Object>(roots_table()[RootIndex::k##AccessorName##Accessor])) \
1697 ->set_getter_side_effect_type(SideEffectType::GetterType); \
1698 Cast<AccessorInfo>( \
1699 Tagged<Object>(roots_table()[RootIndex::k##AccessorName##Accessor])) \
1700 ->set_setter_side_effect_type(SideEffectType::SetterType);
1702#undef INIT_SIDE_EFFECT_FLAG
#define ACCESSOR_INFO_LIST_GENERATOR(V, _)
constexpr int kMinimumOSPageSize
static const int kNoScriptId
bool To(Tagged< T > *obj) const
static AllocationResult FromObject(Tagged< HeapObject > heap_object)
static void PrepareMapNoEnumerableProperties(Tagged< Map > map)
static DirectHandle< FunctionTemplateInfo > CreateAccessorFunctionTemplateInfo(Isolate *isolate, FunctionCallback callback, int length, v8::SideEffectType side_effect_type)
static DirectHandle< ArrayList > New(IsolateT *isolate, int capacity, AllocationType allocation=AllocationType::kYoung)
static const int kNoDebuggingId
static V8_EXPORT_PRIVATE Tagged< DependentCode > empty_dependent_code(const ReadOnlyRoots &roots)
static constexpr RawGCStateType kInitialGCState
static constexpr int SizeFor(int number_of_all_descriptors)
static Descriptor DataField(Isolate *isolate, DirectHandle< Name > key, int field_index, PropertyAttributes attributes, Representation representation)
V8_INLINE Address address() const
Handle< HeapNumber > NewHeapNumberFromBits(uint64_t bits)
Handle< HeapNumber > NewHeapNumber(double value)
Handle< ByteArray > NewByteArray(int length, AllocationType allocation=AllocationType::kYoung)
Handle< DescriptorArray > NewDescriptorArray(int number_of_descriptors, int slack=0, AllocationType allocation=AllocationType::kYoung)
Handle< Script > NewScript(DirectHandle< UnionOf< String, Undefined > > source, ScriptEventType event_type=ScriptEventType::kCreate)
Handle< FixedArray > NewFixedArray(int length, AllocationType allocation=AllocationType::kYoung)
Handle< FeedbackMetadata > NewFeedbackMetadata(int slot_count, int create_closure_slot_count, AllocationType allocation=AllocationType::kOld)
DirectHandle< SwissNameDictionary > CreateCanonicalEmptySwissNameDictionary()
DirectHandle< PropertyCell > NewProtector()
DirectHandle< Hole > NewHole()
DirectHandle< FeedbackCell > NewManyClosuresCell(AllocationType allocation=AllocationType::kOld)
Handle< String > InternalizeString(base::Vector< const char > str, bool convert_encoding=false)
static const int kAlignedSize
static V8_EXPORT_PRIVATE Tagged< FieldType > Any()
static void SealAndPrepareForPromotionToReadOnly(Isolate *isolate, DirectHandle< FunctionTemplateInfo > info)
static V8_INLINE bool InYoungGeneration(Tagged< Object > object)
static constexpr int kMapOffset
void StaticRootsEnsureAllocatedSize(DirectHandle< HeapObject > obj, int required)
void CreateInitialMutableObjects()
NewSpace * new_space() const
void set_native_contexts_list(Tagged< Object > object)
void set_allocation_sites_list(Tagged< UnionOf< Smi, Undefined, AllocationSiteWithWeakNext > > object)
V8_WARN_UNUSED_RESULT AllocationResult AllocatePartialMap(InstanceType instance_type, int instance_size)
void CreateReadOnlyApiObjects()
void InitializeHashSeed()
V8_EXPORT_PRIVATE void CreateFillerObjectAt(Address addr, int size, ClearFreedMemoryMode clear_memory_mode=ClearFreedMemoryMode::kDontClearFreedMemory)
static const int kInitialNumberStringCacheSize
V8_INLINE RootsTable & roots_table()
V8_INLINE Tagged< FixedArray > single_character_string_table()
ReadOnlySpace * read_only_space_
bool CreateReadOnlyObjects()
V8_WARN_UNUSED_RESULT AllocationResult AllocateMap(AllocationType allocation_type, InstanceType instance_type, int instance_size, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND, int inobject_properties=0)
void CreateInternalAccessorInfoObjects()
void set_dirty_js_finalization_registries_list_tail(Tagged< Object > object)
bool CreateLateReadOnlyJSReceiverMaps()
V8_WARN_UNUSED_RESULT AllocationResult Allocate(DirectHandle< Map > map, AllocationType allocation)
bool CreateImportantReadOnlyObjects()
ReadOnlySpace * read_only_space() const
void set_dirty_js_finalization_registries_list(Tagged< Object > object)
bool CreateEarlyReadOnlyMapsAndObjects()
bool CreateLateReadOnlyNonJSReceiverMaps()
void CreateMutableApiObjects()
void FinalizePartialMap(Tagged< Map > map)
V8_WARN_UNUSED_RESULT V8_INLINE AllocationResult AllocateRaw(int size_in_bytes, AllocationType allocation, AllocationOrigin origin=AllocationOrigin::kRuntime, AllocationAlignment alignment=kTaggedAligned)
static void Initialize(Isolate *isolate, DirectHandle< Hole > hole, DirectHandle< HeapNumber > numeric_value)
static constexpr int kSize
static constexpr int kSize
static constexpr Tagged< Smi > kPrototypeChainValidSmi
static const int kNoSlackTracking
bool CanHaveFastTransitionableElementsKind() const
static constexpr int kPrototypeChainInvalid
static V8_EXPORT_PRIVATE VisitorId GetVisitorId(Tagged< Map > map)
static V8_WARN_UNUSED_RESULT Handle< NameDictionary > New(IsolateT *isolate, int at_least_space_for, AllocationType allocation=AllocationType::kYoung, MinimumCapacity capacity_option=USE_DEFAULT_MINIMUM_CAPACITY)
static constexpr int kEmptyHashField
virtual void MakeIterable()=0
static double NumberValue(Tagged< Number > obj)
static constexpr uint8_t kNull
static constexpr uint8_t kUndefined
static constexpr uint8_t kFalse
static void Initialize(Isolate *isolate, DirectHandle< Oddball > oddball, const char *to_string, DirectHandle< Number > to_number, const char *type_of, uint8_t kind)
static constexpr uint8_t kTrue
static MaybeHandle< OrderedHashMap > AllocateEmpty(Isolate *isolate, AllocationType allocation=AllocationType::kReadOnly)
static MaybeHandle< OrderedHashSet > AllocateEmpty(Isolate *isolate, AllocationType allocation=AllocationType::kReadOnly)
static MaybeHandle< OrderedNameDictionary > AllocateEmpty(Isolate *isolate, AllocationType allocation=AllocationType::kReadOnly)
static constexpr int SizeFor(int length)
static Handle< ProtectedFixedArray > New(IsolateT *isolate, int capacity)
static Handle< ProtectedWeakFixedArray > New(IsolateT *isolate, int capacity)
static V8_EXPORT_PRIVATE bool Contains(Address address)
V8_INLINE Tagged< Object > object_at(RootIndex root_index) const
V8_INLINE void VerifyNameForProtectorsPages() const
V8_INLINE bool is_initialized(RootIndex root_index) const
void EnsureSpaceForAllocation(int size_in_bytes)
static constexpr int kSize
static constexpr int kRegExpResultsCacheSize
static constexpr Representation Smi()
static constexpr RootIndex SingleCharacterStringIndex(int c)
static DirectHandle< ScopeInfo > CreateGlobalThisBinding(Isolate *isolate)
static DirectHandle< ScopeInfo > CreateForShadowRealmNativeContext(Isolate *isolate)
static constexpr int SizeFor(int length)
static V8_EXPORT_PRIVATE DirectHandle< ScopeInfo > CreateForEmptyFunction(Isolate *isolate)
static DirectHandle< ScopeInfo > CreateForNativeContext(Isolate *isolate)
static V8_INLINE constexpr int32_t SizeFor(int32_t length)
static bool SetupHeapInternal(Isolate *isolate)
static constexpr Tagged< Smi > FromInt(int value)
static constexpr Tagged< Smi > zero()
V8_INLINE bool IsCons() const
static const int32_t kMaxOneByteCharCode
static constexpr int SizeFor(int capacity)
static const int kUninitializedSerialNumber
static Handle< TrustedByteArray > New(IsolateT *isolate, int capacity, AllocationType allocation_type=AllocationType::kTrusted)
static Handle< TrustedFixedArray > New(IsolateT *isolate, int capacity, AllocationType allocation=AllocationType::kTrusted)
static Handle< TrustedWeakFixedArray > New(IsolateT *isolate, int capacity)
static V8_INLINE constexpr Tagged_t CompressAny(Address tagged)
static constexpr int kSize
static constexpr int SizeForCapacity(int capacity)
#define V8_STATIC_ROOTS_GENERATION_BOOL
#define WELL_KNOWN_SYMBOL_LIST_GENERATOR(V, _)
#define INTERNALIZED_STRING_FOR_PROTECTOR_LIST_GENERATOR(V, _)
#define IMPORTANT_INTERNALIZED_STRING_LIST_GENERATOR(V, _)
#define NOT_IMPORTANT_INTERNALIZED_STRING_LIST_GENERATOR(V, _)
#define PUBLIC_SYMBOL_LIST_GENERATOR(V, _)
#define WELL_KNOWN_SYMBOL_FOR_PROTECTOR_LIST_GENERATOR(V, _)
#define EXTRA_IMPORTANT_INTERNALIZED_STRING_LIST_GENERATOR(V, _)
#define SYMBOL_FOR_PROTECTOR_LIST_GENERATOR(V, _)
#define PUBLIC_SYMBOL_FOR_PROTECTOR_LIST_GENERATOR(V, _)
#define SINGLE_CHARACTER_INTERNALIZED_STRING_LIST_GENERATOR(V_, _)
#define NOT_IMPORTANT_PRIVATE_SYMBOL_LIST_GENERATOR(V, _)
#define IMPORTANT_PRIVATE_SYMBOL_LIST_GENERATOR(V, _)
SharedFunctionInfoRef shared
ZoneVector< RpoNumber > & result
V8_INLINE constexpr bool IsMaybeReadOnlyJSObject(InstanceType instance_type)
constexpr int kTaggedSize
constexpr double kMaxSafeInteger
constexpr intptr_t kObjectAlignment
@ USE_CUSTOM_MINIMUM_CAPACITY
constexpr uint64_t kHoleNanInt64
@ TERMINAL_FAST_ELEMENTS_KIND
V8_INLINE DirectHandle< T > direct_handle(Tagged< T > object, Isolate *isolate)
const int kVariableSizeSentinel
Handle< To > UncheckedCast(Handle< From > value)
constexpr int kSystemPointerSize
static const int kInvalidEnumCacheSentinel
bool IsTerminalElementsKind(ElementsKind kind)
refactor address components for immediate indexing make OptimizeMaglevOnNextCall optimize to turbofan instead of maglev filter for tracing turbofan compilation trace turbo cfg trace TurboFan s graph trimmer trace TurboFan s control equivalence trace TurboFan s register allocator trace stack load store counters for optimized code in run fuzzing &&concurrent_recompilation trace_turbo trace_turbo_scheduled trace_turbo_stack_accesses verify TurboFan machine graph of code stubs enable FixedArray bounds checks print TurboFan statistics of wasm compilations maximum cumulative size of bytecode considered for inlining scale factor of bytecode size used to calculate the inlining budget * KB
DONT_OVERRIDE DISABLE_ALLOCATION_SITES DISABLE_ALLOCATION_SITES HOLEY_DOUBLE_ELEMENTS
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit Map::Bits2::IsImmutablePrototypeBit Map::Bits3::IsDeprecatedBit Map::Bits3::IsPrototypeMapBit bit_field3
bool IsDictionaryElementsKind(ElementsKind kind)
constexpr AdaptArguments kAdapt
constexpr uint32_t kMaxUInt32
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
@ kHasSideEffectToReceiver
static constexpr RelaxedStoreTag kRelaxedStore
#define STRING_TYPE_LIST(V)
#define DATA_HANDLER_LIST(V, _)
#define ALLOCATION_SITE_LIST(V, _)
#define PUBLIC_SYMBOL_INIT(_, name, description)
#define ALLOCATE_PARTIAL_MAP(instance_type, size, field_name)
base::Vector< const char > contents
#define STRUCT_TABLE_ELEMENT(TYPE, Name, name)
#define ALLOCATE_ALWAYS_SHARED_SPACE_JSOBJECT_MAP(instance_type, size, field_name)
#define INTERNALIZED_STRING_INIT(_, name, description)
#define WELL_KNOWN_SYMBOL_INIT(_, name, description)
#define INIT_SIDE_EFFECT_FLAG(_, accessor_name, AccessorName, GetterType, SetterType)
#define ENSURE_SINGLE_CHAR_STRINGS_ARE_SINGLE_CHAR(_, name, contents)
#define ALLOCATE_SYMBOL_STRING(_, name, description)
#define TORQUE_ALLOCATE_MAP(NAME, Name, name)
#define TORQUE_ALLOCATE_VARSIZE_MAP(NAME, Name, name)
#define ALLOCATE_MAP(instance_type, size, field_name)
#define ALLOCATION_SITE_ELEMENT(_, TYPE, Name, Size, name)
#define DATA_HANDLER_ELEMENT(_, TYPE, Name, Size, name)
#define STRING_TYPE_ELEMENT(type, size, name, CamelName)
#define ALLOCATE_AND_SET_ROOT(Type, name, Size)
#define INIT_ACCESSOR_INFO(_, accessor_name, AccessorName,...)
#define CONSTANT_STRING_ELEMENT(_, name, contents)
#define SYMBOL_INIT(_, name)
#define ALLOCATE_VARSIZE_MAP(instance_type, field_name)
#define CHECK_IMPLIES(lhs, rhs)
#define CHECK_LT(lhs, rhs)
#define DCHECK_IMPLIES(v1, v2)
#define DCHECK_NE(v1, v2)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
constexpr T RoundUp(T x, intptr_t m)
#define V8_STATIC_ROOTS_BOOL