Loading...
Searching...
No Matches
v8-isolate.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_V8_ISOLATE_H_
6#define INCLUDE_V8_ISOLATE_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include <memory>
12#include <string>
13#include <utility>
14
15#include "cppgc/common.h"
16#include "v8-array-buffer.h" // NOLINT(build/include_directory)
17#include "v8-callbacks.h" // NOLINT(build/include_directory)
18#include "v8-data.h" // NOLINT(build/include_directory)
19#include "v8-debug.h" // NOLINT(build/include_directory)
20#include "v8-embedder-heap.h" // NOLINT(build/include_directory)
21#include "v8-exception.h" // NOLINT(build/include_directory)
22#include "v8-function-callback.h" // NOLINT(build/include_directory)
23#include "v8-internal.h" // NOLINT(build/include_directory)
24#include "v8-local-handle.h" // NOLINT(build/include_directory)
25#include "v8-microtask.h" // NOLINT(build/include_directory)
26#include "v8-persistent-handle.h" // NOLINT(build/include_directory)
27#include "v8-primitive.h" // NOLINT(build/include_directory)
28#include "v8-statistics.h" // NOLINT(build/include_directory)
29#include "v8-unwinder.h" // NOLINT(build/include_directory)
30#include "v8config.h" // NOLINT(build/include_directory)
31
32namespace v8 {
33
34class CppHeap;
35class HeapProfiler;
36class MicrotaskQueue;
37class StartupData;
38class ScriptOrModule;
39class SharedArrayBuffer;
40
41namespace internal {
42class MicrotaskQueue;
43class ThreadLocalTop;
44} // namespace internal
45
46namespace metrics {
47class Recorder;
48} // namespace metrics
49
65 public:
84 void ConfigureDefaultsFromHeapSize(size_t initial_heap_size_in_bytes,
85 size_t maximum_heap_size_in_bytes);
86
96 void ConfigureDefaults(uint64_t physical_memory,
97 uint64_t virtual_memory_limit);
98
102 uint32_t* stack_limit() const { return stack_limit_; }
103 void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
104
114 size_t code_range_size_in_bytes() const { return code_range_size_; }
115 void set_code_range_size_in_bytes(size_t limit) { code_range_size_ = limit; }
116
125 return max_old_generation_size_;
126 }
128 max_old_generation_size_ = limit;
129 }
130
137 return max_young_generation_size_;
138 }
140 max_young_generation_size_ = limit;
141 }
142
144 return initial_old_generation_size_;
145 }
147 initial_old_generation_size_ = initial_size;
148 }
149
151 return initial_young_generation_size_;
152 }
154 initial_young_generation_size_ = initial_size;
155 }
156
158 return physical_memory_size_;
159 }
160
161 private:
162 static constexpr size_t kMB = 1048576u;
163 size_t code_range_size_ = 0;
164 size_t max_old_generation_size_ = 0;
165 size_t max_young_generation_size_ = 0;
166 size_t initial_old_generation_size_ = 0;
167 size_t initial_young_generation_size_ = 0;
168 uint64_t physical_memory_size_ = 0;
169 uint32_t* stack_limit_ = nullptr;
170};
171
181
192};
193
198
224 public:
232
237 static bool CanCreateNewGroups();
238
244
247
250
252
253 bool operator==(const IsolateGroup& other) const {
254 return isolate_group_ == other.isolate_group_;
255 }
256
257 bool operator!=(const IsolateGroup& other) const {
258 return !operator==(other);
259 }
260
261#ifdef V8_ENABLE_SANDBOX
266 bool SandboxContains(void* pointer) const;
267 VirtualAddressSpace* GetSandboxAddressSpace();
268#else
269 V8_INLINE bool SandboxContains(void* pointer) const { return true; }
270#endif
271
272 private:
273 friend class Isolate;
275
276 // The isolate_group pointer should be already acquired.
277 explicit IsolateGroup(internal::IsolateGroup*&& isolate_group);
278
279 internal::IsolateGroup* isolate_group_;
280};
281
291 public:
298
300
301
305 JitCodeEventHandler code_event_handler = nullptr;
306
311
316 const StartupData* snapshot_blob = nullptr;
317
322 CounterLookupCallback counter_lookup_callback = nullptr;
323
330 CreateHistogramCallback create_histogram_callback = nullptr;
331 AddHistogramSampleCallback add_histogram_sample_callback = nullptr;
332
342 ArrayBuffer::Allocator* array_buffer_allocator = nullptr;
343 std::shared_ptr<ArrayBuffer::Allocator> array_buffer_allocator_shared;
344
351 const intptr_t* external_references = nullptr;
352
357 bool allow_atomics_wait = true;
358
364 V8_DEPRECATE_SOON("This field is unused.")
365 int embedder_wrapper_type_index = -1;
366 V8_DEPRECATE_SOON("This field is unused.")
367 int embedder_wrapper_object_index = -1;
368
372 FatalErrorCallback fatal_error_callback = nullptr;
373 OOMErrorCallback oom_error_callback = nullptr;
374
379 CppHeap* cpp_heap = nullptr;
380 };
381
387 public:
388 explicit Scope(Isolate* isolate) : v8_isolate_(isolate) {
389 v8_isolate_->Enter();
390 }
391
392 ~Scope() { v8_isolate_->Exit(); }
393
394 // Prevent copying of Scope objects.
395 Scope(const Scope&) = delete;
396 Scope& operator=(const Scope&) = delete;
397
398 private:
399 Isolate* const v8_isolate_;
400 };
401
406 public:
407 enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE, DUMP_ON_FAILURE };
408
411
412 // Prevent copying of Scope objects.
414 delete;
416 const DisallowJavascriptExecutionScope&) = delete;
417
418 private:
419 v8::Isolate* const v8_isolate_;
420 const OnFailure on_failure_;
421 bool was_execution_allowed_;
422 };
423
428 public:
431
432 // Prevent copying of Scope objects.
434 delete;
436 const AllowJavascriptExecutionScope&) = delete;
437
438 private:
439 Isolate* const v8_isolate_;
440 bool was_execution_allowed_assert_;
441 bool was_execution_allowed_throws_;
442 bool was_execution_allowed_dump_;
443 };
444
450 public:
452 Isolate* isolate, MicrotaskQueue* microtask_queue = nullptr);
454
455 // Prevent copying of Scope objects.
457 delete;
459 const SuppressMicrotaskExecutionScope&) = delete;
460
461 private:
462 internal::Isolate* const i_isolate_;
463 internal::MicrotaskQueue* const microtask_queue_;
464 internal::Address previous_stack_height_;
465
466 friend class internal::ThreadLocalTop;
467 };
468
475 kMinorGarbageCollection
476 };
477
487 kUseAsm = 0,
488 kBreakIterator = 1,
489 kOBSOLETE_LegacyConst = 2,
490 kOBSOLETE_MarkDequeOverflow = 3,
491 kOBSOLETE_StoreBufferOverflow = 4,
492 kOBSOLETE_SlotsBufferOverflow = 5,
493 kOBSOLETE_ObjectObserve = 6,
494 kForcedGC = 7,
495 kSloppyMode = 8,
496 kStrictMode = 9,
497 kOBSOLETE_StrongMode = 10,
498 kRegExpPrototypeStickyGetter = 11,
499 kRegExpPrototypeToString = 12,
500 kRegExpPrototypeUnicodeGetter = 13,
501 kOBSOLETE_IntlV8Parse = 14,
502 kOBSOLETE_IntlPattern = 15,
503 kOBSOLETE_IntlResolved = 16,
504 kOBSOLETE_PromiseChain = 17,
505 kOBSOLETE_PromiseAccept = 18,
506 kOBSOLETE_PromiseDefer = 19,
507 kHtmlCommentInExternalScript = 20,
508 kHtmlComment = 21,
509 kSloppyModeBlockScopedFunctionRedefinition = 22,
510 kForInInitializer = 23,
511 kOBSOLETE_ArrayProtectorDirtied = 24,
512 kArraySpeciesModified = 25,
513 kArrayPrototypeConstructorModified = 26,
514 kOBSOLETE_ArrayInstanceProtoModified = 27,
515 kArrayInstanceConstructorModified = 28,
516 kOBSOLETE_LegacyFunctionDeclaration = 29,
517 kOBSOLETE_RegExpPrototypeSourceGetter = 30,
518 kOBSOLETE_RegExpPrototypeOldFlagGetter = 31,
519 kDecimalWithLeadingZeroInStrictMode = 32,
520 kLegacyDateParser = 33,
521 kDefineGetterOrSetterWouldThrow = 34,
522 kFunctionConstructorReturnedUndefined = 35,
523 kAssigmentExpressionLHSIsCallInSloppy = 36,
524 kAssigmentExpressionLHSIsCallInStrict = 37,
525 kPromiseConstructorReturnedUndefined = 38,
526 kOBSOLETE_ConstructorNonUndefinedPrimitiveReturn = 39,
527 kOBSOLETE_LabeledExpressionStatement = 40,
528 kOBSOLETE_LineOrParagraphSeparatorAsLineTerminator = 41,
529 kIndexAccessor = 42,
530 kErrorCaptureStackTrace = 43,
531 kErrorPrepareStackTrace = 44,
532 kErrorStackTraceLimit = 45,
533 kWebAssemblyInstantiation = 46,
534 kDeoptimizerDisableSpeculation = 47,
535 kOBSOLETE_ArrayPrototypeSortJSArrayModifiedPrototype = 48,
536 kFunctionTokenOffsetTooLongForToString = 49,
537 kWasmSharedMemory = 50,
538 kWasmThreadOpcodes = 51,
539 kOBSOLETE_AtomicsNotify = 52,
540 kOBSOLETE_AtomicsWake = 53,
541 kCollator = 54,
542 kNumberFormat = 55,
543 kDateTimeFormat = 56,
544 kPluralRules = 57,
545 kRelativeTimeFormat = 58,
546 kLocale = 59,
547 kListFormat = 60,
548 kSegmenter = 61,
549 kStringLocaleCompare = 62,
550 kOBSOLETE_StringToLocaleUpperCase = 63,
551 kStringToLocaleLowerCase = 64,
552 kNumberToLocaleString = 65,
553 kDateToLocaleString = 66,
554 kDateToLocaleDateString = 67,
555 kDateToLocaleTimeString = 68,
556 kAttemptOverrideReadOnlyOnPrototypeSloppy = 69,
557 kAttemptOverrideReadOnlyOnPrototypeStrict = 70,
558 kOBSOLETE_OptimizedFunctionWithOneShotBytecode = 71,
559 kRegExpMatchIsTrueishOnNonJSRegExp = 72,
560 kRegExpMatchIsFalseishOnJSRegExp = 73,
561 kOBSOLETE_DateGetTimezoneOffset = 74,
562 kStringNormalize = 75,
563 kCallSiteAPIGetFunctionSloppyCall = 76,
564 kCallSiteAPIGetThisSloppyCall = 77,
565 kOBSOLETE_RegExpMatchAllWithNonGlobalRegExp = 78,
566 kRegExpExecCalledOnSlowRegExp = 79,
567 kRegExpReplaceCalledOnSlowRegExp = 80,
568 kDisplayNames = 81,
569 kSharedArrayBufferConstructed = 82,
570 kArrayPrototypeHasElements = 83,
571 kObjectPrototypeHasElements = 84,
572 kNumberFormatStyleUnit = 85,
573 kDateTimeFormatRange = 86,
574 kDateTimeFormatDateTimeStyle = 87,
575 kBreakIteratorTypeWord = 88,
576 kBreakIteratorTypeLine = 89,
577 kInvalidatedArrayBufferDetachingProtector = 90,
578 kInvalidatedArrayConstructorProtector V8_DEPRECATE_SOON(
579 "The ArrayConstructorProtector has been removed") = 91,
580 kInvalidatedArrayIteratorLookupChainProtector = 92,
581 kInvalidatedArraySpeciesLookupChainProtector = 93,
582 kInvalidatedIsConcatSpreadableLookupChainProtector = 94,
583 kInvalidatedMapIteratorLookupChainProtector = 95,
584 kInvalidatedNoElementsProtector = 96,
585 kInvalidatedPromiseHookProtector = 97,
586 kInvalidatedPromiseResolveLookupChainProtector = 98,
587 kInvalidatedPromiseSpeciesLookupChainProtector = 99,
588 kInvalidatedPromiseThenLookupChainProtector = 100,
589 kInvalidatedRegExpSpeciesLookupChainProtector = 101,
590 kInvalidatedSetIteratorLookupChainProtector = 102,
591 kInvalidatedStringIteratorLookupChainProtector = 103,
592 kInvalidatedStringLengthOverflowLookupChainProtector = 104,
593 kInvalidatedTypedArraySpeciesLookupChainProtector = 105,
594 kWasmSimdOpcodes = 106,
595 kVarRedeclaredCatchBinding = 107,
596 kWasmRefTypes = 108,
597 kWasmBulkMemory = 109,
598 kWasmMultiValue = 110,
599 kWasmExceptionHandling = 111,
600 kInvalidatedMegaDOMProtector = 112,
601 kFunctionPrototypeArguments = 113,
602 kFunctionPrototypeCaller = 114,
603 kTurboFanOsrCompileStarted = 115,
604 kAsyncStackTaggingCreateTaskCall = 116,
605 kDurationFormat = 117,
606 kInvalidatedNumberStringNotRegexpLikeProtector = 118,
607 kOBSOLETE_RegExpUnicodeSetIncompatibilitiesWithUnicodeMode = 119,
608 kOBSOLETE_ImportAssertionDeprecatedSyntax = 120,
609 kLocaleInfoObsoletedGetters = 121,
610 kLocaleInfoFunctions = 122,
611 kCompileHintsMagicAll = 123,
612 kInvalidatedNoProfilingProtector = 124,
613 kWasmMemory64 = 125,
614 kWasmMultiMemory = 126,
615 kWasmGC = 127,
616 kWasmImportedStrings = 128,
617 kSourceMappingUrlMagicCommentAtSign = 129,
618 kTemporalObject = 130,
619 kWasmModuleCompilation = 131,
620 kInvalidatedNoUndetectableObjectsProtector = 132,
621 kWasmJavaScriptPromiseIntegration = 133,
622 kWasmReturnCall = 134,
623 kWasmExtendedConst = 135,
624 kWasmRelaxedSimd = 136,
625 kWasmTypeReflection = 137,
626 kWasmExnRef = 138,
627 kWasmTypedFuncRef = 139,
628 kInvalidatedStringWrapperToPrimitiveProtector = 140,
629 kDocumentAllLegacyCall = 141,
630 kDocumentAllLegacyConstruct = 142,
631 kConsoleContext = 143,
632 kWasmImportedStringsUtf8 = 144,
633 kResizableArrayBuffer = 145,
634 kGrowableSharedArrayBuffer = 146,
635 kArrayByCopy = 147,
636 kArrayFromAsync = 148,
637 kIteratorMethods = 149,
638 kPromiseAny = 150,
639 kSetMethods = 151,
640 kArrayFindLast = 152,
641 kArrayGroup = 153,
642 kArrayBufferTransfer = 154,
643 kPromiseWithResolvers = 155,
644 kAtomicsWaitAsync = 156,
645 kExtendingNonExtensibleWithPrivate = 157,
646 kPromiseTry = 158,
647 kStringReplaceAll = 159,
648 kStringWellFormed = 160,
649 kWeakReferences = 161,
650 kErrorIsError = 162,
651 kInvalidatedTypedArrayLengthLookupChainProtector = 163,
652 kRegExpEscape = 164,
653 kFloat16Array = 165,
654 kExplicitResourceManagement = 166,
655 kWasmBranchHinting = 167,
656 kWasmMutableGlobals = 168,
657 kUint8ArrayToFromBase64AndHex = 169,
658 kAtomicsPause = 170,
659 kTopLevelAwait = 171,
660 kLogicalAssignment = 172,
661 kNullishCoalescing = 173,
662 kInvalidatedNoDateTimeConfigurationChangeProtector = 174,
663 kWasmNonTrappingFloatToInt = 175,
664 kWasmSignExtensionOps = 176,
665 kRegExpCompile = 177,
666 kRegExpStaticProperties = 178,
667 kRegExpStaticPropertiesWithLastMatch = 179,
668 kWithStatement = 180,
669 kHtmlWrapperMethods = 181,
670 kWasmCustomDescriptors = 182,
671
672 // If you add new values here, you'll also need to update Chromium's:
673 // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
674 // this list need to be landed first, then changes on the Chromium side.
675 kUseCounterFeatureCount // This enum value must be last.
676 };
677
679 kMessageLog = (1 << 0),
680 kMessageDebug = (1 << 1),
681 kMessageInfo = (1 << 2),
682 kMessageError = (1 << 3),
683 kMessageWarning = (1 << 4),
684 kMessageAll = kMessageLog | kMessageDebug | kMessageInfo | kMessageError |
685 kMessageWarning,
686 };
687
688 // The different priorities that an isolate can have.
689 enum class Priority {
690 // The isolate does not relate to content that is currently important
691 // to the user. Lowest priority.
693
694 // The isolate contributes to content that is visible to the user, like a
695 // visible iframe that's not interacted directly with. High priority.
697
698 // The isolate contributes to content that is of the utmost importance to
699 // the user, like visible content in the focused window. Highest priority.
701 };
702
703 using UseCounterCallback = void (*)(Isolate* isolate,
704 UseCounterFeature feature);
705
720 static Isolate* Allocate();
721 static Isolate* Allocate(const IsolateGroup& group);
722
727
731 static void Initialize(Isolate* isolate, const CreateParams& params);
732
742 static Isolate* New(const CreateParams& params);
743 static Isolate* New(const IsolateGroup& group, const CreateParams& params);
744
752
760
764 bool IsCurrent() const;
765
780
793
800
812
819
826
834
840
845
846#if defined(V8_OS_WIN)
850 V8_DEPRECATE_SOON("Use SetFilterETWSessionByURL2Callback instead")
851 void SetFilterETWSessionByURLCallback(FilterETWSessionByURLCallback callback);
852 void SetFilterETWSessionByURL2Callback(
853 FilterETWSessionByURL2Callback callback);
854#endif // V8_OS_WIN
855
863
870 void SetBatterySaverMode(bool battery_saver_mode_enabled);
871
878 void SetMemorySaverMode(bool memory_saver_mode_enabled);
879
886
897 void Enter();
898
906 void Exit();
907
912 void Dispose();
913
920
927 static void Free(Isolate* isolate);
928
934
943
948 V8_INLINE void SetData(uint32_t slot, void* data);
949
954 V8_INLINE void* GetData(uint32_t slot);
955
960 V8_INLINE static uint32_t GetNumberOfDataSlots();
961
967 template <class T>
968 V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
969
974 V8_DEPRECATED("Use GetContinuationPreservedEmbedderDataV2 instead")
975 Local<Value> GetContinuationPreservedEmbedderData();
976
981 V8_DEPRECATED("Use SetContinuationPreservedEmbedderDataV2 instead")
982 void SetContinuationPreservedEmbedderData(Local<Value> data);
983
990 Local<Data> GetContinuationPreservedEmbedderDataV2();
991
997 void SetContinuationPreservedEmbedderDataV2(Local<Data> data);
998
1002 void GetHeapStatistics(HeapStatistics* heap_statistics);
1003
1007 size_t NumberOfHeapSpaces();
1008
1018 bool GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
1019 size_t index);
1020
1024 size_t NumberOfTrackedHeapObjectTypes();
1025
1035 bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics* object_statistics,
1036 size_t type_index);
1037
1045 bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics* object_statistics);
1046
1059 bool MeasureMemory(
1060 std::unique_ptr<MeasureMemoryDelegate> delegate,
1061 MeasureMemoryExecution execution = MeasureMemoryExecution::kDefault);
1062
1075 void GetStackSample(const RegisterState& state, void** frames,
1076 size_t frames_limit, SampleInfo* sample_info);
1077
1086 int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
1087
1092 HeapProfiler* GetHeapProfiler();
1093
1097 void SetIdle(bool is_idle);
1098
1100 ArrayBuffer::Allocator* GetArrayBufferAllocator();
1101
1103 bool InContext();
1104
1109 Local<Context> GetCurrentContext();
1110
1117 Local<Context> GetEnteredOrMicrotaskContext();
1118
1123 Local<Context> GetIncumbentContext();
1124
1129 MaybeLocal<Data> GetCurrentHostDefinedOptions();
1130
1136 template <int N>
1137 Local<Value> ThrowError(const char (&message)[N]) {
1138 return ThrowError(String::NewFromUtf8Literal(this, message));
1139 }
1141
1149
1157
1158 using GCCallback = void (*)(Isolate* isolate, GCType type,
1159 GCCallbackFlags flags);
1160 using GCCallbackWithData = void (*)(Isolate* isolate, GCType type,
1161 GCCallbackFlags flags, void* data);
1162
1174 GCType gc_type_filter = kGCTypeAll);
1175
1181 void AddGCPrologueCallback(GCCallbackWithData callback, void* data = nullptr,
1182 GCType gc_type_filter = kGCTypeAll);
1183
1191
1198
1206 GCType gc_type_filter = kGCTypeAll);
1207
1213 void AddGCEpilogueCallback(GCCallbackWithData callback, void* data = nullptr,
1214 GCType gc_type_filter = kGCTypeAll);
1215
1223
1230 void* data = nullptr);
1231
1240
1241 using ReleaseCppHeapCallback = void (*)(std::unique_ptr<CppHeap>);
1242
1249
1255
1257
1266
1275
1285
1301
1310 void RequestInterrupt(InterruptCallback callback, void* data);
1311
1318
1329
1341 StackState stack_state);
1342
1347
1355
1360
1369
1374
1380
1386
1395
1403
1408
1412 void EnqueueMicrotask(MicrotaskCallback callback, void* data = nullptr);
1413
1418
1423
1438 MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
1439
1444 MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
1445
1450
1456
1465
1476 const std::shared_ptr<metrics::Recorder>& metrics_recorder);
1477
1484
1490
1500 V8_DEPRECATE_SOON("Use version that passes ContextDependants.")
1501 int ContextDisposedNotification(bool dependant_context = true);
1502
1510 void ContextDisposedNotification(ContextDependants dependants);
1511
1516 V8_DEPRECATE_SOON("Use SetPriority(Priority::kUserBlocking) instead")
1517 void IsolateInForegroundNotification();
1518
1523 V8_DEPRECATE_SOON("Use SetPriority(Priority::kBestEffort) instead")
1524 void IsolateInBackgroundNotification();
1525
1530 void SetPriority(Priority priority);
1531
1544 void SetIsLoading(bool is_loading);
1545
1552 void Freeze(bool is_frozen);
1553
1558 void IncreaseHeapLimitForDebugging();
1559
1563 void RestoreOriginalHeapLimit();
1564
1569 bool IsHeapLimitIncreasedForDebugging();
1570
1593 void SetJitCodeEventHandler(JitCodeEventOptions options,
1594 JitCodeEventHandler event_handler);
1595
1605 void SetStackLimit(uintptr_t stack_limit);
1606
1622 void GetCodeRange(void** start, size_t* length_in_bytes);
1623
1628 void GetEmbeddedCodeRange(const void** start, size_t* length_in_bytes);
1629
1633 JSEntryStubs GetJSEntryStubs();
1634
1635 static constexpr size_t kMinCodePagesBufferSize = 32;
1636
1650 size_t CopyCodePages(size_t capacity, MemoryRange* code_pages_out);
1651
1653 void SetFatalErrorHandler(FatalErrorCallback that);
1654
1656 void SetOOMErrorHandler(OOMErrorCallback that);
1657
1663 void AddNearHeapLimitCallback(NearHeapLimitCallback callback, void* data);
1664
1672 void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback,
1673 size_t heap_limit);
1674
1681 void AutomaticallyRestoreInitialHeapLimit(double threshold_percent = 0.5);
1682
1687 void SetModifyCodeGenerationFromStringsCallback(
1689
1694 void SetAllowWasmCodeGenerationCallback(
1696
1701 void SetWasmModuleCallback(ExtensionCallback callback);
1702 void SetWasmInstanceCallback(ExtensionCallback callback);
1703
1704 void SetWasmStreamingCallback(WasmStreamingCallback callback);
1705
1706 void SetWasmAsyncResolvePromiseCallback(
1708
1709 void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
1710
1711 void SetWasmImportedStringsEnabledCallback(
1713
1714 void SetWasmCustomDescriptorsEnabledCallback(
1716
1717 void SetSharedArrayBufferConstructorEnabledCallback(
1719
1720 void SetWasmJSPIEnabledCallback(WasmJSPIEnabledCallback callback);
1721
1727 void InstallConditionalFeatures(Local<Context> context);
1728
1733 bool IsDead();
1734
1744 bool AddMessageListener(MessageCallback callback,
1745 Local<Value> data = Local<Value>());
1746
1758 bool AddMessageListenerWithErrorLevel(MessageCallback callback,
1759 int message_levels,
1760 Local<Value> data = Local<Value>());
1761
1765 void RemoveMessageListeners(MessageCallback callback);
1766
1768 void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
1769
1774 void SetCaptureStackTraceForUncaughtExceptions(
1775 bool capture, int frame_limit = 10,
1776 StackTrace::StackTraceOptions options = StackTrace::kOverview);
1777
1782 bool IsInUse();
1783
1789 void SetAllowAtomicsWait(bool allow);
1790
1804 enum class TimeZoneDetection { kSkip, kRedetect };
1805
1817 TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip);
1818
1829
1834 std::string GetDefaultLocale();
1835
1850
1854 uint64_t GetHashSeed();
1855
1856 Isolate() = delete;
1857 ~Isolate() = delete;
1858 Isolate(const Isolate&) = delete;
1859 Isolate& operator=(const Isolate&) = delete;
1860 // Deleting operator new and delete here is allowed as ctor and dtor is also
1861 // deleted.
1862 void* operator new(size_t size) = delete;
1863 void* operator new[](size_t size) = delete;
1864 void operator delete(void*, size_t) = delete;
1865 void operator delete[](void*, size_t) = delete;
1866
1867 private:
1868 template <class K, class V, class Traits>
1871
1873 size_t index);
1874 int64_t AdjustAmountOfExternalAllocatedMemoryImpl(int64_t change_in_bytes);
1875 void HandleExternalMemoryInterrupt();
1876};
1877
1878void Isolate::SetData(uint32_t slot, void* data) {
1879 using I = internal::Internals;
1880 I::SetEmbedderData(this, slot, data);
1881}
1882
1883void* Isolate::GetData(uint32_t slot) {
1884 using I = internal::Internals;
1885 return I::GetEmbedderData(this, slot);
1886}
1887
1888uint32_t Isolate::GetNumberOfDataSlots() {
1889 using I = internal::Internals;
1890 return I::kNumIsolateDataSlots;
1891}
1892
1893template <class T>
1894MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
1895 if (auto repr = GetDataFromSnapshotOnce(index);
1896 repr != internal::ValueHelper::kEmpty) {
1897 internal::PerformCastCheck(internal::ValueHelper::ReprAsValue<T>(repr));
1898 return Local<T>::FromRepr(repr);
1899 }
1900 return {};
1901}
1902
1903} // namespace v8
1904
1905#endif // INCLUDE_V8_ISOLATE_H_
Definition: v8-array-buffer.h:148
Definition: v8-array-buffer.h:131
Definition: v8-context.h:48
Definition: v8-cppgc.h:65
Definition: v8-data.h:18
Definition: v8-embedder-heap.h:22
Definition: v8-external-memory-accounter.h:23
Definition: v8-statistics.h:219
Definition: v8-statistics.h:202
Definition: v8-profiler.h:969
Definition: v8-statistics.h:183
Definition: v8-statistics.h:140
Definition: v8-isolate.h:223
static IsolateGroup Create()
static IsolateGroup GetDefault()
bool operator!=(const IsolateGroup &other) const
Definition: v8-isolate.h:257
bool SandboxContains(void *pointer) const
Definition: v8-isolate.h:269
IsolateGroup & operator=(const IsolateGroup &)
IsolateGroup(IsolateGroup &&other)
IsolateGroup(const IsolateGroup &)
bool operator==(const IsolateGroup &other) const
Definition: v8-isolate.h:253
static bool CanCreateNewGroups()
IsolateGroup & operator=(IsolateGroup &&other)
Definition: v8-isolate.h:427
AllowJavascriptExecutionScope(const AllowJavascriptExecutionScope &)=delete
AllowJavascriptExecutionScope & operator=(const AllowJavascriptExecutionScope &)=delete
DisallowJavascriptExecutionScope(Isolate *isolate, OnFailure on_failure)
DisallowJavascriptExecutionScope(const DisallowJavascriptExecutionScope &)=delete
DisallowJavascriptExecutionScope & operator=(const DisallowJavascriptExecutionScope &)=delete
@ CRASH_ON_FAILURE
Definition: v8-isolate.h:407
Definition: v8-isolate.h:386
Scope(Isolate *isolate)
Definition: v8-isolate.h:388
Scope(const Scope &)=delete
~Scope()
Definition: v8-isolate.h:392
Scope & operator=(const Scope &)=delete
SuppressMicrotaskExecutionScope(Isolate *isolate, MicrotaskQueue *microtask_queue=nullptr)
SuppressMicrotaskExecutionScope & operator=(const SuppressMicrotaskExecutionScope &)=delete
SuppressMicrotaskExecutionScope(const SuppressMicrotaskExecutionScope &)=delete
Definition: v8-isolate.h:290
int GetStackTraceLimit()
void RemoveGCEpilogueCallback(GCCallback callback)
void AddGCPrologueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
void RemoveGCEpilogueCallback(GCCallbackWithData callback, void *data=nullptr)
void Dispose()
void LocaleConfigurationChangeNotification()
void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)
void(*)(std::unique_ptr< CppHeap >) ReleaseCppHeapCallback
Definition: v8-isolate.h:1241
void SetEventLogger(LogEventCallback that)
Maybe< std::string > ValidateAndCanonicalizeUnicodeLocaleId(std::string_view locale)
void SetExceptionPropagationCallback(ExceptionPropagationCallback callback)
void RequestGarbageCollectionForTesting(GarbageCollectionType type, StackState stack_state)
void ClearKeptObjects()
void Deinitialize()
Local< Value > ThrowError(Local< String > message)
CppHeap * GetCppHeap() const
size_t(*)() GetExternallyAllocatedMemoryInBytesCallback
Definition: v8-isolate.h:1256
static Isolate * New(const CreateParams &params)
Isolate()=delete
void SetAddCrashKeyCallback(AddCrashKeyCallback)
static Isolate * GetCurrent()
void RemoveCallCompletedCallback(CallCompletedCallback callback)
static void Free(Isolate *isolate)
static void Initialize(Isolate *isolate, const CreateParams &params)
bool HasPendingException()
static Isolate * New(const IsolateGroup &group, const CreateParams &params)
TimeZoneDetection
Definition: v8-isolate.h:1804
void RequestGarbageCollectionForTesting(GarbageCollectionType type)
void SetMemorySaverMode(bool memory_saver_mode_enabled)
GarbageCollectionType
Definition: v8-isolate.h:473
@ kFullGarbageCollection
Definition: v8-isolate.h:474
void DumpAndResetStats()
void SetHostImportModuleDynamicallyCallback(HostImportModuleDynamicallyCallback callback)
void(*)(Isolate *isolate, GCType type, GCCallbackFlags flags) GCCallback
Definition: v8-isolate.h:1159
static Isolate * Allocate(const IsolateGroup &group)
void SetMicrotasksPolicy(MicrotasksPolicy policy)
void SetIsJSApiWrapperNativeErrorCallback(IsJSApiWrapperNativeErrorCallback callback)
void SetPromiseRejectCallback(PromiseRejectCallback callback)
void SetPromiseHook(PromiseHook hook)
void(*)(Isolate *isolate, UseCounterFeature feature) UseCounterCallback
Definition: v8-isolate.h:704
void CancelTerminateExecution()
void(*)(Isolate *isolate, GCType type, GCCallbackFlags flags, void *data) GCCallbackWithData
Definition: v8-isolate.h:1161
void SetHostCreateShadowRealmContextCallback(HostCreateShadowRealmContextCallback callback)
bool IsCurrent() const
void EnqueueMicrotask(Local< Function > microtask)
void AddGCPrologueCallback(GCCallback callback, GCType gc_type_filter=kGCTypeAll)
void RemoveGCPrologueCallback(GCCallback callback)
void SetBatterySaverMode(bool battery_saver_mode_enabled)
void DateTimeConfigurationChangeNotification(TimeZoneDetection time_zone_detection=TimeZoneDetection::kSkip)
void AddCallCompletedCallback(CallCompletedCallback callback)
void SetEmbedderRootsHandler(EmbedderRootsHandler *handler)
void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
void RequestInterrupt(InterruptCallback callback, void *data)
uint64_t GetHashSeed()
void AddGCEpilogueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
Isolate & operator=(const Isolate &)=delete
std::string GetDefaultLocale()
void PerformMicrotaskCheckpoint()
void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback)
void LowMemoryNotification()
Priority
Definition: v8-isolate.h:689
Isolate(const Isolate &)=delete
void SetCounterFunction(CounterLookupCallback)
MicrotasksPolicy GetMicrotasksPolicy() const
void AddGCEpilogueCallback(GCCallback callback, GCType gc_type_filter=kGCTypeAll)
bool HasPendingBackgroundTasks()
void DiscardThreadSpecificMetadata()
static Isolate * TryGetCurrent()
Local< Value > ThrowException(Local< Value > exception)
static Isolate * Allocate()
MessageErrorLevel
Definition: v8-isolate.h:678
bool(*)(Isolate *) AbortOnUncaughtExceptionCallback
Definition: v8-isolate.h:790
void AddMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)
void TerminateExecution()
void SetHostInitializeImportMetaObjectCallback(HostInitializeImportMetaObjectCallback callback)
void SetUseCounterCallback(UseCounterCallback callback)
void SetMetricsRecorder(const std::shared_ptr< metrics::Recorder > &metrics_recorder)
void MemoryPressureNotification(MemoryPressureLevel level)
void EnqueueMicrotask(MicrotaskCallback callback, void *data=nullptr)
void SetAddHistogramSampleFunction(AddHistogramSampleCallback)
IsolateGroup GetGroup() const
void SetGetExternallyAllocatedMemoryInBytesCallback(GetExternallyAllocatedMemoryInBytesCallback callback)
void Enter()
UseCounterFeature
Definition: v8-isolate.h:486
bool IsExecutionTerminating()
void SetReleaseCppHeapCallbackForTesting(ReleaseCppHeapCallback callback)
~Isolate()=delete
void RemoveGCPrologueCallback(GCCallbackWithData, void *data=nullptr)
void SetAbortOnUncaughtExceptionCallback(AbortOnUncaughtExceptionCallback callback)
void ClearCachesForTesting()
void SetHostImportModuleWithPhaseDynamicallyCallback(HostImportModuleWithPhaseDynamicallyCallback callback)
void SetCreateHistogramFunction(CreateHistogramCallback)
Definition: v8-local-handle.h:366
Definition: v8-local-handle.h:734
Definition: v8-maybe.h:39
Definition: v8-statistics.h:55
Definition: v8-microtask-queue.h:40
Definition: v8-util.h:166
Definition: v8-isolate.h:64
void set_code_range_size_in_bytes(size_t limit)
Definition: v8-isolate.h:115
size_t max_old_generation_size_in_bytes() const
Definition: v8-isolate.h:124
void set_stack_limit(uint32_t *value)
Definition: v8-isolate.h:103
void set_initial_old_generation_size_in_bytes(size_t initial_size)
Definition: v8-isolate.h:146
void ConfigureDefaultsFromHeapSize(size_t initial_heap_size_in_bytes, size_t maximum_heap_size_in_bytes)
uint32_t * stack_limit() const
Definition: v8-isolate.h:102
size_t code_range_size_in_bytes() const
Definition: v8-isolate.h:114
void set_initial_young_generation_size_in_bytes(size_t initial_size)
Definition: v8-isolate.h:153
size_t initial_young_generation_size_in_bytes() const
Definition: v8-isolate.h:150
size_t max_young_generation_size_in_bytes() const
Definition: v8-isolate.h:136
void set_max_young_generation_size_in_bytes(size_t limit)
Definition: v8-isolate.h:139
size_t initial_old_generation_size_in_bytes() const
Definition: v8-isolate.h:143
uint64_t physical_memory_size_in_bytes() const
Definition: v8-isolate.h:157
void ConfigureDefaults(uint64_t physical_memory, uint64_t virtual_memory_limit)
void set_max_old_generation_size_in_bytes(size_t limit)
Definition: v8-isolate.h:127
Definition: v8-debug.h:117
Definition: v8-snapshot.h:21
Definition: v8-value.h:32
Definition: v8-platform.h:778
Definition: v8-internal.h:883
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1729
Definition: v8-metrics.h:200
EmbedderStackState
Definition: common.h:15
uintptr_t Address
Definition: v8-internal.h:52
Definition: libplatform.h:15
void(*)(const JitCodeEvent *event) JitCodeEventHandler
Definition: v8-callbacks.h:142
JitCodeEventOptions
Definition: v8-callbacks.h:129
void(*)(const char *location, const OOMDetails &details) OOMErrorCallback
Definition: v8-callbacks.h:233
bool(*)(Local< Context > context) SharedArrayBufferConstructorEnabledCallback
Definition: v8-callbacks.h:332
void(*)(void *data) MicrotaskCallback
Definition: v8-microtask.h:14
GCCallbackFlags
Definition: v8-callbacks.h:179
bool(*)(Local< Context > context) WasmJSPIEnabledCallback
Definition: v8-callbacks.h:335
bool(*)(Local< Context > context) WasmCustomDescriptorsEnabledCallback
Definition: v8-callbacks.h:328
MicrotasksPolicy
Definition: v8-microtask.h:24
void(*)(Isolate *isolate, Local< Context > context, Local< Promise::Resolver > resolver, Local< Value > result, WasmAsyncSuccess success) WasmAsyncResolvePromiseCallback
Definition: v8-callbacks.h:318
bool(*)(const FunctionCallbackInfo< Value > &) ExtensionCallback
Definition: v8-callbacks.h:301
void(*)(PromiseHookType type, Local< Promise > promise, Local< Value > parent) PromiseHook
Definition: v8-promise.h:144
void(*)(Isolate *, void *) MicrotasksCompletedCallbackWithData
Definition: v8-microtask.h:13
ContextDependants
Definition: v8-isolate.h:186
void(*)(ExceptionPropagationMessage message) ExceptionPropagationCallback
Definition: v8-exception.h:133
void(*)(const FunctionCallbackInfo< Value > &) WasmStreamingCallback
Definition: v8-callbacks.h:311
void *(*)(const char *name, int min, int max, size_t buckets) CreateHistogramCallback
Definition: v8-callbacks.h:219
void(*)(Local< Context > context, Local< Module > module, Local< Object > meta) HostInitializeImportMetaObjectCallback
Definition: v8-callbacks.h:436
void(*)(Local< Message > message, Local< Value > data) MessageCallback
Definition: v8-callbacks.h:235
void(*)(CrashKeyId id, const std::string &value) AddCrashKeyCallback
Definition: v8-callbacks.h:256
void(*)(Isolate *isolate, void *data) InterruptCallback
Definition: v8-callbacks.h:191
void(*)(Isolate *) CallCompletedCallback
Definition: v8-callbacks.h:260
void(*)(void *histogram, int sample) AddHistogramSampleCallback
Definition: v8-callbacks.h:221
size_t(*)(void *data, size_t current_heap_limit, size_t initial_heap_limit) NearHeapLimitCallback
Definition: v8-callbacks.h:204
void(*)(Isolate *) BeforeCallEnteredCallback
Definition: v8-callbacks.h:259
bool(*)(Local< Context > context, Local< String > source) AllowWasmCodeGenerationCallback
Definition: v8-callbacks.h:304
void(*)(const char *location, const char *message) FatalErrorCallback
Definition: v8-callbacks.h:225
void(*)(PromiseRejectMessage message) PromiseRejectCallback
Definition: v8-promise.h:170
GCType
Definition: v8-callbacks.h:154
ModifyCodeGenerationFromStringsResult(*)(Local< Context > context, Local< Value > source, bool is_code_like) ModifyCodeGenerationFromStringsCallback2
Definition: v8-callbacks.h:282
void(*)(Local< Object > target, AccessType type, Local< Value > data) FailedAccessCheckCallback
Definition: v8-callbacks.h:298
bool(*)(Local< Context > context) WasmImportedStringsEnabledCallback
Definition: v8-callbacks.h:325
void(*)(const char *name, int status) LogEventCallback
Definition: v8-callbacks.h:241
MemoryPressureLevel
Definition: v8-isolate.h:180
MeasureMemoryExecution
Definition: v8-statistics.h:43
int *(*)(const char *name) CounterLookupCallback
Definition: v8-callbacks.h:216
bool(*)(Isolate *isolate, Local< Object > obj) IsJSApiWrapperNativeErrorCallback
Definition: v8-callbacks.h:458
Definition: v8-isolate.h:295
Definition: v8-unwinder.h:82
Definition: v8-unwinder.h:73
Definition: v8-unwinder.h:21
Definition: v8-unwinder.h:63
#define V8_EXPORT
Definition: v8config.h:860
#define V8_INLINE
Definition: v8config.h:513
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:627
#define V8_DEPRECATED(message)
Definition: v8config.h:619
#define ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS(ClassName)
Definition: v8config.h:650
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:684
#define V8_NODISCARD
Definition: v8config.h:706