14#if V8_ENABLE_WEBASSEMBLY
23 return fun == fun->native_context()->promise_all();
29 return fun == fun->native_context()->promise_all_settled();
35 return fun == fun->native_context()->promise_any();
39#if V8_ENABLE_WEBASSEMBLY
40 if (IsBuiltin())
return true;
56#if V8_ENABLE_WEBASSEMBLY
57 if (IsWasm())
return false;
58 if (IsBuiltin())
return false;
64#if V8_ENABLE_WEBASSEMBLY
65 if (IsWasm())
return false;
66 if (IsBuiltin())
return false;
72 return IsJSGlobalProxy(receiver_or_instance()) ||
78 Isolate* isolate = info->GetIsolate();
79#if V8_ENABLE_WEBASSEMBLY
80 if (info->IsWasm() && !info->IsAsmJsWasm()) {
85 if (
GetScript(isolate, info).ToHandle(&script)) {
88 if (script->HasSourceURLComment()) {
89 line_number -= script->line_offset();
98 Isolate* isolate = callsite_info->GetIsolate();
100#if V8_ENABLE_WEBASSEMBLY
101 if (callsite_info->IsWasm() && !callsite_info->IsAsmJsWasm()) {
106 if (
GetScript(isolate, callsite_info).ToHandle(&script)) {
109 int column_number = position_info.
column + 1;
110 if (script->HasSourceURLComment() &&
111 position_info.
line == script->line_offset()) {
112 column_number -= script->column_offset();
114 return column_number;
121 Isolate* isolate = info->GetIsolate();
122#if V8_ENABLE_WEBASSEMBLY
123 if (info->IsWasm() && !info->IsAsmJsWasm()) {
128 if (!
GetScript(isolate, info).ToHandle(&script)) {
131#if V8_ENABLE_WEBASSEMBLY
132 if (info->IsAsmJsWasm()) {
133 auto*
module = info->GetWasmInstance()->module();
134 auto func_index = info->GetWasmFunctionIndex();
136 info->IsAsmJsAtNumberConversion());
140 int position = info->GetSharedFunctionInfo()->function_token_position();
146 Isolate* isolate = info->GetIsolate();
147#if V8_ENABLE_WEBASSEMBLY
148 if (info->IsWasm() && !info->IsAsmJsWasm()) {
149 auto*
module = info->GetWasmInstance()->module();
150 auto func_index = info->GetWasmFunctionIndex();
151 return GetWasmFunctionOffset(module, func_index);
155 if (!
GetScript(isolate, info).ToHandle(&script)) {
158#if V8_ENABLE_WEBASSEMBLY
159 if (info->IsAsmJsWasm()) {
160 auto*
module = info->GetWasmInstance()->module();
161 auto func_index = info->GetWasmFunctionIndex();
163 info->IsAsmJsAtNumberConversion());
167 int position = info->GetSharedFunctionInfo()->function_token_position();
173 return script.value()->id();
180 return script.value()->name();
187 return script.value()->GetNameOrSourceURL();
194 if (script.value()->HasValidSource()) {
195 return script.value()->source();
203 return script.value()->source_mapping_url();
212 Isolate* isolate = info->GetIsolate();
213 if (!
GetScript(isolate, info).ToHandle(&script)) {
214 return isolate->factory()->empty_string();
216 if (script->HasValidSource()) {
219 return isolate->
factory()->empty_string();
227 if (IsString(*sourceURL))
return Cast<String>(sourceURL);
230 builder.AppendCStringLiteral(
"eval at ");
231 if (script->has_eval_from_shared()) {
235 if (eval_name->length() != 0) {
236 builder.AppendString(eval_name);
238 builder.AppendCStringLiteral(
"<anonymous>");
240 if (IsScript(eval_shared->script())) {
241 DirectHandle<Script> eval_script(
Cast<Script>(eval_shared->script()),
243 builder.AppendCStringLiteral(
" (");
246 DirectHandle<String> str;
248 FormatEvalOrigin(isolate, eval_script));
249 builder.AppendString(str);
252 DirectHandle<Object> eval_script_name(eval_script->name(), isolate);
253 if (IsString(*eval_script_name)) {
255 Script::PositionInfo
info;
259 builder.AppendCharacter(
':');
260 builder.AppendInt(info.line + 1);
261 builder.AppendCharacter(
':');
262 builder.AppendInt(info.column + 1);
265 builder.AppendCStringLiteral(
"unknown source");
268 builder.AppendCharacter(
')');
271 builder.AppendCStringLiteral(
"<anonymous>");
281 auto isolate = info->GetIsolate();
283 if (!
GetScript(isolate, info).ToHandle(&script) ||
285 return isolate->factory()->undefined_value();
287 return FormatEvalOrigin(isolate, script).ToHandleChecked();
293 Isolate* isolate = info->GetIsolate();
294#if V8_ENABLE_WEBASSEMBLY
295 if (info->IsWasm()) {
297 info->GetWasmInstance()->module_object(), isolate);
298 uint32_t func_index = info->GetWasmFunctionIndex();
305 return isolate->factory()->null_value();
307 if (info->IsBuiltin()) {
309 return isolate->factory()->NewStringFromAsciiChecked(
315 if (function->shared()->HasBuiltinId()) {
316 Builtin builtin = function->shared()->builtin_id();
317 const char* maybe_known_name =
319 if (maybe_known_name) {
323 return isolate->factory()->NewStringFromAsciiChecked(maybe_known_name);
327 if (name->length() != 0)
return name;
328 if (info->IsEval())
return isolate->factory()->eval_string();
329 return isolate->factory()->null_value();
335 Isolate* isolate = info->GetIsolate();
336#if V8_ENABLE_WEBASSEMBLY
337 if (info->IsWasm()) {
340 direct_handle(info->GetWasmInstance()->trusted_data(isolate), isolate),
341 info->GetWasmFunctionIndex());
343 if (info->IsBuiltin()) {
350 if (name->length() == 0 && info->IsEval()) {
351 name = isolate->factory()->eval_string();
364 for (
auto i : map->IterateOwnDescriptors()) {
366 if (IsSymbol(
key))
continue;
367 auto details = descriptors->GetDetails(
i);
368 if (details.IsDontEnum())
continue;
372 map, details.field_index(), details.representation());
373 if (field_index.is_double())
continue;
374 value =
receiver->RawFastPropertyAt(isolate, field_index);
376 value = descriptors->GetStrongValue(
i);
379 if (!IsAccessorPair(value))
continue;
381 if (pair->getter() != fun && pair->setter() != fun)
continue;
384 name = IsUndefined(name, isolate)
392template <
typename Dictionary>
396 ReadOnlyRoots roots(isolate);
397 for (
auto i : dictionary->IterateEntries()) {
399 if (!dictionary->ToKey(roots,
i, &
key))
continue;
400 if (IsSymbol(
key))
continue;
401 auto details = dictionary->DetailsAt(
i);
402 if (details.IsDontEnum())
continue;
403 auto value = dictionary->ValueAt(
i);
405 if (!IsAccessorPair(value))
continue;
407 if (pair->getter() != fun && pair->setter() != fun)
continue;
410 name = IsUndefined(name, isolate)
412 :
Tagged<PrimitiveHeapObject>(roots.null_value());
422 ReadOnlyRoots roots(isolate);
426 auto current = it.GetCurrent();
427 if (!IsJSObject(current))
break;
429 if (IsAccessCheckNeeded(
object))
break;
430 if (object->HasFastProperties()) {
431 name = InferMethodNameFromFastObject(isolate,
object, fun, name);
432 }
else if (IsJSGlobalObject(
object)) {
433 name = InferMethodNameFromDictionary(
438 name = InferMethodNameFromDictionary(
439 isolate, object->property_dictionary_swiss(), fun, name);
441 name = InferMethodNameFromDictionary(
442 isolate, object->property_dictionary(), fun, name);
445 if (IsUndefined(name, isolate))
return roots.null_value();
454 Isolate* isolate = info->GetIsolate();
457#if V8_ENABLE_WEBASSEMBLY
458 if (info->IsWasm())
return isolate->factory()->null_value();
461 return isolate->factory()->null_value();
468 return isolate->factory()->null_value();
480 name = isolate->factory()->NewProperSubString(name, 4, name->length());
481 }
else if (name->length() == 0) {
486 name =
handle(function->shared()->inferred_name(), isolate);
487 for (
int index = name->length(); --index >= 0;) {
488 if (name->Get(index, isolate) ==
'.') {
489 name = isolate->factory()->NewProperSubString(name, index + 1,
496 if (name->length() != 0) {
501 if (it.GetDataValue().is_identical_to(function)) {
506 if (IsAccessorPair(*accessors)) {
508 if (pair->getter() == *function || pair->setter() == *function) {
521 Isolate* isolate = info->GetIsolate();
522 if (!info->IsMethodCall()) {
523 return isolate->factory()->null_value();
530 return isolate->factory()->Proxy_string();
535 if (class_name->length() != 0) {
542#if V8_ENABLE_WEBASSEMBLY
543uint32_t CallSiteInfo::GetWasmFunctionIndex()
const {
554DirectHandle<Object> CallSiteInfo::GetWasmModuleName(
555 DirectHandle<CallSiteInfo> info) {
556 Isolate* isolate = info->GetIsolate();
557 if (info->IsWasm()) {
558 DirectHandle<String>
name;
560 direct_handle(info->GetWasmInstance()->module_object(), isolate);
566 return isolate->factory()->null_value();
572 if (info->flags() & kIsSourcePositionComputed) {
573 return info->code_offset_or_source_position();
575 DCHECK(!info->IsPromiseAll());
576 DCHECK(!info->IsPromiseAllSettled());
577 DCHECK(!info->IsPromiseAny());
578 int source_position =
580 info->set_code_offset_or_source_position(source_position);
581 info->set_flags(info->flags() | kIsSourcePositionComputed);
582 return source_position;
588 Isolate* isolate = info->GetIsolate();
589#if V8_ENABLE_WEBASSEMBLY
590 if (info->IsWasm()) {
597 if (info->IsBuiltin()) {
603 if (!shared->IsSubjectToDebugging())
return false;
605 if (IsUndefined(script->source()))
return false;
606 if (info->flags() & kIsSourcePositionComputed ||
607 (shared->HasBytecodeArray() &&
608 shared->GetBytecodeArray(isolate)->HasSourcePositionTable())) {
612 int code_offset = info->code_offset_or_source_position();
621 Isolate* isolate = info->GetIsolate();
622#if V8_ENABLE_WEBASSEMBLY
623#if V8_ENABLE_DRUMBRAKE
624 if (info->IsWasmInterpretedFrame()) {
625 auto module = info->GetWasmInstance()->module();
626 uint32_t func_index = info->GetWasmFunctionIndex();
628 info->IsAsmJsAtNumberConversion());
631 if (info->IsWasm()) {
632 auto module = info->GetWasmInstance()->trusted_data(isolate)->module();
633 uint32_t func_index = info->GetWasmFunctionIndex();
635 info->IsAsmJsAtNumberConversion());
637#if V8_ENABLE_DRUMBRAKE
640 if (info->IsBuiltin()) {
648 DCHECK(IsCode(code) || IsBytecodeArray(code));
653#if V8_ENABLE_WEBASSEMBLY
655 return GetWasmInstance()
656 ->trusted_data(GetIsolate())
670#if V8_ENABLE_WEBASSEMBLY
680 if (
auto script = info->GetScript()) {
689 return (IsString(*
object) &&
Cast<String>(*object)->length() > 0);
692void AppendFileLocation(
Isolate* isolate, DirectHandle<CallSiteInfo> frame,
693 IncrementalStringBuilder* builder) {
694 DirectHandle<Object> script_name_or_source_url(
695 frame->GetScriptNameOrSourceURL(), isolate);
696 if (!IsString(*script_name_or_source_url) && frame->IsEval()) {
699 builder->AppendCStringLiteral(
", ");
702 if (IsNonEmptyString(script_name_or_source_url)) {
703 builder->AppendString(
Cast<String>(script_name_or_source_url));
708 builder->AppendCStringLiteral(
"<anonymous>");
713 builder->AppendCharacter(
':');
714 builder->AppendInt(line_number);
718 builder->AppendCharacter(
':');
719 builder->AppendInt(column_number);
727bool StringEndsWithMethodName(Isolate* isolate, DirectHandle<String> subject,
728 DirectHandle<String>
pattern) {
731 FlatStringReader subject_reader(isolate,
String::Flatten(isolate, subject));
734 int pattern_index = pattern_reader.length() - 1;
735 int subject_index = subject_reader.length() - 1;
737 for (uint32_t
i = 0;
i <= pattern_reader.
length();
i++) {
738 if (subject_index < 0) {
742 const base::uc32 subject_char = subject_reader.Get(subject_index);
743 if (
i == pattern_reader.
length()) {
744 if (subject_char !=
'.' && subject_char !=
' ')
return false;
745 }
else if (subject_char != pattern_reader.Get(pattern_index)) {
756void AppendMethodCall(Isolate* isolate, DirectHandle<CallSiteInfo> frame,
757 IncrementalStringBuilder* builder) {
762 if (IsNonEmptyString(function_name)) {
763 DirectHandle<String> function_string =
Cast<String>(function_name);
764 if (IsNonEmptyString(type_name)) {
765 DirectHandle<String> type_string =
Cast<String>(type_name);
768 builder->AppendString(type_string);
769 builder->AppendCharacter(
'.');
772 builder->AppendString(function_string);
774 if (IsNonEmptyString(method_name)) {
775 DirectHandle<String> method_string =
Cast<String>(method_name);
776 if (!StringEndsWithMethodName(isolate, function_string, method_string)) {
777 builder->AppendCStringLiteral(
" [as ");
778 builder->AppendString(method_string);
779 builder->AppendCharacter(
']');
783 if (IsNonEmptyString(type_name)) {
785 builder->AppendCharacter(
'.');
787 if (IsNonEmptyString(method_name)) {
790 builder->AppendCStringLiteral(
"<anonymous>");
795void SerializeJSStackFrame(Isolate* isolate, DirectHandle<CallSiteInfo> frame,
796 IncrementalStringBuilder* builder) {
798 if (frame->IsAsync()) {
799 builder->AppendCStringLiteral(
"async ");
800 if (frame->IsPromiseAll() || frame->IsPromiseAny() ||
801 frame->IsPromiseAllSettled()) {
802 builder->AppendCStringLiteral(
"Promise.");
804 builder->AppendCStringLiteral(
" (index ");
806 builder->AppendCharacter(
')');
810 if (frame->IsMethodCall()) {
811 AppendMethodCall(isolate, frame, builder);
812 }
else if (frame->IsConstructor()) {
813 builder->AppendCStringLiteral(
"new ");
814 if (IsNonEmptyString(function_name)) {
817 builder->AppendCStringLiteral(
"<anonymous>");
819 }
else if (IsNonEmptyString(function_name)) {
822 AppendFileLocation(isolate, frame, builder);
825 builder->AppendCStringLiteral(
" (");
826 AppendFileLocation(isolate, frame, builder);
827 builder->AppendCharacter(
')');
830#if V8_ENABLE_WEBASSEMBLY
831void SerializeWasmStackFrame(Isolate* isolate, DirectHandle<CallSiteInfo> frame,
832 IncrementalStringBuilder* builder) {
833 DirectHandle<Object> module_name = CallSiteInfo::GetWasmModuleName(frame);
835 const bool has_name = !
IsNull(*module_name) || !
IsNull(*function_name);
837 if (
IsNull(*module_name)) {
841 if (!
IsNull(*function_name)) {
842 builder->AppendCharacter(
'.');
846 builder->AppendCStringLiteral(
" (");
849 DirectHandle<Object> url(frame->GetScriptNameOrSourceURL(), isolate);
850 if (IsNonEmptyString(url)) {
853 builder->AppendCStringLiteral(
"<anonymous>");
855 builder->AppendCharacter(
':');
857 const int wasm_func_index = frame->GetWasmFunctionIndex();
858 builder->AppendCStringLiteral(
"wasm-function[");
859 builder->AppendInt(wasm_func_index);
860 builder->AppendCStringLiteral(
"]:");
865 builder->AppendCString(buffer);
867 if (has_name) builder->AppendCharacter(
')');
870void SerializeBuiltinStackFrame(Isolate* isolate,
871 DirectHandle<CallSiteInfo> frame,
872 IncrementalStringBuilder* builder) {
874 builder->AppendCStringLiteral(
" (<anonymous>)");
882#if V8_ENABLE_WEBASSEMBLY
883 if (frame->IsWasm() && !frame->IsAsmJsWasm()) {
884 SerializeWasmStackFrame(isolate, frame, builder);
887 if (frame->IsBuiltin()) {
888 SerializeBuiltinStackFrame(isolate, frame, builder);
892 SerializeJSStackFrame(isolate, frame, builder);
static const int kNoLineNumberInfo
static const int kNoScriptIdInfo
static const int kNoColumnInfo
static V8_EXPORT_PRIVATE const char * NameForStackTrace(Isolate *isolate, Builtin builtin)
static constexpr Builtin FromInt(int id)
static DirectHandle< String > GetScriptHash(DirectHandle< CallSiteInfo > info)
bool IsMethodCall() const
static int GetEnclosingColumnNumber(DirectHandle< CallSiteInfo > info)
static V8_EXPORT_PRIVATE int GetLineNumber(DirectHandle< CallSiteInfo > info)
Tagged< Object > GetScriptName() const
Tagged< SharedFunctionInfo > GetSharedFunctionInfo() const
static Handle< PrimitiveHeapObject > GetEvalOrigin(DirectHandle< CallSiteInfo > info)
bool IsPromiseAll() const
static DirectHandle< String > GetFunctionDebugName(DirectHandle< CallSiteInfo > info)
bool IsConstructor() const
bool IsUserJavaScript() const
static int ComputeSourcePosition(DirectHandle< CallSiteInfo > info, int offset)
std::optional< Tagged< Script > > GetScript() const
static V8_EXPORT_PRIVATE int GetColumnNumber(DirectHandle< CallSiteInfo > info)
Tagged< Object > GetScriptSource() const
static int GetEnclosingLineNumber(DirectHandle< CallSiteInfo > info)
static bool ComputeLocation(DirectHandle< CallSiteInfo > info, MessageLocation *location)
bool IsPromiseAny() const
Tagged< Object > GetScriptSourceMappingURL() const
static DirectHandle< Object > GetTypeName(DirectHandle< CallSiteInfo > info)
bool IsPromiseAllSettled() const
static int GetSourcePosition(DirectHandle< CallSiteInfo > info)
static V8_EXPORT_PRIVATE DirectHandle< PrimitiveHeapObject > GetFunctionName(DirectHandle< CallSiteInfo > info)
static DirectHandle< Object > GetMethodName(DirectHandle< CallSiteInfo > info)
Tagged< Object > GetScriptNameOrSourceURL() const
static FieldIndex ForPropertyIndex(Tagged< Map > map, int index, Representation representation=Representation::Tagged())
MaybeDirectHandle< String > Finish()
v8::internal::Factory * factory()
static DirectHandle< String > GetDebugName(DirectHandle< JSFunction > function)
static DirectHandle< String > GetConstructorName(Isolate *isolate, DirectHandle< JSReceiver > receiver)
@ PROTOTYPE_CHAIN_SKIP_INTERCEPTOR
static V8_WARN_UNUSED_RESULT HandleType< JSReceiver >::MaybeType ToObject(Isolate *isolate, HandleType< T > object, const char *method_name=nullptr)
static DirectHandle< String > GetScriptHash(Isolate *isolate, DirectHandle< Script > script, bool forceForInspector)
static V8_EXPORT_PRIVATE int GetLineNumber(DirectHandle< Script > script, int code_offset)
static bool GetPositionInfo(DirectHandle< Script > script, int position, PositionInfo *info, OffsetFlag offset_flag=OffsetFlag::kWithOffset)
static int GetColumnNumber(DirectHandle< Script > script, int code_offset)
static int GetEvalPosition(Isolate *isolate, DirectHandle< Script > script)
static void EnsureSourcePositionsAvailable(Isolate *isolate, DirectHandle< SharedFunctionInfo > shared_info)
static Handle< String > DebugName(Isolate *isolate, DirectHandle< SharedFunctionInfo > shared)
static constexpr int ToInt(const Tagged< Object > object)
static V8_INLINE HandleType< String > Flatten(Isolate *isolate, HandleType< T > string, AllocationType allocation=AllocationType::kYoung)
static bool IsIdentifier(Isolate *isolate, DirectHandle< String > str)
bool Equals(Tagged< String > other) const
static MaybeDirectHandle< String > GetFunctionNameOrNull(Isolate *, DirectHandle< WasmModuleObject >, uint32_t func_index)
static MaybeDirectHandle< String > GetModuleNameOrNull(Isolate *, DirectHandle< WasmModuleObject >)
#define V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL
Handle< SharedFunctionInfo > info
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
SharedFunctionInfoRef shared
int SNPrintF(Vector< char > str, const char *format,...)
constexpr Vector< T > ArrayVector(T(&arr)[N])
Vector< const char > CStrVector(const char *data)
int GetSourcePosition(const WasmModule *module, uint32_t func_index, uint32_t byte_offset, bool is_at_number_conversion)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
constexpr NullMaybeHandleType kNullMaybeHandle
PerThreadAssertScopeDebugOnly< false, SAFEPOINTS_ASSERT, HEAP_ALLOCATION_ASSERT > DisallowGarbageCollection
Tagged(T object) -> Tagged< T >
V8_INLINE IndirectHandle< T > indirect_handle(DirectHandle< T > handle)
void SerializeCallSiteInfo(Isolate *isolate, DirectHandle< CallSiteInfo > frame, IncrementalStringBuilder *builder)
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
kMemory0SizeOffset Address kNewAllocationLimitAddressOffset Address kOldAllocationLimitAddressOffset uint8_t kGlobalsStartOffset kJumpTableStartOffset std::atomic< uint32_t > kTieringBudgetArrayOffset kDataSegmentStartsOffset kElementSegmentsOffset Tagged< WasmInstanceObject >
bool IsNullOrUndefined(Tagged< Object > obj, Isolate *isolate)
bool IsClassMembersInitializerFunction(FunctionKind kind)
kInstanceDescriptorsOffset kTransitionsOrPrototypeInfoOffset IsNull(value)||IsJSProxy(value)||IsWasmObject(value)||(IsJSObject(value) &&(HeapLayout
DirectHandle< String > GetWasmFunctionDebugName(Isolate *isolate, DirectHandle< WasmTrustedInstanceData > instance_data, uint32_t func_index)
kInterpreterTrampolineOffset script
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
static constexpr AcquireLoadTag kAcquireLoad
#define DCHECK(condition)