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
176
181
207 public:
215
220 static bool CanCreateNewGroups();
221
227
230
231 IsolateGroup(const IsolateGroup&) = delete;
233
235
236 bool operator==(const IsolateGroup& other) const {
237 return isolate_group_ == other.isolate_group_;
238 }
239
240 bool operator!=(const IsolateGroup& other) const {
241 return !operator==(other);
242 }
243
244 private:
245 friend class Isolate;
246
247 // The isolate_group pointer should be already acquired.
248 explicit IsolateGroup(internal::IsolateGroup*&& isolate_group);
249
250 internal::IsolateGroup* isolate_group_;
251};
252
262 public:
269
271
272
276 JitCodeEventHandler code_event_handler = nullptr;
277
282
287 const StartupData* snapshot_blob = nullptr;
288
293 CounterLookupCallback counter_lookup_callback = nullptr;
294
301 CreateHistogramCallback create_histogram_callback = nullptr;
302 AddHistogramSampleCallback add_histogram_sample_callback = nullptr;
303
313 ArrayBuffer::Allocator* array_buffer_allocator = nullptr;
314 std::shared_ptr<ArrayBuffer::Allocator> array_buffer_allocator_shared;
315
322 const intptr_t* external_references = nullptr;
323
328 bool allow_atomics_wait = true;
329
335 int embedder_wrapper_type_index = -1;
336 int embedder_wrapper_object_index = -1;
337
341 FatalErrorCallback fatal_error_callback = nullptr;
342 OOMErrorCallback oom_error_callback = nullptr;
343
348 CppHeap* cpp_heap = nullptr;
349 };
350
356 public:
357 explicit Scope(Isolate* isolate) : v8_isolate_(isolate) {
358 v8_isolate_->Enter();
359 }
360
361 ~Scope() { v8_isolate_->Exit(); }
362
363 // Prevent copying of Scope objects.
364 Scope(const Scope&) = delete;
365 Scope& operator=(const Scope&) = delete;
366
367 private:
368 Isolate* const v8_isolate_;
369 };
370
375 public:
376 enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE, DUMP_ON_FAILURE };
377
380
381 // Prevent copying of Scope objects.
383 delete;
385 const DisallowJavascriptExecutionScope&) = delete;
386
387 private:
388 v8::Isolate* const v8_isolate_;
389 const OnFailure on_failure_;
390 bool was_execution_allowed_;
391 };
392
397 public:
400
401 // Prevent copying of Scope objects.
403 delete;
405 const AllowJavascriptExecutionScope&) = delete;
406
407 private:
408 Isolate* const v8_isolate_;
409 bool was_execution_allowed_assert_;
410 bool was_execution_allowed_throws_;
411 bool was_execution_allowed_dump_;
412 };
413
419 public:
421 Isolate* isolate, MicrotaskQueue* microtask_queue = nullptr);
423
424 // Prevent copying of Scope objects.
426 delete;
428 const SuppressMicrotaskExecutionScope&) = delete;
429
430 private:
431 internal::Isolate* const i_isolate_;
432 internal::MicrotaskQueue* const microtask_queue_;
433 internal::Address previous_stack_height_;
434
435 friend class internal::ThreadLocalTop;
436 };
437
444 kMinorGarbageCollection
445 };
446
456 kUseAsm = 0,
457 kBreakIterator = 1,
458 kOBSOLETE_LegacyConst = 2,
459 kOBSOLETE_MarkDequeOverflow = 3,
460 kOBSOLETE_StoreBufferOverflow = 4,
461 kOBSOLETE_SlotsBufferOverflow = 5,
462 kOBSOLETE_ObjectObserve = 6,
463 kForcedGC = 7,
464 kSloppyMode = 8,
465 kStrictMode = 9,
466 kOBSOLETE_StrongMode = 10,
467 kRegExpPrototypeStickyGetter = 11,
468 kRegExpPrototypeToString = 12,
469 kRegExpPrototypeUnicodeGetter = 13,
470 kOBSOLETE_IntlV8Parse = 14,
471 kOBSOLETE_IntlPattern = 15,
472 kOBSOLETE_IntlResolved = 16,
473 kOBSOLETE_PromiseChain = 17,
474 kOBSOLETE_PromiseAccept = 18,
475 kOBSOLETE_PromiseDefer = 19,
476 kHtmlCommentInExternalScript = 20,
477 kHtmlComment = 21,
478 kSloppyModeBlockScopedFunctionRedefinition = 22,
479 kForInInitializer = 23,
480 kOBSOLETE_ArrayProtectorDirtied = 24,
481 kArraySpeciesModified = 25,
482 kArrayPrototypeConstructorModified = 26,
483 kOBSOLETE_ArrayInstanceProtoModified = 27,
484 kArrayInstanceConstructorModified = 28,
485 kOBSOLETE_LegacyFunctionDeclaration = 29,
486 kOBSOLETE_RegExpPrototypeSourceGetter = 30,
487 kOBSOLETE_RegExpPrototypeOldFlagGetter = 31,
488 kDecimalWithLeadingZeroInStrictMode = 32,
489 kLegacyDateParser = 33,
490 kDefineGetterOrSetterWouldThrow = 34,
491 kFunctionConstructorReturnedUndefined = 35,
492 kAssigmentExpressionLHSIsCallInSloppy = 36,
493 kAssigmentExpressionLHSIsCallInStrict = 37,
494 kPromiseConstructorReturnedUndefined = 38,
495 kOBSOLETE_ConstructorNonUndefinedPrimitiveReturn = 39,
496 kOBSOLETE_LabeledExpressionStatement = 40,
497 kOBSOLETE_LineOrParagraphSeparatorAsLineTerminator = 41,
498 kIndexAccessor = 42,
499 kErrorCaptureStackTrace = 43,
500 kErrorPrepareStackTrace = 44,
501 kErrorStackTraceLimit = 45,
502 kWebAssemblyInstantiation = 46,
503 kDeoptimizerDisableSpeculation = 47,
504 kOBSOLETE_ArrayPrototypeSortJSArrayModifiedPrototype = 48,
505 kFunctionTokenOffsetTooLongForToString = 49,
506 kWasmSharedMemory = 50,
507 kWasmThreadOpcodes = 51,
508 kOBSOLETE_AtomicsNotify = 52,
509 kOBSOLETE_AtomicsWake = 53,
510 kCollator = 54,
511 kNumberFormat = 55,
512 kDateTimeFormat = 56,
513 kPluralRules = 57,
514 kRelativeTimeFormat = 58,
515 kLocale = 59,
516 kListFormat = 60,
517 kSegmenter = 61,
518 kStringLocaleCompare = 62,
519 kOBSOLETE_StringToLocaleUpperCase = 63,
520 kStringToLocaleLowerCase = 64,
521 kNumberToLocaleString = 65,
522 kDateToLocaleString = 66,
523 kDateToLocaleDateString = 67,
524 kDateToLocaleTimeString = 68,
525 kAttemptOverrideReadOnlyOnPrototypeSloppy = 69,
526 kAttemptOverrideReadOnlyOnPrototypeStrict = 70,
527 kOBSOLETE_OptimizedFunctionWithOneShotBytecode = 71,
528 kRegExpMatchIsTrueishOnNonJSRegExp = 72,
529 kRegExpMatchIsFalseishOnJSRegExp = 73,
530 kOBSOLETE_DateGetTimezoneOffset = 74,
531 kStringNormalize = 75,
532 kCallSiteAPIGetFunctionSloppyCall = 76,
533 kCallSiteAPIGetThisSloppyCall = 77,
534 kOBSOLETE_RegExpMatchAllWithNonGlobalRegExp = 78,
535 kRegExpExecCalledOnSlowRegExp = 79,
536 kRegExpReplaceCalledOnSlowRegExp = 80,
537 kDisplayNames = 81,
538 kSharedArrayBufferConstructed = 82,
539 kArrayPrototypeHasElements = 83,
540 kObjectPrototypeHasElements = 84,
541 kNumberFormatStyleUnit = 85,
542 kDateTimeFormatRange = 86,
543 kDateTimeFormatDateTimeStyle = 87,
544 kBreakIteratorTypeWord = 88,
545 kBreakIteratorTypeLine = 89,
546 kInvalidatedArrayBufferDetachingProtector = 90,
547 kInvalidatedArrayConstructorProtector = 91,
548 kInvalidatedArrayIteratorLookupChainProtector = 92,
549 kInvalidatedArraySpeciesLookupChainProtector = 93,
550 kInvalidatedIsConcatSpreadableLookupChainProtector = 94,
551 kInvalidatedMapIteratorLookupChainProtector = 95,
552 kInvalidatedNoElementsProtector = 96,
553 kInvalidatedPromiseHookProtector = 97,
554 kInvalidatedPromiseResolveLookupChainProtector = 98,
555 kInvalidatedPromiseSpeciesLookupChainProtector = 99,
556 kInvalidatedPromiseThenLookupChainProtector = 100,
557 kInvalidatedRegExpSpeciesLookupChainProtector = 101,
558 kInvalidatedSetIteratorLookupChainProtector = 102,
559 kInvalidatedStringIteratorLookupChainProtector = 103,
560 kInvalidatedStringLengthOverflowLookupChainProtector = 104,
561 kInvalidatedTypedArraySpeciesLookupChainProtector = 105,
562 kWasmSimdOpcodes = 106,
563 kVarRedeclaredCatchBinding = 107,
564 kWasmRefTypes = 108,
565 kOBSOLETE_WasmBulkMemory = 109,
566 kOBSOLETE_WasmMultiValue = 110,
567 kWasmExceptionHandling = 111,
568 kInvalidatedMegaDOMProtector = 112,
569 kFunctionPrototypeArguments = 113,
570 kFunctionPrototypeCaller = 114,
571 kTurboFanOsrCompileStarted = 115,
572 kAsyncStackTaggingCreateTaskCall = 116,
573 kDurationFormat = 117,
574 kInvalidatedNumberStringNotRegexpLikeProtector = 118,
575 kOBSOLETE_RegExpUnicodeSetIncompatibilitiesWithUnicodeMode = 119,
576 kOBSOLETE_ImportAssertionDeprecatedSyntax = 120,
577 kLocaleInfoObsoletedGetters = 121,
578 kLocaleInfoFunctions = 122,
579 kCompileHintsMagicAll = 123,
580 kInvalidatedNoProfilingProtector = 124,
581 kWasmMemory64 = 125,
582 kWasmMultiMemory = 126,
583 kWasmGC = 127,
584 kWasmImportedStrings = 128,
585 kSourceMappingUrlMagicCommentAtSign = 129,
586 kTemporalObject = 130,
587 kWasmModuleCompilation = 131,
588 kInvalidatedNoUndetectableObjectsProtector = 132,
589 kWasmJavaScriptPromiseIntegration = 133,
590 kWasmReturnCall = 134,
591 kWasmExtendedConst = 135,
592 kWasmRelaxedSimd = 136,
593 kWasmTypeReflection = 137,
594 kWasmExnRef = 138,
595 kWasmTypedFuncRef = 139,
596 kInvalidatedStringWrapperToPrimitiveProtector = 140,
597 kDocumentAllLegacyCall = 141,
598 kDocumentAllLegacyConstruct = 142,
599 kConsoleContext = 143,
600 kWasmImportedStringsUtf8 = 144,
601 kResizableArrayBuffer = 145,
602 kGrowableSharedArrayBuffer = 146,
603 kArrayByCopy = 147,
604 kArrayFromAsync = 148,
605 kIteratorMethods = 149,
606 kPromiseAny = 150,
607 kSetMethods = 151,
608 kArrayFindLast = 152,
609 kArrayGroup = 153,
610 kArrayBufferTransfer = 154,
611 kPromiseWithResolvers = 155,
612 kAtomicsWaitAsync = 156,
613 kExtendingNonExtensibleWithPrivate = 157,
614 kPromiseTry = 158,
615 kStringReplaceAll = 159,
616 kStringWellFormed = 160,
617 kWeakReferences = 161,
618 kErrorIsError = 162,
619
620 // If you add new values here, you'll also need to update Chromium's:
621 // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
622 // this list need to be landed first, then changes on the Chromium side.
623 kUseCounterFeatureCount // This enum value must be last.
624 };
625
627 kMessageLog = (1 << 0),
628 kMessageDebug = (1 << 1),
629 kMessageInfo = (1 << 2),
630 kMessageError = (1 << 3),
631 kMessageWarning = (1 << 4),
632 kMessageAll = kMessageLog | kMessageDebug | kMessageInfo | kMessageError |
633 kMessageWarning,
634 };
635
636 // The different priorities that an isolate can have.
637 enum class Priority {
638 // The isolate does not relate to content that is currently important
639 // to the user. Lowest priority.
641
642 // The isolate contributes to content that is visible to the user, like a
643 // visible iframe that's not interacted directly with. High priority.
645
646 // The isolate contributes to content that is of the utmost importance to
647 // the user, like visible content in the focused window. Highest priority.
649 };
650
651 using UseCounterCallback = void (*)(Isolate* isolate,
652 UseCounterFeature feature);
653
668 static Isolate* Allocate();
669 static Isolate* Allocate(const IsolateGroup& group);
670
675
679 static void Initialize(Isolate* isolate, const CreateParams& params);
680
690 static Isolate* New(const CreateParams& params);
691 static Isolate* New(const IsolateGroup& group, const CreateParams& params);
692
700
708
712 bool IsCurrent() const;
713
728
741
748
760
767
774
782
788
793
794#if defined(V8_OS_WIN)
798 V8_DEPRECATE_SOON("Use SetFilterETWSessionByURL2Callback instead")
799 void SetFilterETWSessionByURLCallback(FilterETWSessionByURLCallback callback);
800 void SetFilterETWSessionByURL2Callback(
801 FilterETWSessionByURL2Callback callback);
802#endif // V8_OS_WIN
803
811
818 void SetBatterySaverMode(bool battery_saver_mode_enabled);
819
826
837 void Enter();
838
846 void Exit();
847
852 void Dispose();
853
859
868
873 V8_INLINE void SetData(uint32_t slot, void* data);
874
879 V8_INLINE void* GetData(uint32_t slot);
880
885 V8_INLINE static uint32_t GetNumberOfDataSlots();
886
892 template <class T>
893 V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
894
900
906
910 void GetHeapStatistics(HeapStatistics* heap_statistics);
911
916
927 size_t index);
928
933
944 size_t type_index);
945
954
968 std::unique_ptr<MeasureMemoryDelegate> delegate,
969 MeasureMemoryExecution execution = MeasureMemoryExecution::kDefault);
970
983 void GetStackSample(const RegisterState& state, void** frames,
984 size_t frames_limit, SampleInfo* sample_info);
985
993 V8_DEPRECATE_SOON("Use ExternalMemoryAccounter instead.")
994 int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
995
1000 HeapProfiler* GetHeapProfiler();
1001
1005 void SetIdle(bool is_idle);
1006
1008 ArrayBuffer::Allocator* GetArrayBufferAllocator();
1009
1011 bool InContext();
1012
1017 Local<Context> GetCurrentContext();
1018
1025 Local<Context> GetEnteredOrMicrotaskContext();
1026
1031 Local<Context> GetIncumbentContext();
1032
1037 MaybeLocal<Data> GetCurrentHostDefinedOptions();
1038
1044 template <int N>
1045 Local<Value> ThrowError(const char (&message)[N]) {
1046 return ThrowError(String::NewFromUtf8Literal(this, message));
1047 }
1049
1057
1065
1066 using GCCallback = void (*)(Isolate* isolate, GCType type,
1067 GCCallbackFlags flags);
1068 using GCCallbackWithData = void (*)(Isolate* isolate, GCType type,
1069 GCCallbackFlags flags, void* data);
1070
1082 GCType gc_type_filter = kGCTypeAll);
1083
1089 void AddGCPrologueCallback(GCCallbackWithData callback, void* data = nullptr,
1090 GCType gc_type_filter = kGCTypeAll);
1091
1099
1106
1114 GCType gc_type_filter = kGCTypeAll);
1115
1121 void AddGCEpilogueCallback(GCCallbackWithData callback, void* data = nullptr,
1122 GCType gc_type_filter = kGCTypeAll);
1123
1131
1138 void* data = nullptr);
1139
1148
1160 "Set the heap on Isolate creation using CreateParams instead.")
1161 void AttachCppHeap(CppHeap*);
1162
1169 "Set the heap on Isolate creation using CreateParams instead.")
1170 void DetachCppHeap();
1171
1176 CppHeap* GetCppHeap() const;
1177
1181 enum class AtomicsWaitEvent {
1183 kStartWait,
1185 kWokenUp,
1187 kTimedOut,
1189 kTerminatedExecution,
1191 kAPIStopped,
1193 kNotEqual
1194 };
1195
1201 public:
1216 void Wake();
1217 };
1218
1243 Local<SharedArrayBuffer> array_buffer,
1244 size_t offset_in_bytes, int64_t value,
1245 double timeout_in_ms,
1246 AtomicsWaitWakeHandle* stop_handle,
1247 void* data);
1248
1256
1258
1267
1276
1286
1302
1311 void RequestInterrupt(InterruptCallback callback, void* data);
1312
1319
1330
1342 StackState stack_state);
1343
1348
1356
1361
1370
1375
1381
1387
1396
1404
1409
1413 void EnqueueMicrotask(MicrotaskCallback callback, void* data = nullptr);
1414
1419
1424
1439 MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
1440
1445 MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
1446
1451
1457
1466
1477 const std::shared_ptr<metrics::Recorder>& metrics_recorder);
1478
1485
1491
1501 int ContextDisposedNotification(bool dependant_context = true);
1502
1507 V8_DEPRECATE_SOON("Use SetPriority(Priority::kUserBlocking) instead")
1508 void IsolateInForegroundNotification();
1509
1514 V8_DEPRECATE_SOON("Use SetPriority(Priority::kBestEffort) instead")
1515 void IsolateInBackgroundNotification();
1516
1521 void SetPriority(Priority priority);
1522
1535 void SetIsLoading(bool is_loading);
1536
1541 void IncreaseHeapLimitForDebugging();
1542
1546 void RestoreOriginalHeapLimit();
1547
1552 bool IsHeapLimitIncreasedForDebugging();
1553
1576 void SetJitCodeEventHandler(JitCodeEventOptions options,
1577 JitCodeEventHandler event_handler);
1578
1588 void SetStackLimit(uintptr_t stack_limit);
1589
1605 void GetCodeRange(void** start, size_t* length_in_bytes);
1606
1611 void GetEmbeddedCodeRange(const void** start, size_t* length_in_bytes);
1612
1616 JSEntryStubs GetJSEntryStubs();
1617
1618 static constexpr size_t kMinCodePagesBufferSize = 32;
1619
1633 size_t CopyCodePages(size_t capacity, MemoryRange* code_pages_out);
1634
1636 void SetFatalErrorHandler(FatalErrorCallback that);
1637
1639 void SetOOMErrorHandler(OOMErrorCallback that);
1640
1646 void AddNearHeapLimitCallback(NearHeapLimitCallback callback, void* data);
1647
1655 void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback,
1656 size_t heap_limit);
1657
1664 void AutomaticallyRestoreInitialHeapLimit(double threshold_percent = 0.5);
1665
1670 void SetModifyCodeGenerationFromStringsCallback(
1672
1677 void SetAllowWasmCodeGenerationCallback(
1679
1684 void SetWasmModuleCallback(ExtensionCallback callback);
1685 void SetWasmInstanceCallback(ExtensionCallback callback);
1686
1687 void SetWasmStreamingCallback(WasmStreamingCallback callback);
1688
1689 void SetWasmAsyncResolvePromiseCallback(
1691
1692 void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
1693
1694 void SetWasmImportedStringsEnabledCallback(
1696
1697 void SetSharedArrayBufferConstructorEnabledCallback(
1699
1700 void SetWasmJSPIEnabledCallback(WasmJSPIEnabledCallback callback);
1701
1707 "Will be removed, use ScriptCompiler::CompileOptions for enabling the "
1708 "compile hints magic comments")
1709 void SetJavaScriptCompileHintsMagicEnabledCallback(
1711
1717 void InstallConditionalFeatures(Local<Context> context);
1718
1723 bool IsDead();
1724
1734 bool AddMessageListener(MessageCallback that,
1735 Local<Value> data = Local<Value>());
1736
1748 bool AddMessageListenerWithErrorLevel(MessageCallback that,
1749 int message_levels,
1750 Local<Value> data = Local<Value>());
1751
1755 void RemoveMessageListeners(MessageCallback that);
1756
1758 void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
1759
1764 void SetCaptureStackTraceForUncaughtExceptions(
1765 bool capture, int frame_limit = 10,
1766 StackTrace::StackTraceOptions options = StackTrace::kOverview);
1767
1772 bool IsInUse();
1773
1779 void SetAllowAtomicsWait(bool allow);
1780
1794 enum class TimeZoneDetection { kSkip, kRedetect };
1795
1807 TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip);
1808
1819
1824 std::string GetDefaultLocale();
1825
1826 Isolate() = delete;
1827 ~Isolate() = delete;
1828 Isolate(const Isolate&) = delete;
1829 Isolate& operator=(const Isolate&) = delete;
1830 // Deleting operator new and delete here is allowed as ctor and dtor is also
1831 // deleted.
1832 void* operator new(size_t size) = delete;
1833 void* operator new[](size_t size) = delete;
1834 void operator delete(void*, size_t) = delete;
1835 void operator delete[](void*, size_t) = delete;
1836
1837 private:
1838 template <class K, class V, class Traits>
1841
1843 size_t index);
1844 int64_t AdjustAmountOfExternalAllocatedMemoryImpl(int64_t change_in_bytes);
1845 void HandleExternalMemoryInterrupt();
1846};
1847
1848void Isolate::SetData(uint32_t slot, void* data) {
1849 using I = internal::Internals;
1850 I::SetEmbedderData(this, slot, data);
1851}
1852
1853void* Isolate::GetData(uint32_t slot) {
1854 using I = internal::Internals;
1855 return I::GetEmbedderData(this, slot);
1856}
1857
1858uint32_t Isolate::GetNumberOfDataSlots() {
1859 using I = internal::Internals;
1860 return I::kNumIsolateDataSlots;
1861}
1862
1863template <class T>
1864MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
1865 if (auto repr = GetDataFromSnapshotOnce(index);
1866 repr != internal::ValueHelper::kEmpty) {
1867 internal::PerformCastCheck(internal::ValueHelper::ReprAsValue<T>(repr));
1868 return Local<T>::FromRepr(repr);
1869 }
1870 return {};
1871}
1872
1873} // namespace v8
1874
1875#endif // INCLUDE_V8_ISOLATE_H_
Definition: v8-array-buffer.h:136
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:953
Definition: v8-statistics.h:183
Definition: v8-statistics.h:140
Definition: v8-isolate.h:206
static IsolateGroup Create()
IsolateGroup & operator=(const IsolateGroup &)=delete
static IsolateGroup GetDefault()
bool operator!=(const IsolateGroup &other) const
Definition: v8-isolate.h:240
IsolateGroup(const IsolateGroup &)=delete
IsolateGroup(IsolateGroup &&other)
bool operator==(const IsolateGroup &other) const
Definition: v8-isolate.h:236
static bool CanCreateNewGroups()
IsolateGroup & operator=(IsolateGroup &&other)
Definition: v8-isolate.h:396
AllowJavascriptExecutionScope(const AllowJavascriptExecutionScope &)=delete
AllowJavascriptExecutionScope & operator=(const AllowJavascriptExecutionScope &)=delete
Definition: v8-isolate.h:1200
DisallowJavascriptExecutionScope(Isolate *isolate, OnFailure on_failure)
DisallowJavascriptExecutionScope(const DisallowJavascriptExecutionScope &)=delete
DisallowJavascriptExecutionScope & operator=(const DisallowJavascriptExecutionScope &)=delete
@ CRASH_ON_FAILURE
Definition: v8-isolate.h:376
Definition: v8-isolate.h:355
Scope(Isolate *isolate)
Definition: v8-isolate.h:357
Scope(const Scope &)=delete
~Scope()
Definition: v8-isolate.h:361
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:261
int GetStackTraceLimit()
void RemoveGCEpilogueCallback(GCCallback callback)
void AddGCPrologueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics *object_statistics)
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:1257
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()
static Isolate * New(const IsolateGroup &group, const CreateParams &params)
TimeZoneDetection
Definition: v8-isolate.h:1794
void RequestGarbageCollectionForTesting(GarbageCollectionType type)
GarbageCollectionType
Definition: v8-isolate.h:442
@ kFullGarbageCollection
Definition: v8-isolate.h:443
void DumpAndResetStats()
void SetHostImportModuleDynamicallyCallback(HostImportModuleDynamicallyCallback callback)
void(*)(Isolate *isolate, GCType type, GCCallbackFlags flags) GCCallback
Definition: v8-isolate.h:1067
bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics *object_statistics, size_t type_index)
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:652
void CancelTerminateExecution()
void(*)(Isolate *isolate, GCType type, GCCallbackFlags flags, void *data) GCCallbackWithData
Definition: v8-isolate.h:1069
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 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
std::string GetDefaultLocale()
void PerformMicrotaskCheckpoint()
AtomicsWaitEvent
Definition: v8-isolate.h:1181
void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback)
void LowMemoryNotification()
Priority
Definition: v8-isolate.h:637
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:1247
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:626
bool(*)(Isolate *) AbortOnUncaughtExceptionCallback
Definition: v8-isolate.h:738
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)
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)
IsolateGroup GetGroup() const
void SetGetExternallyAllocatedMemoryInBytesCallback(GetExternallyAllocatedMemoryInBytesCallback callback)
void Enter()
UseCounterFeature
Definition: v8-isolate.h:455
bool IsExecutionTerminating()
~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: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:117
Definition: v8-snapshot.h:21
Definition: v8-value.h:32
Definition: v8-internal.h:794
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1579
Definition: v8-metrics.h:186
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: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:133
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
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:175
MeasureMemoryExecution
Definition: v8-statistics.h:43
int *(*)(const char *name) CounterLookupCallback
Definition: v8-callbacks.h:211
bool(*)(Isolate *isolate, Local< Object > obj) IsJSApiWrapperNativeErrorCallback
Definition: v8-callbacks.h:454
Definition: v8-isolate.h:266
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