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
157 private:
158 static constexpr size_t kMB = 1048576u;
159 size_t code_range_size_ = 0;
160 size_t max_old_generation_size_ = 0;
161 size_t max_young_generation_size_ = 0;
162 size_t initial_old_generation_size_ = 0;
163 size_t initial_young_generation_size_ = 0;
164 uint32_t* stack_limit_ = nullptr;
165};
166
172enum RAILMode : unsigned {
173 // Response performance mode: In this mode very low virtual machine latency
174 // is provided. V8 will try to avoid JavaScript execution interruptions.
175 // Throughput may be throttled.
177 // Animation performance mode: In this mode low virtual machine latency is
178 // provided. V8 will try to avoid as many JavaScript execution interruptions
179 // as possible. Throughput may be throttled. This is the default mode.
181 // Idle performance mode: The embedder is idle. V8 can complete deferred work
182 // in this mode.
184 // Load performance mode: In this mode high throughput is provided. V8 may
185 // turn off latency optimizations.
188
198
203
213 public:
220
222
223
227 JitCodeEventHandler code_event_handler = nullptr;
228
233
238 const StartupData* snapshot_blob = nullptr;
239
244 CounterLookupCallback counter_lookup_callback = nullptr;
245
252 CreateHistogramCallback create_histogram_callback = nullptr;
253 AddHistogramSampleCallback add_histogram_sample_callback = nullptr;
254
264 ArrayBuffer::Allocator* array_buffer_allocator = nullptr;
265 std::shared_ptr<ArrayBuffer::Allocator> array_buffer_allocator_shared;
266
273 const intptr_t* external_references = nullptr;
274
279 bool allow_atomics_wait = true;
280
286 int embedder_wrapper_type_index = -1;
287 int embedder_wrapper_object_index = -1;
288
292 FatalErrorCallback fatal_error_callback = nullptr;
293 OOMErrorCallback oom_error_callback = nullptr;
294
299 CppHeap* cpp_heap = nullptr;
300 };
301
307 public:
308 explicit Scope(Isolate* isolate) : v8_isolate_(isolate) {
309 v8_isolate_->Enter();
310 }
311
312 ~Scope() { v8_isolate_->Exit(); }
313
314 // Prevent copying of Scope objects.
315 Scope(const Scope&) = delete;
316 Scope& operator=(const Scope&) = delete;
317
318 private:
319 Isolate* const v8_isolate_;
320 };
321
326 public:
327 enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE, DUMP_ON_FAILURE };
328
331
332 // Prevent copying of Scope objects.
334 delete;
336 const DisallowJavascriptExecutionScope&) = delete;
337
338 private:
339 v8::Isolate* const v8_isolate_;
340 const OnFailure on_failure_;
341 bool was_execution_allowed_;
342 };
343
348 public:
351
352 // Prevent copying of Scope objects.
354 delete;
356 const AllowJavascriptExecutionScope&) = delete;
357
358 private:
359 Isolate* const v8_isolate_;
360 bool was_execution_allowed_assert_;
361 bool was_execution_allowed_throws_;
362 bool was_execution_allowed_dump_;
363 };
364
370 public:
372 Isolate* isolate, MicrotaskQueue* microtask_queue = nullptr);
374
375 // Prevent copying of Scope objects.
377 delete;
379 const SuppressMicrotaskExecutionScope&) = delete;
380
381 private:
382 internal::Isolate* const i_isolate_;
383 internal::MicrotaskQueue* const microtask_queue_;
384 internal::Address previous_stack_height_;
385
386 friend class internal::ThreadLocalTop;
387 };
388
395 kMinorGarbageCollection
396 };
397
407 kUseAsm = 0,
408 kBreakIterator = 1,
409 kOBSOLETE_LegacyConst = 2,
410 kOBSOLETE_MarkDequeOverflow = 3,
411 kOBSOLETE_StoreBufferOverflow = 4,
412 kOBSOLETE_SlotsBufferOverflow = 5,
413 kOBSOLETE_ObjectObserve = 6,
414 kForcedGC = 7,
415 kSloppyMode = 8,
416 kStrictMode = 9,
417 kOBSOLETE_StrongMode = 10,
418 kRegExpPrototypeStickyGetter = 11,
419 kRegExpPrototypeToString = 12,
420 kRegExpPrototypeUnicodeGetter = 13,
421 kOBSOLETE_IntlV8Parse = 14,
422 kOBSOLETE_IntlPattern = 15,
423 kOBSOLETE_IntlResolved = 16,
424 kOBSOLETE_PromiseChain = 17,
425 kOBSOLETE_PromiseAccept = 18,
426 kOBSOLETE_PromiseDefer = 19,
427 kHtmlCommentInExternalScript = 20,
428 kHtmlComment = 21,
429 kSloppyModeBlockScopedFunctionRedefinition = 22,
430 kForInInitializer = 23,
431 kOBSOLETE_ArrayProtectorDirtied = 24,
432 kArraySpeciesModified = 25,
433 kArrayPrototypeConstructorModified = 26,
434 kOBSOLETE_ArrayInstanceProtoModified = 27,
435 kArrayInstanceConstructorModified = 28,
436 kOBSOLETE_LegacyFunctionDeclaration = 29,
437 kOBSOLETE_RegExpPrototypeSourceGetter = 30,
438 kOBSOLETE_RegExpPrototypeOldFlagGetter = 31,
439 kDecimalWithLeadingZeroInStrictMode = 32,
440 kLegacyDateParser = 33,
441 kDefineGetterOrSetterWouldThrow = 34,
442 kFunctionConstructorReturnedUndefined = 35,
443 kAssigmentExpressionLHSIsCallInSloppy = 36,
444 kAssigmentExpressionLHSIsCallInStrict = 37,
445 kPromiseConstructorReturnedUndefined = 38,
446 kOBSOLETE_ConstructorNonUndefinedPrimitiveReturn = 39,
447 kOBSOLETE_LabeledExpressionStatement = 40,
448 kOBSOLETE_LineOrParagraphSeparatorAsLineTerminator = 41,
449 kIndexAccessor = 42,
450 kErrorCaptureStackTrace = 43,
451 kErrorPrepareStackTrace = 44,
452 kErrorStackTraceLimit = 45,
453 kWebAssemblyInstantiation = 46,
454 kDeoptimizerDisableSpeculation = 47,
455 kOBSOLETE_ArrayPrototypeSortJSArrayModifiedPrototype = 48,
456 kFunctionTokenOffsetTooLongForToString = 49,
457 kWasmSharedMemory = 50,
458 kWasmThreadOpcodes = 51,
459 kOBSOLETE_AtomicsNotify = 52,
460 kOBSOLETE_AtomicsWake = 53,
461 kCollator = 54,
462 kNumberFormat = 55,
463 kDateTimeFormat = 56,
464 kPluralRules = 57,
465 kRelativeTimeFormat = 58,
466 kLocale = 59,
467 kListFormat = 60,
468 kSegmenter = 61,
469 kStringLocaleCompare = 62,
470 kOBSOLETE_StringToLocaleUpperCase = 63,
471 kStringToLocaleLowerCase = 64,
472 kNumberToLocaleString = 65,
473 kDateToLocaleString = 66,
474 kDateToLocaleDateString = 67,
475 kDateToLocaleTimeString = 68,
476 kAttemptOverrideReadOnlyOnPrototypeSloppy = 69,
477 kAttemptOverrideReadOnlyOnPrototypeStrict = 70,
478 kOBSOLETE_OptimizedFunctionWithOneShotBytecode = 71,
479 kRegExpMatchIsTrueishOnNonJSRegExp = 72,
480 kRegExpMatchIsFalseishOnJSRegExp = 73,
481 kOBSOLETE_DateGetTimezoneOffset = 74,
482 kStringNormalize = 75,
483 kCallSiteAPIGetFunctionSloppyCall = 76,
484 kCallSiteAPIGetThisSloppyCall = 77,
485 kOBSOLETE_RegExpMatchAllWithNonGlobalRegExp = 78,
486 kRegExpExecCalledOnSlowRegExp = 79,
487 kRegExpReplaceCalledOnSlowRegExp = 80,
488 kDisplayNames = 81,
489 kSharedArrayBufferConstructed = 82,
490 kArrayPrototypeHasElements = 83,
491 kObjectPrototypeHasElements = 84,
492 kNumberFormatStyleUnit = 85,
493 kDateTimeFormatRange = 86,
494 kDateTimeFormatDateTimeStyle = 87,
495 kBreakIteratorTypeWord = 88,
496 kBreakIteratorTypeLine = 89,
497 kInvalidatedArrayBufferDetachingProtector = 90,
498 kInvalidatedArrayConstructorProtector = 91,
499 kInvalidatedArrayIteratorLookupChainProtector = 92,
500 kInvalidatedArraySpeciesLookupChainProtector = 93,
501 kInvalidatedIsConcatSpreadableLookupChainProtector = 94,
502 kInvalidatedMapIteratorLookupChainProtector = 95,
503 kInvalidatedNoElementsProtector = 96,
504 kInvalidatedPromiseHookProtector = 97,
505 kInvalidatedPromiseResolveLookupChainProtector = 98,
506 kInvalidatedPromiseSpeciesLookupChainProtector = 99,
507 kInvalidatedPromiseThenLookupChainProtector = 100,
508 kInvalidatedRegExpSpeciesLookupChainProtector = 101,
509 kInvalidatedSetIteratorLookupChainProtector = 102,
510 kInvalidatedStringIteratorLookupChainProtector = 103,
511 kInvalidatedStringLengthOverflowLookupChainProtector = 104,
512 kInvalidatedTypedArraySpeciesLookupChainProtector = 105,
513 kWasmSimdOpcodes = 106,
514 kVarRedeclaredCatchBinding = 107,
515 kWasmRefTypes = 108,
516 kOBSOLETE_WasmBulkMemory = 109,
517 kOBSOLETE_WasmMultiValue = 110,
518 kWasmExceptionHandling = 111,
519 kInvalidatedMegaDOMProtector = 112,
520 kFunctionPrototypeArguments = 113,
521 kFunctionPrototypeCaller = 114,
522 kTurboFanOsrCompileStarted = 115,
523 kAsyncStackTaggingCreateTaskCall = 116,
524 kDurationFormat = 117,
525 kInvalidatedNumberStringNotRegexpLikeProtector = 118,
526 kOBSOLETE_RegExpUnicodeSetIncompatibilitiesWithUnicodeMode = 119,
527 kOBSOLETE_ImportAssertionDeprecatedSyntax = 120,
528 kLocaleInfoObsoletedGetters = 121,
529 kLocaleInfoFunctions = 122,
530 kCompileHintsMagicAll = 123,
531 kInvalidatedNoProfilingProtector = 124,
532 kWasmMemory64 = 125,
533 kWasmMultiMemory = 126,
534 kWasmGC = 127,
535 kWasmImportedStrings = 128,
536 kSourceMappingUrlMagicCommentAtSign = 129,
537 kTemporalObject = 130,
538 kWasmModuleCompilation = 131,
539 kInvalidatedNoUndetectableObjectsProtector = 132,
540 kWasmJavaScriptPromiseIntegration = 133,
541 kWasmReturnCall = 134,
542 kWasmExtendedConst = 135,
543 kWasmRelaxedSimd = 136,
544 kWasmTypeReflection = 137,
545 kWasmExnRef = 138,
546 kWasmTypedFuncRef = 139,
547 kInvalidatedStringWrapperToPrimitiveProtector = 140,
548 kDocumentAllLegacyCall = 141,
549 kDocumentAllLegacyConstruct = 142,
550 kConsoleContext = 143,
551 kWasmImportedStringsUtf8 = 144,
552 kResizableArrayBuffer = 145,
553 kGrowableSharedArrayBuffer = 146,
554 kArrayByCopy = 147,
555 kArrayFromAsync = 148,
556 kIteratorMethods = 149,
557 kPromiseAny = 150,
558 kSetMethods = 151,
559 kArrayFindLast = 152,
560 kArrayGroup = 153,
561 kArrayBufferTransfer = 154,
562 kPromiseWithResolvers = 155,
563 kAtomicsWaitAsync = 156,
564
565 // If you add new values here, you'll also need to update Chromium's:
566 // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
567 // this list need to be landed first, then changes on the Chromium side.
568 kUseCounterFeatureCount // This enum value must be last.
569 };
570
572 kMessageLog = (1 << 0),
573 kMessageDebug = (1 << 1),
574 kMessageInfo = (1 << 2),
575 kMessageError = (1 << 3),
576 kMessageWarning = (1 << 4),
577 kMessageAll = kMessageLog | kMessageDebug | kMessageInfo | kMessageError |
578 kMessageWarning,
579 };
580
581 // The different priorities that an isolate can have.
582 enum class Priority {
583 // The isolate does not relate to content that is currently important
584 // to the user. Lowest priority.
586
587 // The isolate contributes to content that is visible to the user, like a
588 // visible iframe that's not interacted directly with. High priority.
590
591 // The isolate contributes to content that is of the utmost importance to
592 // the user, like visible content in the focused window. Highest priority.
594 };
595
596 using UseCounterCallback = void (*)(Isolate* isolate,
597 UseCounterFeature feature);
598
613 static Isolate* Allocate();
614
618 static void Initialize(Isolate* isolate, const CreateParams& params);
619
629 static Isolate* New(const CreateParams& params);
630
638
646
650 bool IsCurrent() const;
651
666
679
686
698
705
712
718
723
724#if defined(V8_OS_WIN)
728 void SetFilterETWSessionByURLCallback(FilterETWSessionByURLCallback callback);
729#endif // V8_OS_WIN
730
738
745 void SetBatterySaverMode(bool battery_saver_mode_enabled);
746
753
764 void Enter();
765
773 void Exit();
774
779 void Dispose();
780
786
795
800 V8_INLINE void SetData(uint32_t slot, void* data);
801
806 V8_INLINE void* GetData(uint32_t slot);
807
812 V8_INLINE static uint32_t GetNumberOfDataSlots();
813
819 template <class T>
820 V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
821
827
833
837 void GetHeapStatistics(HeapStatistics* heap_statistics);
838
843
854 size_t index);
855
860
871 size_t type_index);
872
881
895 std::unique_ptr<MeasureMemoryDelegate> delegate,
896 MeasureMemoryExecution execution = MeasureMemoryExecution::kDefault);
897
910 void GetStackSample(const RegisterState& state, void** frames,
911 size_t frames_limit, SampleInfo* sample_info);
912
926 int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
927
933
937 void SetIdle(bool is_idle);
938
941
943 bool InContext();
944
950
958
964
970
976 template <int N>
977 Local<Value> ThrowError(const char (&message)[N]) {
978 return ThrowError(String::NewFromUtf8Literal(this, message));
979 }
981
989
997
998 using GCCallback = void (*)(Isolate* isolate, GCType type,
999 GCCallbackFlags flags);
1000 using GCCallbackWithData = void (*)(Isolate* isolate, GCType type,
1001 GCCallbackFlags flags, void* data);
1002
1014 GCType gc_type_filter = kGCTypeAll);
1015
1021 void AddGCPrologueCallback(GCCallbackWithData callback, void* data = nullptr,
1022 GCType gc_type_filter = kGCTypeAll);
1023
1031
1038
1046 GCType gc_type_filter = kGCTypeAll);
1047
1053 void AddGCEpilogueCallback(GCCallbackWithData callback, void* data = nullptr,
1054 GCType gc_type_filter = kGCTypeAll);
1055
1063
1070 void* data = nullptr);
1071
1080
1092 "Set the heap on Isolate creation using CreateParams instead.")
1093 void AttachCppHeap(CppHeap*);
1094
1101 "Set the heap on Isolate creation using CreateParams instead.")
1102 void DetachCppHeap();
1103
1108 CppHeap* GetCppHeap() const;
1109
1113 enum class AtomicsWaitEvent {
1115 kStartWait,
1117 kWokenUp,
1119 kTimedOut,
1121 kTerminatedExecution,
1123 kAPIStopped,
1125 kNotEqual
1126 };
1127
1133 public:
1148 void Wake();
1149 };
1150
1175 Local<SharedArrayBuffer> array_buffer,
1176 size_t offset_in_bytes, int64_t value,
1177 double timeout_in_ms,
1178 AtomicsWaitWakeHandle* stop_handle,
1179 void* data);
1180
1188
1190
1199
1208
1218
1234
1243 void RequestInterrupt(InterruptCallback callback, void* data);
1244
1251
1262
1274 StackState stack_state);
1275
1280
1288
1293
1302
1307
1313
1319
1328
1336
1341
1345 void EnqueueMicrotask(MicrotaskCallback callback, void* data = nullptr);
1346
1351
1356
1371 MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
1372
1377 MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
1378
1383
1389
1398
1409 const std::shared_ptr<metrics::Recorder>& metrics_recorder);
1410
1417
1423
1433 int ContextDisposedNotification(bool dependant_context = true);
1434
1439 V8_DEPRECATE_SOON("Use SetPriority(Priority::kUserBlocking) instead")
1440 void IsolateInForegroundNotification();
1441
1446 V8_DEPRECATE_SOON("Use SetPriority(Priority::kBestEffort) instead")
1447 void IsolateInBackgroundNotification();
1448
1453 void SetPriority(Priority priority);
1454
1462 V8_DEPRECATED("Use SetIsLoading instead")
1463 void SetRAILMode(RAILMode rail_mode);
1464
1468 V8_DEPRECATED("Use SetIsLoading instead")
1469 void UpdateLoadStartTime();
1470
1483 void SetIsLoading(bool is_loading);
1484
1489 void IncreaseHeapLimitForDebugging();
1490
1494 void RestoreOriginalHeapLimit();
1495
1500 bool IsHeapLimitIncreasedForDebugging();
1501
1524 void SetJitCodeEventHandler(JitCodeEventOptions options,
1525 JitCodeEventHandler event_handler);
1526
1536 void SetStackLimit(uintptr_t stack_limit);
1537
1553 void GetCodeRange(void** start, size_t* length_in_bytes);
1554
1559 void GetEmbeddedCodeRange(const void** start, size_t* length_in_bytes);
1560
1564 JSEntryStubs GetJSEntryStubs();
1565
1566 static constexpr size_t kMinCodePagesBufferSize = 32;
1567
1581 size_t CopyCodePages(size_t capacity, MemoryRange* code_pages_out);
1582
1584 void SetFatalErrorHandler(FatalErrorCallback that);
1585
1587 void SetOOMErrorHandler(OOMErrorCallback that);
1588
1594 void AddNearHeapLimitCallback(NearHeapLimitCallback callback, void* data);
1595
1603 void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback,
1604 size_t heap_limit);
1605
1612 void AutomaticallyRestoreInitialHeapLimit(double threshold_percent = 0.5);
1613
1618 void SetModifyCodeGenerationFromStringsCallback(
1620
1625 void SetAllowWasmCodeGenerationCallback(
1627
1632 void SetWasmModuleCallback(ExtensionCallback callback);
1633 void SetWasmInstanceCallback(ExtensionCallback callback);
1634
1635 void SetWasmStreamingCallback(WasmStreamingCallback callback);
1636
1637 void SetWasmAsyncResolvePromiseCallback(
1639
1640 void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
1641
1642 void SetWasmImportedStringsEnabledCallback(
1644
1645 void SetSharedArrayBufferConstructorEnabledCallback(
1647
1648 void SetWasmJSPIEnabledCallback(WasmJSPIEnabledCallback callback);
1649
1655 "Will be removed, use ScriptCompiler::CompileOptions for enabling the "
1656 "compile hints magic comments")
1657 void SetJavaScriptCompileHintsMagicEnabledCallback(
1659
1665 void InstallConditionalFeatures(Local<Context> context);
1666
1671 bool IsDead();
1672
1682 bool AddMessageListener(MessageCallback that,
1683 Local<Value> data = Local<Value>());
1684
1696 bool AddMessageListenerWithErrorLevel(MessageCallback that,
1697 int message_levels,
1698 Local<Value> data = Local<Value>());
1699
1703 void RemoveMessageListeners(MessageCallback that);
1704
1706 void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
1707
1712 void SetCaptureStackTraceForUncaughtExceptions(
1713 bool capture, int frame_limit = 10,
1714 StackTrace::StackTraceOptions options = StackTrace::kOverview);
1715
1721 V8_DEPRECATED("Will be removed without replacement. crbug.com/v8/14172")
1722 void VisitExternalResources(ExternalResourceVisitor* visitor);
1723
1728 bool IsInUse();
1729
1735 void SetAllowAtomicsWait(bool allow);
1736
1750 enum class TimeZoneDetection { kSkip, kRedetect };
1751
1763 TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip);
1764
1775
1780 std::string GetDefaultLocale();
1781
1782 Isolate() = delete;
1783 ~Isolate() = delete;
1784 Isolate(const Isolate&) = delete;
1785 Isolate& operator=(const Isolate&) = delete;
1786 // Deleting operator new and delete here is allowed as ctor and dtor is also
1787 // deleted.
1788 void* operator new(size_t size) = delete;
1789 void* operator new[](size_t size) = delete;
1790 void operator delete(void*, size_t) = delete;
1791 void operator delete[](void*, size_t) = delete;
1792
1793 private:
1794 template <class K, class V, class Traits>
1796
1798 size_t index);
1799 void HandleExternalMemoryInterrupt();
1800};
1801
1802void Isolate::SetData(uint32_t slot, void* data) {
1803 using I = internal::Internals;
1804 I::SetEmbedderData(this, slot, data);
1805}
1806
1807void* Isolate::GetData(uint32_t slot) {
1808 using I = internal::Internals;
1809 return I::GetEmbedderData(this, slot);
1810}
1811
1812uint32_t Isolate::GetNumberOfDataSlots() {
1813 using I = internal::Internals;
1814 return I::kNumIsolateDataSlots;
1815}
1816
1817template <class T>
1818MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
1819 if (auto repr = GetDataFromSnapshotOnce(index);
1820 repr != internal::ValueHelper::kEmpty) {
1821 internal::PerformCastCheck(internal::ValueHelper::ReprAsValue<T>(repr));
1822 return Local<T>::FromRepr(repr);
1823 }
1824 return {};
1825}
1826
1827} // namespace v8
1828
1829#endif // INCLUDE_V8_ISOLATE_H_
Definition: v8-array-buffer.h:153
Definition: v8-array-buffer.h:136
Definition: v8-context.h:48
Definition: v8-cppgc.h:65
Definition: v8-embedder-heap.h:22
Definition: v8-primitive.h:737
Definition: v8-statistics.h:219
Definition: v8-statistics.h:202
Definition: v8-profiler.h:953
Definition: v8-statistics.h:183
Definition: v8-statistics.h:140
Definition: v8-isolate.h:347
AllowJavascriptExecutionScope(const AllowJavascriptExecutionScope &)=delete
AllowJavascriptExecutionScope & operator=(const AllowJavascriptExecutionScope &)=delete
Definition: v8-isolate.h:1132
DisallowJavascriptExecutionScope(Isolate *isolate, OnFailure on_failure)
DisallowJavascriptExecutionScope(const DisallowJavascriptExecutionScope &)=delete
DisallowJavascriptExecutionScope & operator=(const DisallowJavascriptExecutionScope &)=delete
@ CRASH_ON_FAILURE
Definition: v8-isolate.h:327
Definition: v8-isolate.h:306
Scope(Isolate *isolate)
Definition: v8-isolate.h:308
Scope(const Scope &)=delete
~Scope()
Definition: v8-isolate.h:312
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:212
int GetStackTraceLimit()
void RemoveGCEpilogueCallback(GCCallback callback)
void AddGCPrologueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics *object_statistics)
HeapProfiler * GetHeapProfiler()
bool MeasureMemory(std::unique_ptr< MeasureMemoryDelegate > delegate, MeasureMemoryExecution execution=MeasureMemoryExecution::kDefault)
size_t NumberOfTrackedHeapObjectTypes()
void RemoveGCEpilogueCallback(GCCallbackWithData callback, void *data=nullptr)
void Dispose()
void LocaleConfigurationChangeNotification()
void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)
bool GetHeapSpaceStatistics(HeapSpaceStatistics *space_statistics, size_t index)
void SetEventLogger(LogEventCallback that)
void SetExceptionPropagationCallback(ExceptionPropagationCallback callback)
void RequestGarbageCollectionForTesting(GarbageCollectionType type, StackState stack_state)
void ClearKeptObjects()
Local< Value > ThrowError(Local< String > message)
size_t(*)() GetExternallyAllocatedMemoryInBytesCallback
Definition: v8-isolate.h:1189
static Isolate * New(const CreateParams &params)
Isolate()=delete
void SetAddCrashKeyCallback(AddCrashKeyCallback)
static Isolate * GetCurrent()
void RemoveCallCompletedCallback(CallCompletedCallback callback)
int ContextDisposedNotification(bool dependant_context=true)
static void Initialize(Isolate *isolate, const CreateParams &params)
bool HasPendingException()
TimeZoneDetection
Definition: v8-isolate.h:1750
void RequestGarbageCollectionForTesting(GarbageCollectionType type)
GarbageCollectionType
Definition: v8-isolate.h:393
@ kFullGarbageCollection
Definition: v8-isolate.h:394
void DumpAndResetStats()
void SetHostImportModuleDynamicallyCallback(HostImportModuleDynamicallyCallback callback)
void(*)(Isolate *isolate, GCType type, GCCallbackFlags flags) GCCallback
Definition: v8-isolate.h:999
bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics *object_statistics, size_t type_index)
void SetMicrotasksPolicy(MicrotasksPolicy policy)
void SetPromiseRejectCallback(PromiseRejectCallback callback)
void SetPromiseHook(PromiseHook hook)
void(*)(Isolate *isolate, UseCounterFeature feature) UseCounterCallback
Definition: v8-isolate.h:597
void CancelTerminateExecution()
void(*)(Isolate *isolate, GCType type, GCCallbackFlags flags, void *data) GCCallbackWithData
Definition: v8-isolate.h:1001
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)
MaybeLocal< Data > GetCurrentHostDefinedOptions()
void AddCallCompletedCallback(CallCompletedCallback callback)
void GetStackSample(const RegisterState &state, void **frames, size_t frames_limit, SampleInfo *sample_info)
void SetEmbedderRootsHandler(EmbedderRootsHandler *handler)
void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
void RequestInterrupt(InterruptCallback callback, void *data)
void AddGCEpilogueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
Isolate & operator=(const Isolate &)=delete
void SetIdle(bool is_idle)
std::string GetDefaultLocale()
void PerformMicrotaskCheckpoint()
AtomicsWaitEvent
Definition: v8-isolate.h:1113
Local< Value > ThrowError(const char(&message)[N])
Definition: v8-isolate.h:977
void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback)
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
void LowMemoryNotification()
Priority
Definition: v8-isolate.h:582
Isolate(const Isolate &)=delete
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
Definition: v8-isolate.h:1179
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)
Local< Context > GetCurrentContext()
static Isolate * Allocate()
MessageErrorLevel
Definition: v8-isolate.h:571
bool(*)(Isolate *) AbortOnUncaughtExceptionCallback
Definition: v8-isolate.h:676
void AddMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)
void TerminateExecution()
void SetHostInitializeImportMetaObjectCallback(HostInitializeImportMetaObjectCallback callback)
void SetUseCounterCallback(UseCounterCallback callback)
Local< Value > GetContinuationPreservedEmbedderData()
size_t NumberOfHeapSpaces()
void GetHeapStatistics(HeapStatistics *heap_statistics)
void SetContinuationPreservedEmbedderData(Local< Value > data)
Local< Context > GetIncumbentContext()
void SetMetricsRecorder(const std::shared_ptr< metrics::Recorder > &metrics_recorder)
void MemoryPressureNotification(MemoryPressureLevel level)
void SetAtomicsWaitCallback(AtomicsWaitCallback callback, void *data)
void EnqueueMicrotask(MicrotaskCallback callback, void *data=nullptr)
void SetAddHistogramSampleFunction(AddHistogramSampleCallback)
Local< Context > GetEnteredOrMicrotaskContext()
void SetGetExternallyAllocatedMemoryInBytesCallback(GetExternallyAllocatedMemoryInBytesCallback callback)
void Enter()
UseCounterFeature
Definition: v8-isolate.h:406
bool IsExecutionTerminating()
ArrayBuffer::Allocator * GetArrayBufferAllocator()
~Isolate()=delete
void RemoveGCPrologueCallback(GCCallbackWithData, void *data=nullptr)
bool InContext()
void SetAbortOnUncaughtExceptionCallback(AbortOnUncaughtExceptionCallback callback)
void ClearCachesForTesting()
void SetHostImportModuleWithPhaseDynamicallyCallback(HostImportModuleWithPhaseDynamicallyCallback callback)
void SetCreateHistogramFunction(CreateHistogramCallback)
Definition: v8-local-handle.h:266
Definition: v8-local-handle.h:632
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
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-script.h:402
Definition: v8-container.h:148
Definition: v8-debug.h:111
Definition: v8-snapshot.h:21
Definition: v8-value.h:32
Definition: v8-internal.h:855
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1641
Definition: v8-metrics.h:186
EmbedderStackState
Definition: common.h:15
uintptr_t Address
Definition: v8-internal.h:51
Definition: libplatform.h:15
void(*)(const JitCodeEvent *event) JitCodeEventHandler
Definition: v8-callbacks.h:140
JitCodeEventOptions
Definition: v8-callbacks.h:129
void(*)(const char *location, const OOMDetails &details) OOMErrorCallback
Definition: v8-callbacks.h:228
bool(*)(Local< Context > context) SharedArrayBufferConstructorEnabledCallback
Definition: v8-callbacks.h:324
void(*)(void *data) MicrotaskCallback
Definition: v8-microtask.h:14
GCCallbackFlags
Definition: v8-callbacks.h:177
bool(*)(Local< Context > context) WasmJSPIEnabledCallback
Definition: v8-callbacks.h:331
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:313
bool(*)(const FunctionCallbackInfo< Value > &) ExtensionCallback
Definition: v8-callbacks.h:296
void(*)(PromiseHookType type, Local< Promise > promise, Local< Value > parent) PromiseHook
Definition: v8-promise.h:144
void(*)(Isolate *, void *) MicrotasksCompletedCallbackWithData
Definition: v8-microtask.h:13
bool(*)(Local< Context > context) JavaScriptCompileHintsMagicEnabledCallback
Definition: v8-callbacks.h:328
void(*)(ExceptionPropagationMessage message) ExceptionPropagationCallback
Definition: v8-exception.h:131
void(*)(const FunctionCallbackInfo< Value > &) WasmStreamingCallback
Definition: v8-callbacks.h:306
void *(*)(const char *name, int min, int max, size_t buckets) CreateHistogramCallback
Definition: v8-callbacks.h:214
void(*)(Local< Context > context, Local< Module > module, Local< Object > meta) HostInitializeImportMetaObjectCallback
Definition: v8-callbacks.h:432
void(*)(Local< Message > message, Local< Value > data) MessageCallback
Definition: v8-callbacks.h:230
void(*)(CrashKeyId id, const std::string &value) AddCrashKeyCallback
Definition: v8-callbacks.h:251
void(*)(Isolate *isolate, void *data) InterruptCallback
Definition: v8-callbacks.h:189
RAILMode
Definition: v8-isolate.h:172
@ PERFORMANCE_IDLE
Definition: v8-isolate.h:183
@ PERFORMANCE_LOAD
Definition: v8-isolate.h:186
@ PERFORMANCE_ANIMATION
Definition: v8-isolate.h:180
@ PERFORMANCE_RESPONSE
Definition: v8-isolate.h:176
void(*)(Isolate *) CallCompletedCallback
Definition: v8-callbacks.h:255
void(*)(void *histogram, int sample) AddHistogramSampleCallback
Definition: v8-callbacks.h:216
size_t(*)(void *data, size_t current_heap_limit, size_t initial_heap_limit) NearHeapLimitCallback
Definition: v8-callbacks.h:199
void(*)(Isolate *) BeforeCallEnteredCallback
Definition: v8-callbacks.h:254
bool(*)(Local< Context > context, Local< String > source) AllowWasmCodeGenerationCallback
Definition: v8-callbacks.h:299
void(*)(const char *location, const char *message) FatalErrorCallback
Definition: v8-callbacks.h:220
void(*)(PromiseRejectMessage message) PromiseRejectCallback
Definition: v8-promise.h:170
GCType
Definition: v8-callbacks.h:152
ModifyCodeGenerationFromStringsResult(*)(Local< Context > context, Local< Value > source, bool is_code_like) ModifyCodeGenerationFromStringsCallback2
Definition: v8-callbacks.h:277
void(*)(Local< Object > target, AccessType type, Local< Value > data) FailedAccessCheckCallback
Definition: v8-callbacks.h:293
bool(*)(Local< Context > context) WasmImportedStringsEnabledCallback
Definition: v8-callbacks.h:320
void(*)(const char *name, int status) LogEventCallback
Definition: v8-callbacks.h:236
MemoryPressureLevel
Definition: v8-isolate.h:197
MeasureMemoryExecution
Definition: v8-statistics.h:43
int *(*)(const char *name) CounterLookupCallback
Definition: v8-callbacks.h:211
Definition: v8-isolate.h:217
Definition: v8-unwinder.h:69
Definition: v8-unwinder.h:60
Definition: v8-unwinder.h:21
Definition: v8-unwinder.h:50
#define V8_EXPORT
Definition: v8config.h:793
#define V8_INLINE
Definition: v8config.h:499
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:603
#define V8_DEPRECATED(message)
Definition: v8config.h:595
#define ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS(ClassName)
Definition: v8config.h:626
#define V8_NODISCARD
Definition: v8config.h:682