32 code(isolate)->marked_for_deoptimization()) {
41 if ((
result & CodeKindFlag::INTERPRETED_FUNCTION) == 0) {
43 if (
shared()->HasBytecodeArray()) {
44 result |= CodeKindFlag::INTERPRETED_FUNCTION;
48 if ((
result & CodeKindFlag::BASELINE) == 0) {
50 if (
shared()->HasBaselineCode()) {
51 result |= CodeKindFlag::BASELINE;
55#ifndef V8_ENABLE_LEAPTIERING
57 if (has_feedback_vector() && feedback_vector()->has_optimized_code() &&
59 ->optimized_code(isolate)
60 ->marked_for_deoptimization()) {
61 Tagged<Code> code = feedback_vector()->optimized_code(isolate);
71void JSFunction::TraceOptimizationStatus(
const char* format, ...) {
72 if (!
v8_flags.trace_opt_status)
return;
73 Isolate*
const isolate = GetIsolate();
74 PrintF(
"[optimization status (");
77 va_start(arguments, format);
78 base::OS::VPrint(format, arguments);
83 PrintF(
" (anonymous %p)",
reinterpret_cast<void*
>(ptr()));
87 if (!has_feedback_vector()) {
101 for (
int i = 0;
i < metadata->slot_count();
i++) {
102 FeedbackSlot slot(
i);
105 if (value.IsCleared()) {
111 PrintF(
" %i:", code->osr_offset().ToInt());
112 if (code->kind() == CodeKind::MAGLEV) {
115 DCHECK_EQ(CodeKind::TURBOFAN_JS, code->kind());
140 const int mask = kind_as_int_flag | (kind_as_int_flag - 1);
143 return (masked_available_kinds &
static_cast<CodeKinds>(~
mask)) != 0;
171 static_assert(CodeKind::TURBOFAN_JS > CodeKind::INTERPRETED_FUNCTION);
172 if (kinds == 0)
return false;
173 const int highest_tier_log2 =
176 *highest_tier =
static_cast<CodeKind>(highest_tier_log2);
184#if V8_ENABLE_WEBASSEMBLY
188 if (
shared()->HasAsmWasmData() ||
189 code(isolate)->builtin_id() == Builtin::kInstantiateAsmJs) {
198 CHECK(highest_tier == CodeKind::TURBOFAN_JS ||
199 highest_tier == CodeKind::BASELINE ||
200 highest_tier == CodeKind::MAGLEV ||
201 highest_tier == CodeKind::INTERPRETED_FUNCTION);
203 if (highest_tier == CodeKind::INTERPRETED_FUNCTION) {
204 CHECK(
code(isolate)->is_interpreter_trampoline_builtin() ||
206 code(isolate)->marked_for_deoptimization()) ||
207 (
code(isolate)->builtin_id() == Builtin::kCompileLazy &&
208 shared()->HasBytecodeArray() && !
shared()->HasBaselineCode()));
216 return GetActiveTier(isolate) == CodeKind::INTERPRETED_FUNCTION;
248#ifndef V8_ENABLE_LEAPTIERING
251 DCHECK(target_kind == CodeKind::MAGLEV ||
252 target_kind == CodeKind::TURBOFAN_JS);
253 return target_kind == CodeKind::MAGLEV
254 ? (
IsConcurrent(mode) ? TieringState::kRequestMaglev_Concurrent
255 : TieringState::kRequestMaglev_Synchronous)
266 if (!isolate->concurrent_recompilation_enabled() ||
267 isolate->bootstrapper()->IsActive()) {
277 !
shared()->optimization_disabled());
281 if (
v8_flags.trace_concurrent_recompilation) {
282 PrintF(
" ** Not marking ");
284 PrintF(
" -- already in optimization queue.\n");
288 if (
v8_flags.trace_concurrent_recompilation) {
291 PrintF(
" for concurrent %s recompilation.\n",
296#ifdef V8_ENABLE_LEAPTIERING
298 switch (target_kind) {
299 case CodeKind::MAGLEV:
302 jdt->SetTieringRequest(dispatch_handle(),
303 TieringBuiltin::kStartMaglevOptimizeJob,
307 jdt->SetTieringRequest(dispatch_handle(),
308 TieringBuiltin::kOptimizeMaglevEager, isolate);
312 case CodeKind::TURBOFAN_JS:
315 jdt->SetTieringRequest(dispatch_handle(),
316 TieringBuiltin::kStartTurbofanOptimizeJob,
320 jdt->SetTieringRequest(dispatch_handle(),
321 TieringBuiltin::kOptimizeTurbofanEager,
336 std::optional<CodeKind> override_active_tier) {
342 new_budget = std::max(current, new_budget);
345 new_budget = std::min(current, new_budget);
365 isolate->factory()->function_length_accessor();
367 isolate->factory()->length_string(), target,
369 if (!IsJSFunction(*target) ||
371 !length_lookup.
GetAccessors().is_identical_to(function_length_accessor)) {
382 length = isolate->factory()->NewNumber(std::max(
387 LookupIterator it(isolate, function, isolate->factory()->length_string(),
392 &it, length, it.property_attributes()),
402 isolate->factory()->function_name_accessor();
403 LookupIterator name_lookup(isolate, target, isolate->factory()->name_string(),
405 if (!IsJSFunction(*target) ||
407 !name_lookup.
GetAccessors().is_identical_to(function_name_accessor) ||
414 if (IsString(*target_name)) {
421 isolate, name, isolate->factory()->NewConsString(prefix, name),
425 name = isolate->factory()->empty_string();
429 LookupIterator it(isolate, function, isolate->factory()->name_string());
433 &it, name, it.property_attributes()),
445 Factory* factory = isolate->factory();
447 while (IsJSBoundFunction(function->bound_target_function())) {
453 if (IsJSWrappedFunction(function->bound_target_function())) {
461 if (IsJSFunction(function->bound_target_function())) {
474 int nof_bound_arguments = function->bound_arguments()->length();
475 while (IsJSBoundFunction(function->bound_target_function())) {
481 int length = function->bound_arguments()->length();
483 nof_bound_arguments +=
length;
488 if (IsJSWrappedFunction(function->bound_target_function())) {
491 int target_length = 0;
495 int length = std::max(0, target_length - nof_bound_arguments);
502 int target_length = target->length();
504 int length = std::max(0, target_length - nof_bound_arguments);
511 Isolate*
const isolate = function->GetIsolate();
512 return isolate->
factory()->function_native_code_string();
519 Factory* factory = isolate->factory();
522 if (IsJSBoundFunction(*target)) {
527 }
else if (IsJSFunction(*target)) {
542 if (IsJSBoundFunction(*target)) {
556 Isolate*
const isolate = function->GetIsolate();
557 return isolate->
factory()->function_native_code_string();
565 DCHECK(IsCallable(*value));
569 if (IsJSWrappedFunction(*value)) {
571 value =
direct_handle(target_wrapped->wrapped_target_function(), isolate);
583 isolate->factory()->NewJSWrappedFunction(creation_context, value);
592 DCHECK(isolate->has_exception());
594 isolate->clear_exception();
599 creation_context->type_error_function(), isolate);
604 NewError(type_error_function, MessageTemplate::kCannotWrap,
string),
616 if (function->shared()->name_should_print_as_anonymous()) {
617 return isolate->factory()->anonymous_string();
619 return handle(function->shared()->Name(), isolate);
625 Isolate*
const isolate = function->GetIsolate();
626 DCHECK(function->shared()->is_compiled());
627 DCHECK(function->shared()->HasFeedbackMetadata());
628#if V8_ENABLE_WEBASSEMBLY
629 if (function->shared()->HasAsmWasmData())
return;
633 DCHECK(shared->HasBytecodeArray());
635 (function->has_closure_feedback_cell_array() ||
636 function->has_feedback_vector());
648 const bool allocate_new_feedback_cell =
649 function->raw_feedback_cell() ==
650 *isolate->factory()->many_closures_cell();
654 if (allocate_new_feedback_cell) {
656 isolate->factory()->NewOneClosureCell(feedback_cell_array);
657#ifdef V8_ENABLE_LEAPTIERING
666 DCHECK(!function->code(isolate)->is_context_specialized());
667 feedback_cell->set_dispatch_handle(function->dispatch_handle());
669 function->set_raw_feedback_cell(*feedback_cell,
kReleaseStore);
671 function->raw_feedback_cell()->set_value(*feedback_cell_array,
685 DCHECK(function->shared()->HasFeedbackMetadata());
686 if (function->has_feedback_vector())
return;
687#if V8_ENABLE_WEBASSEMBLY
688 if (function->shared()->HasAsmWasmData())
return;
699 DCHECK(function->shared()->HasFeedbackMetadata());
700 DCHECK(!function->has_feedback_vector());
701#if V8_ENABLE_WEBASSEMBLY
702 DCHECK(!function->shared()->HasAsmWasmData());
706 DCHECK(function->shared()->HasBytecodeArray());
710 function->closure_feedback_cell_array(), isolate);
713 direct_handle(function->raw_feedback_cell(isolate), isolate),
715 USE(feedback_vector);
719 DCHECK(function->raw_feedback_cell() !=
720 *isolate->factory()->many_closures_cell());
721 DCHECK_EQ(function->raw_feedback_cell()->value(), *feedback_vector);
724#ifndef V8_ENABLE_LEAPTIERING
726 feedback_vector->log_next_execution());
729 if (
v8_flags.profile_guided_optimization &&
730 v8_flags.profile_guided_optimization_for_empty_feedback_vector &&
731 function->feedback_vector()->length() == 0) {
732 if (function->shared()->cached_tiering_decision() ==
734 function->RequestOptimization(isolate, CodeKind::MAGLEV,
736 }
else if (function->shared()->cached_tiering_decision() ==
738 function->RequestOptimization(isolate, CodeKind::TURBOFAN_JS,
747 bool reset_budget_for_feedback_allocation) {
748 Isolate*
const isolate = function->GetIsolate();
749#if V8_ENABLE_WEBASSEMBLY
755 if (function->shared()->HasAsmWasmData())
return;
758 if (function->has_feedback_vector()) {
759 CHECK_EQ(function->feedback_vector()->length(),
760 function->feedback_vector()->metadata()->slot_count());
765 function->has_closure_feedback_cell_array();
768 function->closure_feedback_cell_array()->length(),
769 function->shared()->feedback_metadata()->create_closure_slot_count());
772 const bool needs_feedback_vector =
777 !isolate->is_best_effort_code_coverage() ||
778 function->shared()->cached_tiering_decision() !=
781 if (needs_feedback_vector) {
788 if (reset_budget_for_feedback_allocation) {
794#ifdef V8_ENABLE_SPARKPLUG
796 if (function->shared()->cached_tiering_decision() !=
799 function->ActiveTierIsIgnition(isolate)) {
800 if (
v8_flags.baseline_batch_compilation) {
801 isolate->baseline_batch_compiler()->EnqueueFunction(function);
804 function->shared()->is_compiled_scope(isolate));
806 &is_compiled_inner_scope);
818 if (function->has_initial_map()) {
823 function->CompleteInobjectSlackTrackingIfActive();
827 if (!isolate->bootstrapper()->IsActive() &&
828 initial_map->instance_type() == JS_OBJECT_TYPE) {
832 function->set_prototype_or_initial_map(*value,
kReleaseStore);
838 DirectHandle<Map> new_map =
839 Map::Copy(isolate, initial_map,
"SetInstancePrototype");
842 *function != function->native_context()->array_function());
852 function->set_prototype_or_initial_map(*value,
kReleaseStore);
864 DCHECK(IsConstructor(*function) ||
866 Isolate* isolate = function->GetIsolate();
873 if (!IsJSReceiver(*value)) {
878 isolate,
direct_handle(function->map(), isolate),
"SetPrototype");
886 new_map->set_has_non_instance_prototype(
true);
887 new_map->SetConstructor(*non_instance_prototype_constructor_tuple);
903 function->map()->set_has_non_instance_prototype(
false);
906 SetInstancePrototype(isolate, function, construct_prototype);
921 if (map->prototype() != *prototype) {
924 map->SetConstructor(*constructor);
928 MapEvent(
"InitialMap", {},
map,
"",
935 DCHECK(function->has_prototype_slot());
936 DCHECK(IsConstructor(*function) ||
938 if (function->has_initial_map())
return;
939 Isolate* isolate = function->GetIsolate();
941 int expected_nof_properties =
947 if (function->has_initial_map())
return;
954 ? JS_ASYNC_GENERATOR_OBJECT_TYPE
955 : JS_GENERATOR_OBJECT_TYPE;
957 instance_type = JS_OBJECT_TYPE;
961 int inobject_properties;
963 &instance_size, &inobject_properties);
968 creation_context, instance_type, instance_size,
973 if (function->has_instance_prototype()) {
974 prototype =
direct_handle(function->instance_prototype(), isolate);
975 map->set_prototype(*prototype);
977 prototype = isolate->factory()->NewFunctionPrototype(function);
980 DCHECK(map->has_fast_object_elements());
986 CHECK(IsJSReceiver(*prototype));
988 map->StartInobjectSlackTracking();
994bool CanSubclassHaveInobjectProperties(
InstanceType instance_type) {
995 switch (instance_type) {
996 case JS_API_OBJECT_TYPE:
997 case JS_ARRAY_BUFFER_TYPE:
998 case JS_ARRAY_ITERATOR_PROTOTYPE_TYPE:
1000 case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE:
1001 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
1002 case JS_DATA_VIEW_TYPE:
1003 case JS_RAB_GSAB_DATA_VIEW_TYPE:
1005 case JS_GENERATOR_OBJECT_TYPE:
1006 case JS_FUNCTION_TYPE:
1007 case JS_CLASS_CONSTRUCTOR_TYPE:
1008 case JS_PROMISE_CONSTRUCTOR_TYPE:
1009 case JS_REG_EXP_CONSTRUCTOR_TYPE:
1010 case JS_ARRAY_CONSTRUCTOR_TYPE:
1011 case JS_ASYNC_DISPOSABLE_STACK_TYPE:
1012 case JS_SYNC_DISPOSABLE_STACK_TYPE:
1013#define TYPED_ARRAY_CONSTRUCTORS_SWITCH(Type, type, TYPE, Ctype) \
1014 case TYPE##_TYPED_ARRAY_CONSTRUCTOR_TYPE:
1016#undef TYPED_ARRAY_CONSTRUCTORS_SWITCH
1017 case JS_ITERATOR_PROTOTYPE_TYPE:
1018 case JS_MAP_ITERATOR_PROTOTYPE_TYPE:
1019 case JS_OBJECT_PROTOTYPE_TYPE:
1020 case JS_PROMISE_PROTOTYPE_TYPE:
1021 case JS_REG_EXP_PROTOTYPE_TYPE:
1022 case JS_SET_ITERATOR_PROTOTYPE_TYPE:
1023 case JS_SET_PROTOTYPE_TYPE:
1024 case JS_STRING_ITERATOR_PROTOTYPE_TYPE:
1025 case JS_TYPED_ARRAY_PROTOTYPE_TYPE:
1026#ifdef V8_INTL_SUPPORT
1027 case JS_COLLATOR_TYPE:
1028 case JS_DATE_TIME_FORMAT_TYPE:
1029 case JS_DISPLAY_NAMES_TYPE:
1030 case JS_DURATION_FORMAT_TYPE:
1031 case JS_LIST_FORMAT_TYPE:
1032 case JS_LOCALE_TYPE:
1033 case JS_NUMBER_FORMAT_TYPE:
1034 case JS_PLURAL_RULES_TYPE:
1035 case JS_RELATIVE_TIME_FORMAT_TYPE:
1036 case JS_SEGMENT_ITERATOR_TYPE:
1037 case JS_SEGMENTER_TYPE:
1038 case JS_SEGMENTS_TYPE:
1039 case JS_V8_BREAK_ITERATOR_TYPE:
1041 case JS_ASYNC_FUNCTION_OBJECT_TYPE:
1042 case JS_ASYNC_GENERATOR_OBJECT_TYPE:
1044 case JS_MESSAGE_OBJECT_TYPE:
1045 case JS_OBJECT_TYPE:
1047 case JS_FINALIZATION_REGISTRY_TYPE:
1048 case JS_ARGUMENTS_OBJECT_TYPE:
1049 case JS_PROMISE_TYPE:
1050 case JS_REG_EXP_TYPE:
1052 case JS_SHADOW_REALM_TYPE:
1053 case JS_SPECIAL_API_OBJECT_TYPE:
1054 case JS_TYPED_ARRAY_TYPE:
1055 case JS_PRIMITIVE_WRAPPER_TYPE:
1056 case JS_TEMPORAL_CALENDAR_TYPE:
1057 case JS_TEMPORAL_DURATION_TYPE:
1058 case JS_TEMPORAL_INSTANT_TYPE:
1059 case JS_TEMPORAL_PLAIN_DATE_TYPE:
1060 case JS_TEMPORAL_PLAIN_DATE_TIME_TYPE:
1061 case JS_TEMPORAL_PLAIN_MONTH_DAY_TYPE:
1062 case JS_TEMPORAL_PLAIN_TIME_TYPE:
1063 case JS_TEMPORAL_PLAIN_YEAR_MONTH_TYPE:
1064 case JS_TEMPORAL_TIME_ZONE_TYPE:
1065 case JS_TEMPORAL_ZONED_DATE_TIME_TYPE:
1066 case JS_WEAK_MAP_TYPE:
1067 case JS_WEAK_REF_TYPE:
1068 case JS_WEAK_SET_TYPE:
1069#if V8_ENABLE_WEBASSEMBLY
1070 case WASM_GLOBAL_OBJECT_TYPE:
1071 case WASM_INSTANCE_OBJECT_TYPE:
1072 case WASM_MEMORY_OBJECT_TYPE:
1073 case WASM_MODULE_OBJECT_TYPE:
1074 case WASM_TABLE_OBJECT_TYPE:
1075 case WASM_VALUE_OBJECT_TYPE:
1080 case OBJECT_BOILERPLATE_DESCRIPTION_TYPE:
1081 case BYTECODE_ARRAY_TYPE:
1082 case BYTE_ARRAY_TYPE:
1084 case INSTRUCTION_STREAM_TYPE:
1086 case FIXED_ARRAY_TYPE:
1087 case SCRIPT_CONTEXT_TABLE_TYPE:
1088 case FIXED_DOUBLE_ARRAY_TYPE:
1089 case FEEDBACK_METADATA_TYPE:
1091 case FREE_SPACE_TYPE:
1092 case HASH_TABLE_TYPE:
1093 case ORDERED_HASH_MAP_TYPE:
1094 case ORDERED_HASH_SET_TYPE:
1095 case ORDERED_NAME_DICTIONARY_TYPE:
1096 case NAME_DICTIONARY_TYPE:
1097 case GLOBAL_DICTIONARY_TYPE:
1098 case NUMBER_DICTIONARY_TYPE:
1099 case SIMPLE_NUMBER_DICTIONARY_TYPE:
1100 case HEAP_NUMBER_TYPE:
1101 case JS_BOUND_FUNCTION_TYPE:
1102 case JS_GLOBAL_OBJECT_TYPE:
1103 case JS_GLOBAL_PROXY_TYPE:
1105 case JS_WRAPPED_FUNCTION_TYPE:
1108 case PROPERTY_CELL_TYPE:
1109 case CONTEXT_SIDE_PROPERTY_CELL_TYPE:
1110 case SHARED_FUNCTION_INFO_TYPE:
1112 case ALLOCATION_SITE_TYPE:
1114#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1115 case FIXED_##TYPE##_ARRAY_TYPE:
1116#undef TYPED_ARRAY_CASE
1118#define MAKE_STRUCT_CASE(TYPE, Name, name) case TYPE:
1120#undef MAKE_STRUCT_CASE
1125 if (InstanceTypeChecker::IsJSApiObject(instance_type))
return true;
1131bool FastInitializeDerivedMap(Isolate* isolate,
1133 DirectHandle<JSFunction> constructor,
1134 DirectHandle<Map> constructor_initial_map) {
1136 if (!
new_target->has_prototype_slot())
return false;
1140 new_target->initial_map()->GetConstructor() == *constructor) {
1144 InstanceType instance_type = constructor_initial_map->instance_type();
1145 DCHECK(CanSubclassHaveInobjectProperties(instance_type));
1154 int in_object_properties;
1155 int embedder_fields =
1163 int expected_nof_properties = std::max(
1164 static_cast<int>(constructor->shared()->expected_nof_properties()),
1167 instance_type, constructor_initial_map->has_prototype_slot(),
1168 embedder_fields, expected_nof_properties, &instance_size,
1169 &in_object_properties);
1171 int pre_allocated = constructor_initial_map->GetInObjectProperties() -
1172 constructor_initial_map->UnusedPropertyFields();
1173 CHECK_LE(constructor_initial_map->UsedInstanceSize(), instance_size);
1174 int unused_property_fields = in_object_properties - pre_allocated;
1175 DirectHandle<Map> map =
1177 in_object_properties, unused_property_fields);
1178 map->set_new_target_is_base(
false);
1184 map->StartInobjectSlackTracking();
1207 if (InstanceTypeChecker::IsJSFunction(new_target_instance_type)) {
1209 if (FastInitializeDerivedMap(isolate, function, constructor,
1210 constructor_initial_map)) {
1211 return handle(function->initial_map(), isolate);
1219 if (InstanceTypeChecker::IsJSFunction(new_target_instance_type) &&
1229 isolate->factory()->prototype_string();
1236 constructor_initial_map =
1244 if (!IsJSReceiver(*prototype)) {
1249 isolate, constructor,
1250 isolate->factory()->native_context_index_symbol());
1252 : Context::OBJECT_FUNCTION_INDEX;
1255 prototype =
direct_handle(realm_constructor->prototype(), isolate);
1257 DCHECK_EQ(constructor_initial_map->constructor_or_back_pointer(),
1267#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) \
1268 static_assert(Context::TYPE##_ARRAY_FUN_INDEX == \
1269 Context::FIRST_FIXED_TYPED_ARRAY_FUN_INDEX + \
1270 ElementsKind::TYPE##_ELEMENTS - \
1271 ElementsKind::FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND); \
1272 static_assert(Context::RAB_GSAB_##TYPE##_ARRAY_MAP_INDEX == \
1273 Context::FIRST_RAB_GSAB_TYPED_ARRAY_MAP_INDEX + \
1274 ElementsKind::TYPE##_ELEMENTS - \
1275 ElementsKind::FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND);
1278#undef TYPED_ARRAY_CASE
1280int TypedArrayElementsKindToConstructorIndex(
ElementsKind elements_kind) {
1285int TypedArrayElementsKindToRabGsabCtorIndex(
ElementsKind elements_kind) {
1298 if (!maybe_map.
ToHandle(&map))
return {};
1303 TypedArrayElementsKindToConstructorIndex(map->elements_kind());
1304 if (*
new_target == context->get(ctor_index)) {
1306 TypedArrayElementsKindToRabGsabCtorIndex(map->elements_kind());
1315 rab_gsab_map->set_elements_kind(
1317 return rab_gsab_map;
1327 if (!maybe_map.
ToHandle(&map))
return {};
1328 if (*map == constructor->initial_map()) {
1337 rab_gsab_map->set_instance_type(JS_RAB_GSAB_DATA_VIEW_TYPE);
1338 return rab_gsab_map;
1342 CHECK(has_initial_map());
1343 if (initial_map()->IsInobjectSlackTrackingInProgress()) {
1344 int slack = initial_map()->ComputeMinObjectSlack(isolate);
1345 return initial_map()->InstanceSizeFromSlack(slack);
1347 return initial_map()->instance_size();
1351 return shared()->DebugNameCStr();
1361 DCHECK(IsJSFunctionMap(map));
1362 if (map->NumberOfOwnDescriptors() <
1366 DCHECK(!map->is_dictionary_map());
1368 ReadOnlyRoots roots(isolate);
1369 auto descriptors = map->instance_descriptors(isolate);
1370 InternalIndex kNameIndex{JSFunction::kNameDescriptorIndex};
1371 if (descriptors->GetKey(kNameIndex) != roots.name_string() ||
1372 !descriptors->GetValue(kNameIndex)
1373 .GetHeapObjectIfStrong(isolate, &value)) {
1376 return IsAccessorInfo(value);
1389 Isolate* isolate = function->GetIsolate();
1390 if (!UseFastFunctionNameLookup(isolate, function->map())) {
1399 GetDataProperty(isolate, function, isolate->factory()->name_string());
1408 Isolate* isolate = function->GetIsolate();
1412 if (prefix->length() > 0) {
1423 function, isolate->factory()->name_string(), function_name,
1434 builder.AppendCStringLiteral(
"function ");
1435 builder.AppendString(
direct_handle(shared_info->Name(), isolate));
1436 builder.AppendCStringLiteral(
"() { [native code] }");
1437 return builder.Finish().ToHandleChecked();
1444 Isolate*
const isolate = function->GetIsolate();
1448 if (!shared_info->IsUserJavaScript()) {
1449 return NativeCodeFunctionSourceString(isolate, shared_info);
1455 isolate, function, isolate->factory()->class_positions_symbol());
1456 if (IsClassPositions(*maybe_class_positions)) {
1459 int start_position = class_positions->start();
1460 int end_position = class_positions->end();
1463 return isolate->factory()->NewSubString(script_source, start_position,
1469 if (!shared_info->HasSourceCode()) {
1470 return NativeCodeFunctionSourceString(isolate, shared_info);
1475#if V8_ENABLE_WEBASSEMBLY
1476 if (shared_info->HasWasmExportedFunctionData()) {
1478 shared_info->wasm_exported_function_data(), isolate);
1480 if (is_asmjs_module(module)) {
1481 std::pair<int, int> offsets =
1482 module->asm_js_offset_information->GetFunctionOffsets(
1483 declared_function_index(module, function_data->function_index()));
1486 return isolate->factory()->NewSubString(source, offsets.first,
1496 isolate->CountUsage(
1498 return NativeCodeFunctionSourceString(isolate, shared_info);
1507 int expected_nof_properties = 0;
1509 !iter.
IsAtEnd(); iter.Advance()) {
1512 if (!IsJSFunction(*current))
break;
1517 IsCompiledScope is_compiled_scope(shared->is_compiled_scope(isolate));
1520 &is_compiled_scope)) {
1521 DCHECK(shared->is_compiled());
1522 int count = shared->expected_nof_properties();
1525 expected_nof_properties +=
count;
1539 if (expected_nof_properties > 0) {
1540 expected_nof_properties += 8;
1545 return expected_nof_properties;
1551 int requested_embedder_fields,
1552 int requested_in_object_properties,
1554 int* in_object_properties) {
1555 DCHECK_LE(
static_cast<unsigned>(requested_embedder_fields),
1560 int max_nof_fields =
1563 CHECK_LE(
static_cast<unsigned>(requested_embedder_fields),
1564 static_cast<unsigned>(max_nof_fields));
1565 *in_object_properties = std::min(requested_in_object_properties,
1566 max_nof_fields - requested_embedder_fields);
1569 ((requested_embedder_fields + *in_object_properties) <<
kTaggedSizeLog2);
1572 requested_embedder_fields);
1573 CHECK_LE(
static_cast<unsigned>(*instance_size),
1578 Isolate* isolate = GetIsolate();
1580 if (has_feedback_vector()) {
1582 if (vector->ClearAllSlotsForTesting(isolate)) {
1584 "ClearAllTypeFeedbackInfoForTesting");
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype)
@ kFunctionTokenOffsetTooLongForToString
V8_INLINE T FromJust() const &
V8_INLINE bool IsNothing() const
static V8_EXPORT_PRIVATE DirectHandle< ClosureFeedbackCellArray > New(Isolate *isolate, DirectHandle< SharedFunctionInfo > shared, AllocationType allocation=AllocationType::kYoung)
static bool CompileBaseline(Isolate *isolate, DirectHandle< JSFunction > function, ClearExceptionFlag flag, IsCompiledScope *is_compiled_scope)
static bool Compile(Isolate *isolate, Handle< SharedFunctionInfo > shared, ClearExceptionFlag flag, IsCompiledScope *is_compiled_scope, CreateSourcePositions create_source_positions_flag=CreateSourcePositions::kNo)
static const int FIRST_FIXED_TYPED_ARRAY_FUN_INDEX
static const int FIRST_RAB_GSAB_TYPED_ARRAY_MAP_INDEX
@ kInitialMapChangedGroup
static void DeoptimizeDependencyGroups(Isolate *isolate, ObjectT object, DependencyGroups groups)
V8_INLINE bool is_null() const
V8_WARN_UNUSED_RESULT HandleType< String >::MaybeType NewConsString(HandleType< String > left, HandleType< String > right, AllocationType allocation=AllocationType::kYoung)
static FeedbackSlot Invalid()
static V8_EXPORT_PRIVATE Handle< FeedbackVector > New(Isolate *isolate, DirectHandle< SharedFunctionInfo > shared, DirectHandle< ClosureFeedbackCellArray > closure_feedback_cell_array, DirectHandle< FeedbackCell > parent_feedback_cell, IsCompiledScope *is_compiled_scope)
static void OnFeedbackChanged(Isolate *isolate, Tagged< FeedbackVector > vector, FeedbackSlot slot, const char *reason)
MaybeDirectHandle< String > Finish()
V8_INLINE void AppendCharacter(uint8_t c)
V8_INLINE void AppendString(std::string_view str)
static IsolateGroup * current()
v8::internal::Factory * factory()
static MaybeHandle< String > GetName(Isolate *isolate, DirectHandle< JSBoundFunction > function)
static Maybe< int > GetLength(Isolate *isolate, DirectHandle< JSBoundFunction > function)
static DirectHandle< String > ToString(DirectHandle< JSBoundFunction > function)
static Maybe< bool > CopyNameAndLength(Isolate *isolate, DirectHandle< JSFunctionOrBoundFunctionOrWrappedFunction > function, DirectHandle< JSReceiver > target, DirectHandle< String > prefix, int arg_count)
std::unique_ptr< char[]> DebugNameCStr()
static void CalculateInstanceSizeHelper(InstanceType instance_type, bool has_prototype_slot, int requested_embedder_fields, int requested_in_object_properties, int *instance_size, int *in_object_properties)
void ClearAllTypeFeedbackInfoForTesting()
Tagged< Context > context()
void RequestOptimization(Isolate *isolate, CodeKind target_kind, ConcurrencyMode mode=ConcurrencyMode::kConcurrent)
bool HasAvailableHigherTierCodeThan(IsolateForSandbox isolate, CodeKind kind) const
static void SetPrototype(DirectHandle< JSFunction > function, DirectHandle< Object > value)
int ComputeInstanceSizeWithMinSlack(Isolate *isolate)
bool tiering_in_progress() const
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Map > GetDerivedRabGsabDataViewMap(Isolate *isolate, DirectHandle< JSReceiver > new_target)
static V8_WARN_UNUSED_RESULT bool SetName(DirectHandle< JSFunction > function, DirectHandle< Name > name, DirectHandle< String > prefix)
static V8_EXPORT_PRIVATE void EnsureFeedbackVector(Isolate *isolate, DirectHandle< JSFunction > function, IsCompiledScope *compiled_scope)
FeedbackVector eventually. Generally this shouldn't be used to get the.
static V8_WARN_UNUSED_RESULT int CalculateExpectedNofProperties(Isolate *isolate, DirectHandle< JSFunction > function)
bool IsMaglevRequested(Isolate *isolate) const
static Handle< String > GetName(Isolate *isolate, DirectHandle< JSFunction > function)
bool HasAvailableCodeKind(IsolateForSandbox isolate, CodeKind kind) const
bool HasAvailableHigherTierCodeThanWithFilter(IsolateForSandbox isolate, CodeKind kind, CodeKinds filter_mask) const
void set_tiering_state(IsolateForSandbox isolate, TieringState state)
CodeKinds GetAttachedCodeKinds(IsolateForSandbox isolate) const
bool HasAvailableOptimizedCode(IsolateForSandbox isolate) const
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Map > GetDerivedRabGsabTypedArrayMap(Isolate *isolate, DirectHandle< JSFunction > constructor, DirectHandle< JSReceiver > new_target)
bool has_closure_feedback_cell_array() const
bool ActiveTierIsMaglev(IsolateForSandbox isolate) const
static V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT MaybeHandle< Map > GetDerivedMap(Isolate *isolate, DirectHandle< JSFunction > constructor, DirectHandle< JSReceiver > new_target)
static DirectHandle< String > GetDebugName(DirectHandle< JSFunction > function)
static const int kMinDescriptorsForFastBindAndWrap
bool HasAttachedCodeKind(IsolateForSandbox isolate, CodeKind kind) const
bool is_compiled(IsolateForSandbox isolate) const
static void InitializeFeedbackCell(DirectHandle< JSFunction > function, IsCompiledScope *compiled_scope, bool reset_budget_for_feedback_allocation)
static V8_EXPORT_PRIVATE void EnsureHasInitialMap(DirectHandle< JSFunction > function)
bool IsTurbofanRequested(Isolate *isolate) const
bool ActiveTierIsBaseline(IsolateForSandbox isolate) const
static void EnsureClosureFeedbackCellArray(DirectHandle< JSFunction > function)
static DirectHandle< String > ToString(DirectHandle< JSFunction > function)
Tagged< ClosureFeedbackCellArray > closure_feedback_cell_array() const
CodeKinds GetAvailableCodeKinds(IsolateForSandbox isolate) const
Tagged< NativeContext > native_context()
V8_EXPORT_PRIVATE bool HasAttachedOptimizedCode(IsolateForSandbox isolate) const
void SetInterruptBudget(Isolate *isolate, BudgetModification kind, std::optional< CodeKind > override_active_tier={})
static void SetInitialMap(Isolate *isolate, DirectHandle< JSFunction > function, DirectHandle< Map > map, DirectHandle< JSPrototype > prototype)
bool ActiveTierIsTurbofan(IsolateForSandbox isolate) const
static void CreateAndAttachFeedbackVector(Isolate *isolate, DirectHandle< JSFunction > function, IsCompiledScope *compiled_scope)
std::optional< CodeKind > GetActiveTier(IsolateForSandbox isolate) const
void ResetIfCodeFlushed(Isolate *isolate, std::optional< std::function< void(Tagged< HeapObject > object, ObjectSlot slot, Tagged< HeapObject > target)> > gc_notify_updated_slot=std::nullopt)
bool CanDiscardCompiled(IsolateForSandbox isolate) const
V8_EXPORT_PRIVATE bool ActiveTierIsIgnition(IsolateForSandbox isolate) const
void PrintName(FILE *out=stdout)
static const int kMaxInObjectProperties
static V8_WARN_UNUSED_RESULT HandleType< Object >::MaybeType DefineOwnPropertyIgnoreAttributes(LookupIterator *it, HandleType< T > value, PropertyAttributes attributes, AccessorInfoHandling handling=DONT_FORCE_FIELD, EnforceDefineSemantics semantics=EnforceDefineSemantics::kSet)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > DefinePropertyOrElementIgnoreAttributes(DirectHandle< JSObject > object, DirectHandle< Name > name, DirectHandle< Object > value, PropertyAttributes attributes=NONE)
static void OptimizeAsPrototype(DirectHandle< JSObject > object, bool enable_setup_mode=true)
int GetEmbedderFieldCount() const
static const int kMaxInstanceSize
static const int kMaxEmbedderFields
static V8_EXPORT_PRIVATE void MigrateToMap(Isolate *isolate, DirectHandle< JSObject > object, DirectHandle< Map > new_map, int expected_additional_properties=0)
static V8_EXPORT_PRIVATE int GetHeaderSize(InstanceType instance_type, bool function_has_prototype_slot=false)
static MaybeDirectHandle< NativeContext > GetFunctionRealm(DirectHandle< JSReceiver > receiver)
static Handle< Object > GetDataProperty(Isolate *isolate, DirectHandle< JSReceiver > object, DirectHandle< Name > name)
static V8_WARN_UNUSED_RESULT Maybe< PropertyAttributes > GetPropertyAttributes(Isolate *isolate, DirectHandle< JSReceiver > object, DirectHandle< Name > name)
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > GetProperty(Isolate *isolate, DirectHandle< JSReceiver > receiver, const char *key)
static DirectHandle< String > ToString(DirectHandle< JSWrappedFunction > function)
static Maybe< int > GetLength(Isolate *isolate, DirectHandle< JSWrappedFunction > function)
static MaybeDirectHandle< Object > Create(Isolate *isolate, DirectHandle< NativeContext > creation_context, DirectHandle< JSReceiver > value)
static MaybeHandle< String > GetName(Isolate *isolate, DirectHandle< JSWrappedFunction > function)
DirectHandle< Object > GetAccessors() const
bool HolderIsReceiver() const
static const int kNoSlackTracking
static Handle< Map > Copy(Isolate *isolate, DirectHandle< Map > map, const char *reason, TransitionKindFlag kind=SPECIAL_TRANSITION)
static V8_EXPORT_PRIVATE void SetPrototype(Isolate *isolate, DirectHandle< Map > map, DirectHandle< JSPrototype > prototype, bool enable_prototype_setup_mode=true)
static Handle< Map > GetDerivedMap(Isolate *isolate, DirectHandle< Map > from, DirectHandle< JSReceiver > prototype)
static Handle< Map > CopyInitialMap(Isolate *isolate, DirectHandle< Map > map)
V8_WARN_UNUSED_RESULT V8_INLINE bool ToHandle(DirectHandle< S > *out) const
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > ToFunctionName(Isolate *isolate, DirectHandle< Name > name)
static V8_EXPORT_PRIVATE DirectHandle< String > NoSideEffectsToString(Isolate *isolate, DirectHandle< Object > input)
static double NumberValue(Tagged< Number > obj)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Object > GetProperty(LookupIterator *it, bool is_global_reference=false)
Tagged< T > GetCurrent() const
static Handle< Object > GetSourceCodeHarmony(Isolate *isolate, DirectHandle< SharedFunctionInfo > shared)
static Handle< String > DebugName(Isolate *isolate, DirectHandle< SharedFunctionInfo > shared)
static constexpr int ToInt(const Tagged< Object > object)
static constexpr Tagged< Smi > zero()
static constexpr int kMaxValue
static int InterruptBudgetFor(Isolate *isolate, Tagged< JSFunction > function, std::optional< CodeKind > override_active_tier={})
#define THROW_NEW_ERROR_RETURN_VALUE(isolate, call, value)
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
#define STACK_CHECK(isolate, result_value)
#define RETURN_ON_EXCEPTION_VALUE(isolate, call, value)
#define MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
DirectHandle< Object > new_target
SharedFunctionInfoRef shared
ZoneVector< RpoNumber > & result
#define LOG(isolate, Call)
InstructionOperand source
constexpr unsigned CountLeadingZeros(T value)
constexpr bool IsPowerOfTwo(T value)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
constexpr bool CodeKindIsOptimizedJSFunction(CodeKind kind)
constexpr int kNoSourcePosition
bool IsClassConstructor(FunctionKind kind)
bool IsNumber(Tagged< Object > obj)
void PrintF(const char *format,...)
const char * CodeKindToString(CodeKind kind)
Tagged(T object) -> Tagged< T >
bool IsGeneratorFunction(FunctionKind kind)
bool IsDerivedConstructor(FunctionKind kind)
double DoubleToInteger(double x)
ElementsKind GetCorrespondingRabGsabElementsKind(ElementsKind typed_array_kind)
bool IsResumableFunction(FunctionKind kind)
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
V8_INLINE IndirectHandle< T > indirect_handle(DirectHandle< T > handle)
kInterpreterTrampolineOffset Tagged< HeapObject >
bool IsAsyncFunction(FunctionKind kind)
@ FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND
@ TERMINAL_FAST_ELEMENTS_KIND
V8_INLINE DirectHandle< T > direct_handle(Tagged< T > object, Isolate *isolate)
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
constexpr int kTaggedSizeLog2
constexpr int kEmbedderDataSlotSizeInTaggedSlots
constexpr CodeKindFlag CodeKindToCodeKindFlag(CodeKind kind)
bool IsAsyncGeneratorFunction(FunctionKind kind)
constexpr JSDispatchHandle kNullJSDispatchHandle(0)
void ShortPrint(Tagged< Object > obj, FILE *out)
bool IsJSObjectThatCanBeTrackedAsPrototype(Tagged< Object > obj)
static constexpr CodeKinds kOptimizedJSFunctionCodeKindsMask
static constexpr CodeKinds kJSFunctionCodeKindsMask
V8_EXPORT_PRIVATE FlagValues v8_flags
constexpr bool CodeKindIsJSFunction(CodeKind kind)
constexpr bool IsConcurrent(ConcurrencyMode mode)
kInstanceDescriptorsOffset kTransitionsOrPrototypeInfoOffset prototype
bool CanCompileWithBaseline(Isolate *isolate, Tagged< SharedFunctionInfo > shared)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
static constexpr ReleaseStoreTag kReleaseStore
Maybe< T > Just(const T &t)
#define MAKE_STRUCT_CASE(TYPE, Name, name)
#define DCHECK_LE(v1, v2)
#define CHECK_LE(lhs, rhs)
#define DCHECK_IMPLIES(v1, v2)
#define DCHECK_NE(v1, v2)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define TYPED_ARRAY_CONSTRUCTORS_SWITCH(Type, type, TYPE, Ctype)
#define V8_LIKELY(condition)
#define V8_WARN_UNUSED_RESULT