17#include <unordered_map>
128#if defined(V8_USE_PERFETTO)
138#ifdef V8_INTL_SUPPORT
140#include "unicode/locid.h"
141#include "unicode/uobject.h"
148#if V8_ENABLE_WEBASSEMBLY
159#if V8_ENABLE_DRUMBRAKE
164#if defined(V8_ENABLE_ETW_STACK_WALKING)
168#if defined(V8_OS_WIN64)
185#define TRACE_ISOLATE(tag) \
187 if (v8_flags.trace_isolates) { \
188 PrintF("Isolate %p (id %d)" #tag "\n", reinterpret_cast<void*>(this), \
193#define TRACE_ISOLATE(tag)
219std::atomic<const uint8_t*> current_embedded_blob_code_(
nullptr);
220std::atomic<uint32_t> current_embedded_blob_code_size_(0);
221std::atomic<const uint8_t*> current_embedded_blob_data_(
nullptr);
222std::atomic<uint32_t> current_embedded_blob_data_size_(0);
254const uint8_t* sticky_embedded_blob_code_ =
nullptr;
255uint32_t sticky_embedded_blob_code_size_ = 0;
256const uint8_t* sticky_embedded_blob_data_ =
nullptr;
257uint32_t sticky_embedded_blob_data_size_ = 0;
259bool enable_embedded_blob_refcounting_ =
true;
260int current_embedded_blob_refs_ = 0;
262const uint8_t* StickyEmbeddedBlobCode() {
return sticky_embedded_blob_code_; }
263uint32_t StickyEmbeddedBlobCodeSize() {
264 return sticky_embedded_blob_code_size_;
266const uint8_t* StickyEmbeddedBlobData() {
return sticky_embedded_blob_data_; }
267uint32_t StickyEmbeddedBlobDataSize() {
268 return sticky_embedded_blob_data_size_;
271void SetStickyEmbeddedBlob(
const uint8_t* code, uint32_t code_size,
272 const uint8_t* data, uint32_t data_size) {
273 sticky_embedded_blob_code_ =
code;
274 sticky_embedded_blob_code_size_ = code_size;
275 sticky_embedded_blob_data_ =
data;
276 sticky_embedded_blob_data_size_ = data_size;
283 enable_embedded_blob_refcounting_ =
false;
287 CHECK(!enable_embedded_blob_refcounting_);
290 if (StickyEmbeddedBlobCode() ==
nullptr)
return;
301 current_embedded_blob_code_.store(
nullptr, std::memory_order_relaxed);
302 current_embedded_blob_code_size_.store(0, std::memory_order_relaxed);
303 current_embedded_blob_data_.store(
nullptr, std::memory_order_relaxed);
304 current_embedded_blob_data_size_.store(0, std::memory_order_relaxed);
305 sticky_embedded_blob_code_ =
nullptr;
306 sticky_embedded_blob_code_size_ = 0;
307 sticky_embedded_blob_data_ =
nullptr;
308 sticky_embedded_blob_data_size_ = 0;
318 const uint8_t* code =
319 current_embedded_blob_code_.load(std::memory_order_relaxed);
320 if (code ==
nullptr)
return false;
325 const uint8_t* data, uint32_t data_size) {
333 current_embedded_blob_code_.store(code, std::memory_order_relaxed);
334 current_embedded_blob_code_size_.store(code_size, std::memory_order_relaxed);
335 current_embedded_blob_data_.store(data, std::memory_order_relaxed);
336 current_embedded_blob_data_size_.store(data_size, std::memory_order_relaxed);
342 if (d.EmbeddedBlobDataHash() != d.CreateEmbeddedBlobDataHash()) {
344 "Embedded blob data section checksum verification failed. This "
345 "indicates that the embedded blob has been modified since compilation "
349 if (d.EmbeddedBlobCodeHash() != d.CreateEmbeddedBlobCodeHash()) {
351 "Embedded blob code section checksum verification failed. This "
352 "indicates that the embedded blob has been modified since "
353 "compilation time. A common cause is a debugging breakpoint set "
354 "within builtin code.");
361 CHECK(enable_embedded_blob_refcounting_);
371 current_embedded_blob_code_.store(
nullptr, std::memory_order_relaxed);
372 current_embedded_blob_code_size_.store(0, std::memory_order_relaxed);
373 current_embedded_blob_data_.store(
nullptr, std::memory_order_relaxed);
374 current_embedded_blob_data_size_.store(0, std::memory_order_relaxed);
375 sticky_embedded_blob_code_ =
nullptr;
376 sticky_embedded_blob_code_size_ = 0;
377 sticky_embedded_blob_data_ =
nullptr;
378 sticky_embedded_blob_data_size_ = 0;
396 return current_embedded_blob_code_.load(std::memory_order_relaxed);
401 return current_embedded_blob_code_size_.load(std::memory_order_relaxed);
406 return current_embedded_blob_data_.load(std::memory_order_relaxed);
411 return current_embedded_blob_data_size_.load(std::memory_order_relaxed);
422 constexpr size_t max_size = std::numeric_limits<size_t>::max();
430 Address embedded_blob_code_start =
436 Address embedded_blob_code_end =
439 (embedded_blob_code_end > radius) ? (embedded_blob_code_end - radius) : 0;
440 Address region_end = embedded_blob_code_start + radius;
441 if (region_end < embedded_blob_code_start) {
442 region_end =
static_cast<Address>(-1);
453 static constexpr size_t kSeed = 0;
458#if V8_STATIC_ROOTS_BOOL
462 for (
auto ptr : StaticReadOnlyRootsPointerTable) {
474 uint8_t*
const code_ptr =
reinterpret_cast<uint8_t*
>(code.address());
478 static_assert(Code::kEndOfStrongFieldsOffset ==
479 Code::kInstructionStartOffset);
480#ifndef V8_ENABLE_SANDBOX
482 Code::kInstructionStartOffsetEnd + 1 +
486 static_assert(Code::kFlagsOffsetEnd + 1 == Code::kInstructionSizeOffset);
487 static_assert(Code::kInstructionSizeOffsetEnd + 1 ==
488 Code::kMetadataSizeOffset);
489 static_assert(Code::kMetadataSizeOffsetEnd + 1 ==
490 Code::kInlinedBytecodeSizeOffset);
491 static_assert(Code::kInlinedBytecodeSizeOffsetEnd + 1 ==
492 Code::kOsrOffsetOffset);
493 static_assert(Code::kOsrOffsetOffsetEnd + 1 ==
494 Code::kHandlerTableOffsetOffset);
495 static_assert(Code::kHandlerTableOffsetOffsetEnd + 1 ==
496 Code::kUnwindingInfoOffsetOffset);
497 static_assert(Code::kUnwindingInfoOffsetOffsetEnd + 1 ==
498 Code::kConstantPoolOffsetOffset);
499 static_assert(Code::kConstantPoolOffsetOffsetEnd + 1 ==
500 Code::kCodeCommentsOffsetOffset);
501 static_assert(Code::kCodeCommentsOffsetOffsetEnd + 1 ==
502 Code::kBuiltinJumpTableInfoOffsetOffset);
503 static_assert(Code::kBuiltinJumpTableInfoOffsetOffsetEnd + 1 ==
504 Code::kParameterCountOffset);
505 static_assert(Code::kParameterCountOffsetEnd + 1 == Code::kBuiltinIdOffset);
506 static_assert(Code::kBuiltinIdOffsetEnd + 1 == Code::kUnalignedSize);
507 static constexpr int kStartOffset = Code::kFlagsOffset;
509 for (
int j = kStartOffset; j < Code::kUnalignedSize; j++) {
516 hash,
static_cast<size_t>(
heap_.builtins_constants_table()->length()));
532std::atomic<int> isolate_counter{0};
535Isolate::PerIsolateThreadData*
542 if (per_thread ==
nullptr) {
543 if (
v8_flags.adjust_os_scheduling_parameters) {
596 thread->topmost_script_having_context_ =
Context();
614 for (
v8::TryCatch* block = thread->try_catch_handler_; block !=
nullptr;
615 block = block->
next_) {
618 Root::kStackRoots,
nullptr,
621 Root::kStackRoots,
nullptr,
626 Root::kStackRoots,
nullptr,
630#if V8_ENABLE_WEBASSEMBLY
633 for (
const std::unique_ptr<wasm::StackMemory>& stack : wasm_stacks_) {
634 if (stack->IsActive()) {
638 it.frame()->Iterate(v);
645 for (; !it.done(); it.Advance()) {
646 it.frame()->Iterate(v);
679 base::OS::PrintError(
680 "\n\nAttempt to print stack while printing stack (double fault)\n");
681 base::OS::PrintError(
682 "If you are lucky you may find a partial stack dump on stdout.\n\n");
684 return factory()->empty_string();
691 void* ptr4,
void* ptr5,
void* ptr6) {
694 {ptr1, ptr2, ptr3, ptr4, ptr5, ptr6});
700 void* ptr5,
void* ptr6) {
703 {ptr1, ptr2, ptr3, ptr4, ptr5, ptr6});
709 void* ptr4,
void* ptr5,
void* ptr6) {
712 {ptr1, ptr2, ptr3, ptr4, ptr5, ptr6});
718 void* ptr4,
void* ptr5,
void* ptr6) {
721 {ptr1, ptr2, ptr3, ptr4, ptr5, ptr6});
730 base::OS::PrintError(
731 "Stacktrace:\n ptr0=%p\n ptr1=%p\n ptr2=%p\n ptr3=%p\n "
732 "ptr4=%p\n ptr5=%p\n failure_message_object=%p\n%s",
733 reinterpret_cast<void*
>(
ptrs_[0]),
reinterpret_cast<void*
>(
ptrs_[1]),
734 reinterpret_cast<void*
>(
ptrs_[2]),
reinterpret_cast<void*
>(
ptrs_[3]),
735 reinterpret_cast<void*
>(
ptrs_[4]),
reinterpret_cast<void*
>(
ptrs_[5]),
741 const Address* ptrs,
size_t ptrs_count)
744 std::copy(ptrs, ptrs + ptrs_size, &
ptrs_[0]);
757 for (; !it.done() &&
i < code_objects_length; it.Advance()) {
769 if (!IsJSFunction(
object))
return false;
775 return function->code(isolate).SafeEquals(isolate->builtins()->code(builtin));
781 return IsBuiltinFunction(isolate,
object,
782 Builtin::kAsyncFunctionAwaitResolveClosure) ||
783 IsBuiltinFunction(isolate,
object,
784 Builtin::kAsyncGeneratorAwaitResolveClosure) ||
787 Builtin::kAsyncGeneratorYieldWithAwaitResolveClosure);
793 return IsBuiltinFunction(isolate,
object,
794 Builtin::kAsyncFunctionAwaitRejectClosure) ||
795 IsBuiltinFunction(isolate,
object,
796 Builtin::kAsyncGeneratorAwaitRejectClosure);
801bool IsBuiltinForwardingRejectHandler(Isolate* isolate,
803 return IsBuiltinFunction(isolate,
object, Builtin::kPromiseCatchFinally) ||
804 IsBuiltinFunction(isolate,
object,
805 Builtin::kAsyncFromSyncIteratorCloseSyncAndRethrow);
808MaybeHandle<JSGeneratorObject> TryGetAsyncGenerator(
809 Isolate* isolate, DirectHandle<PromiseReaction> reaction) {
812 if (IsBuiltinAsyncFulfillHandler(isolate, reaction->fulfill_handler())) {
819 return generator_object;
821 return MaybeHandle<JSGeneratorObject>();
824#if V8_ENABLE_WEBASSEMBLY
825MaybeDirectHandle<WasmSuspenderObject> TryGetWasmSuspender(
828 if (IsBuiltinFunction(isolate, handler, Builtin::kWasmResume)) {
832 if (shared->HasWasmResumeData()) {
833 return direct_handle(shared->wasm_resume_data()->suspender(), isolate);
836 return MaybeDirectHandle<WasmSuspenderObject>();
840int GetGeneratorBytecodeOffset(
841 DirectHandle<JSGeneratorObject> generator_object) {
844 return Smi::ToInt(generator_object->input_or_debug_pos()) -
848class CallSiteBuilder {
850 CallSiteBuilder(Isolate* isolate,
FrameSkipMode mode,
int limit,
851 Handle<Object> caller)
862 elements_ = isolate->factory()->NewFixedArray(std::min(64, limit));
865 void SetPrevFrameAsConstructCall() {
866 if (skipped_prev_frame_)
return;
870 info->set_flags(info->flags() | CallSiteInfo::kIsConstructor);
873 bool Visit(FrameSummary
const& summary) {
874 if (Full())
return false;
875#if V8_ENABLE_WEBASSEMBLY
876#if V8_ENABLE_DRUMBRAKE
877 if (summary.IsWasmInterpreted()) {
878 AppendWasmInterpretedFrame(summary.AsWasmInterpreted());
885 if (summary.IsWasm()) {
886 AppendWasmFrame(summary.AsWasm());
889#if V8_ENABLE_DRUMBRAKE
892 if (summary.IsWasmInlined()) {
893 AppendWasmInlinedFrame(summary.AsWasmInlined());
896 if (summary.IsBuiltin()) {
897 AppendBuiltinFrame(summary.AsBuiltin());
901 AppendJavaScriptFrame(summary.AsJavaScript());
905 void AppendAsyncFrame(DirectHandle<JSGeneratorObject> generator_object) {
906 DirectHandle<JSFunction> function(generator_object->function(), isolate_);
907 if (!IsVisibleInStackTrace(function)) {
911 int flags = CallSiteInfo::kIsAsync;
912 if (IsStrictFrame(function)) flags |= CallSiteInfo::kIsStrict;
914 DirectHandle<JSAny>
receiver(generator_object->receiver(), isolate_);
915 DirectHandle<BytecodeArray>
code(
916 function->shared()->GetBytecodeArray(isolate_), isolate_);
917 int offset = GetGeneratorBytecodeOffset(generator_object);
919 DirectHandle<FixedArray> parameters =
920 isolate_->factory()->empty_fixed_array();
922 parameters =
isolate_->factory()->CopyFixedArrayUpTo(
923 direct_handle(generator_object->parameters_and_registers(), isolate_),
925 ->internal_formal_parameter_count_without_receiver());
931 void AppendPromiseCombinatorFrame(DirectHandle<JSFunction> element_function,
932 DirectHandle<JSFunction> combinator) {
933 if (!IsVisibleInStackTrace(combinator)) {
938 CallSiteInfo::kIsAsync | CallSiteInfo::kIsSourcePositionComputed;
941 combinator->native_context()->promise_function(), isolate_);
942 DirectHandle<Code>
code(combinator->code(isolate_), isolate_);
945 DirectHandle<FixedArray> parameters =
946 isolate_->factory()->empty_fixed_array();
950 int promise_index =
Smi::ToInt(element_function->GetIdentityHash()) - 1;
952 AppendFrame(
receiver, combinator, code, promise_index, flags, parameters);
955 void AppendJavaScriptFrame(
956 FrameSummary::JavaScriptFrameSummary
const& summary) {
958 if (!IsVisibleInStackTrace(summary.function())) {
964 DirectHandle<JSFunction> function = summary.function();
965 if (IsStrictFrame(function)) flags |= CallSiteInfo::kIsStrict;
966 if (summary.is_constructor()) flags |= CallSiteInfo::kIsConstructor;
969 summary.abstract_code(), summary.code_offset(), flags,
970 summary.parameters());
973#if V8_ENABLE_WEBASSEMBLY
974 void AppendWasmFrame(FrameSummary::WasmFrameSummary
const& summary) {
976 DirectHandle<WasmInstanceObject> instance = summary.wasm_instance();
977 int flags = CallSiteInfo::kIsWasm;
978 if (instance->module_object()->is_asm_js()) {
979 flags |= CallSiteInfo::kIsAsmJsWasm;
980 if (summary.at_to_number_conversion()) {
981 flags |= CallSiteInfo::kIsAsmJsAtNumberConversion;
985 DirectHandle<HeapObject> code =
isolate_->factory()->undefined_value();
986 AppendFrame(instance,
988 code, summary.code_offset(), flags,
989 isolate_->factory()->empty_fixed_array());
992#if V8_ENABLE_DRUMBRAKE
993 void AppendWasmInterpretedFrame(
994 FrameSummary::WasmInterpretedFrameSummary
const& summary) {
996 int flags = CallSiteInfo::kIsWasm | CallSiteInfo::kIsWasmInterpretedFrame;
997 DCHECK(!instance->module_object()->is_asm_js());
999 auto code =
isolate_->factory()->undefined_value();
1000 AppendFrame(instance,
1002 summary.byte_offset(), flags,
1003 isolate_->factory()->empty_fixed_array());
1007 void AppendWasmInlinedFrame(
1008 FrameSummary::WasmInlinedFrameSummary
const& summary) {
1009 DirectHandle<HeapObject> code =
isolate_->factory()->undefined_value();
1010 int flags = CallSiteInfo::kIsWasm;
1011 AppendFrame(summary.wasm_instance(),
1013 code, summary.code_offset(), flags,
1014 isolate_->factory()->empty_fixed_array());
1017 void AppendBuiltinFrame(FrameSummary::BuiltinFrameSummary
const& summary) {
1018 Builtin builtin = summary.builtin();
1019 DirectHandle<Code> code =
isolate_->builtins()->code_handle(builtin);
1020 DirectHandle<Smi> function(
Smi::FromInt(
static_cast<int>(builtin)),
1022 int flags = CallSiteInfo::kIsBuiltin;
1024 summary.code_offset(), flags,
1025 isolate_->factory()->empty_fixed_array());
1040 bool IsStrictFrame(DirectHandle<JSFunction> function) {
1041 if (!encountered_strict_function_) {
1043 is_strict(function->shared()->language_mode());
1050 bool IsVisibleInStackTrace(DirectHandle<JSFunction> function) {
1051 return ShouldIncludeFrame(function) && IsNotHidden(function);
1058 bool ShouldIncludeFrame(DirectHandle<JSFunction> function) {
1063 if (!skip_next_frame_)
return true;
1067 if (skip_next_frame_ && (*function == *caller_)) {
1076 bool IsNotHidden(DirectHandle<JSFunction> function) {
1079 if (!
v8_flags.experimental_stack_trace_frames &&
1080 function->shared()->IsApiFunction()) {
1087 if (!
v8_flags.builtins_in_stack_traces &&
1088 !function->shared()->IsUserJavaScript()) {
1089 return function->shared()->native() ||
1090 function->shared()->IsApiFunction();
1097 DirectHandle<HeapObject> code,
int offset,
int flags,
1098 DirectHandle<FixedArray> parameters) {
1099 if (IsTheHole(*receiver_or_instance, isolate_)) {
1102 receiver_or_instance =
isolate_->factory()->undefined_value();
1104 auto info =
isolate_->factory()->NewCallSiteInfo(
1122void CaptureAsyncStackTrace(Isolate* isolate, DirectHandle<JSPromise> promise,
1123 CallSiteBuilder* builder) {
1124 while (!builder->Full()) {
1129 if (!IsPromiseReaction(promise->reactions()))
return;
1130 DirectHandle<PromiseReaction> reaction(
1132 if (!
IsSmi(reaction->next()))
return;
1136 if (TryGetAsyncGenerator(isolate, reaction).ToHandle(&generator_object)) {
1137 CHECK(generator_object->is_suspended());
1140 builder->AppendAsyncFrame(generator_object);
1143 if (IsJSAsyncFunctionObject(*generator_object)) {
1144 auto async_function_object =
1146 promise =
direct_handle(async_function_object->promise(), isolate);
1148 auto async_generator_object =
1150 if (IsUndefined(async_generator_object->queue(), isolate))
return;
1151 DirectHandle<AsyncGeneratorRequest> async_generator_request(
1157 }
else if (IsBuiltinFunction(isolate, reaction->fulfill_handler(),
1158 Builtin::kPromiseAllResolveElementClosure)) {
1159 DirectHandle<JSFunction> function(
1161 DirectHandle<Context>
context(function->context(), isolate);
1162 DirectHandle<JSFunction> combinator(
1163 context->native_context()->promise_all(), isolate);
1164 builder->AppendPromiseCombinatorFrame(function, combinator);
1166 if (IsNativeContext(*context)) {
1177 DirectHandle<PromiseCapability> capability(
1179 if (!IsJSPromise(capability->promise()))
return;
1181 }
else if (IsBuiltinFunction(
1182 isolate, reaction->fulfill_handler(),
1183 Builtin::kPromiseAllSettledResolveElementClosure)) {
1184 DirectHandle<JSFunction> function(
1186 DirectHandle<Context>
context(function->context(), isolate);
1187 DirectHandle<JSFunction> combinator(
1188 context->native_context()->promise_all_settled(), isolate);
1189 builder->AppendPromiseCombinatorFrame(function, combinator);
1191 if (IsNativeContext(*context)) {
1202 DirectHandle<PromiseCapability> capability(
1204 if (!IsJSPromise(capability->promise()))
return;
1206 }
else if (IsBuiltinFunction(isolate, reaction->reject_handler(),
1207 Builtin::kPromiseAnyRejectElementClosure)) {
1208 DirectHandle<JSFunction> function(
1210 DirectHandle<Context>
context(function->context(), isolate);
1211 DirectHandle<JSFunction> combinator(
1212 context->native_context()->promise_any(), isolate);
1213 builder->AppendPromiseCombinatorFrame(function, combinator);
1215 if (IsNativeContext(*context)) {
1225 DirectHandle<PromiseCapability> capability(
1227 if (!IsJSPromise(capability->promise()))
return;
1229 }
else if (IsBuiltinFunction(isolate, reaction->fulfill_handler(),
1230 Builtin::kPromiseCapabilityDefaultResolve)) {
1231 DirectHandle<JSFunction> function(
1233 DirectHandle<Context>
context(function->context(), isolate);
1241 Handle<HeapObject> promise_or_capability(
1242 reaction->promise_or_capability(), isolate);
1243 if (IsJSPromise(*promise_or_capability)) {
1245 }
else if (IsPromiseCapability(*promise_or_capability)) {
1247 if (!IsJSPromise(capability->promise()))
return;
1252 CHECK(IsUndefined(*promise_or_capability, isolate));
1259MaybeDirectHandle<JSPromise> TryGetCurrentTaskPromise(Isolate* isolate) {
1260 Handle<Object> current_microtask = isolate->factory()->current_microtask();
1261 if (IsPromiseReactionJobTask(*current_microtask)) {
1262 auto promise_reaction_job_task =
1266 if (IsBuiltinAsyncFulfillHandler(isolate,
1267 promise_reaction_job_task->handler()) ||
1268 IsBuiltinAsyncRejectHandler(isolate,
1269 promise_reaction_job_task->handler())) {
1272 DirectHandle<Context>
context(
1277 if (generator_object->is_executing()) {
1278 if (IsJSAsyncFunctionObject(*generator_object)) {
1279 auto async_function_object =
1281 DirectHandle<JSPromise> promise(async_function_object->promise(),
1285 auto async_generator_object =
1287 DirectHandle<Object> queue(async_generator_object->queue(), isolate);
1288 if (!IsUndefined(*queue, isolate)) {
1290 DirectHandle<JSPromise> promise(
1297#if V8_ENABLE_WEBASSEMBLY
1298 DirectHandle<WasmSuspenderObject> suspender;
1299 if (TryGetWasmSuspender(isolate, promise_reaction_job_task->handler())
1300 .ToHandle(&suspender)) {
1310 DirectHandle<HeapObject> promise_or_capability(
1311 promise_reaction_job_task->promise_or_capability(), isolate);
1312 if (IsJSPromise(*promise_or_capability)) {
1313 DirectHandle<JSPromise> promise =
1319 return MaybeDirectHandle<JSPromise>();
1322void CaptureAsyncStackTrace(Isolate* isolate, CallSiteBuilder* builder) {
1323 DirectHandle<JSPromise> promise;
1324 if (TryGetCurrentTaskPromise(isolate).ToHandle(&promise)) {
1325 CaptureAsyncStackTrace(isolate, promise, builder);
1329template <
typename Visitor>
1330void VisitStack(Isolate* isolate, Visitor* visitor,
1332 DisallowJavascriptExecution no_js(isolate);
1336 bool skipped_last_frame =
true;
1337 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
1338 StackFrame* frame = it.frame();
1339 switch (frame->type()) {
1340 case StackFrame::API_CALLBACK_EXIT:
1341 case StackFrame::BUILTIN_EXIT:
1342 case StackFrame::JAVASCRIPT_BUILTIN_CONTINUATION:
1343 case StackFrame::JAVASCRIPT_BUILTIN_CONTINUATION_WITH_CATCH:
1344 case StackFrame::TURBOFAN_JS:
1345 case StackFrame::MAGLEV:
1346 case StackFrame::INTERPRETED:
1347 case StackFrame::BASELINE:
1348 case StackFrame::BUILTIN:
1349#if V8_ENABLE_WEBASSEMBLY
1350 case StackFrame::STUB:
1351 case StackFrame::WASM:
1352 case StackFrame::WASM_SEGMENT_START:
1353#if V8_ENABLE_DRUMBRAKE
1354 case StackFrame::WASM_INTERPRETER_ENTRY:
1361 if (summaries.top_frame_is_construct_call && !skipped_last_frame) {
1362 visitor->SetPrevFrameAsConstructCall();
1364 skipped_last_frame =
true;
1365 for (
auto summary = summaries.frames.rbegin();
1366 summary != summaries.frames.rend(); ++summary) {
1369 !summary->native_context()->HasSameSecurityTokenAs(
1370 isolate->context())) {
1373 if (!visitor->Visit(*summary))
return;
1374 skipped_last_frame =
false;
1387 Handle<Object> caller) {
1389 "maxFrameCount", limit);
1391#if V8_ENABLE_WEBASSEMBLY
1392 wasm::WasmCodeRefScope code_ref_scope;
1395 CallSiteBuilder builder(isolate, mode, limit, caller);
1396 VisitStack(isolate, &builder);
1402 CaptureAsyncStackTrace(isolate, &builder);
1407 "frameCount", stack_trace->length());
1411DirectHandle<StackTraceInfo> GetDetailedStackTraceFromCallSiteInfos(
1412 Isolate* isolate, DirectHandle<FixedArray> call_site_infos,
int limit) {
1413 auto frames = isolate->factory()->NewFixedArray(
1414 std::min(limit, call_site_infos->length()));
1416 for (
int i = 0;
i < call_site_infos->
length() && index < limit; ++
i) {
1417 DirectHandle<CallSiteInfo> call_site_info(
1419 if (call_site_info->IsAsync()) {
1422 DirectHandle<Script>
script;
1424 !script->IsSubjectToDebugging()) {
1427 DirectHandle<StackFrameInfo> stack_frame_info =
1428 isolate->factory()->NewStackFrameInfo(
1431 IsConstructor(*call_site_info));
1432 frames->set(index++, *stack_frame_info);
1435 return isolate->factory()->NewStackTraceInfo(frames);
1452 int stack_trace_limit = 0;
1454 int limit = stack_trace_limit;
1468 call_site_infos_or_formatted_stack =
1469 CaptureSimpleStackTrace(
this, limit, mode, caller);
1482 if (IsUndefined(*call_site_infos_or_formatted_stack,
this) ||
1489 auto call_site_infos =
1491 stack_trace = GetDetailedStackTraceFromCallSiteInfos(
1492 this, call_site_infos,
1494 if (stack_trace_limit < call_site_infos->
length()) {
1496 this, call_site_infos, stack_trace_limit);
1502 call_site_infos_or_formatted_stack, stack_trace);
1510 return error_object;
1517 if (!IsErrorStackData(*lookup.
error_stack))
return {};
1530 return factory()->empty_fixed_array();
1533 if (!error_stack_data->HasCallSiteInfos()) {
1534 return factory()->empty_fixed_array();
1536 return handle(error_stack_data->call_site_infos(),
this);
1555 if (IsScript(maybe_script)) {
1559 *line = info.line + 1;
1560 *column = info.column + 1;
1578class StackFrameBuilder {
1580 StackFrameBuilder(
Isolate* isolate,
int limit)
1586 void SetPrevFrameAsConstructCall() {
1590 bool Visit(FrameSummary& summary) {
1592 if (index_ >= limit_)
return false;
1594 if (!summary.is_subject_to_debugging())
return true;
1595 DirectHandle<StackFrameInfo> frame = summary.CreateStackFrameInfo();
1616 "maxFrameCount", limit);
1617 StackFrameBuilder builder(
this, limit);
1618 VisitStack(
this, &builder, options);
1619 auto frames = builder.Build();
1621 "frameCount", frames->length());
1629class CurrentScriptNameStackVisitor {
1631 explicit CurrentScriptNameStackVisitor(
Isolate* isolate)
1634 void SetPrevFrameAsConstructCall() {
1638 bool Visit(FrameSummary& summary) {
1641 if (!summary.is_subject_to_debugging())
return true;
1645 Handle<Object> name_or_url_obj(script->GetNameOrSourceURL(), isolate_);
1646 if (!IsString(*name_or_url_obj))
return true;
1649 if (!name_or_url->length())
return true;
1655 DirectHandle<String> CurrentScriptNameOrSourceURL()
const {
1664class CurrentScriptStackVisitor {
1666 void SetPrevFrameAsConstructCall() {
1670 bool Visit(FrameSummary& summary) {
1673 if (!summary.is_subject_to_debugging())
return true;
1680 MaybeDirectHandle<Script> CurrentScript()
const {
return current_script_; }
1690 CurrentScriptNameStackVisitor visitor(
this);
1691 VisitStack(
this, &visitor);
1692 return visitor.CurrentScriptNameOrSourceURL();
1697 CurrentScriptStackVisitor visitor{};
1698 VisitStack(
this, &visitor);
1700 if (!visitor.CurrentScript().ToHandle(&script)) {
1707 if (
v8_flags.correctness_fuzzer_suppressions)
return false;
1713 if (!
IsNumber(*stack_trace_limit))
return false;
1736 accumulator.
Log(
this);
1741 base::OS::PrintError(
1742 "\n\nAttempt to print stack while printing stack (double fault)\n");
1743 base::OS::PrintError(
1744 "If you are lucky you may find a partial stack dump on stdout.\n\n");
1752 for (
int i = 0; !it.done(); it.Advance()) {
1753 it.frame()->Print(accumulator, mode,
i++);
1759 DCHECK(accumulator->IsMentionedObjectCacheClear(
this));
1765 "\n==== JS stack trace =========================================\n\n");
1769 "\n==== Details ================================================\n\n");
1773 accumulator->
Add(
"=====================\n\n");
1797 if (access_check_info.
is_null()) {
1828 std::optional<Tagged<Object>> receiver_context =
1830 if (!receiver_context)
return false;
1832 if (*receiver_context == *accessing_context)
return true;
1835 accessing_context->security_token())
1847 if (access_check_info.
is_null())
return false;
1857 return callback(v8::Utils::ToLocal(accessing_context),
1858 v8::Utils::ToLocal(
receiver), v8::Utils::ToLocal(data));
1870#if defined(V8_USE_ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER)
1874#elif (defined(V8_TARGET_ARCH_RISCV64) || defined(V8_TARGET_ARCH_RISCV32)) && \
1875 defined(USE_SIMULATOR)
1879#elif defined(ENABLE_SLOW_DCHECKS) && V8_HAS_ATTRIBUTE_TRIVIAL_ABI
1887 if (
v8_flags.correctness_fuzzer_suppressions) {
1888 FATAL(
"Aborting on stack overflow");
1897 DisallowJavascriptExecution no_js(
this);
1947 return Throw(*exception, location);
1967 RCS_SCOPE(
this, RuntimeCallCounterId::kInvokeApiInterruptCallbacks);
1979 entry.first(
reinterpret_cast<v8::Isolate*
>(
this), entry.second);
1990 if (Protectors::IsNoProfilingIntact(i_isolate)) {
1991 Protectors::InvalidateNoProfiling(i_isolate);
2001 base::OS::PrintError(
"Exception thrown during bootstrapping\n");
2002 if (location ==
nullptr || location->
script().is_null())
return;
2010 if (IsString(*exception) && IsString(location->
script()->name())) {
2011 base::OS::PrintError(
2012 "Extension or internal compilation error: %s in %s at line %d.\n",
2016 }
else if (IsString(location->
script()->name())) {
2017 base::OS::PrintError(
2018 "Extension or internal compilation error in %s at line %d.\n",
2021 }
else if (IsString(*exception)) {
2022 base::OS::PrintError(
"Extension or internal compilation error: %s.\n",
2025 base::OS::PrintError(
"Extension or internal compilation error.\n");
2030 if (IsString(location->
script()->source())) {
2032 location->
script()->GetIsolate());
2033 PrintF(
"Failing script:");
2034 int len = src->length();
2036 PrintF(
" <not available>\n");
2040 PrintF(
"%5d: ", line_number);
2041 for (
int i = 0;
i < len;
i++) {
2045 PrintF(
"%5d: ", ++line_number);
2067 static bool abort_on_uncaught_exception =
2068 v8_flags.abort_on_uncaught_exception;
2069 if (abort_on_uncaught_exception) {
2076 abort_on_uncaught_exception =
false;
2079 PrintF(stderr,
"%s\n\nFROM\n",
2081 std::ostringstream stack_trace_stream;
2083 PrintF(stderr,
"%s", stack_trace_stream.str().c_str());
2095 raw_exception ==
ReadOnlyRoots{
this}.termination_exception());
2097#if V8_ENABLE_WEBASSEMBLY
2104 if (
v8_flags.print_all_exceptions) {
2105 PrintF(
"=========================================================\n");
2106 PrintF(
"Exception thrown:\n");
2111 if (IsString(*name) &&
Cast<String>(*name)->length() > 0) {
2119 if (AllowGarbageCollection::IsAllowed()) {
2130 PrintF(
", line %d\n", script->GetLineNumber(location->
start_pos()) + 1);
2134 PrintF(
"Stack Trace:\n");
2136 PrintF(
"=========================================================\n");
2157 std::optional<Tagged<Object>> maybe_exception =
debug()->
OnThrow(exception);
2158 if (maybe_exception.has_value()) {
2159 return *maybe_exception;
2166 if (requires_message && !rethrowing_message) {
2170 location = &computed_location;
2176 ReportBootstrappingException(exception, location);
2188 if (
v8_flags.experimental_report_exceptions_from_callbacks &&
2189 exception_propagation_callback_ && !rethrowing_message &&
2218#if V8_ENABLE_WEBASSEMBLY
2221class SetThreadInWasmFlagScope {
2223 SetThreadInWasmFlagScope() { trap_handler::AssertThreadNotInWasm(); }
2225 ~SetThreadInWasmFlagScope() {
2226 if (
enabled_) trap_handler::SetThreadInWasm();
2246#if V8_ENABLE_WEBASSEMBLY
2253 SetThreadInWasmFlagScope set_thread_in_wasm_flag_scope;
2258 Address instruction_start, intptr_t handler_offset,
2260 Address handler_fp,
int num_frames_above_handler) {
2264 instruction_start + handler_offset;
2269 num_frames_above_handler;
2271#if V8_ENABLE_WEBASSEMBLY
2277 if (active_stack !=
nullptr) {
2279 while (active_stack != iter.wasm_stack()) {
2282 SwitchStacks(active_stack, parent);
2284 RetireWasmStack(active_stack);
2285 active_stack = parent;
2290#if USE_SIMULATOR_BOOL && V8_TARGET_ARCH_ARM64
2291 Simulator::current(
this)->SetStackLimit(
2302 iter.wasm_stack()->ShrinkTo(stack_address);
2304 reinterpret_cast<uintptr_t
>(iter.wasm_stack()->jslimit());
2308#if USE_SIMULATOR_BOOL && V8_TARGET_ARCH_ARM64
2309 Simulator::current(
this)->SetStackLimit(limit);
2311 iter.wasm_stack()->clear_stack_switch_info();
2328 if (!catchable_by_js && !
context().is_null()) {
2339 int visited_frames = 0;
2341 iter.
Advance(), visited_frames++) {
2342#if V8_ENABLE_WEBASSEMBLY
2343 if (iter.
frame()->
type() == StackFrame::STACK_SWITCH) {
2345 Builtin::kJSToWasmStressSwitchStacksAsm) {
2347 builtins()->
code(Builtin::kWasmReturnPromiseOnSuspendAsm);
2350 code->InstructionStart(
this, iter.
frame()->
pc());
2351 int handler_offset = table.LookupReturn(0);
2352 return FoundHandler(iter,
Context(), instruction_start, handler_offset,
2354 iter.
frame()->
fp(), visited_frames);
2373 if (
debug()->ShouldRestartFrame(frame->
id())) {
2375 CHECK(!catchable_by_js);
2382 CHECK(code->marked_for_deoptimization());
2388 static_cast<int>(frame->
pc() - code->instruction_start());
2396 return FoundHandler(iter,
Context(), code->instruction_start(),
offset,
2397 code->constant_pool(), return_sp, frame->
fp(),
2403 return FoundHandler(iter,
Context(), code->instruction_start(), 0,
2408 switch (frame->
type()) {
2409 case StackFrame::ENTRY:
2410 case StackFrame::CONSTRUCT_ENTRY: {
2420 return FoundHandler(iter,
Context(),
2421 code->InstructionStart(
this, frame->
pc()),
2422 table.LookupReturn(0), code->constant_pool(),
2427#if V8_ENABLE_WEBASSEMBLY
2428 case StackFrame::C_WASM_ENTRY: {
2429#if V8_ENABLE_DRUMBRAKE
2437 Address instruction_start = code->InstructionStart(
this, frame->
pc());
2441 frame->
fp() + WasmInterpreterCWasmEntryConstants::kSPFPOffset);
2442 const int handler_offset = table.LookupReturn(0);
2446 return FoundHandler(iter,
Context(), instruction_start,
2447 handler_offset, code->constant_pool(), return_sp,
2448 frame->
fp(), visited_frames);
2456 Address instruction_start = code->instruction_start();
2457 int return_offset =
static_cast<int>(frame->
pc() - instruction_start);
2458 int handler_offset = table.LookupReturn(return_offset);
2465 return FoundHandler(iter,
Context(), instruction_start, handler_offset,
2466 code->constant_pool(), return_sp, frame->
fp(),
2470#if V8_ENABLE_DRUMBRAKE
2471 case StackFrame::WASM_INTERPRETER_ENTRY: {
2478 case StackFrame::WASM:
2479 case StackFrame::WASM_SEGMENT_START: {
2482 WasmFrame* wasm_frame =
static_cast<WasmFrame*
>(frame);
2485 int offset = wasm_frame->LookupExceptionHandlerInTable();
2500#if V8_ENABLE_DRUMBRAKE
2502 if (
v8_flags.wasm_enable_exec_time_histograms &&
2505 wasm_execution_timer()->Start();
2512 set_thread_in_wasm_flag_scope.Enable();
2515 frame->
fp(), visited_frames);
2518 case StackFrame::WASM_LIFTOFF_SETUP: {
2525 case StackFrame::MAGLEV:
2526 case StackFrame::TURBOFAN_JS: {
2528 if (!catchable_by_js)
break;
2543 code->marked_for_deoptimization()) {
2547 offset =
static_cast<int>(frame->
pc() - code->instruction_start());
2551 return FoundHandler(
2553 code->constant_pool(), return_sp, frame->
fp(), visited_frames);
2556 case StackFrame::STUB: {
2558 if (!catchable_by_js)
break;
2560#if V8_ENABLE_WEBASSEMBLY
2567 if (!code->is_turbofanned() || !code->has_handler_table()) {
2580 return FoundHandler(
2582 code->constant_pool(), return_sp, frame->
fp(), visited_frames);
2585 case StackFrame::INTERPRETED:
2586 case StackFrame::BASELINE: {
2588 if (!catchable_by_js)
break;
2592 int context_reg = 0;
2611 DCHECK(IsContext(context));
2620 return FoundHandler(iter,
Context(), code->instruction_start(),
2621 pc_offset, code->constant_pool(), return_sp,
2622 sp_frame->
fp(), visited_frames);
2625 static_cast<int>(
offset));
2636 return FoundHandler(iter, context, code->instruction_start(), 0,
2637 code->constant_pool(), return_sp, frame->
fp(),
2638 visited_frames - 1);
2642 case StackFrame::BUILTIN:
2644 if (catchable_by_js) {
2650 case StackFrame::JAVASCRIPT_BUILTIN_CONTINUATION_WITH_CATCH: {
2652 if (!catchable_by_js)
break;
2660 return FoundHandler(iter,
Context(), code->instruction_start(), 0,
2661 code->constant_pool(), return_sp, frame->
fp(),
2685class StackFrameSummaryIterator {
2687 explicit StackFrameSummaryIterator(
Isolate* isolate)
2703 const FrameSummary& frame_summary()
const {
2704 DCHECK(has_frame_summary());
2710 void InitSummaries() {
2711 if (!done() && frame()->is_javascript()) {
2712 summaries_ = JavaScriptFrame::cast(frame())->Summarize();
2723 switch (builtin_id) {
2725 case Builtin::k##Name: \
2726 return HandlerTable::PROMISE;
2736 HandlerTable table(bytecode);
2737 int handler_index = table.LookupHandlerIndexForRange(code_offset);
2739 return table.GetRangePrediction(handler_index);
2744 if (!summary.IsJavaScript()) {
2752 DirectHandle<AbstractCode> code = summary.AsJavaScript().abstract_code();
2753 if (code->kind(
cage_base) == CodeKind::BUILTIN) {
2754 return CatchPredictionFor(code->GetCode()->builtin_id());
2759 return PredictExceptionFromBytecode(code->GetBytecodeArray(),
2760 summary.code_offset());
2764 DirectHandle<JSGeneratorObject> generator,
Isolate* isolate) {
2765 return PredictExceptionFromBytecode(
2766 generator->function()->shared()->GetBytecodeArray(isolate),
2767 GetGeneratorBytecodeOffset(generator));
2771 switch (prediction) {
2787 const StackFrameSummaryIterator& iterator) {
2788 const StackFrame* frame = iterator.frame();
2789 switch (frame->type()) {
2790 case StackFrame::ENTRY:
2791 case StackFrame::CONSTRUCT_ENTRY: {
2793 iterator.isolate()->thread_local_top()->try_catch_handler_address();
2794 Address entry_handler = frame->top_handler()->next_address();
2798 !iterator.isolate()->try_catch_handler()->IsVerbose()) {
2799 if (entry_handler ==
kNullAddress || entry_handler > external_handler) {
2806 case StackFrame::INTERPRETED:
2807 case StackFrame::BASELINE:
2808 case StackFrame::TURBOFAN_JS:
2809 case StackFrame::MAGLEV:
2810 case StackFrame::BUILTIN: {
2811 DCHECK(iterator.has_frame_summary());
2813 PredictException(iterator.frame_summary(), iterator.isolate()));
2816 case StackFrame::STUB: {
2818 if (code->kind() != CodeKind::BUILTIN || !code->has_handler_table() ||
2819 !code->is_turbofanned()) {
2823 return ToCatchType(CatchPredictionFor(code->builtin_id()));
2826 case StackFrame::JAVASCRIPT_BUILTIN_CONTINUATION_WITH_CATCH: {
2828 return ToCatchType(CatchPredictionFor(code->builtin_id()));
2846 for (StackFrameSummaryIterator iter(
this); !iter.done(); iter.Advance()) {
2848 if (prediction !=
NOT_CAUGHT)
return prediction;
2867 for (
int i = 0;
i < frames->
length(); ++
i) {
2870 if (should_include_frame_callback) {
2871 Tagged<Object> raw_script_name = frame->GetScriptNameOrSourceURL();
2875 if (IsString(raw_script_name)) {
2878 script_name_local = v8::Utils::ToLocal(script_name);
2883 if (should_include_frame_callback(v8_isolate, script_name_local)) {
2896 stack_trace->PrintOn(out);
2901 if (it.done())
return false;
2905#if V8_ENABLE_WEBASSEMBLY
2911 if (!IsScript(*script) ||
2916 if (summary.IsJavaScript()) {
2917 shared =
handle(summary.AsJavaScript().function()->shared(),
this);
2931 if (!IsJSObject(*exception))
return false;
2936 if (!
IsSmi(*start_pos))
return false;
2937 int start_pos_value =
Cast<Smi>(*start_pos).value();
2942 if (!
IsSmi(*end_pos))
return false;
2943 int end_pos_value =
Cast<Smi>(*end_pos).value();
2948 if (!IsScript(*script))
return false;
2951 *target =
MessageLocation(cast_script, start_pos_value, end_pos_value);
2957 if (!IsJSReceiver(*exception)) {
2962 for (
int i = 0;
i < call_site_infos->length(); ++
i) {
2974 if (!IsJSReceiver(*exception))
return false;
2978 if (stack_trace.
is_null() || stack_trace->length() == 0) {
2992 if (IsJSObject(*exception)) {
3008 if (location ==
nullptr &&
3012 location = &computed_location;
3016 MessageTemplate::kUncaughtException,
3017 location, exception, stack_trace);
3023 if (IsJSError(*exception)) {
3031 location = &computed_location;
3035 MessageTemplate::kPlaceholderOnly,
3036 location, exception, stack_trace);
3067 if (external_handler < js_handler) {
3074 return code_pages_.load(std::memory_order_acquire);
3078 code_pages_.store(new_code_pages, std::memory_order_release);
3089 if (!has_been_propagated)
return;
3090 if (!report)
return;
3092 DCHECK(AllowExceptions::IsAllowed(
this));
3095 AllowJavascriptExecutionDebugOnly allow_script(
this);
3111 bool should_report_exception;
3115 should_report_exception =
true;
3119 if (!IsTheHole(message_obj,
this) && should_report_exception) {
3130 int start_pos = message->GetStartPosition();
3131 int end_pos = message->GetEndPosition();
3138bool ReceiverIsForwardingHandler(
Isolate* isolate,
3148 isolate->factory()->promise_forwarding_handler_symbol();
3151 return !IsUndefined(*forwarding_handler, isolate);
3154bool WalkPromiseTreeInternal(
3155 Isolate* isolate, DirectHandle<JSPromise> promise,
3156 const std::function<
void(Isolate::PromiseHandler)>&
callback) {
3163 bool any_caught =
false;
3164 bool any_uncaught =
false;
3165 DirectHandle<Object>
current(promise->reactions(), isolate);
3166 while (!
IsSmi(*current)) {
3168 DirectHandle<HeapObject> promise_or_capability(
3169 reaction->promise_or_capability(), isolate);
3170 if (!IsUndefined(*promise_or_capability, isolate)) {
3171 if (!IsJSPromise(*promise_or_capability)) {
3175 if (IsJSPromise(*promise_or_capability)) {
3176 DirectHandle<JSPromise> next_promise =
3178 bool caught =
false;
3179 DirectHandle<JSReceiver> reject_handler;
3180 if (!IsUndefined(reaction->reject_handler(), isolate)) {
3183 if (!ReceiverIsForwardingHandler(isolate, reject_handler) &&
3184 !IsBuiltinForwardingRejectHandler(isolate, *reject_handler)) {
3189 DirectHandle<JSGeneratorObject> async_function;
3190 if (TryGetAsyncGenerator(isolate, reaction).ToHandle(&async_function)) {
3192 PredictExceptionFromGenerator(async_function, isolate) ==
3195 callback({async_function->function()->shared(),
true});
3198 if (!IsUndefined(reaction->fulfill_handler(), isolate)) {
3199 DirectHandle<JSReceiver> fulfill_handler(
3201 if (!ReceiverIsForwardingHandler(isolate, fulfill_handler)) {
3202 if (IsBuiltinFunction(isolate, *fulfill_handler,
3203 Builtin::kPromiseThenFinally)) {
3206 DirectHandle<Context>
context(
3214 if (IsJSFunction(*fulfill_handler)) {
3222 if (IsJSFunction(*reject_handler)) {
3228 caught || WalkPromiseTreeInternal(isolate, next_promise,
callback);
3229 any_caught = any_caught || caught;
3230 any_uncaught = any_uncaught || !caught;
3233#if V8_ENABLE_WEBASSEMBLY
3234 DirectHandle<WasmSuspenderObject> suspender;
3235 if (TryGetWasmSuspender(isolate, reaction->fulfill_handler())
3236 .ToHandle(&suspender)) {
3240 DirectHandle<JSPromise> next_promise(suspender->promise(), isolate);
3241 bool caught = WalkPromiseTreeInternal(isolate, next_promise,
callback);
3242 any_caught = any_caught || caught;
3243 any_uncaught = any_uncaught || !caught;
3250 bool caught = any_caught && !any_uncaught;
3254 DirectHandle<Symbol>
key = isolate->factory()->promise_handled_by_symbol();
3255 DirectHandle<Object> outer_promise_obj =
3256 JSObject::GetDataProperty(isolate, promise,
key);
3257 if (IsJSPromise(*outer_promise_obj)) {
3258 return WalkPromiseTreeInternal(
3267using interpreter::Bytecodes;
3272PromiseMethod GetPromiseMethod(
3273 Isolate* isolate,
const interpreter::BytecodeArrayIterator& iterator) {
3274 DirectHandle<Object>
object = iterator.GetConstantForIndexOperand(1, isolate);
3275 if (!IsString(*
object)) {
3279 if (str->Equals(ReadOnlyRoots(isolate).then_string())) {
3290bool TouchesRegister(
const interpreter::BytecodeArrayIterator& iterator,
3292 Bytecode bytecode = iterator.current_bytecode();
3293 int num_operands = Bytecodes::NumberOfOperands(bytecode);
3295 Bytecodes::GetOperandTypes(bytecode);
3297 for (
int i = 0;
i < num_operands; ++
i) {
3298 if (Bytecodes::IsRegisterOperandType(operand_types[
i])) {
3299 int base_index = iterator.GetRegisterOperand(
i).index();
3301 if (Bytecodes::IsRegisterListOperandType(operand_types[
i])) {
3302 num_registers = iterator.GetRegisterCountOperand(++
i);
3305 Bytecodes::GetNumberOfRegistersRepresentedBy(operand_types[
i]);
3308 if (base_index <= index && index < base_index + num_registers) {
3314 if (Bytecodes::WritesImplicitRegister(bytecode)) {
3315 return iterator.GetStarTargetRegister().index() ==
index;
3323 interpreter::BytecodeArrayIterator iterator(bytecode_array,
offset);
3325 while (!iterator.done()) {
3330 if (!Bytecodes::WritesAccumulator(iterator.current_bytecode())) {
3337 if (iterator.done()) {
3340 if (iterator.current_bytecode() == Bytecode::kStaCurrentContextSlot) {
3344 unsigned int slot = iterator.GetIndexOperand(0);
3346 if (!iterator.done() &&
3347 (iterator.current_bytecode() ==
3348 Bytecode::kLdaImmutableCurrentContextSlot ||
3349 iterator.current_bytecode() == Bytecode::kLdaCurrentContextSlot)) {
3350 if (iterator.GetIndexOperand(0) != slot) {
3355 }
else if (iterator.current_bytecode() == Bytecode::kStaContextSlot) {
3359 int context = iterator.GetRegisterOperand(0).index();
3360 unsigned int slot = iterator.GetIndexOperand(1);
3361 unsigned int depth = iterator.GetUnsignedImmediateOperand(2);
3363 if (!iterator.done() &&
3364 (iterator.current_bytecode() == Bytecode::kLdaImmutableContextSlot ||
3365 iterator.current_bytecode() == Bytecode::kLdaContextSlot)) {
3366 if (iterator.GetRegisterOperand(0).index() != context ||
3367 iterator.GetIndexOperand(1) != slot ||
3368 iterator.GetUnsignedImmediateOperand(2) != depth) {
3373 }
else if (iterator.current_bytecode() == Bytecode::kStaLookupSlot) {
3377 unsigned int slot = iterator.GetIndexOperand(0);
3379 if (!iterator.done() &&
3380 (iterator.current_bytecode() == Bytecode::kLdaLookupSlot ||
3381 iterator.current_bytecode() ==
3382 Bytecode::kLdaLookupSlotInsideTypeof)) {
3383 if (iterator.GetIndexOperand(0) != slot) {
3391 if (iterator.done() || !Bytecodes::IsAnyStar(iterator.current_bytecode())) {
3395 int promise_register = iterator.GetStarTargetRegister().index();
3403 if (iterator.done() ||
3404 iterator.current_bytecode() != Bytecode::kGetNamedProperty ||
3405 iterator.GetRegisterOperand(0).index() != promise_register) {
3408 PromiseMethod
method = GetPromiseMethod(isolate, iterator);
3415 if (iterator.done() || !Bytecodes::IsAnyStar(iterator.current_bytecode())) {
3419 int method_register = iterator.GetStarTargetRegister().index();
3420 if (method_register == promise_register) {
3428 if (iterator.done()) {
3431 Bytecode bytecode = iterator.current_bytecode();
3432 if (bytecode == Bytecode::kCallProperty1 ||
3433 bytecode == Bytecode::kCallProperty2) {
3436 if (iterator.GetRegisterOperand(0).index() == method_register &&
3437 iterator.GetRegisterOperand(1).index() == promise_register) {
3440 (
method ==
kThen && bytecode == Bytecode::kCallProperty2)) {
3450 if (Bytecodes::IsJump(bytecode) || Bytecodes::IsSwitch(bytecode) ||
3451 Bytecodes::Returns(bytecode) ||
3452 Bytecodes::UnconditionallyThrows(bytecode)) {
3457 if (TouchesRegister(iterator, promise_register) ||
3458 TouchesRegister(iterator, method_register)) {
3468bool CallsCatchMethod(
const StackFrameSummaryIterator& iterator) {
3469 if (!iterator.frame()->is_javascript()) {
3472 if (iterator.frame_summary().IsJavaScript()) {
3473 auto& js_summary = iterator.frame_summary().AsJavaScript();
3474 if (IsBytecodeArray(*js_summary.abstract_code())) {
3475 if (CallsCatchMethod(iterator.isolate(),
3477 js_summary.code_offset())) {
3490 bool is_promise_rejection =
false;
3493 if (rejected_promise.
ToHandle(&promise)) {
3494 is_promise_rejection =
true;
3502 }
else if (
IsSmi(promise->reactions())) {
3505 if (!IsJSPromise(*JSObject::GetDataProperty(
this, promise,
key))) {
3518 for (StackFrameSummaryIterator iter(
this); !iter.done(); iter.Advance()) {
3522 if (rejected_promise.
is_null()) {
3523 switch (prediction) {
3527 caught = is_promise_rejection && CallsCatchMethod(iter);
3532 caught = is_promise_rejection && CallsCatchMethod(iter);
3534 is_promise_rejection =
true;
3542 is_promise_rejection =
true;
3546 caught = !is_promise_rejection;
3551 DCHECK(iter.has_frame_summary());
3553 if (is_promise_rejection && summary.IsJavaScript()) {
3562 CallsCatchMethod(iter);
3575 if (iter.frame()->is_javascript()) {
3576 bool debuggable =
false;
3577 DCHECK(iter.has_frame_summary());
3579 if (summary.IsJavaScript()) {
3580 const auto& info = summary.AsJavaScript().function()->shared();
3581 if (info->IsSubjectToDebugging()) {
3590 if (debuggable && !rejected_promise.
is_null()) {
3600 if (rejected_promise.
is_null()) {
3602 rejected_promise = TryGetCurrentTaskPromise(
this);
3605 if (rejected_promise.
ToHandle(&promise)) {
3606 return WalkPromiseTreeInternal(
this, promise,
callback);
3633 if (!global->map()->is_extensible())
return;
3646 if (!
v8_flags.enable_sharedarraybuffer_per_context)
return true;
3648 if (sharedarraybuffer_constructor_enabled_callback()) {
3650 return sharedarraybuffer_constructor_enabled_callback()(api_context);
3656#ifdef V8_ENABLE_WEBASSEMBLY
3660 wasm_imported_strings_enabled_callback();
3661 if (callback_imported_strings) {
3663 if (callback_imported_strings(api_context))
return true;
3666 return v8_flags.experimental_wasm_stringref;
3673#ifdef V8_ENABLE_WEBASSEMBLY
3674 if (
v8_flags.wasm_jitless)
return false;
3677 if (jspi_callback) {
3679 if (jspi_callback(api_context))
return true;
3683 return v8_flags.experimental_wasm_jspi;
3690#ifdef V8_ENABLE_WEBASSEMBLY
3692 context->is_wasm_jspi_installed() !=
Smi::zero();
3700#ifdef V8_ENABLE_WEBASSEMBLY
3702 wasm_imported_strings_enabled_callback();
3705 if (
callback(api_context))
return true;
3707 return v8_flags.experimental_wasm_imported_strings;
3720 Address top_backup_incumbent =
3725 (!top_backup_incumbent || it.frame()->sp() < top_backup_incumbent)) {
3730 context->native_context());
3748 reinterpret_cast<v8::Isolate*
>(
this)->GetEnteredOrMicrotaskContext();
3771 for (; l !=
nullptr; l =
n) {
3772 l->external_memory_accounter_.Decrease(
3773 reinterpret_cast<v8::Isolate*
>(
this), l->estimated_size_);
3774 l->destructor_(l->shared_ptr_ptr_);
3785 if (location >= last_root)
return false;
3786 if (location < first_root)
return false;
3803 if (destructor->
prev_) {
3810 destructor->
prev_ =
nullptr;
3811 destructor->
next_ =
nullptr;
3818 if (!isolate)
return;
3822#if V8_ENABLE_WEBASSEMBLY
3824 auto stack = SimulatorStack::GetCentralStackView(
this);
3827 return stack_top < addr && addr <= stack_base;
3838void Isolate::AddSharedWasmMemory(
3839 DirectHandle<WasmMemoryObject> memory_object) {
3840 DirectHandle<WeakArrayList> shared_wasm_memories =
3841 factory()->shared_wasm_memories();
3844 heap()->set_shared_wasm_memories(*shared_wasm_memories);
3847void Isolate::SwitchStacks(wasm::StackMemory* from, wasm::StackMemory* to) {
3857 if (
v8_flags.trace_wasm_stack_switching) {
3859 PrintF(
"Switch from stack %d to %d (resume/start)\n", from->id(),
3862 PrintF(
"Switch from stack %d to %d (suspend/return)\n", from->id(),
3869 to->jmpbuf()->parent =
from;
3877 uintptr_t limit =
reinterpret_cast<uintptr_t
>(to->jmpbuf()->stack_limit);
3889 reinterpret_cast<Address>(to->jmpbuf()->stack_limit);
3895 reinterpret_cast<Address>(from->jmpbuf()->stack_limit);
3899void Isolate::RetireWasmStack(wasm::StackMemory* stack) {
3901 size_t index = stack->index();
3904 std::unique_ptr<wasm::StackMemory> stack_ptr =
3905 std::move(wasm_stacks()[index]);
3907 if (index != wasm_stacks().
size() - 1) {
3908 wasm_stacks()[
index] = std::move(wasm_stacks().back());
3909 wasm_stacks()[
index]->set_index(index);
3911 wasm_stacks().pop_back();
3912 for (
size_t i = 0;
i < wasm_stacks().
size(); ++
i) {
3915 stack_pool().Add(std::move(stack_ptr));
3918wasm::WasmOrphanedGlobalHandle* Isolate::NewWasmOrphanedGlobalHandle() {
3925#if defined(USE_SIMULATOR)
3933 if (t ==
table_.end())
return nullptr;
3938 bool inserted =
table_.insert(std::make_pair(data->thread_id_, data)).second;
3943 table_.erase(data->thread_id_);
3962 UpdateMemoryTrafficAndReportMemoryUsage(segment->
total_size());
3967 active_zones_.insert(zone);
3973#ifdef V8_ENABLE_PRECISE_ZONE_STATS
3974 if (
v8_flags.trace_zone_type_stats) {
3975 type_stats_.MergeWith(zone->type_stats());
3979 active_zones_.erase(zone);
3982#ifdef V8_ENABLE_PRECISE_ZONE_STATS
3983 if (
v8_flags.trace_zone_type_stats && active_zones_.empty()) {
3992 !(TracingFlags::zone_stats.load(std::memory_order_relaxed) &
3999 memory_traffic_since_last_report_ += memory_traffic_delta;
4000 if (memory_traffic_since_last_report_ <
v8_flags.zone_stats_tolerance)
4002 memory_traffic_since_last_report_ = 0;
4007 std::string trace_str =
buffer_.str();
4012 "\"type\": \"v8-zone-trace\", "
4018 TracingFlags::zone_stats.load(std::memory_order_relaxed) &
4030 void Dump(std::ostringstream& out,
bool dump_details) {
4033 double time =
isolate_->time_millis_since_init();
4034 out <<
"{" <<
"\"isolate\": \"" <<
reinterpret_cast<void*
>(
isolate_)
4035 <<
"\", " <<
"\"time\": " << time <<
", ";
4036 size_t total_segment_bytes_allocated = 0;
4037 size_t total_zone_allocation_size = 0;
4038 size_t total_zone_freed_size = 0;
4042 out <<
"\"zones\": [";
4044 for (
const Zone* zone : active_zones_) {
4045 size_t zone_segment_bytes_allocated = zone->segment_bytes_allocated();
4046 size_t zone_allocation_size = zone->allocation_size_for_tracing();
4047 size_t freed_size = zone->freed_size_for_tracing();
4053 out <<
"{" <<
"\"name\": \"" << zone->name() <<
"\", "
4054 <<
"\"allocated\": " << zone_segment_bytes_allocated <<
", "
4055 <<
"\"used\": " << zone_allocation_size <<
", "
4056 <<
"\"freed\": " << freed_size <<
"}";
4057 total_segment_bytes_allocated += zone_segment_bytes_allocated;
4058 total_zone_allocation_size += zone_allocation_size;
4059 total_zone_freed_size += freed_size;
4064 for (
const Zone* zone : active_zones_) {
4065 total_segment_bytes_allocated += zone->segment_bytes_allocated();
4066 total_zone_allocation_size += zone->allocation_size_for_tracing();
4067 total_zone_freed_size += zone->freed_size_for_tracing();
4070 out <<
"\"allocated\": " << total_segment_bytes_allocated <<
", "
4071 <<
"\"used\": " << total_zone_allocation_size <<
", "
4072 <<
"\"freed\": " << total_zone_freed_size <<
"}";
4076 std::atomic<size_t> nesting_depth_{0};
4080#ifdef V8_ENABLE_PRECISE_ZONE_STATS
4081 TypeStats type_stats_;
4085 size_t memory_traffic_since_last_report_ = 0;
4089std::atomic<size_t> Isolate::non_disposed_isolates_;
4108 non_disposed_isolates_++;
4124 Isolate* saved_isolate = isolate->TryGetCurrent();
4127 isolate->heap()->SetStackStart();
4132 non_disposed_isolates_--;
4136 isolate->~Isolate();
4163 id_(isolate_counter.fetch_add(1,
std::memory_order_relaxed)),
4168 num_active_deserializers_(0),
4178#if
defined(V8_ENABLE_ETW_STACK_WALKING)
4179 etw_tracing_enabled_(false),
4180 etw_trace_interpreted_frames_(
v8_flags.interpreted_frames_native_stack),
4181 etw_in_rundown_(false),
4193#define ISOLATE_INIT_EXECUTE(type, name, initial_value) \
4194 name##_ = (initial_value);
4196#undef ISOLATE_INIT_EXECUTE
4198#define ISOLATE_INIT_ARRAY_EXECUTE(type, name, length) \
4199 memset(name##_, 0, sizeof(type) * length);
4201#undef ISOLATE_INIT_ARRAY_EXECUTE
4208#if V8_ENABLE_WEBASSEMBLY
4223 i::trap_handler::SetLandingPad(landing_pad);
4231#ifdef V8_ENABLE_SANDBOX
4232 static_assert(
static_cast<int>(
OFFSET_OF(ExternalPointerTable,
base_)) ==
4234 static_assert(
static_cast<int>(
OFFSET_OF(TrustedPointerTable,
base_)) ==
4236 static_assert(
static_cast<int>(
sizeof(ExternalPointerTable)) ==
4238 static_assert(
static_cast<int>(
sizeof(TrustedPointerTable)) ==
4249 static_assert(
static_cast<int>(
4252 static_assert(
static_cast<int>(
OFFSET_OF(
4255 static_assert(
static_cast<int>(
4258 static_assert(
static_cast<int>(
4261 static_assert(
static_cast<int>(
4264 static_assert(
static_cast<int>(
4267 static_assert(
static_cast<int>(
4273 static_assert(
static_cast<int>(
OFFSET_OF(
4289#ifdef V8_COMPRESS_POINTERS
4290 static_assert(
static_cast<int>(
OFFSET_OF(
4292 Internals::kIsolateExternalPointerTableOffset);
4294 static_assert(
static_cast<int>(
OFFSET_OF(
4296 Internals::kIsolateSharedExternalPointerTableAddressOffset);
4298#ifdef V8_ENABLE_SANDBOX
4301 Internals::kIsolateTrustedCageBaseOffset);
4303 static_assert(
static_cast<int>(
4305 Internals::kIsolateTrustedPointerTableOffset);
4307 static_assert(
static_cast<int>(
OFFSET_OF(
4309 Internals::kIsolateSharedTrustedPointerTableAddressOffset);
4311 static_assert(
static_cast<int>(
OFFSET_OF(
4313 Internals::kIsolateCodePointerTableBaseAddressOffset);
4315 static_assert(
static_cast<int>(
OFFSET_OF(
4338 constexpr size_t kCacheLineSize = 64;
4345 static_assert(kCEntryFPCacheLine ==
4348 static_assert(kCEntryFPCacheLine ==
4352 kCEntryFPCacheLine ==
4354 IsolateData, thread_local_top_.topmost_script_having_context_)));
4355 static_assert(kCEntryFPCacheLine ==
4377 delete external_reference_map_;
4378 external_reference_map_ =
nullptr;
4395#if defined(V8_USE_PERFETTO)
4419#if V8_ENABLE_WEBASSEMBLY && V8_ENABLE_DRUMBRAKE
4422 }
else if (
v8_flags.wasm_enable_exec_time_histograms &&
4424 wasm_execution_timer_->Terminate();
4429 if (
v8_flags.stress_sampling_allocation_profiler > 0) {
4445#if V8_ENABLE_WEBASSEMBLY
4448 BackingStore::RemoveSharedWasmMemoryObjects(
this);
4456 PrintF(stdout,
"=== Stress deopt counter: %" PRIu64
"\n",
4478#ifdef V8_ENABLE_SPARKPLUG
4479 delete baseline_batch_compiler_;
4480 baseline_batch_compiler_ =
nullptr;
4483#ifdef V8_ENABLE_MAGLEV
4484 delete maglev_concurrent_dispatcher_;
4485 maglev_concurrent_dispatcher_ =
nullptr;
4531 delete simulator_data_;
4532 simulator_data_ =
nullptr;
4550#if defined(V8_ENABLE_ETW_STACK_WALKING)
4551 if (
v8_flags.enable_etw_stack_walking ||
4552 v8_flags.enable_etw_by_custom_filter_only) {
4557#if V8_ENABLE_WEBASSEMBLY
4560 delete wasm_code_look_up_cache_;
4561 wasm_code_look_up_cache_ =
nullptr;
4575 delete root_index_map_;
4576 root_index_map_ =
nullptr;
4597#ifdef V8_COMPRESS_POINTERS
4598 external_pointer_table().TearDownSpace(
4599 heap()->young_external_pointer_space());
4600 external_pointer_table().TearDownSpace(
heap()->old_external_pointer_space());
4601 external_pointer_table().DetachSpaceFromReadOnlySegment(
4602 heap()->read_only_external_pointer_space());
4603 external_pointer_table().TearDownSpace(
4604 heap()->read_only_external_pointer_space());
4605 external_pointer_table().TearDown();
4607 shared_external_pointer_table().TearDownSpace(
4608 shared_external_pointer_space());
4609 shared_external_pointer_table().TearDown();
4612 delete shared_external_pointer_space_;
4613 shared_external_pointer_space_ =
nullptr;
4615 cpp_heap_pointer_table().TearDownSpace(
heap()->cpp_heap_pointer_space());
4616 cpp_heap_pointer_table().TearDown();
4619#ifdef V8_ENABLE_SANDBOX
4620 trusted_pointer_table().TearDownSpace(
heap()->trusted_pointer_space());
4621 trusted_pointer_table().TearDown();
4623 shared_trusted_pointer_table().TearDownSpace(
4624 shared_trusted_pointer_space());
4625 shared_trusted_pointer_table().TearDown();
4628 delete shared_trusted_pointer_space_;
4629 shared_trusted_pointer_space_ =
nullptr;
4633 heap()->code_pointer_space());
4635#ifdef V8_ENABLE_LEAPTIERING
4637 heap()->js_dispatch_table_space());
4649 g_current_per_isolate_thread_data_ =
data;
4651#ifdef V8_COMPRESS_POINTERS_IN_MULTIPLE_CAGES
4654 IsolateGroup::set_current(isolate ? isolate->isolate_group() :
nullptr);
4655#ifdef V8_EXTERNAL_CODE_SPACE
4656 ExternalCodeCompressionScheme::InitBase(isolate ? isolate->code_cage_base()
4659#ifdef V8_ENABLE_SANDBOX
4660 Sandbox::set_current(isolate ? isolate->isolate_group()->sandbox() :
nullptr);
4664 if (isolate && isolate->main_thread_local_isolate()) {
4666 isolate->main_thread_local_heap()->marking_barrier());
4708 delete code_tracer();
4709 set_code_tracer(
nullptr);
4726#if V8_ENABLE_WEBASSEMBLY
4730 delete string_stream_debug_object_cache_;
4731 string_stream_debug_object_cache_ =
nullptr;
4750 default_microtask_queue_ == default_microtask_queue_->next());
4751 delete default_microtask_queue_;
4752 default_microtask_queue_ =
nullptr;
4791 handler->can_continue_ =
true;
4792 handler->exception_ =
reinterpret_cast<void*
>(exception.ptr());
4805 if (IsFunctionTemplateInfo(target)) {
4810 return shared_info->api_func_data();
4825 if (it.done() && !ext_callback_scope) {
4831 (ext_callback_scope &&
4843 auto callback_info =
4850 GetTargetFunctionTemplateInfo(*callback_info),
this);
4870 auto callback_info =
4888 DCHECK(IsJSReceiver(*holder));
4901 "ExternalCallbackScope should not use "
4902 "v8::ExceptionContext::kUnknown exception context");
4915 switch (frame_type) {
4916 case StackFrame::API_CALLBACK_EXIT: {
4930 case StackFrame::API_ACCESSOR_EXIT: {
4935 DCHECK(IsJSReceiver(*holder));
4942 case StackFrame::TURBOFAN_JS:
4944 CHECK(it.frame()->InFastCCall());
4947 case StackFrame::EXIT:
4948 case StackFrame::BUILTIN_EXIT:
4951#if V8_ENABLE_WEBASSEMBLY
4952 case StackFrame::WASM:
4953 case StackFrame::WASM_SEGMENT_START:
4972 if (!IsJSReceiver(this->
exception()))
return;
4978 IsUndefined(function->class_name(),
this)
4982 IsUndefined(function->interface_name(),
this)
4997 v8_isolate, v8::Utils::ToLocal(exception),
4998 v8::Utils::ToLocal(interface_name), v8::Utils::ToLocal(property_name),
4999 exception_context));
5003 ReThrow(*exception, *maybe_message);
5011 if (!IsJSReceiver(this->
exception()))
return;
5028 v8_isolate, v8::Utils::ToLocal(exception),
5029 v8::Utils::ToLocal(interface_name), v8::Utils::ToLocal(property_name),
5030 exception_context));
5034 ReThrow(*exception, *maybe_message);
5039 exception_propagation_callback_ =
callback;
5057void FinalizeBuiltinCodeObjects(
Isolate* isolate) {
5059 DCHECK_NE(0, isolate->embedded_blob_code_size());
5061 DCHECK_NE(0, isolate->embedded_blob_data_size());
5072 Address instruction_start = d.InstructionStartOf(builtin);
5074 isolate->factory()->NewCodeObjectForEmbeddedBuiltin(old_code,
5079 isolate->builtins()->set_code(builtin, *new_code);
5084bool IsolateIsCompatibleWithEmbeddedBlob(Isolate* isolate) {
5086 return (d.IsolateHash() == isolate->HashIsolateForEmbeddedBlob());
5098 if (StickyEmbeddedBlobCode() !=
nullptr) {
5101 if (StickyEmbeddedBlobCode() !=
nullptr) {
5102 code = StickyEmbeddedBlobCode();
5103 code_size = StickyEmbeddedBlobCodeSize();
5104 data = StickyEmbeddedBlobData();
5105 data_size = StickyEmbeddedBlobDataSize();
5106 current_embedded_blob_refs_++;
5110 if (code_size == 0) {
5123 if (StickyEmbeddedBlobCode() !=
nullptr) {
5135 this, &code, &code_size, &data, &data_size);
5137 CHECK_EQ(0, current_embedded_blob_refs_);
5138 const uint8_t* const_code =
const_cast<const uint8_t*
>(
code);
5139 const uint8_t* const_data =
const_cast<const uint8_t*
>(
data);
5141 current_embedded_blob_refs_++;
5143 SetStickyEmbeddedBlob(code, code_size, data, data_size);
5147 FinalizeBuiltinCodeObjects(
this);
5152#if defined(V8_OS_ANDROID)
5204 if (StickyEmbeddedBlobCode() ==
nullptr)
return;
5214 current_embedded_blob_refs_--;
5215 if (current_embedded_blob_refs_ == 0 && enable_embedded_blob_refcounting_) {
5227 return Init(
nullptr,
nullptr,
nullptr,
false);
5237 return Init(startup_snapshot_data, read_only_snapshot_data,
5238 shared_heap_snapshot_data, can_rehash);
5242static std::string ToHexString(uintptr_t address) {
5243 std::stringstream stream_address;
5244 stream_address <<
"0x" << std::hex << address;
5245 return stream_address.str();
5252 const uintptr_t isolate_address =
reinterpret_cast<uintptr_t
>(
this);
5254 ToHexString(isolate_address));
5256 const uintptr_t ro_space_firstpage_address =
5259 ToHexString(ro_space_firstpage_address));
5261 const uintptr_t old_space_firstpage_address =
5264 ToHexString(old_space_firstpage_address));
5266 if (
heap()->code_range_base()) {
5269 ToHexString(code_range_base_address));
5272 if (
heap()->code_space()->first_page()) {
5273 const uintptr_t code_space_firstpage_address =
5276 ToHexString(code_space_firstpage_address));
5280 const uint32_t v8_snapshot_checksum_calculated = 0;
5282 ToHexString(v8_snapshot_checksum_calculated));
5283 const uint32_t v8_snapshot_checksum_expected =
5286 ToHexString(v8_snapshot_checksum_expected));
5302using MapOfLoadsAndStoresPerFunction =
5303 std::map<std::string ,
5304 std::pair<uint64_t , uint64_t >>;
5305MapOfLoadsAndStoresPerFunction* stack_access_count_map =
nullptr;
5310 ~BigIntPlatform()
override =
default;
5312 bool InterruptRequested()
override {
5313 StackLimitCheck interrupt_check(isolate_);
5314 return (interrupt_check.InterruptRequested() &&
5315 isolate_->stack_guard()->HasTerminationRequest());
5323#ifdef V8_COMPRESS_POINTERS
5324VirtualMemoryCage* Isolate::GetPtrComprCodeCageForTesting() {
5331#if V8_STATIC_ROOTS_BOOL
5332#define STATIC_ROOTS_FAILED_MSG \
5333 "Read-only heap layout changed. Run `tools/dev/gen-static-roots.py` to " \
5334 "update static-roots.h."
5336 StaticReadOnlyRootsPointerTable.size(),
5340 for (
Tagged_t cmp_ptr : StaticReadOnlyRootsPointerTable) {
5341 Address the_root = roots[idx];
5349#define CHECK_NAME(_1, _2, CamelName) \
5350 CHECK_WITH_MSG(StaticReadOnlyRoot::k##CamelName == \
5351 V8HeapCompressionScheme::CompressObject(roots[idx]), \
5352 STATIC_ROOTS_FAILED_MSG); \
5374#define INSTANCE_TYPE_CHECKER_SINGLE(type, _) \
5375 CHECK_EQ(InstanceTypeChecker::Is##type(map), \
5376 InstanceTypeChecker::Is##type(map->instance_type()));
5378#undef INSTANCE_TYPE_CHECKER_SINGLE
5380#define INSTANCE_TYPE_CHECKER_RANGE(type, _1, _2) \
5381 CHECK_EQ(InstanceTypeChecker::Is##type(map), \
5382 InstanceTypeChecker::Is##type(map->instance_type()));
5384#undef INSTANCE_TYPE_CHECKER_RANGE
5388 InstanceTypeChecker::IsPrimitiveHeapObject(map->instance_type()),
5391 CHECK_IMPLIES(InstanceTypeChecker::IsJSReceiver(map->instance_type()),
5397 if (InstanceTypeChecker::IsString(map->instance_type())) {
5398 CHECK_EQ(InstanceTypeChecker::IsString(map),
5399 InstanceTypeChecker::IsString(map->instance_type()));
5425 static_cast<int>(RootIndex::kNullValue)),
5427#undef STATIC_ROOTS_FAILED_MSG
5433 SnapshotData* shared_heap_snapshot_data,
bool can_rehash) {
5436#ifdef V8_COMPRESS_POINTERS_IN_SHARED_CAGE
5440 const bool create_heap_objects = (shared_heap_snapshot_data ==
nullptr);
5442 DCHECK_EQ(create_heap_objects, startup_snapshot_data ==
nullptr);
5443 DCHECK_EQ(create_heap_objects, read_only_snapshot_data ==
nullptr);
5448 if (create_heap_objects &&
v8_flags.profile_deserialization) timer.
Start();
5456 Isolate*
const use_shared_space_isolate =
5471#define ASSIGN_ELEMENT(CamelName, hacker_name) \
5472 isolate_addresses_[IsolateAddressId::k##CamelName##Address] = \
5473 reinterpret_cast<Address>(hacker_name##_address());
5475#undef ASSIGN_ELEMENT
5492 isolate_data()->set_regexp_static_result_offsets_vector(
5493 jsregexp_static_offsets_vector());
5502 if (
v8_flags.lazy_compile_dispatcher) {
5506#ifdef V8_ENABLE_SPARKPLUG
5509#ifdef V8_ENABLE_MAGLEV
5510 maglev_concurrent_dispatcher_ =
new maglev::MaglevConcurrentDispatcher(
this);
5514 simulator_data_ =
new SimulatorData;
5541#if V8_ENABLE_WEBASSEMBLY
5547 std::optional<base::RecursiveMutexGuard> clients_guard;
5550 clients_guard.emplace(
5561 use_shared_space_isolate->
heap()
5571 if (!create_heap_objects) {
5582#ifdef V8_COMPRESS_POINTERS
5583 external_pointer_table().Initialize();
5584 external_pointer_table().InitializeSpace(
5585 heap()->read_only_external_pointer_space());
5586 external_pointer_table().AttachSpaceToReadOnlySegment(
5587 heap()->read_only_external_pointer_space());
5588 external_pointer_table().InitializeSpace(
5589 heap()->young_external_pointer_space());
5590 external_pointer_table().InitializeSpace(
5591 heap()->old_external_pointer_space());
5592 cpp_heap_pointer_table().Initialize();
5593 cpp_heap_pointer_table().InitializeSpace(
heap()->cpp_heap_pointer_space());
5596#ifdef V8_ENABLE_SANDBOX
5597 trusted_pointer_table().Initialize();
5598 trusted_pointer_table().InitializeSpace(
heap()->trusted_pointer_space());
5621#ifdef V8_EXTERNAL_CODE_SPACE
5632 code_cage_base_ = ExternalCodeCompressionScheme::PrepareCageBaseAddress(
5636 ExternalCodeCompressionScheme::InitBase(code_cage_base_);
5638 CHECK_EQ(ExternalCodeCompressionScheme::base(), code_cage_base_);
5642 using ComprScheme = ExternalCodeCompressionScheme;
5649 CHECK_EQ(last, ComprScheme::DecompressTagged(
5652 ComprScheme::DecompressTagged(
5659#ifdef V8_COMPRESS_POINTERS
5661 isolate_data_.shared_external_pointer_table_ =
new ExternalPointerTable();
5662 shared_external_pointer_space_ =
new ExternalPointerTable::Space();
5663 shared_external_pointer_table().Initialize();
5664 shared_external_pointer_table().InitializeSpace(
5665 shared_external_pointer_space());
5670 shared_external_pointer_space_ =
5675#ifdef V8_ENABLE_SANDBOX
5677 heap()->code_pointer_space());
5679 isolate_data_.shared_trusted_pointer_table_ =
new TrustedPointerTable();
5680 shared_trusted_pointer_space_ =
new TrustedPointerTable::Space();
5681 shared_trusted_pointer_table().Initialize();
5682 shared_trusted_pointer_table().InitializeSpace(
5683 shared_trusted_pointer_space());
5688 shared_trusted_pointer_space_ =
5693#ifdef V8_ENABLE_LEAPTIERING
5695 heap()->js_dispatch_table_space());
5698#if V8_ENABLE_WEBASSEMBLY
5702#if defined(V8_ENABLE_ETW_STACK_WALKING)
5703 if (
v8_flags.enable_etw_stack_walking ||
5704 v8_flags.enable_etw_by_custom_filter_only) {
5719 if (create_heap_objects) {
5733 if (create_heap_objects) {
5736 if (
v8_flags.concurrent_builtin_generation) {
5744 if (
v8_flags.concurrent_builtin_generation) {
5764 !
v8_flags.concurrent_turbo_tracing) {
5765 PrintF(
"Concurrent recompilation has been disabled for tracing.\n");
5775 if (!create_heap_objects) {
5778 this, shared_heap_snapshot_data, can_rehash);
5806 if (!IsolateIsCompatibleWithEmbeddedBlob(
this)) {
5808 "The Isolate is incompatible with the embedded blob. This is usually "
5809 "caused by incorrect usage of mksnapshot. When generating custom "
5810 "snapshots, embedders must ensure they pass the same flags as during "
5811 "the V8 build process (e.g.: --turbo-instruction-scheduling).");
5823 if (!create_heap_objects)
5832 *
factory()->undefined_value();
5841 if (
v8_flags.stress_sampling_allocation_profiler > 0) {
5842 uint64_t sample_interval =
v8_flags.stress_sampling_allocation_profiler;
5843 int stack_depth = 128;
5847 sample_interval, stack_depth, sampling_flags);
5850 if (create_heap_objects &&
v8_flags.profile_deserialization) {
5851 double ms = timer.Elapsed().InMillisecondsF();
5852 PrintF(
"[Initializing isolate from scratch took %0.3f ms]\n", ms);
5856 SLOW_DCHECK(SharedFunctionInfo::UniqueIdsAreUnique(
this));
5863 std::make_unique<SharedStructTypeRegistry>();
5869#ifdef V8_ENABLE_WEBASSEMBLY
5870#if V8_STATIC_ROOTS_BOOL
5873 reinterpret_cast<void*
>(
factory()->wasm_null()->payload()),
5886#if defined(V8_ENABLE_ETW_STACK_WALKING)
5887 if (
v8_flags.enable_etw_stack_walking ||
5888 v8_flags.enable_etw_by_custom_filter_only) {
5893#if defined(V8_USE_PERFETTO)
5903 Isolate* current_isolate =
nullptr;
5906#ifdef V8_ENABLE_CHECKS
5909 if (current_thread_id_.IsValid()) {
5912 CHECK_EQ(0, current_thread_counter_);
5915 current_thread_counter_++;
5921 if (current_data !=
nullptr) {
5922 current_isolate = current_data->
isolate_;
5924 if (current_isolate ==
this) {
5928 DCHECK(entry_stack->previous_thread_data ==
nullptr ||
5929 entry_stack->previous_thread_data->thread_id() ==
5932 entry_stack->entry_count++;
5939 DCHECK(data->isolate_ ==
this);
5954 DCHECK(current_entry_stack->previous_thread_data ==
nullptr ||
5955 current_entry_stack->previous_thread_data->thread_id() ==
5958#ifdef V8_ENABLE_CHECKS
5964 if (--current_entry_stack->entry_count > 0)
return;
5973 current_entry_stack->previous_thread_data;
5974 Isolate* previous_isolate = current_entry_stack->previous_isolate;
5976 delete current_entry_stack;
5988 return std::make_unique<PersistentHandles>(
this);
5992 if (
v8_flags.trace_turbo_stack_accesses) {
5994 uint64_t total_loads = 0;
5995 uint64_t total_stores = 0;
5996 os <<
"=== Stack access counters === " << std::endl;
5997 if (!stack_access_count_map) {
5998 os <<
"No stack accesses in optimized/wasm functions found.";
6001 os <<
"Number of optimized/wasm stack-access functions: "
6002 << stack_access_count_map->size() << std::endl;
6003 for (
auto it = stack_access_count_map->cbegin();
6004 it != stack_access_count_map->cend(); it++) {
6005 std::string function_name((*it).first);
6006 std::pair<uint64_t, uint64_t> per_func_count = (*it).second;
6007 os <<
"Name: " << function_name <<
", Loads: " << per_func_count.first
6008 <<
", Stores: " << per_func_count.second << std::endl;
6009 total_loads += per_func_count.first;
6010 total_stores += per_func_count.second;
6012 os <<
"Total Loads: " << total_loads <<
", Total Stores: " << total_stores
6014 stack_access_count_map =
nullptr;
6022 os << ps << std::endl;
6026 os << ps << std::endl;
6031#ifdef V8_ENABLE_MAGLEV
6032 if (maglev_statistics_ !=
nullptr) {
6037 os << ps << std::endl;
6041 os << ps << std::endl;
6043 maglev_statistics_.reset();
6047#if V8_ENABLE_WEBASSEMBLY
6054#if V8_RUNTIME_CALL_STATS
6067 if (
v8_flags.turbo_profiling_output) {
6068 FILE* f = std::fopen(
v8_flags.turbo_profiling_output,
"w");
6070 FATAL(
"Unable to open file \"%s\" for writing.\n",
6071 v8_flags.turbo_profiling_output.value());
6098#ifdef V8_ENABLE_MAGLEV
6099 if (maglev_concurrent_dispatcher()->is_enabled()) {
6101 maglev_concurrent_dispatcher()->Flush(behavior);
6113#ifdef V8_ENABLE_MAGLEV
6115std::shared_ptr<CompilationStatistics> Isolate::GetMaglevStatistics() {
6116 if (maglev_statistics_ ==
nullptr) {
6119 return maglev_statistics_;
6125 if (code_tracer() ==
nullptr) set_code_tracer(
new CodeTracer(
id()));
6126 return code_tracer();
6170 DCHECK(IsUndefined(value,
this) || IsArrayList(value));
6171 heap()->set_feedback_vectors_for_profiling_tools(value);
6175 if (!IsUndefined(
heap()->feedback_vectors_for_profiling_tools(),
this)) {
6177 DCHECK(IsArrayList(
heap()->feedback_vectors_for_profiling_tools()));
6187 !current_obj.
is_null(); current_obj = heap_iterator.
Next()) {
6188 if (!IsFeedbackVector(current_obj))
continue;
6194 if (!shared->IsSubjectToDebugging())
continue;
6196 vectors.emplace_back(vector,
this);
6203 for (
const auto& vector : vectors) list =
ArrayList::Add(
this, list, vector);
6216 Tagged<Map> metamap =
object->map(
this)->map(
this);
6220 }
else if (
native_context->initial_array_prototype() ==
object) {
6222 }
else if (
native_context->initial_string_prototype() ==
object) {
6230 Tagged<Map> metamap =
object->map(
this)->map(
this);
6232 if (metamap ==
ReadOnlyRoots(
this).meta_map())
return false;
6240 if (!object->map()->is_prototype_map())
return;
6241 if (!Protectors::IsNoElementsIntact(
this))
return;
6249 Protectors::InvalidateNoElements(
this);
6263 if ((IsJSTypedArrayPrototype(*
object) || IsJSTypedArray(*
object)) &&
6264 Protectors::IsTypedArrayLengthLookupChainIntact(
this)) {
6265 Protectors::InvalidateTypedArrayLengthLookupChain(
this);
6273 if (IsTypedArrayConstructor(*
object) &&
6274 Protectors::IsTypedArraySpeciesLookupChainIntact(
this)) {
6275 Protectors::InvalidateTypedArraySpeciesLookupChain(
this);
6281 if (!Protectors::IsNumberStringNotRegexpLikeIntact(
this)) {
6291 DCHECK(!IsJSObjectPrototype(*
object));
6292 if (object->map()->is_prototype_map() && (IsJSPrimitiveWrapper(*
object))) {
6293 Protectors::InvalidateNumberStringNotRegexpLike(
this);
6299 if (!Protectors::IsStringWrapperToPrimitiveIntact(
this)) {
6307 if (IsStringWrapper(*
object) || IsStringWrapper(*new_prototype)) {
6308 Protectors::InvalidateStringWrapperToPrimitive(
this);
6314 if (*rng ==
nullptr) {
6332 int64_t seed =
v8_flags.fuzzer_random_seed;
6348 }
while (hash == 0 && attempts++ < 30);
6349 return hash != 0 ? hash : 1;
6353#define ISOLATE_FIELD_OFFSET(type, name, ignored) \
6354 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
6357#undef ISOLATE_FIELD_OFFSET
6362 bool private_symbol) {
6371 symbol->set_description(*
key);
6374 switch (dictionary_index) {
6375 case RootIndex::kPublicSymbolTable:
6376 symbol->set_is_in_public_symbol_table(
true);
6377 heap()->set_public_symbol_table(*dictionary);
6379 case RootIndex::kApiSymbolTable:
6380 heap()->set_api_symbol_table(*dictionary);
6382 case RootIndex::kApiPrivateSymbolTable:
6383 heap()->set_api_private_symbol_table(*dictionary);
6428 bool perform_checkpoint =
6445#ifdef V8_ENABLE_WEBASSEMBLY
6446void Isolate::WasmInitJSPIFeature() {
6452 this->wasm_stacks().emplace_back(stack);
6453 stack->set_index(0);
6454 if (
v8_flags.trace_wasm_stack_switching) {
6455 PrintF(
"Set up native stack object (limit: %p, base: %p)\n",
6456 stack->jslimit(),
reinterpret_cast<void*
>(stack->base()));
6465 if (Protectors::IsPromiseHookIntact(
this)) {
6467 Protectors::InvalidatePromiseHook(
this);
6494 isolate, resolver->Reject(api_context, v8::Utils::ToLocal(exception)),
6512 return NewRejectedPromise(
this, api_context, exception);
6517 if (!maybe_specifier.
ToHandle(&specifier_str)) {
6523 return NewRejectedPromise(
this, api_context, exception);
6530 .ToHandle(&import_attributes_array)) {
6536 return NewRejectedPromise(
this, api_context, exception);
6540 if (maybe_referrer.
is_null()) {
6541 host_defined_options =
factory()->empty_fixed_array();
6542 resource_name =
factory()->null_value();
6545 host_defined_options =
6557 api_context, v8::Utils::ToLocal(host_defined_options),
6558 v8::Utils::ToLocal(resource_name),
6559 v8::Utils::ToLocal(specifier_str),
6569 api_context, v8::Utils::ToLocal(host_defined_options),
6570 v8::Utils::ToLocal(resource_name),
6571 v8::Utils::ToLocal(specifier_str), phase,
6585 factory()->empty_fixed_array();
6587 if (!maybe_import_options_argument.
ToHandle(&import_options_argument) ||
6588 IsUndefined(*import_options_argument)) {
6589 return import_attributes_array;
6596 if (!IsJSReceiver(*import_options_argument)) {
6598 *
factory()->NewTypeError(MessageTemplate::kNonObjectImportArgument));
6607 if (
v8_flags.harmony_import_attributes) {
6611 .ToHandle(&import_attributes_object)) {
6620 if (IsUndefined(*import_attributes_object))
return import_attributes_array;
6622 if (!IsJSReceiver(*import_attributes_object)) {
6624 *
factory()->NewTypeError(MessageTemplate::kNonObjectAttributesOption));
6635 .ToHandle(&attribute_keys)) {
6641 bool has_non_string_attribute =
false;
6645 constexpr size_t kAttributeEntrySizeForDynamicImport = 2;
6647 attribute_keys->length() * kAttributeEntrySizeForDynamicImport));
6648 for (
int i = 0;
i < attribute_keys->length();
i++) {
6654 .ToHandle(&attribute_value)) {
6660 if (!IsString(*attribute_value)) {
6661 has_non_string_attribute =
true;
6664 import_attributes_array->set((
i * kAttributeEntrySizeForDynamicImport),
6666 import_attributes_array->set((
i * kAttributeEntrySizeForDynamicImport) + 1,
6670 if (has_non_string_attribute) {
6672 MessageTemplate::kNonStringImportAttributeValue));
6676 return import_attributes_array;
6727 this, shadow_realm_context,
6732 DCHECK(IsNativeContext(*shadow_realm_context_handle));
6733 shadow_realm_context_handle->set_scope_info(
6747 Utils::ToLocal(sites)),
6753 return is_js_api_wrapper_native_error_callback_ !=
nullptr &&
6754 is_js_api_wrapper_native_error_callback_(
6755 reinterpret_cast<v8::Isolate*
>(
this), Utils::ToLocal(obj));
6787#if defined(V8_OS_WIN64)
6788void Isolate::SetBuiltinUnwindData(
6790 const win64_unwindinfo::BuiltinUnwindInfo& unwinding_info) {
6805#if defined(V8_ENABLE_ETW_STACK_WALKING)
6806void Isolate::SetFilterETWSessionByURLCallback(
6807 FilterETWSessionByURLCallback
callback) {
6808 filter_etw_session_by_url_callback_ =
callback;
6810void Isolate::SetFilterETWSessionByURL2Callback(
6811 FilterETWSessionByURL2Callback
callback) {
6812 filter_etw_session_by_url2_callback_ =
callback;
6815FilterETWSessionByURLResult Isolate::RunFilterETWSessionByURLCallback(
6816 const std::string& etw_filter_payload) {
6819 return {
false,
false};
6823 if (filter_etw_session_by_url2_callback_) {
6824 return filter_etw_session_by_url2_callback_(context, etw_filter_payload);
6825 }
else if (filter_etw_session_by_url_callback_) {
6826 bool enable_etw_tracing =
6827 filter_etw_session_by_url_callback_(context, etw_filter_payload);
6828 return {enable_etw_tracing,
v8_flags.interpreted_frames_native_stack};
6833 return {
true,
v8_flags.interpreted_frames_native_stack};
6864#ifdef V8_ENABLE_JAVASCRIPT_PROMISE_HOOKS
6880 v8::Utils::ToLocal(parent));
6885 DCHECK(!promise->has_async_task_id());
6893 promise->async_task_id(),
false);
6902 frame_it.Advance()) {
6903 std::vector<Handle<SharedFunctionInfo>> infos;
6904 frame_it.frame()->GetFunctions(&infos);
6905 for (
auto it = infos.rbegin(); it != infos.rend(); ++it) {
6907 if (info->HasBuiltinId()) {
6910 switch (info->builtin_id()) {
6911 case Builtin::kPromisePrototypeCatch:
6914 case Builtin::kPromisePrototypeFinally:
6917 case Builtin::kPromisePrototypeThen:
6924 if (info->IsUserJavaScript() && action_type.
IsJust()) {
6925 DCHECK(!promise->has_async_task_id());
6930 promise->async_task_id(),
6931 debug()->IsBlackboxed(info));
6940 factory()->undefined_value());
6942 if (promise->has_async_task_id()) {
6951 factory()->undefined_value());
6953 if (promise->has_async_task_id()) {
6963 stack_trace->id(),
false);
6988 if (IsPromiseReactionJobTask(*current_microtask)) {
6989 auto promise_reaction_job_task =
6992 promise_reaction_job_task->promise_or_capability(),
this);
6993 if (IsPromiseCapability(*promise_or_capability)) {
6997 if (IsJSPromise(*promise_or_capability)) {
7000 }
else if (IsPromiseResolveThenableJobTask(*current_microtask)) {
7001 auto promise_resolve_thenable_job_task =
7004 promise_resolve_thenable_job_task->promise_to_resolve(),
this);
7012 promise_reject_callback_ =
callback;
7018 if (promise_reject_callback_ ==
nullptr)
return;
7020 v8::Utils::PromiseToLocal(promise), event, v8::Utils::ToLocal(value)));
7040 if (
heap_.
gc_state() == Heap::NOT_IN_GC && !context().is_null()) {
7045 for (
auto feature : features) {
7059 std::ostringstream os;
7061 if (isolate !=
nullptr) {
7062 os << isolate->id();
7078 heap()->set_detached_contexts(*detached_contexts);
7084 factory()->detached_contexts();
7085 int length = detached_contexts->length();
7086 if (length == 0)
return;
7090 DCHECK(context.IsWeakOrCleared());
7091 if (!context.IsCleared()) {
7092 int mark_sweeps = detached_contexts->Get(
i + 1).ToSmi().value();
7104 if (
v8_flags.trace_detached_contexts) {
7105 PrintF(
"%d detached contexts are collected out of %d\n",
7109 int mark_sweeps = detached_contexts->Get(
i + 1).ToSmi().value();
7110 DCHECK(context.IsWeakOrCleared());
7111 if (mark_sweeps > 3) {
7112 PrintF(
"detached context %p\n survived %d GCs (leak?)\n",
7113 reinterpret_cast<void*
>(context.ptr()), mark_sweeps);
7120 counters()->errors_thrown_per_context()->AddSample(
7121 env->native_context()->GetErrorsThrown());
7131 global_proxy->map()->set_constructor_or_back_pointer(roots.null_value(),
7136 env->native_context()->set_microtask_queue(
this,
nullptr);
7147 PrintIsolate(
this,
"RAIL mode: %s\n", is_loading ?
"LOAD" :
"ANIMATION");
7163void Isolate::PrintWithTimestamp(
const char* format, ...) {
7168 va_start(arguments, format);
7169 base::OS::VPrint(format, arguments);
7174 StateTag state = current_vm_state();
7178 set_current_vm_state(
IDLE);
7179 }
else if (state ==
IDLE) {
7188 std::vector<Handle<SharedFunctionInfo>> sfis;
7192 obj = iterator.
Next()) {
7193 if (!IsSharedFunctionInfo(obj))
continue;
7198 if (
IsSmi(script)) {
7202 if (!sfi->CanCollectSourcePosition(
this))
continue;
7206 for (
auto sfi : sfis) {
7211#ifdef V8_INTL_SUPPORT
7215std::string GetStringFromLocales(
Isolate* isolate,
7217 if (IsUndefined(*locales, isolate))
return "";
7218 return std::string(
Cast<String>(*locales)->ToCString().get());
7221bool StringEqualsLocales(
Isolate* isolate,
const std::string& str,
7222 DirectHandle<Object> locales) {
7223 if (IsUndefined(*locales, isolate))
return str.empty();
7230const std::string& Isolate::DefaultLocale() {
7231 if (default_locale_.empty()) {
7232 icu::Locale default_locale;
7234 if (strcmp(default_locale.getName(),
"en_US_POSIX") == 0 ||
7235 strcmp(default_locale.getName(),
"c") == 0) {
7236 set_default_locale(
"en-US");
7239 set_default_locale(default_locale.isBogus()
7243 DCHECK(!default_locale_.empty());
7245 return default_locale_;
7248void Isolate::ResetDefaultLocale() {
7249 default_locale_.clear();
7250 clear_cached_icu_objects();
7256icu::UMemory* Isolate::get_cached_icu_object(ICUObjectCacheType cache_type,
7257 DirectHandle<Object> locales) {
7258 const ICUObjectCacheEntry& entry =
7259 icu_object_cache_[
static_cast<int>(cache_type)];
7260 return StringEqualsLocales(
this, entry.locales, locales) ? entry.obj.get()
7264void Isolate::set_icu_object_in_cache(ICUObjectCacheType cache_type,
7265 DirectHandle<Object> locales,
7266 std::shared_ptr<icu::UMemory> obj) {
7267 icu_object_cache_[
static_cast<int>(cache_type)] = {
7268 GetStringFromLocales(
this, locales), std::move(obj)};
7271void Isolate::clear_cached_icu_object(ICUObjectCacheType cache_type) {
7272 icu_object_cache_[
static_cast<int>(cache_type)] = ICUObjectCacheEntry{};
7275void Isolate::clear_cached_icu_objects() {
7276 for (
int i = 0;
i < kICUObjectCacheTypeCount;
i++) {
7277 clear_cached_icu_object(
static_cast<ICUObjectCacheType
>(
i));
7301 uintptr_t jssp =
static_cast<uintptr_t
>(jssp_address);
7302 if (jssp - gap < stack_guard->real_jslimit())
return true;
7316 uintptr_t jssp =
static_cast<uintptr_t
>(jssp_address);
7317 if (jssp - gap < stack_guard->real_jslimit())
return true;
7322 return sp - gap < limit;
7326 if (!isolate->context().is_null()) {
7327 context_ = Handle<Context>(isolate->context(), isolate);
7329 if (!isolate->topmost_script_having_context().is_null()) {
7330 topmost_script_having_context_ =
7331 Handle<Context>(isolate->topmost_script_having_context(), isolate);
7346 isolate->set_context(new_context);
7352 context_(isolate->context(), isolate),
7353 topmost_script_having_context_(isolate->topmost_script_having_context(),
7359 uintptr_t a1 =
reinterpret_cast<uintptr_t
>(a.start);
7360 uintptr_t a2 = a1 + a.length_in_bytes;
7361 uintptr_t b1 =
reinterpret_cast<uintptr_t
>(b.
start);
7364 return (a1 <= b1 && b1 < a2) || (a1 <= b2 && b2 < a2);
7373 std::vector<MemoryRange>* old_code_pages =
GetCodePages();
7377 return Overlapping(range, a);
7380 std::find_if(old_code_pages->begin(), old_code_pages->end(),
7384 std::vector<MemoryRange>* new_code_pages;
7393 new_code_pages->clear();
7394 new_code_pages->reserve(old_code_pages->size() + 1);
7395 std::merge(old_code_pages->begin(), old_code_pages->end(), &range, &range + 1,
7396 std::back_inserter(*new_code_pages),
7398 return a.start < b.start;
7409#if defined(V8_TARGET_ARCH_ARM)
7410 void* new_page_start =
reinterpret_cast<void*
>(chunk->
area_start());
7411 size_t new_page_size = chunk->
area_size();
7413 MemoryRange new_range{new_page_start, new_page_size};
7421 MemoryRange{
reinterpret_cast<void*
>(begin), length_in_bytes});
7434 context->set_recorder_context_id(
7438 std::piecewise_construct,
7440 std::forward_as_tuple(
reinterpret_cast<v8::Isolate*
>(
this),
7442 result.first->second.SetWeak(
7449 static_cast<uintptr_t
>(i::Smi::ToInt(
id)));
7474 Isolate* isolate =
reinterpret_cast<Isolate*
>(data.GetIsolate());
7475 uintptr_t context_id =
reinterpret_cast<uintptr_t
>(data.GetParameter());
7484 LocalHeap* local_heap = LocalHeap::Current();
7485 if (local_heap)
return local_heap;
7494#if defined(V8_TARGET_ARCH_ARM)
7495 void* removed_page_start =
reinterpret_cast<void*
>(chunk->
area_start());
7496 std::vector<MemoryRange>* old_code_pages =
GetCodePages();
7499 std::vector<MemoryRange>* new_code_pages;
7508 new_code_pages->clear();
7509 new_code_pages->reserve(old_code_pages->size() - 1);
7510 std::remove_copy_if(old_code_pages->begin(), old_code_pages->end(),
7511 std::back_inserter(*new_code_pages),
7513 return range.start == removed_page_start;
7515 DCHECK_EQ(old_code_pages->size(), new_code_pages->size() + 1);
7521#if V8_ENABLE_DRUMBRAKE
7522void Isolate::initialize_wasm_execution_timer() {
7525 wasm_execution_timer_ =
7526 std::make_unique<wasm::WasmExecutionTimer>(
this,
false);
7535 if (!stack_access_count_map) {
7536 stack_access_count_map =
new MapOfLoadsAndStoresPerFunction{};
7538 auto& map = *stack_access_count_map;
7539 std::string
name(function_name);
7542 return reinterpret_cast<Address>(&map[
name].first);
7548 if (!stack_access_count_map) {
7549 stack_access_count_map =
new MapOfLoadsAndStoresPerFunction{};
7551 auto& map = *stack_access_count_map;
7552 std::string
name(function_name);
7555 return reinterpret_cast<Address>(&map[
name].second);
7559 if (IsEphemeronHashTable(
heap()->locals_block_list_cache())) {
7562 cache->Rehash(
this);
7570 if (IsEphemeronHashTable(
heap()->locals_block_list_cache())) {
7574 CHECK(IsUndefined(
heap()->locals_block_list_cache()));
7575 constexpr int kInitialCapacity = 8;
7576 cache = EphemeronHashTable::New(
this, kInitialCapacity);
7578 DCHECK(IsEphemeronHashTable(*cache));
7581 if (!outer_scope_info.
is_null()) {
7585 value = locals_blocklist;
7588 CHECK(!value.is_null());
7589 cache = EphemeronHashTable::Put(cache, scope_info, value);
7590 heap()->set_locals_block_list_cache(*cache);
7597 if (!IsEphemeronHashTable(
heap()->locals_block_list_cache())) {
7603 ->Lookup(scope_info);
7604 if (IsTuple2(maybe_value))
return Cast<Tuple2>(maybe_value)->value2();
7606 CHECK(IsStringSet(maybe_value) || IsTheHole(maybe_value));
7610std::list<std::unique_ptr<detail::WaiterQueueNode>>&
7623 ? resolver->Resolve(context,
result)
7624 : resolver->Reject(context,
result);
7635#ifdef V8_ENABLE_LEAPTIERING
7644 bool needs_initialization =
7645 !V8_STATIC_DISPATCH_HANDLES_BOOL ||
7646 jdt->PreAllocatedEntryNeedsInitialization(
7648 builtin_dispatch_handle(JSBuiltinDispatchHandleRoot::Idx::kFirst));
7650 if (needs_initialization) {
7651 std::optional<JSDispatchTable::UnsealReadOnlySegmentScope> unseal_scope;
7652 if (V8_STATIC_DISPATCH_HANDLES_BOOL) {
7653 unseal_scope.emplace(jdt);
7655 for (JSBuiltinDispatchHandleRoot::Idx idx =
7656 JSBuiltinDispatchHandleRoot::kFirst;
7657 idx < JSBuiltinDispatchHandleRoot::kCount;
7658 idx =
static_cast<JSBuiltinDispatchHandleRoot::Idx
>(
7659 static_cast<int>(idx) + 1)) {
7660 Builtin builtin = JSBuiltinDispatchHandleRoot::to_builtin(idx);
7667#if V8_STATIC_DISPATCH_HANDLES_BOOL
7669 jdt->InitializePreAllocatedEntry(
7673 CHECK_LT(idx, JSBuiltinDispatchHandleRoot::kTableSize);
constexpr int kMinimumOSPageSize
#define BUILTIN_PROMISE_REJECTION_PREDICTION_LIST(V)
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
#define BUILTIN_CODE(isolate, name)
#define SBXCHECK_EQ(lhs, rhs)
#define SLOW_DCHECK(condition)
static Isolate * Allocate()
void(*)(std::unique_ptr< CppHeap >) ReleaseCppHeapCallback
static Isolate * TryGetCurrent()
bool(*)(Isolate *) AbortOnUncaughtExceptionCallback
@ kObjectPrototypeHasElements
@ kArrayPrototypeHasElements
void(*)(Isolate *isolate, UseCounterFeature feature) UseCounterCallback
V8_INLINE bool IsJust() const
V8_INLINE T FromJust() const &
static V8_WARN_UNUSED_RESULT MaybeLocal< Resolver > New(Local< Context > context)
@ kExposeFramesAcrossSecurityOrigins
static V8_INLINE Local< String > Empty(Isolate *isolate)
static v8::internal::DirectHandle< To > OpenDirectHandle(v8::Local< From > handle)
bool contains(Address address) const
static constexpr U encode(T value)
static V8_BASE_EXPORT bool GetFlushDenormals()
static int GetCurrentProcessId()
static void AdjustSchedulingParams()
int64_t initial_seed() const
V8_INLINE int NextInt() V8_WARN_UNUSED_RESULT
static Processor * New(Platform *platform)
virtual void AsyncEventOccurred(debug::DebugAsyncActionType type, int id, bool is_blackboxed)=0
static Tagged< AccessCheckInfo > Get(Isolate *isolate, DirectHandle< JSObject > receiver)
static ApiAccessorExitFrame * cast(StackFrame *frame)
Tagged< Object > holder() const
Tagged< Name > property_name() const
DirectHandle< FunctionTemplateInfo > GetFunctionTemplateInfo() const
static ApiCallbackExitFrame * cast(StackFrame *frame)
bool IsConstructor() const
Tagged< Object > receiver() const
static V8_EXPORT_PRIVATE DirectHandle< ArrayList > Add(Isolate *isolate, DirectHandle< ArrayList > array, Tagged< Smi > obj, AllocationType allocation=AllocationType::kYoung)
static DirectHandle< ArrayList > New(IsolateT *isolate, int capacity, AllocationType allocation=AllocationType::kYoung)
static void QuietNaN(Tagged< HeapObject > nan)
AssertNoContextChange(Isolate *isolate)
void PatchContext(Tagged< Context > value)
intptr_t GetPCForBytecodeOffset(int lookup_offset) const
static BaselineFrame * cast(StackFrame *frame)
static V8_EXPORT_PRIVATE BasicBlockProfiler * Get()
V8_EXPORT_PRIVATE void Log(Isolate *isolate, std::ostream &os)
V8_EXPORT_PRIVATE void ResetCounts(Isolate *isolate)
V8_EXPORT_PRIVATE void Print(Isolate *isolate, std::ostream &os)
void Initialize(bool create_heap_objects)
static BuiltinFrame * cast(StackFrame *frame)
V8_EXPORT_PRIVATE Tagged< Code > code(Builtin builtin)
bool is_initialized() const
static constexpr int kBuiltinCount
static constexpr Builtin kFirst
static constexpr bool IsIsolateIndependent(Builtin builtin)
static void InitializeIsolateDataTables(Isolate *isolate)
static constexpr bool AllBuiltinsAreIsolateIndependent()
static constexpr int kBuiltinTier0Count
static constexpr bool kAllBuiltinsAreIsolateIndependent
static constexpr Builtin kLast
static DirectHandle< String > GetFunctionDebugName(DirectHandle< CallSiteInfo > info)
std::optional< Tagged< Script > > GetScript() const
static bool ComputeLocation(DirectHandle< CallSiteInfo > info, MessageLocation *location)
static int GetSourcePosition(DirectHandle< CallSiteInfo > info)
uint8_t * embedded_blob_code_copy() const
static constexpr int kFixedFrameSizeAboveFp
virtual int position() const
virtual FrameSummaries Summarize() const
static CommonFrame * cast(StackFrame *frame)
WorkerThreadRuntimeCallStats * worker_thread_runtime_call_stats()
RuntimeCallStats * runtime_call_stats()
static bool SupportsOptimizer()
std::optional< Tagged< Object > > OnThrow(DirectHandle< Object > exception) V8_WARN_UNUSED_RESULT
void clear_restart_frame()
static V8_EXPORT_PRIVATE void DeoptimizeAll(Isolate *isolate)
V8_INLINE bool is_null() const
Address InstructionStartOf(Builtin builtin) const
static EmbeddedData FromBlob()
virtual int LookupOrAddExternallyCompiledFilename(const char *filename)=0
virtual int GetExternallyCompiledFilenameCount() const =0
virtual void PrepareBuiltinSourcePositionMap(Builtins *builtins)=0
virtual const char * GetExternallyCompiledFilename(int index) const =0
static StackPropertyLookupResult GetErrorStackProperty(Isolate *isolate, DirectHandle< JSReceiver > maybe_error_object)
static MaybeDirectHandle< JSObject > Construct(Isolate *isolate, DirectHandle< JSFunction > target, DirectHandle< Object > new_target, DirectHandle< Object > message, DirectHandle< Object > options)
v8::ExceptionContext exception_context() const
Address JSStackComparableAddress()
const void * callback_info()
void Init(Isolate *isolate)
void InitIsolateIndependent(MemorySpan< Address > shared_external_references)
Handle< String > NewStringFromAsciiChecked(const char *str, AllocationType allocation=AllocationType::kYoung)
Handle< FixedArray > NewFixedArray(int length, AllocationType allocation=AllocationType::kYoung)
Isolate * isolate() const
Handle< Symbol > NewSymbol(AllocationType allocation=AllocationType::kOld)
Handle< Symbol > NewPrivateSymbol(AllocationType allocation=AllocationType::kOld)
Handle< JSObject > NewJSObjectWithNullProto()
DirectHandle< Tuple2 > NewTuple2(DirectHandle< Object > value1, DirectHandle< Object > value2, AllocationType allocation)
Handle< StackTraceInfo > NewStackTraceInfo(DirectHandle< FixedArray > frames)
DirectHandle< ErrorStackData > NewErrorStackData(DirectHandle< UnionOf< JSAny, FixedArray > > call_site_infos_or_formatted_stack, DirectHandle< StackTraceInfo > stack_trace)
Handle< String > InternalizeString(base::Vector< const char > str, bool convert_encoding=false)
Handle< JSObject > NewError(DirectHandle< JSFunction > constructor, DirectHandle< String > message, DirectHandle< Object > options={})
Handle< String > SizeToString(size_t value, bool check_cache=true)
static constexpr int kMaxLength
static HandleType< FixedArray > RightTrimOrEmpty(Isolate *isolate, HandleType< FixedArray > array, int new_length)
static V8_EXPORT_PRIVATE HandleType< FixedArray > SetAndGrow(Isolate *isolate, HandleType< FixedArray > array, int index, DirectHandle< Object > value)
Handle< Object > script() const
int SourcePosition() const
bool AreSourcePositionsAvailable() const
Tagged< Object > load() const
static Tagged< Object > GetTarget(const FunctionCallbackInfo< T > &info)
static void IsolateDeinit(Isolate *isolate)
void UpdateCurrentEventPriority(Priority priority)
void RemoveClient(Isolate *client)
base::RecursiveMutex clients_mutex_
void AssertNoClientsOnTearDown()
void AppendClient(Isolate *client)
Tagged< HeapObject > Next()
static constexpr int kHeaderSize
void StopSamplingHeapProfiler()
bool StartSamplingHeapProfiler(uint64_t sample_interval, int stack_depth, v8::HeapProfiler::SamplingFlags)
bool is_tracking_object_moves() const
void SetUpFromReadOnlyHeap(ReadOnlyHeap *ro_heap)
Address code_range_base()
size_t MaxOldGenerationSize()
HeapState gc_state() const
void SetUp(LocalHeap *main_thread_local_heap)
void NotifyLoadingStarted()
bool has_heap_object_allocation_tracker() const
IncrementalMarking * incremental_marking() const
void ActivateMemoryReducerIfNeeded()
void NotifyLoadingEnded()
std::unique_ptr< CodeRange > code_range_
OldSpace * old_space() const
V8_EXPORT_PRIVATE void CollectAllGarbage(GCFlags gc_flags, GarbageCollectionReason gc_reason, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
HeapProfiler * heap_profiler() const
V8_EXPORT_PRIVATE double MonotonicallyIncreasingTimeInMs() const
void IncrementDeferredCounts(base::Vector< const v8::Isolate::UseCounterFeature > features)
bool HasBeenSetUp() const
V8_EXPORT_PRIVATE void DisableInlineAllocation()
IsolateSafepoint * safepoint()
const base::AddressRegion & code_region()
void TearDownWithSharedHeap()
ReadOnlySpace * read_only_space() const
CodeSpace * code_space() const
void SetUpSpaces(LinearAllocationArea &new_allocation_info, LinearAllocationArea &old_allocation_info)
V8_EXPORT_PRIVATE void SetStackStart()
void SetIsMarkingFlag(bool value)
void NotifyDeserializationComplete()
bool IsMajorMarking() const
MaybeDirectHandle< String > Finish()
V8_INLINE void AppendCharacter(uint8_t c)
V8_INLINE void AppendString(std::string_view str)
bool is_not_found() const
static V8_INLINE constexpr bool HasHeapObjectTag(Address value)
static const int kIsolateCageBaseOffset
static const int kIsolateApiCallbackThunkArgumentOffset
static const int kNewAllocationInfoOffset
static const int kIsolateFastCCallCallerPcOffset
static const int kIsolateThreadLocalTopOffset
static V8_INLINE Address GetRoot(v8::Isolate *isolate, int index)
static const int kIsolateRootsOffset
static const int kExternalPointerTableSize
static const int kIsolateStackGuardOffset
static const int kIsolateFastCCallCallerFpOffset
static const int kBuiltinTier0TableOffset
static const int kIsolateLongTaskStatsCounterOffset
static const int kIsolateHandleScopeDataOffset
static const int kBuiltinTier0EntryTableOffset
static const int kStackGuardSize
static const int kErrorMessageParamOffset
static const int kExternalPointerTableBasePointerOffset
static const int kBuiltinTier0TableSize
static const int kContinuationPreservedEmbedderDataOffset
static const int kTrustedPointerTableSize
static const int kBuiltinTier0EntryTableSize
static const int kOldAllocationInfoOffset
static const int kIsolateEmbedderDataOffset
static const int kTrustedPointerTableBasePointerOffset
static const int kVariousBooleanFlagsOffset
static InterpretedFrame * cast(StackFrame *frame)
void PatchBytecodeOffset(int new_offset)
static Maybe< std::string > ToLanguageTag(const icu::Locale &locale)
Address builtin_tier0_table_[Builtins::kBuiltinTier0Count]
Tagged< Object > continuation_preserved_embedder_data_
HandleScopeData handle_scope_data_
wasm::StackMemory * active_stack()
Address builtin_tier0_entry_table_[Builtins::kBuiltinTier0Count]
uint8_t error_message_param_
void * embedder_data_[Internals::kNumIsolateDataSlots]
ThreadLocalTop thread_local_top_
uint8_t is_shared_space_isolate_flag_
Address api_callback_thunk_argument_
LinearAllocationArea new_allocation_info_
LinearAllocationArea old_allocation_info_
ExternalReferenceTable * external_reference_table()
Address fast_c_call_caller_fp_
size_t long_task_stats_counter_
void set_active_stack(wasm::StackMemory *stack)
Address fast_c_call_caller_pc_
uint8_t uses_shared_heap_flag_
static IsolateGroup * current()
void AddIsolate(Isolate *isolate)
OptimizingCompileTaskExecutor * optimizing_compile_task_executor()
void RemoveIsolate(Isolate *isolate)
Isolate * shared_space_isolate() const
v8::PageAllocator * page_allocator() const
static IsolateGroup * AcquireDefault()
CodeRange * GetCodeRange() const
void SetupReadOnlyHeap(Isolate *isolate, SnapshotData *read_only_snapshot_data, bool can_rehash)
V8_EXPORT_PRIVATE void AssertMainThreadIsOnlyThread()
base::RecursiveMutex local_heaps_mutex_
Isolate * isolate() const
ThreadState * thread_state_
void Remove(PerIsolateThreadData *data)
PerIsolateThreadData * Lookup(ThreadId thread_id)
void Insert(PerIsolateThreadData *data)
PerIsolateThreadData * FindPerThreadDataForThread(ThreadId thread_id)
void set_topmost_script_having_context(Tagged< Context > context)
Address continuation_preserved_embedder_data_address()
Isolate(const Isolate &)=delete
double time_millis_at_init_
int stack_trace_for_uncaught_exceptions_frame_limit_
std::vector< CallCompletedCallback > call_completed_callbacks_
V8_INLINE Address * builtin_table()
V8_NOINLINE void PushParamsAndDie(void *ptr1=nullptr, void *ptr2=nullptr, void *ptr3=nullptr, void *ptr4=nullptr, void *ptr5=nullptr, void *ptr6=nullptr)
static void InitializeOncePerProcess()
int GetExternallyCompiledFilenameCount() const
std::vector< Tagged< Object > > shared_heap_object_cache_
bool initialized_from_snapshot_
v8::TryCatch * try_catch_handler()
void UpdateLogObjectRelocation()
std::shared_ptr< CompilationStatistics > turbo_statistics_
base::Mutex managed_ptr_destructors_mutex_
std::shared_ptr< v8::TaskRunner > task_runner_
ReadOnlyHeap * read_only_heap() const
bool IsWasmImportedStringsEnabled(DirectHandle< NativeContext > context)
std::queue< InterruptEntry > api_interrupts_queue_
bool HasIsolatePromiseHooks() const
bool InitWithoutSnapshot()
MaybeDirectHandle< Script > CurrentReferrerScript()
const uint8_t * embedded_blob_data() const
void SetHostCreateShadowRealmContextCallback(HostCreateShadowRealmContextCallback callback)
uint32_t embedded_blob_data_size() const
void SetTerminationOnExternalTryCatch()
void OnTerminationDuringRunMicrotasks()
void CollectSourcePositionsForAllBytecodeArrays()
AccountingAllocator * allocator()
void InitializeIsShortBuiltinCallsEnabled()
base::RandomNumberGenerator * random_number_generator_
std::list< std::unique_ptr< detail::WaiterQueueNode > > async_waiter_queue_nodes_
uint32_t embedded_blob_data_size_
void OnPromiseAfter(DirectHandle< JSPromise > promise)
void CreateAndSetEmbeddedBlob()
void SetHostImportModuleDynamicallyCallback(HostImportModuleDynamicallyCallback callback)
void PrintStack(StringStream *accumulator, PrintStackMode mode=kPrintStackVerbose)
static void SetCurrent(Isolate *isolate)
bool IsLoggingCodeCreation() const
MaybeDirectHandle< NativeContext > RunHostCreateShadowRealmContextCallback()
Tagged< Object > ThrowIllegalOperation()
bool InitializeCounters()
void SetEmbeddedBlob(const uint8_t *code, uint32_t code_size, const uint8_t *data, uint32_t data_size)
bigint::Processor * bigint_processor_
void SetPromiseHook(PromiseHook hook)
bool OwnsStringTables() const
bool has_pending_message()
static const uint8_t * CurrentEmbeddedBlobCode()
V8FileLogger * v8_file_logger_
std::atomic< uint32_t > next_unique_sfi_id_
void InitializeNextUniqueSfiId(uint32_t id)
std::atomic< v8::Isolate::Priority > priority_
void RunPromiseHook(PromiseHookType type, DirectHandle< JSPromise > promise, DirectHandle< Object > parent)
MaybeDirectHandle< JSPromise > RunHostImportModuleDynamicallyCallback(MaybeDirectHandle< Script > maybe_referrer, Handle< Object > specifier, ModuleImportPhase phase, MaybeDirectHandle< Object > maybe_import_options_argument)
static void IterateRegistersAndStackOfSimulator(::heap::base::StackVisitor *visitor)
bool ComputeLocation(MessageLocation *target)
std::unique_ptr< LazyCompileDispatcher > lazy_compile_dispatcher_
bool is_shared_space_isolate() const
bool IsBuiltinTableHandleLocation(Address *handle_location)
static V8_INLINE Isolate * Current()
RegExpStack * regexp_stack_
static Address c_entry_fp(ThreadLocalTop *thread)
std::unique_ptr< PersistentHandlesList > persistent_handles_list_
bool log_object_relocation_
Address code_cage_base() const
void RequestInterrupt(InterruptCallback callback, void *data)
void UpdateTypedArraySpeciesLookupChainProtectorOnSetPrototype(DirectHandle< JSObject > object)
static uint32_t CurrentEmbeddedBlobCodeSize()
DateCache * date_cache() const
uint32_t embedded_blob_code_size() const
CancelableTaskManager * cancelable_task_manager_
void NotifyExceptionPropagationCallback()
void set_thread_id(ThreadId id)
StubCache * define_own_stub_cache_
const IsolateData * isolate_data() const
void SetPromiseRejectCallback(PromiseRejectCallback callback)
void SetHostImportModuleWithPhaseDynamicallyCallback(HostImportModuleWithPhaseDynamicallyCallback callback)
bool ComputeLocationFromDetailedStackTrace(MessageLocation *target, DirectHandle< Object > exception)
void TearDownEmbeddedBlob()
void OnStackTraceCaptured(DirectHandle< StackTraceInfo > stack_trace)
void CountUsage(v8::Isolate::UseCounterFeature feature)
int GenerateIdentityHash(uint32_t mask)
const v8::Context::BackupIncumbentScope * top_backup_incumbent_scope() const
Tagged< Object > ReThrow(Tagged< Object > exception)
bool HasPrepareStackTraceCallback() const
SetupIsolateDelegate * setup_delegate_
TieringManager * tiering_manager_
HandleScopeImplementer * handle_scope_implementer_
std::vector< MemoryRange > * GetCodePages() const
void UpdateProtectorsOnSetPrototype(DirectHandle< JSObject > object, DirectHandle< Object > new_prototype)
void LocalsBlockListCacheRehash()
size_t last_long_task_stats_counter_
void InitializeCodeRanges()
void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback)
void ReportExceptionPropertyCallback(DirectHandle< JSReceiver > holder, DirectHandle< Name > name, v8::ExceptionContext callback_kind)
void clear_pending_message()
void DiscardPerThreadDataForThisThread()
const uint8_t * embedded_blob_data_
LocalIsolate * main_thread_local_isolate()
Bootstrapper * bootstrapper()
StubCache * load_stub_cache_
HostCreateShadowRealmContextCallback host_create_shadow_realm_context_callback_
MaybeLocal< v8::Context > GetContextFromRecorderContextId(v8::metrics::Recorder::ContextId id)
compiler::PerIsolateCompilerCache * compiler_cache_
std::optional< Isolate * > shared_space_isolate_
bool IsInCreationContext(Tagged< JSObject > object, uint32_t index)
DirectHandle< JSMessageObject > CreateMessageOrAbort(DirectHandle< Object > exception, MessageLocation *location)
std::shared_ptr< CompilationStatistics > GetTurboStatistics()
V8_NOINLINE void PushStackTraceAndContinue(void *ptr1=nullptr, void *ptr2=nullptr, void *ptr3=nullptr, void *ptr4=nullptr, void *ptr5=nullptr, void *ptr6=nullptr)
bool Init(SnapshotData *startup_snapshot_data, SnapshotData *read_only_snapshot_data, SnapshotData *shared_heap_snapshot_data, bool can_rehash)
void set_pending_message(Tagged< Object > message_obj)
void RequestInvalidateNoProfilingProtector()
void InstallConditionalFeatures(DirectHandle< NativeContext > context)
LocalHeap * CurrentLocalHeap()
GlobalSafepoint * global_safepoint() const
uint32_t embedded_blob_code_size_
Handle< JSMessageObject > CreateMessage(DirectHandle< Object > exception, MessageLocation *location)
std::list< std::unique_ptr< detail::WaiterQueueNode > > & async_waiter_queue_nodes()
Tagged< Context > context() const
Handle< StackTraceInfo > GetDetailedStackTrace(DirectHandle< JSReceiver > error_object)
v8::metrics::LongTaskStats * GetCurrentLongTaskStats()
base::Mutex thread_data_table_mutex_
OptimizingCompileDispatcher * optimizing_compile_dispatcher()
PrepareStackTraceCallback prepare_stack_trace_callback_
bool is_short_builtin_calls_enabled_
void set_deoptimizer_lazy_throw(bool value)
int LookupOrAddExternallyCompiledFilename(const char *filename)
bool PropagateExceptionToExternalTryCatch(ExceptionHandlerType top_handler)
bool owns_shareable_data()
void UnregisterTryCatchHandler(v8::TryCatch *that)
bool preprocessing_exception_
void RemoveCallCompletedCallback(CallCompletedCallback callback)
void InitializeThreadLocal()
v8::metrics::Recorder::ContextId GetOrRegisterRecorderContextId(DirectHandle< NativeContext > context)
void SetReleaseCppHeapCallback(v8::Isolate::ReleaseCppHeapCallback callback)
void set_context(Tagged< Context > context)
MaybeHandle< JSObject > RunHostInitializeImportMetaObjectCallback(DirectHandle< SourceTextModule > module)
Tagged< Object > Throw(Tagged< Object > exception, MessageLocation *location=nullptr)
void set_date_cache(DateCache *date_cache)
uint32_t current_async_task_id_
CompilationCache * compilation_cache_
void CancelTerminateExecution()
uint64_t stress_deopt_count_
bool InitWithSnapshot(SnapshotData *startup_snapshot_data, SnapshotData *read_only_snapshot_data, SnapshotData *shared_heap_snapshot_data, bool can_rehash)
InnerPointerToCodeCache * inner_pointer_to_code_cache_
Address get_address_from_id(IsolateAddressId id)
bool is_execution_terminating()
bool NeedsDetailedOptimizedCodeLineInfo() const
DirectHandle< String > CurrentScriptNameOrSourceURL()
std::unordered_set< int32_t * > active_dynamic_regexp_result_vectors_
std::vector< MemoryRange > code_pages_buffer1_
static Address load_from_stack_count_address(const char *function_name)
V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > ReportFailedAccessCheck(DirectHandle< JSObject > receiver)
bool IsSharedArrayBufferConstructorEnabled(DirectHandle< NativeContext > context)
void MaybeRemapEmbeddedBuiltinsIntoCodeRange()
TracedHandles traced_handles_
SharedStructTypeRegistry * shared_struct_type_registry() const
void DetachGlobal(DirectHandle< Context > env)
Tagged< NativeContext > raw_native_context()
PerIsolateThreadData * FindPerThreadDataForThisThread()
ManagedPtrDestructor * managed_ptr_destructors_head_
void UpdateNoElementsProtectorOnSetPrototype(DirectHandle< JSObject > object)
std::pair< InterruptCallback, void * > InterruptEntry
void SetFeedbackVectorsForProfilingTools(Tagged< Object > value)
bool ComputeLocationFromException(MessageLocation *target, DirectHandle< Object > exception)
void IncreaseConcurrentOptimizationPriority(CodeKind kind, Tagged< SharedFunctionInfo > function)
static const uint8_t * CurrentEmbeddedBlobData()
bool is_profiling() const
int stack_trace_nesting_level_
IsolateData isolate_data_
void InvokeApiInterruptCallbacks()
void PrintCurrentStackTrace(std::ostream &out, PrintCurrentStackTraceFilterCallback should_include_frame_callback=nullptr)
void AddDetachedContext(DirectHandle< Context > context)
void ReportExceptionFunctionCallback(DirectHandle< JSReceiver > receiver, DirectHandle< FunctionTemplateInfo > function, v8::ExceptionContext callback_kind)
Tagged< Object > exception()
base::RandomNumberGenerator * fuzzer_rng_
bool GetStackTraceLimit(Isolate *isolate, int *result)
void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback)
void AddCodeMemoryChunk(MutablePageMetadata *chunk)
std::unique_ptr< StringTable > string_table_
void SetCaptureStackTraceForUncaughtExceptions(bool capture, int frame_limit, StackTrace::StackTraceOptions options)
const uint8_t * embedded_blob_code() const
void UpdateTypedArrayLengthLookupChainProtectorOnSetPrototype(DirectHandle< JSObject > object)
bool WalkCallStackAndPromiseTree(MaybeDirectHandle< JSPromise > rejected_promise, const std::function< void(PromiseHandler)> &callback)
Handle< JSMessageObject > CreateMessageFromException(DirectHandle< Object > exception)
Handle< FixedArray > GetSimpleStackTrace(DirectHandle< JSReceiver > error_object)
ThreadManager * thread_manager_
void AbortConcurrentOptimization(BlockingBehavior blocking_behavior)
void IterateThread(ThreadVisitor *v, char *t)
void UpdatePromiseHookProtector()
std::unique_ptr< LocalIsolate > main_thread_local_isolate_
static Address store_to_stack_count_address(const char *function_name)
bool ComputeLocationFromSimpleStackTrace(MessageLocation *target, DirectHandle< Object > exception)
void UnregisterManagedPtrDestructor(ManagedPtrDestructor *finalizer)
bool is_catchable_by_javascript(Tagged< Object > exception)
void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
bool HasContextPromiseHooks() const
static void Delete(Isolate *isolate)
V8_INLINE HandleScopeData * handle_scope_data()
DirectHandle< String > StackTraceString()
Address isolate_addresses_[kIsolateAddressCount+1]
char * RestoreThread(char *from)
void FreeThreadResources()
void InitializeLoggingAndCounters()
Tagged< Object > UnwindAndFindHandler()
ThreadId thread_id() const
bool has_shared_space() const
ExceptionHandlerType TopExceptionHandlerType(Tagged< Object > exception)
static bool CurrentEmbeddedBlobIsBinaryEmbedded()
char * ArchiveThread(char *to)
V8_NOINLINE void PushStackTraceAndDie(void *ptr1=nullptr, void *ptr2=nullptr, void *ptr3=nullptr, void *ptr4=nullptr, void *ptr5=nullptr, void *ptr6=nullptr)
std::unordered_map< uintptr_t, v8::Global< v8::Context > > recorder_context_id_map_
void MaybeInitializeVectorListFromHeap()
Deoptimizer * current_deoptimizer_
BuiltinsConstantsTableBuilder * builtins_constants_table_builder_
GlobalHandles * global_handles_
void DumpAndResetBuiltinsProfileData()
bool is_shared_space_isolate_
void RunAllPromiseHooks(PromiseHookType type, DirectHandle< JSPromise > promise, DirectHandle< Object > parent)
void SetIdle(bool is_idle)
bool IsWasmJSPIEnabled(DirectHandle< NativeContext > context)
unsigned next_module_async_evaluation_ordinal_
OptimizingCompileDispatcher * optimizing_compile_dispatcher_
void RegisterManagedPtrDestructor(ManagedPtrDestructor *finalizer)
static std::string GetTurboCfgFileName(Isolate *isolate)
bool AllowsCodeCompaction() const
HostImportModuleWithPhaseDynamicallyCallback host_import_module_with_phase_dynamically_callback_
StringTable * string_table() const
Handle< NativeContext > native_context()
PerIsolateThreadData * FindOrAllocatePerThreadDataForThisThread()
bool HasAsyncEventDelegate() const
static base::AddressRegion GetShortBuiltinsCallRegion()
HostInitializeImportMetaObjectCallback host_initialize_import_meta_object_callback_
void RemoveCodeMemoryChunk(MutablePageMetadata *chunk)
void RunReleaseCppHeapCallback(std::unique_ptr< v8::CppHeap > cpp_heap)
void FireCallCompletedCallbackInternal(MicrotaskQueue *microtask_queue)
std::unique_ptr< SharedStructTypeRegistry > shared_struct_type_registry_
size_t HashIsolateForEmbeddedBlob()
bool detailed_source_positions_for_profiling() const
static void SetIsolateThreadLocals(Isolate *isolate, PerIsolateThreadData *data)
debug::AsyncEventDelegate * async_event_delegate_
void CheckIsolateLayout()
Address GetAbstractPC(int *line, int *column)
ThreadDataTable thread_data_table_
DirectHandle< StackTraceInfo > CaptureDetailedStackTrace(int limit, StackTrace::StackTraceOptions options)
Tagged< Object > ThrowAt(DirectHandle< JSObject > exception, MessageLocation *location)
std::unique_ptr< StringForwardingTable > string_forwarding_table_
StackGuard * stack_guard()
HostImportModuleDynamicallyCallback host_import_module_dynamically_callback_
Tagged< Object > TerminateExecution()
bool is_catchable_by_wasm(Tagged< Object > exception)
void OnAsyncFunctionSuspended(DirectHandle< JSPromise > promise, DirectHandle< JSPromise > parent)
DirectHandle< NativeContext > GetIncumbentContextSlow()
v8::Isolate::AbortOnUncaughtExceptionCallback abort_on_uncaught_exception_callback_
IsolateGroup * isolate_group() const
IsolateGroup * isolate_group_
bool IsWasmStringRefEnabled(DirectHandle< NativeContext > context)
CancelableTaskManager * cancelable_task_manager()
void CheckDetachedContextsAfterGC()
MaybeDirectHandle< JSObject > CaptureAndSetErrorStack(DirectHandle< JSObject > error_object, FrameSkipMode mode, Handle< Object > caller)
bool IsWasmJSPIRequested(DirectHandle< NativeContext > context)
CodeTracer * GetCodeTracer()
void IncreaseTotalRegexpCodeGenerated(DirectHandle< HeapObject > code)
base::RandomNumberGenerator * random_number_generator()
StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_
StubCache * store_stub_cache_
const uint8_t * embedded_blob_code_
void AddCallCompletedCallback(CallCompletedCallback callback)
KnownPrototype IsArrayOrObjectOrStringPrototype(Tagged< JSObject > object)
StringStream * incomplete_message_
void LocalsBlockListCacheSet(DirectHandle< ScopeInfo > scope_info, DirectHandle< ScopeInfo > outer_scope_info, DirectHandle< StringSet > locals_blocklist)
std::unique_ptr< TracingCpuProfilerImpl > tracing_cpu_profiler_
interpreter::Interpreter * interpreter_
V8FileLogger * v8_file_logger() const
void UpdateNoElementsProtectorOnSetElement(DirectHandle< JSObject > object)
Tagged< Object > pending_message()
v8::internal::Factory * factory()
void set_exception(Tagged< Object > exception_obj)
void PromiseHookStateUpdated()
OptimizingCompileDispatcher * SetOptimizingCompileDispatcherForTesting(OptimizingCompileDispatcher *dispatcher)
DescriptorLookupCache * descriptor_lookup_cache_
void InitializeDefaultEmbeddedBlob()
void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
void Iterate(RootVisitor *v)
bool is_precise_count_code_coverage() const
v8::Isolate::ReleaseCppHeapCallback release_cpp_heap_callback_
Tagged< Context > topmost_script_having_context() const
void SetUpFromReadOnlyArtifacts(ReadOnlyArtifacts *artifacts)
double time_millis_since_init() const
void OnPromiseThen(DirectHandle< JSPromise > promise)
Handle< JSGlobalProxy > global_proxy()
void AddCodeRange(Address begin, size_t length_in_bytes)
bool detailed_source_positions_for_profiling_
static Address handler(ThreadLocalTop *thread)
bool get_capture_stack_trace_for_uncaught_exceptions() const
std::unique_ptr< GlobalSafepoint > global_safepoint_
static Isolate * Allocate(IsolateGroup *isolate_group)
PromiseHook promise_hook_
static uint32_t CurrentEmbeddedBlobDataSize()
static V8_INLINE PerIsolateThreadData * CurrentPerIsolateThreadData()
bool is_short_builtin_calls_enabled() const
void SetExceptionPropagationCallback(ExceptionPropagationCallback callback)
void InitializeBuiltinJSDispatchTable()
Address cage_base() const
Isolate * shared_space_isolate() const
EmbeddedFileWriterInterface * embedded_file_writer_
void SetIsLoading(bool is_loading)
std::vector< BeforeCallEnteredCallback > before_call_entered_callbacks_
bool concurrent_recompilation_enabled()
void ReportPendingMessages(bool report=true)
LocalHeap * main_thread_local_heap()
MaterializedObjectStore * materialized_object_store_
void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback)
void clear_topmost_script_having_context()
Handle< Object > root_handle(RootIndex index)
MaybeDirectHandle< Object > RunPrepareStackTraceCallback(DirectHandle< NativeContext >, DirectHandle< JSObject > Error, DirectHandle< JSArray > sites)
void SetCodePages(std::vector< MemoryRange > *new_code_pages)
v8::PageAllocator * page_allocator() const
void UpdateNumberStringNotRegexpLikeProtectorOnSetPrototype(DirectHandle< JSObject > object)
std::vector< Tagged< Object > > startup_object_cache_
ReadOnlyHeap * read_only_heap_
V8_NOINLINE void PushParamsAndContinue(void *ptr1=nullptr, void *ptr2=nullptr, void *ptr3=nullptr, void *ptr4=nullptr, void *ptr5=nullptr, void *ptr6=nullptr)
uint32_t promise_hook_flags_
void SetPriority(v8::Isolate::Priority priority)
std::shared_ptr< Counters > async_counters_
DirectHandle< Symbol > SymbolFor(RootIndex dictionary_index, Handle< String > name, bool private_symbol)
const char * GetExternallyCompiledFilename(int index) const
void PrepareBuiltinSourcePositionMap()
CatchType PredictExceptionCatcher()
Tagged< Object > LocalsBlockListCacheGet(DirectHandle< ScopeInfo > scope_info)
v8::metrics::LongTaskStats long_task_stats_
void SetAddCrashKeyCallback(AddCrashKeyCallback callback)
AccountingAllocator * allocator_
void ClearSerializerData()
Tagged< Object > StackOverflow()
RootsTable & roots_table()
ThreadLocalTop * thread_local_top()
AddCrashKeyCallback add_crash_key_callback_
base::Mutex code_pages_mutex_
void AddCrashKeysForIsolateAndHeapPointers()
bool capture_stack_trace_for_uncaught_exceptions_
uintptr_t last_recorder_context_id_
static void RemoveContextIdCallback(const v8::WeakCallbackInfo< void > &data)
void AddCodeMemoryRange(MemoryRange range)
void UpdateStringWrapperToPrimitiveProtectorOnSetPrototype(DirectHandle< JSObject > object, DirectHandle< Object > new_prototype)
void ReportPromiseReject(DirectHandle< JSPromise > promise, DirectHandle< Object > value, v8::PromiseRejectEvent event)
v8::Isolate::Priority priority()
void clear_internal_exception()
bool RequiresCodeRange() const
void RegisterTryCatchHandler(v8::TryCatch *that)
size_t total_regexp_code_generated_
std::shared_ptr< metrics::Recorder > metrics_recorder_
Bootstrapper * bootstrapper_
std::atomic< EntryStackItem * > entry_stack_
void SetAbortOnUncaughtExceptionCallback(v8::Isolate::AbortOnUncaughtExceptionCallback callback)
bool IsJSApiWrapperNativeError(DirectHandle< JSReceiver > obj)
v8::Isolate::UseCounterCallback use_counter_callback_
StringForwardingTable * string_forwarding_table() const
base::RandomNumberGenerator * fuzzer_rng()
std::vector< MemoryRange > code_pages_buffer2_
void UpdateLongTaskStats()
EternalHandles * eternal_handles_
bool NeedsSourcePositions() const
const AstStringConstants * ast_string_constants_
void OnPromiseBefore(DirectHandle< JSPromise > promise)
std::atomic< std::vector< MemoryRange > * > code_pages_
void SetHostInitializeImportMetaObjectCallback(HostInitializeImportMetaObjectCallback callback)
std::unique_ptr< PersistentHandles > NewPersistentHandles()
bool MayAccess(DirectHandle< NativeContext > accessing_context, DirectHandle< JSObject > receiver)
MaybeDirectHandle< FixedArray > GetImportAttributesFromArgument(MaybeDirectHandle< Object > maybe_import_options_argument)
static void EnsureSourcePositionsAvailable(Isolate *isolate, DirectHandle< JSMessageObject > message)
static V8_EXPORT_PRIVATE void AddProperty(Isolate *isolate, DirectHandle< JSObject > object, DirectHandle< Name > name, DirectHandle< Object > value, PropertyAttributes attributes)
static void ForceSetPrototype(Isolate *isolate, DirectHandle< JSObject > object, DirectHandle< JSPrototype > proto)
static V8_WARN_UNUSED_RESULT Maybe< bool > HasRealNamedProperty(Isolate *isolate, DirectHandle< JSObject > object, DirectHandle< Name > name)
static uint32_t GetNextAsyncTaskId(uint32_t current_async_task_id)
static Handle< Object > GetDataProperty(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 > GetConstructorName(Isolate *isolate, DirectHandle< JSReceiver > receiver)
static void IsolateDeinit(Isolate *isolate)
intptr_t GetSPToFPDelta() const
void SetException(Tagged< Object > exception)
static JavaScriptBuiltinContinuationWithCatchFrame * cast(StackFrame *frame)
Tagged< JSFunction > function() const override
bool is_unoptimized() const
static MaybeHandle< FixedArray > GetKeys(Isolate *isolate, DirectHandle< JSReceiver > object, KeyCollectionMode mode, PropertyFilter filter, GetKeysConversion keys_conversion=GetKeysConversion::kKeepNumbers, bool is_for_in=false, bool skip_indices=false)
V8_INLINE void ExecuteMainThreadWhileParked(Callback callback)
bool allows_code_compaction()
bool is_listening_to_code_events()
V8_INLINE DirectHandle< T > ToHandleChecked() const
V8_WARN_UNUSED_RESULT V8_INLINE bool ToHandle(DirectHandle< S > *out) const
V8_INLINE bool is_null() const
static MaybeObjectDirectHandle Weak(Tagged< Object > object, Isolate *isolate)
static V8_EXPORT_PRIVATE void ReportMessage(Isolate *isolate, const MessageLocation *loc, DirectHandle< JSMessageObject > message)
static std::unique_ptr< char[]> GetLocalizedMessage(Isolate *isolate, DirectHandle< Object > data)
static V8_EXPORT_PRIVATE Handle< JSMessageObject > MakeMessageObject(Isolate *isolate, MessageTemplate type, const MessageLocation *location, DirectHandle< Object > argument, DirectHandle< StackTraceInfo > stack_trace=DirectHandle< StackTraceInfo >::null())
Handle< Script > script() const
static void SetUpDefaultMicrotaskQueue(Isolate *isolate)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > ToFunctionName(Isolate *isolate, DirectHandle< Name > name)
static V8_WARN_UNUSED_RESULT HandleType< String >::MaybeType ToString(Isolate *isolate, HandleType< T > input)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > SetProperty(LookupIterator *it, DirectHandle< Object > value, StoreOrigin store_origin, Maybe< ShouldThrow > should_throw=Nothing< ShouldThrow >())
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > GetPropertyOrElement(Isolate *isolate, DirectHandle< JSAny > object, DirectHandle< Name > name)
static double NumberValue(Tagged< Number > obj)
static void FreeOffHeapOffHeapInstructionStream(uint8_t *code, uint32_t code_size, uint8_t *data, uint32_t data_size)
static void CreateOffHeapOffHeapInstructionStream(Isolate *isolate, uint8_t **code, uint32_t *code_size, uint8_t **data, uint32_t *data_size)
int LookupExceptionHandlerInTable(int *data, HandlerTable::CatchPrediction *prediction) override
void Flush(BlockingBehavior blocking_behavior)
void Prioritize(Tagged< SharedFunctionInfo > function)
void set_finalize(bool finalize)
static void UnregisterIsolate(Isolate *isolate)
static void RegisterIsolate(Isolate *isolate)
@ kPromiseAnyRejectElementCapabilitySlot
@ kPromiseAllResolveElementCapabilitySlot
static uint32_t GetPropertyIndex(const PropertyCallbackInfo< T > &info)
static Handle< Object > GetPropertyKeyHandle(const PropertyCallbackInfo< T > &info)
ReadOnlyHeap * read_only_heap() const
uint32_t initial_next_unique_sfi_id() const
Address FirstPageAddress() const
static Handle< RegisteredSymbolTable > Add(Isolate *isolate, Handle< RegisteredSymbolTable > table, DirectHandle< String > key, DirectHandle< Symbol >)
virtual void VisitRootPointer(Root root, const char *description, FullObjectSlot p)
FullObjectSlot slot(RootIndex root_index)
SaveAndSwitchContext(Isolate *isolate, Tagged< Context > new_context)
SaveContext(Isolate *isolate)
Handle< Context > context_
Handle< Context > topmost_script_having_context_
static bool GetPositionInfo(DirectHandle< Script > script, int position, PositionInfo *info, OffsetFlag offset_flag=OffsetFlag::kWithOffset)
size_t total_size() const
virtual bool SetupHeap(Isolate *isolate, bool create_heap_objects)
virtual void SetupBuiltins(Isolate *isolate, bool compile_builtins)
static void EnsureSourcePositionsAvailable(Isolate *isolate, DirectHandle< SharedFunctionInfo > shared_info)
void DeserializeIntoIsolate()
static void UnregisterJSStackComparableAddress(v8::internal::Isolate *isolate)
static void IterateRegistersAndStack(Isolate *isolate, ::heap::base::StackVisitor *visitor)
static constexpr int ToInt(const Tagged< Object > object)
static constexpr Tagged< Smi > uninitialized_deserialization_value()
static constexpr Tagged< Smi > FromInt(int value)
static constexpr Tagged< Smi > zero()
static const v8::StartupData * DefaultSnapshotBlob()
static V8_EXPORT_PRIVATE uint32_t GetExpectedChecksum(const v8::StartupData *data)
static NEVER_READ_ONLY_SPACE int GetSourcePosition(DirectHandle< StackFrameInfo > info)
V8_EXPORT_PRIVATE void Advance()
StackFrame * frame() const
V8_EXPORT_PRIVATE Tagged< Code > LookupCode() const
virtual Type type() const =0
bool is_javascript() const
StackHandler * top_handler() const
bool is_optimized_js() const
void InitThread(const ExecutionAccess &lock)
bool HasTerminationRequest()
void SetStackLimitForStackSwitching(uintptr_t limit)
bool JsHasOverflowed(uintptr_t gap=0) const
V8_INLINE bool InterruptRequested()
V8_EXPORT_PRIVATE bool HandleStackOverflowAndTerminationRequest()
bool WasmHasOverflowed(uintptr_t gap=0) const
bool HasOverflowed() const
StackTraceFailureMessage(Isolate *isolate, StackTraceMode mode, const Address *ptrs, size_t ptrs_count)
V8_NOINLINE void Print() volatile
char js_stack_trace_[kStacktraceBufferSize]
static constexpr int kFixedFrameSizeFromFp
void DeserializeIntoIsolate()
static V8_EXPORT_PRIVATE void ClearMentionedObjectCache(Isolate *isolate)
DirectHandle< String > ToString(Isolate *isolate)
void PrintMentionedObjectCache(Isolate *isolate)
void OutputToFile(FILE *out)
void Add(const char *format)
void Log(Isolate *isolate)
int LookupExceptionHandlerInTable()
V8_INLINE constexpr StorageType ptr() const
V8_INLINE constexpr bool is_null() const
static ThreadId Current()
static ThreadId TryGetCurrent()
static constexpr ThreadId Invalid()
void Initialize(Isolate *)
Address pending_handler_fp_
uint8_t is_on_central_stack_flag_
Tagged< Context > pending_handler_context_
Address try_catch_handler_address()
Address central_stack_sp_
v8::FailedAccessCheckCallback failed_access_check_callback_
Address pending_handler_constant_pool_
uintptr_t num_frames_above_pending_handler_
v8::TryCatch * try_catch_handler_
Address pending_handler_sp_
uint8_t rethrowing_message_
Address central_stack_limit_
Address pending_handler_entrypoint_
Address secondary_stack_limit_
Address secondary_stack_sp_
std::atomic< ThreadId > mutex_owner_
virtual void VisitThread(Isolate *isolate, ThreadLocalTop *top)=0
void TraceAllocateSegmentImpl(v8::internal::Segment *segment) override
void TraceZoneDestructionImpl(const Zone *zone) override
~TracingAccountingAllocator()=default
void UpdateMemoryTrafficAndReportMemoryUsage(size_t memory_traffic_delta)
void TraceZoneCreationImpl(const Zone *zone) override
TracingAccountingAllocator(Isolate *isolate)
void Dump(std::ostringstream &out, bool dump_details)
std::unordered_set< const Zone * > active_zones_
std::ostringstream buffer_
static int RegisterStackSlotCount(int register_count)
static UnoptimizedJSFrame * cast(StackFrame *frame)
Tagged< BytecodeArray > GetBytecodeArray() const
Tagged< Object > ReadInterpreterRegister(int register_index) const
int LookupExceptionHandlerInTable(int *data, HandlerTable::CatchPrediction *prediction) override
virtual int GetBytecodeOffset() const =0
V8_EXPORT_PRIVATE bool is_logging()
V8_EXPORT_PRIVATE void StopProfilerThread()
V8_EXPORT_PRIVATE FILE * TearDownAndGetLogFile()
bool is_listening_to_code_events() override
void LateSetup(Isolate *isolate)
sampler::Sampler * sampler()
bool SetUp(Isolate *isolate)
static V8_INLINE Tagged_t CompressObject(Address tagged)
static V8_INLINE void InitBase(Address base)
static V8_INLINE Address DecompressTagged(TOnHeapAddress on_heap_addr, Tagged_t raw_value)
V8_CONST static V8_INLINE Address base()
static V8_EXPORT_PRIVATE v8::Platform * GetCurrentPlatform()
static V8_EXPORT_PRIVATE void FatalProcessOutOfMemory(Isolate *isolate, const char *location, const OOMDetails &details=kNoOOMDetails)
static constexpr int kSize
static V8_WARN_UNUSED_RESULT DirectHandle< WeakArrayList > Append(Isolate *isolate, DirectHandle< WeakArrayList > array, MaybeObjectDirectHandle value, AllocationType allocation=AllocationType::kYoung)
NEVER_READ_ONLY_SPACE static V8_EXPORT_PRIVATE Handle< WeakArrayList > AddToEnd(Isolate *isolate, Handle< WeakArrayList > array, MaybeObjectDirectHandle value)
static MarkingBarrier * SetForThread(MarkingBarrier *marking_barrier)
size_t segment_bytes_allocated() const
static StackMemory * GetCentralStackView(Isolate *isolate)
WasmCode * LookupCode(Isolate *isolate, Address pc) const
Address instruction_start() const
Address constant_pool() const
static void FreeAllOrphanedGlobalHandles(WasmOrphanedGlobalHandle *start)
void DumpAndResetTurboStatistics()
static WasmOrphanedGlobalHandle * NewOrphanedGlobalHandle(WasmOrphanedGlobalHandle **pointer)
void DeleteCompileJobsOnIsolate(Isolate *isolate)
void RemoveIsolate(Isolate *isolate)
void AddIsolate(Isolate *isolate)
static void NotifyIsolateDisposal(Isolate *isolate)
static const ContextId Empty()
RecordWriteMode const mode_
base::OwnedVector< uint8_t > buffer_
#define V8_ENABLE_LEAPTIERING_BOOL
#define V8_EXTERNAL_CODE_SPACE_BOOL
#define COMPRESS_POINTERS_BOOL
#define COMPRESS_POINTERS_IN_MULTIPLE_CAGES_BOOL
#define V8_ENABLE_NEAR_CODE_RANGE_BOOL
#define V8_CAN_CREATE_SHARED_HEAP_BOOL
#define FOR_EACH_ISOLATE_ADDRESS_NAME(C)
Handle< SharedFunctionInfo > info
Handle< Context > context_
#define RETURN_ON_EXCEPTION(isolate, call)
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
#define ISOLATE_INIT_ARRAY_LIST(V)
#define THROW_NEW_ERROR(isolate, call)
#define RETURN_VALUE_IF_EXCEPTION(isolate, value)
#define MAYBE_RETURN_ON_EXCEPTION_VALUE(isolate, call, value)
#define ISOLATE_INIT_LIST(V)
#define API_ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
MicrotaskQueue * microtask_queue
#define V8_SHORT_BUILTIN_CALLS_BOOL
#define STATIC_ROOTS_FAILED_MSG
#define INSTANCE_TYPE_CHECKERS_SINGLE(V)
#define INSTANCE_TYPE_CHECKERS_RANGE(V)
uint32_t v8_Default_embedded_blob_code_size_
FrameSummaries summaries_
Handle< FixedArray > frames_
MaybeHandle< Script > current_script_
#define ISOLATE_INIT_ARRAY_EXECUTE(type, name, length)
bool encountered_strict_function_
Handle< String > name_or_url_
const uint8_t v8_Default_embedded_blob_data_[]
#define TRACE_ISOLATE(tag)
const uint8_t v8_Default_embedded_blob_code_[]
const Handle< Object > caller_
Handle< FixedArray > elements_
uint32_t v8_Default_embedded_blob_data_size_
StackFrameIterator stack_iterator_
#define ASSIGN_ELEMENT(CamelName, hacker_name)
#define ISOLATE_INIT_EXECUTE(type, name, initial_value)
std::optional< TNode< JSArray > > a
SharedFunctionInfoRef shared
DirectHandle< JSReceiver > options
ZoneVector< RpoNumber > & result
ZoneStack< RpoNumber > & stack
LiftoffAssembler::CacheState state
base::SmallVector< int32_t, 1 > stack_slots
#define LAZY_MUTEX_INITIALIZER
V8_INLINE size_t hash_combine(size_t seed, size_t hash)
constexpr Vector< const char > StaticCharVector(const char(&array)[N])
constexpr Vector< T > VectorOf(T *start, size_t size)
void AlignedFree(void *ptr)
void * AlignedAlloc(size_t size, size_t alignment)
@ kDebugStackTraceCaptured
void MaybeSetHandlerNow(Isolate *isolate)
void AddIsolate(Isolate *isolate)
void RemoveIsolate(Isolate *isolate)
V8_INLINE constexpr bool IsSeqString(InstanceType instance_type)
V8_INLINE constexpr bool IsThinString(InstanceType instance_type)
V8_INLINE constexpr bool IsConsString(InstanceType instance_type)
V8_INLINE constexpr bool IsExternalString(InstanceType instance_type)
V8_INLINE constexpr bool IsOneByteString(InstanceType instance_type)
constexpr Tagged_t kNonJsReceiverMapLimit
V8_INLINE constexpr bool IsInternalizedString(InstanceType instance_type)
V8_INLINE constexpr bool IsSlicedString(InstanceType instance_type)
V8_INLINE constexpr bool IsUncachedExternalString(InstanceType instance_type)
V8_INLINE constexpr bool IsTwoByteString(InstanceType instance_type)
void AssertThreadNotInWasm()
TH_DISABLE_ASAN bool IsThreadInWasm()
WasmCodeManager * GetWasmCodeManager()
WasmEngine * GetWasmEngine()
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
uint32_t DefaultEmbeddedBlobDataSize()
constexpr NullMaybeHandleType kNullMaybeHandle
constexpr int kTaggedSize
const uint8_t * DefaultEmbeddedBlobCode()
bool NoExtension(const v8::FunctionCallbackInfo< v8::Value > &)
void FreeCurrentEmbeddedBlob()
PerThreadAssertScopeDebugOnly< false, SAFEPOINTS_ASSERT, HEAP_ALLOCATION_ASSERT > DisallowGarbageCollection
base::LazyMutex read_only_dispatch_entries_mutex_
constexpr size_t kIsolateDataAlignment
bool Is(IndirectHandle< U > value)
bool IsNumber(Tagged< Object > obj)
void PrintF(const char *format,...)
constexpr int kJSDispatchHandleSize
const size_t kShortBuiltinCallsOldSpaceSizeThreshold
Tagged(T object) -> Tagged< T >
thread_local Isolate::PerIsolateThreadData *g_current_per_isolate_thread_data_ V8_CONSTINIT
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
static void PrintFrames(Isolate *isolate, StringStream *accumulator, StackFrame::PrintMode mode)
kInterpreterTrampolineOffset Tagged< HeapObject >
BUILTIN_FP_CALL BUILTIN_FP_CALL BUILTIN_FP_CALL BUILTIN_FP_CALL BUILTIN_FP_CALL BUILTIN_FP_CALL BUILTIN_FP_CALL BUILTIN_FP_CALL BUILTIN_FP_CALL BUILTIN_FP_CALL int character
bool IsAsyncFunction(FunctionKind kind)
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
void Print(Tagged< Object > obj)
bool IsNullOrUndefined(Tagged< Object > obj, Isolate *isolate)
constexpr int kSystemPointerSize
uint32_t DefaultEmbeddedBlobCodeSize()
uintptr_t GetCurrentStackPosition()
typename detail::FlattenUnionHelper< Union<>, Ts... >::type UnionOf
constexpr size_t kMaxPCRelativeCodeRangeInMB
void DefaultWasmAsyncResolvePromiseCallback(v8::Isolate *isolate, v8::Local< v8::Context > context, v8::Local< v8::Promise::Resolver > resolver, v8::Local< v8::Value > result, WasmAsyncSuccess success)
const uint8_t * DefaultEmbeddedBlobData()
bool is_strict(LanguageMode language_mode)
constexpr bool kPlatformRequiresCodeRange
V8_EXPORT_PRIVATE FlagValues v8_flags
void DisableEmbeddedBlobRefcounting()
static base::RandomNumberGenerator * ensure_rng_exists(base::RandomNumberGenerator **rng, int seed)
constexpr bool kAllCodeObjectsLiveInTrustedSpace
uint64_t HashSeed(Isolate *isolate)
static constexpr Address kNullAddress
void PrintIsolate(void *isolate, const char *format,...)
void MemCopy(void *dest, const void *src, size_t size)
int FastD2IChecked(double x)
void init_memcopy_functions()
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 allocation gc speed threshold for starting incremental marking via a task in percent of available threshold for starting incremental marking immediately in percent of available Use a single schedule for determining a marking schedule between JS and C objects schedules the minor GC task with kUserVisible priority max worker number of concurrent for NumberOfWorkerThreads start background threads that allocate memory concurrent_array_buffer_sweeping use parallel threads to clear weak refs in the atomic pause trace progress of the incremental marking trace object counts and memory usage * MB
constexpr bool CodeKindCanDeoptimize(CodeKind kind)
kInterpreterTrampolineOffset script
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
bool(*)(Local< Context > context) WasmJSPIEnabledCallback
void(*)(CrashKeyId id, const std::string &value) AddCrashKeyCallback
@ kSnapshotChecksumCalculated
@ kCodeSpaceFirstPageAddress
@ kOldSpaceFirstPageAddress
@ kReadonlySpaceFirstPageAddress
@ kSnapshotChecksumExpected
void(*)(ExceptionPropagationMessage message) ExceptionPropagationCallback
bool(*)(Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data) AccessCheckCallback
void(*)(PromiseRejectMessage message) PromiseRejectCallback
void(*)(Isolate *) CallCompletedCallback
static constexpr RelaxedStoreTag kRelaxedStore
void(*)(Local< Object > target, AccessType type, Local< Value > data) FailedAccessCheckCallback
void(*)(Local< Context > context, Local< Module > module, Local< Object > meta) HostInitializeImportMetaObjectCallback
void(*)(Isolate *isolate, void *data) InterruptCallback
bool(*)(Local< Context > context) WasmImportedStringsEnabledCallback
void(*)(PromiseHookType type, Local< Promise > promise, Local< Value > parent) PromiseHook
v8::Local< T > ToApiHandle(v8::internal::DirectHandle< v8::internal::Object > obj)
T ToCData(i::Isolate *isolate, v8::internal::Tagged< v8::internal::Object > obj)
bool(*)(Isolate *isolate, Local< String > script_name) PrintCurrentStackTraceFilterCallback
void(*)(Isolate *) BeforeCallEnteredCallback
static constexpr AcquireLoadTag kAcquireLoad
Maybe< T > Just(const T &t)
SourcePositionTable *const table_
#define STRONG_READ_ONLY_ROOT_LIST(V)
#define CHECK_GE(lhs, rhs)
#define CHECK_IMPLIES(lhs, rhs)
#define CHECK_LT(lhs, rhs)
#define DCHECK_WITH_MSG(condition, msg)
#define CHECK_WITH_MSG(condition, message)
#define DCHECK_NOT_NULL(val)
#define CHECK_NOT_NULL(val)
#define DCHECK_IMPLIES(v1, v2)
#define DCHECK_NE(v1, v2)
#define CHECK_NE(lhs, rhs)
#define DCHECK_GE(v1, v2)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)
constexpr T RoundDown(T x, intptr_t m)
#define OFFSET_OF(type, field)
constexpr bool IsAligned(T value, U alignment)
Handle< Object > error_stack
ManagedPtrDestructor * prev_
ManagedPtrDestructor * next_
static V8_EXPORT_PRIVATE std::atomic_uint runtime_stats
#define V8_TLS_DEFINE_GETTER(Name, Type, Member)
#define TRACE_EVENT0(category_group, name)
#define TRACE_EVENT_END1(category_group, name, arg1_name, arg1_val)
#define TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val)
#define TRACE_EVENT_SCOPE_THREAD
#define TRACE_DISABLED_BY_DEFAULT(name)
#define TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_val)
#define TRACE_STR_COPY(str)
#define V8_STATIC_ROOTS_BOOL
#define END_ALLOW_USE_DEPRECATED()
#define V8_UNLIKELY(condition)
#define START_ALLOW_USE_DEPRECATED()