5#ifndef INCLUDE_V8_ISOLATE_H_
6#define INCLUDE_V8_ISOLATE_H_
37class SharedArrayBuffer;
83 size_t maximum_heap_size_in_bytes);
95 uint64_t virtual_memory_limit);
123 return max_old_generation_size_;
126 max_old_generation_size_ = limit;
135 return max_young_generation_size_;
138 max_young_generation_size_ = limit;
142 return initial_old_generation_size_;
145 initial_old_generation_size_ = initial_size;
149 return initial_young_generation_size_;
152 initial_young_generation_size_ = initial_size;
156 static constexpr size_t kMB = 1048576u;
157 size_t code_range_size_ = 0;
158 size_t max_old_generation_size_ = 0;
159 size_t max_young_generation_size_ = 0;
160 size_t initial_old_generation_size_ = 0;
161 size_t initial_young_generation_size_ = 0;
162 uint32_t* stack_limit_ =
nullptr;
263 std::shared_ptr<
ArrayBuffer::Allocator> array_buffer_allocator_shared;
271 const intptr_t* external_references =
nullptr;
277 bool allow_atomics_wait = true;
282 bool only_terminate_in_safe_scope = false;
289 int embedder_wrapper_type_index = -1;
290 int embedder_wrapper_object_index = -1;
312 v8_isolate_->Enter();
344 bool was_execution_allowed_;
363 bool was_execution_allowed_assert_;
364 bool was_execution_allowed_throws_;
365 bool was_execution_allowed_dump_;
385 internal::Isolate*
const i_isolate_;
386 internal::MicrotaskQueue*
const microtask_queue_;
389 friend class internal::ThreadLocalTop;
413 kMinorGarbageCollection
427 kOBSOLETE_LegacyConst = 2,
428 kOBSOLETE_MarkDequeOverflow = 3,
429 kOBSOLETE_StoreBufferOverflow = 4,
430 kOBSOLETE_SlotsBufferOverflow = 5,
431 kOBSOLETE_ObjectObserve = 6,
435 kOBSOLETE_StrongMode = 10,
436 kRegExpPrototypeStickyGetter = 11,
437 kRegExpPrototypeToString = 12,
438 kRegExpPrototypeUnicodeGetter = 13,
439 kOBSOLETE_IntlV8Parse = 14,
440 kOBSOLETE_IntlPattern = 15,
441 kOBSOLETE_IntlResolved = 16,
442 kOBSOLETE_PromiseChain = 17,
443 kOBSOLETE_PromiseAccept = 18,
444 kOBSOLETE_PromiseDefer = 19,
445 kHtmlCommentInExternalScript = 20,
447 kSloppyModeBlockScopedFunctionRedefinition = 22,
448 kForInInitializer = 23,
449 kOBSOLETE_ArrayProtectorDirtied = 24,
450 kArraySpeciesModified = 25,
451 kArrayPrototypeConstructorModified = 26,
452 kOBSOLETE_ArrayInstanceProtoModified = 27,
453 kArrayInstanceConstructorModified = 28,
454 kOBSOLETE_LegacyFunctionDeclaration = 29,
455 kOBSOLETE_RegExpPrototypeSourceGetter = 30,
456 kOBSOLETE_RegExpPrototypeOldFlagGetter = 31,
457 kDecimalWithLeadingZeroInStrictMode = 32,
458 kLegacyDateParser = 33,
459 kDefineGetterOrSetterWouldThrow = 34,
460 kFunctionConstructorReturnedUndefined = 35,
461 kAssigmentExpressionLHSIsCallInSloppy = 36,
462 kAssigmentExpressionLHSIsCallInStrict = 37,
463 kPromiseConstructorReturnedUndefined = 38,
464 kOBSOLETE_ConstructorNonUndefinedPrimitiveReturn = 39,
465 kOBSOLETE_LabeledExpressionStatement = 40,
466 kOBSOLETE_LineOrParagraphSeparatorAsLineTerminator = 41,
468 kErrorCaptureStackTrace = 43,
469 kErrorPrepareStackTrace = 44,
470 kErrorStackTraceLimit = 45,
471 kWebAssemblyInstantiation = 46,
472 kDeoptimizerDisableSpeculation = 47,
473 kOBSOLETE_ArrayPrototypeSortJSArrayModifiedPrototype = 48,
474 kFunctionTokenOffsetTooLongForToString = 49,
475 kWasmSharedMemory = 50,
476 kWasmThreadOpcodes = 51,
477 kOBSOLETE_AtomicsNotify = 52,
478 kOBSOLETE_AtomicsWake = 53,
481 kDateTimeFormat = 56,
483 kRelativeTimeFormat = 58,
487 kStringLocaleCompare = 62,
488 kOBSOLETE_StringToLocaleUpperCase = 63,
489 kStringToLocaleLowerCase = 64,
490 kNumberToLocaleString = 65,
491 kDateToLocaleString = 66,
492 kDateToLocaleDateString = 67,
493 kDateToLocaleTimeString = 68,
494 kAttemptOverrideReadOnlyOnPrototypeSloppy = 69,
495 kAttemptOverrideReadOnlyOnPrototypeStrict = 70,
496 kOBSOLETE_OptimizedFunctionWithOneShotBytecode = 71,
497 kRegExpMatchIsTrueishOnNonJSRegExp = 72,
498 kRegExpMatchIsFalseishOnJSRegExp = 73,
499 kOBSOLETE_DateGetTimezoneOffset = 74,
500 kStringNormalize = 75,
501 kCallSiteAPIGetFunctionSloppyCall = 76,
502 kCallSiteAPIGetThisSloppyCall = 77,
503 kOBSOLETE_RegExpMatchAllWithNonGlobalRegExp = 78,
504 kRegExpExecCalledOnSlowRegExp = 79,
505 kRegExpReplaceCalledOnSlowRegExp = 80,
507 kSharedArrayBufferConstructed = 82,
508 kArrayPrototypeHasElements = 83,
509 kObjectPrototypeHasElements = 84,
510 kNumberFormatStyleUnit = 85,
511 kDateTimeFormatRange = 86,
512 kDateTimeFormatDateTimeStyle = 87,
513 kBreakIteratorTypeWord = 88,
514 kBreakIteratorTypeLine = 89,
515 kInvalidatedArrayBufferDetachingProtector = 90,
516 kInvalidatedArrayConstructorProtector = 91,
517 kInvalidatedArrayIteratorLookupChainProtector = 92,
518 kInvalidatedArraySpeciesLookupChainProtector = 93,
519 kInvalidatedIsConcatSpreadableLookupChainProtector = 94,
520 kInvalidatedMapIteratorLookupChainProtector = 95,
521 kInvalidatedNoElementsProtector = 96,
522 kInvalidatedPromiseHookProtector = 97,
523 kInvalidatedPromiseResolveLookupChainProtector = 98,
524 kInvalidatedPromiseSpeciesLookupChainProtector = 99,
525 kInvalidatedPromiseThenLookupChainProtector = 100,
526 kInvalidatedRegExpSpeciesLookupChainProtector = 101,
527 kInvalidatedSetIteratorLookupChainProtector = 102,
528 kInvalidatedStringIteratorLookupChainProtector = 103,
529 kInvalidatedStringLengthOverflowLookupChainProtector = 104,
530 kInvalidatedTypedArraySpeciesLookupChainProtector = 105,
531 kWasmSimdOpcodes = 106,
532 kVarRedeclaredCatchBinding = 107,
534 kOBSOLETE_WasmBulkMemory = 109,
535 kOBSOLETE_WasmMultiValue = 110,
536 kWasmExceptionHandling = 111,
537 kInvalidatedMegaDOMProtector = 112,
538 kFunctionPrototypeArguments = 113,
539 kFunctionPrototypeCaller = 114,
540 kTurboFanOsrCompileStarted = 115,
541 kAsyncStackTaggingCreateTaskCall = 116,
542 kDurationFormat = 117,
543 kInvalidatedNumberStringNotRegexpLikeProtector = 118,
544 kOBSOLETE_RegExpUnicodeSetIncompatibilitiesWithUnicodeMode = 119,
545 kImportAssertionDeprecatedSyntax = 120,
546 kLocaleInfoObsoletedGetters = 121,
547 kLocaleInfoFunctions = 122,
548 kCompileHintsMagicAll = 123,
549 kInvalidatedNoProfilingProtector = 124,
551 kWasmMultiMemory = 126,
553 kWasmImportedStrings = 128,
554 kSourceMappingUrlMagicCommentAtSign = 129,
555 kTemporalObject = 130,
556 kWasmModuleCompilation = 131,
557 kInvalidatedNoUndetectableObjectsProtector = 132,
558 kWasmJavaScriptPromiseIntegration = 133,
559 kWasmReturnCall = 134,
560 kWasmExtendedConst = 135,
561 kWasmRelaxedSimd = 136,
562 kWasmTypeReflection = 137,
564 kWasmTypedFuncRef = 139,
565 kInvalidatedStringWrapperToPrimitiveProtector = 140,
570 kUseCounterFeatureCount
574 kMessageLog = (1 << 0),
575 kMessageDebug = (1 << 1),
576 kMessageInfo = (1 << 2),
577 kMessageError = (1 << 3),
578 kMessageWarning = (1 << 4),
579 kMessageAll = kMessageLog | kMessageDebug | kMessageInfo | kMessageError |
694#if defined(V8_OS_WIN)
698 void SetFilterETWSessionByURLCallback(FilterETWSessionByURLCallback callback);
770 V8_INLINE void SetData(uint32_t slot,
void* data);
782 V8_INLINE static uint32_t GetNumberOfDataSlots();
865 std::unique_ptr<MeasureMemoryDelegate> delegate,
881 size_t frames_limit,
SampleInfo* sample_info);
942 return ThrowError(String::NewFromUtf8Literal(
this, message));
970 GCType gc_type_filter = kGCTypeAll);
978 GCType gc_type_filter = kGCTypeAll);
1002 GCType gc_type_filter = kGCTypeAll);
1010 GCType gc_type_filter = kGCTypeAll);
1026 void* data =
nullptr);
1048 "Set the heap on Isolate creation using CreateParams instead.")
1058 void DetachCppHeap();
1077 kTerminatedExecution,
1132 size_t offset_in_bytes, int64_t value,
1133 double timeout_in_ms,
1356 const std::shared_ptr<metrics::Recorder>& metrics_recorder);
1380 "Use MemoryPressureNotification() to influence the GC schedule.")
1381 bool IdleNotificationDeadline(
double deadline_in_seconds);
1387 void LowMemoryNotification();
1398 int ContextDisposedNotification(
bool dependant_context = true);
1404 void IsolateInForegroundNotification();
1410 void IsolateInBackgroundNotification();
1424 void UpdateLoadStartTime();
1430 void IncreaseHeapLimitForDebugging();
1435 void RestoreOriginalHeapLimit();
1441 bool IsHeapLimitIncreasedForDebugging();
1477 void SetStackLimit(uintptr_t stack_limit);
1494 void GetCodeRange(
void** start,
size_t* length_in_bytes);
1500 void GetEmbeddedCodeRange(const
void** start,
size_t* length_in_bytes);
1507 static constexpr
size_t kMinCodePagesBufferSize = 32;
1553 void AutomaticallyRestoreInitialHeapLimit(
double threshold_percent = 0.5);
1559 void SetModifyCodeGenerationFromStringsCallback(
1566 void SetAllowWasmCodeGenerationCallback(
1578 void SetWasmAsyncResolvePromiseCallback(
1583 void SetWasmImportedStringsEnabledCallback(
1586 void SetSharedArrayBufferConstructorEnabledCallback(
1595 void SetJavaScriptCompileHintsMagicEnabledCallback(
1650 void SetCaptureStackTraceForUncaughtExceptions(
1651 bool capture,
int frame_limit = 10,
1673 void SetAllowAtomicsWait(
bool allow);
1720 void*
operator new(
size_t size) =
delete;
1721 void*
operator new[](
size_t size) =
delete;
1722 void operator delete(
void*, size_t) =
delete;
1723 void operator delete[](
void*, size_t) =
delete;
1726 template <
class K,
class V,
class Traits>
1730 void ReportExternalAllocationLimitReached();
1733void Isolate::SetData(uint32_t slot,
void* data) {
1735 I::SetEmbedderData(
this, slot, data);
1738void* Isolate::GetData(uint32_t slot) {
1740 return I::GetEmbedderData(
this, slot);
1743uint32_t Isolate::GetNumberOfDataSlots() {
1745 return I::kNumIsolateDataSlots;
1750 if (
auto slot = GetDataFromSnapshotOnce(index); slot) {
1751 internal::PerformCastCheck(
1752 internal::ValueHelper::SlotAsValue<T, false>(slot));
AllowJavascriptExecutionScope & operator=(const AllowJavascriptExecutionScope &)=delete
AllowJavascriptExecutionScope(Isolate *isolate)
~AllowJavascriptExecutionScope()
AllowJavascriptExecutionScope(const AllowJavascriptExecutionScope &)=delete
DisallowJavascriptExecutionScope(Isolate *isolate, OnFailure on_failure)
DisallowJavascriptExecutionScope(const DisallowJavascriptExecutionScope &)=delete
~DisallowJavascriptExecutionScope()
DisallowJavascriptExecutionScope & operator=(const DisallowJavascriptExecutionScope &)=delete
SafeForTerminationScope & operator=(const SafeForTerminationScope &)=delete
SafeForTerminationScope(const SafeForTerminationScope &)=delete
~SafeForTerminationScope()
Scope(const Scope &)=delete
Scope & operator=(const Scope &)=delete
~SuppressMicrotaskExecutionScope()
SuppressMicrotaskExecutionScope & operator=(const SuppressMicrotaskExecutionScope &)=delete
SuppressMicrotaskExecutionScope(Isolate *isolate, MicrotaskQueue *microtask_queue=nullptr)
SuppressMicrotaskExecutionScope(const SuppressMicrotaskExecutionScope &)=delete
void SetCounterFunction(CounterLookupCallback)
void DiscardThreadSpecificMetadata()
void SetIdle(bool is_idle)
Local< Context > GetEnteredOrMicrotaskContext()
void SetAddCrashKeyCallback(AddCrashKeyCallback)
void AddGCPrologueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
void SetBatterySaverMode(bool battery_saver_mode_enabled)
bool(*)(Isolate *) AbortOnUncaughtExceptionCallback
void SetHostInitializeImportMetaObjectCallback(HostInitializeImportMetaObjectCallback callback)
void SetHostImportModuleDynamicallyCallback(HostImportModuleDynamicallyCallback callback)
void EnqueueMicrotask(MicrotaskCallback callback, void *data=nullptr)
static void Initialize(Isolate *isolate, const CreateParams ¶ms)
void GetStackSample(const RegisterState &state, void **frames, size_t frames_limit, SampleInfo *sample_info)
void AddCallCompletedCallback(CallCompletedCallback callback)
static Isolate * GetCurrent()
void SetContinuationPreservedEmbedderData(Local< Value > data)
bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics *object_statistics, size_t type_index)
void SetPromiseRejectCallback(PromiseRejectCallback callback)
ArrayBuffer::Allocator * GetArrayBufferAllocator()
void SetCreateHistogramFunction(CreateHistogramCallback)
void GetHeapStatistics(HeapStatistics *heap_statistics)
void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback)
void AddGCEpilogueCallback(GCCallback callback, GCType gc_type_filter=kGCTypeAll)
Local< Context > GetIncumbentContext()
MicrotasksPolicy GetMicrotasksPolicy() const
Local< Value > GetContinuationPreservedEmbedderData()
void RequestGarbageCollectionForTesting(GarbageCollectionType type)
void RemoveGCPrologueCallback(GCCallback callback)
size_t NumberOfHeapSpaces()
void(*)(Isolate *isolate, GCType type, GCCallbackFlags flags, void *data) GCCallbackWithData
bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics *object_statistics)
size_t(*)() GetExternallyAllocatedMemoryInBytesCallback
void RemoveGCEpilogueCallback(GCCallbackWithData callback, void *data=nullptr)
void ClearCachesForTesting()
void SetAtomicsWaitCallback(AtomicsWaitCallback callback, void *data)
void AddGCPrologueCallback(GCCallback callback, GCType gc_type_filter=kGCTypeAll)
void DateTimeConfigurationChangeNotification(TimeZoneDetection time_zone_detection=TimeZoneDetection::kSkip)
void(*)(Isolate *isolate, UseCounterFeature feature) UseCounterCallback
static Isolate * TryGetCurrent()
void RequestInterrupt(InterruptCallback callback, void *data)
void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)
void RemoveCallCompletedCallback(CallCompletedCallback callback)
V8_DEPRECATE_SOON("Use MemoryPressureNotification() to influence the GC schedule.") bool IdleNotificationDeadline(double deadline_in_seconds)
Local< Value > ThrowError(const char(&message)[N])
void SetPromiseHook(PromiseHook hook)
void SetEmbedderRootsHandler(EmbedderRootsHandler *handler)
Local< Value > ThrowError(Local< String > message)
void SetGetExternallyAllocatedMemoryInBytesCallback(GetExternallyAllocatedMemoryInBytesCallback callback)
void SetMicrotasksPolicy(MicrotasksPolicy policy)
HeapProfiler * GetHeapProfiler()
void RequestGarbageCollectionForTesting(GarbageCollectionType type, StackState stack_state)
void TerminateExecution()
V8_INLINE MaybeLocal< T > GetDataFromSnapshotOnce(size_t index)
bool MeasureMemory(std::unique_ptr< MeasureMemoryDelegate > delegate, MeasureMemoryExecution execution=MeasureMemoryExecution::kDefault)
void SetMetricsRecorder(const std::shared_ptr< metrics::Recorder > &metrics_recorder)
size_t NumberOfTrackedHeapObjectTypes()
Local< Value > ThrowException(Local< Value > exception)
Local< Context > GetCurrentContext()
Isolate(const Isolate &)=delete
bool GetHeapSpaceStatistics(HeapSpaceStatistics *space_statistics, size_t index)
void RemoveGCPrologueCallback(GCCallbackWithData, void *data=nullptr)
void SetUseCounterCallback(UseCounterCallback callback)
void LocaleConfigurationChangeNotification()
void CancelTerminateExecution()
void AddMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)
void MemoryPressureNotification(MemoryPressureLevel level)
void AddGCEpilogueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
void SetEventLogger(LogEventCallback that)
V8_DEPRECATE_SOON("Set the heap on Isolate creation using CreateParams instead.") void AttachCppHeap(CppHeap *)
void EnqueueMicrotask(Local< Function > microtask)
Isolate & operator=(const Isolate &)=delete
bool IsExecutionTerminating()
static Isolate * New(const CreateParams ¶ms)
void RemoveGCEpilogueCallback(GCCallback callback)
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
static Isolate * Allocate()
void(*)(Isolate *isolate, GCType type, GCCallbackFlags flags) GCCallback
void SetAddHistogramSampleFunction(AddHistogramSampleCallback)
void SetHostCreateShadowRealmContextCallback(HostCreateShadowRealmContextCallback callback)
void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
void PerformMicrotaskCheckpoint()
void SetAbortOnUncaughtExceptionCallback(AbortOnUncaughtExceptionCallback callback)
bool HasPendingBackgroundTasks()
void(*)(AtomicsWaitEvent event, Local< SharedArrayBuffer > array_buffer, size_t offset_in_bytes, int64_t value, double timeout_in_ms, AtomicsWaitWakeHandle *stop_handle, void *data) AtomicsWaitCallback
void set_max_young_generation_size_in_bytes(size_t limit)
void set_stack_limit(uint32_t *value)
void set_initial_young_generation_size_in_bytes(size_t initial_size)
size_t max_old_generation_size_in_bytes() const
size_t initial_old_generation_size_in_bytes() const
size_t initial_young_generation_size_in_bytes() const
void set_code_range_size_in_bytes(size_t limit)
size_t code_range_size_in_bytes() const
size_t max_young_generation_size_in_bytes() const
void ConfigureDefaults(uint64_t physical_memory, uint64_t virtual_memory_limit)
void set_max_old_generation_size_in_bytes(size_t limit)
uint32_t * stack_limit() const
void set_initial_old_generation_size_in_bytes(size_t initial_size)
void ConfigureDefaultsFromHeapSize(size_t initial_heap_size_in_bytes, size_t maximum_heap_size_in_bytes)
bool(*)(Local< Context > context) WasmJSPIEnabledCallback
void(*)(const char *name, int status) LogEventCallback
bool(*)(const FunctionCallbackInfo< Value > &) ExtensionCallback
void(*)(Local< Message > message, Local< Value > data) MessageCallback
void(*)(Isolate *, void *) MicrotasksCompletedCallbackWithData
void(*)(CrashKeyId id, const std::string &value) AddCrashKeyCallback
void(*)(PromiseRejectMessage message) PromiseRejectCallback
bool(*)(Local< Context > context, Local< String > source) AllowWasmCodeGenerationCallback
void(*)(PromiseHookType type, Local< Promise > promise, Local< Value > parent) PromiseHook
bool(*)(Local< Context > context) JavaScriptCompileHintsMagicEnabledCallback
void(*)(void *data) MicrotaskCallback
ModifyCodeGenerationFromStringsResult(*)(Local< Context > context, Local< Value > source, bool is_code_like) ModifyCodeGenerationFromStringsCallback2
void(*)(Isolate *) CallCompletedCallback
bool(*)(Local< Context > context) WasmImportedStringsEnabledCallback
size_t(*)(void *data, size_t current_heap_limit, size_t initial_heap_limit) NearHeapLimitCallback
void(*)(Local< Object > target, AccessType type, Local< Value > data) FailedAccessCheckCallback
void(*)(Isolate *isolate, void *data) InterruptCallback
bool(*)(Local< Context > context) SharedArrayBufferConstructorEnabledCallback
void(*)(const FunctionCallbackInfo< Value > &) WasmStreamingCallback
void(*)(const char *location, const char *message) FatalErrorCallback
void(*)(const char *location, const OOMDetails &details) OOMErrorCallback
void(*)(Isolate *isolate, Local< Context > context, Local< Promise::Resolver > resolver, Local< Value > result, WasmAsyncSuccess success) WasmAsyncResolvePromiseCallback
void(*)(Isolate *) BeforeCallEnteredCallback
void(*)(void *histogram, int sample) AddHistogramSampleCallback
int *(*)(const char *name) CounterLookupCallback
void(*)(Local< Context > context, Local< Module > module, Local< Object > meta) HostInitializeImportMetaObjectCallback
void *(*)(const char *name, int min, int max, size_t buckets) CreateHistogramCallback
void(*)(const JitCodeEvent *event) JitCodeEventHandler
#define V8_DEPRECATE_SOON(message)
#define ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS(ClassName)