v8 14.1.146 (node 25.0.0)
V8 is Google's open source JavaScript engine
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;
40
41namespace internal {
42class MicrotaskQueue;
43class ThreadLocalTop;
44} // namespace internal
45
46namespace metrics {
47class Recorder;
48} // namespace metrics
49
50/**
51 * A set of constraints that specifies the limits of the runtime's memory use.
52 * You must set the heap size before initializing the VM - the size cannot be
53 * adjusted after the VM is initialized.
54 *
55 * If you are using threads then you should hold the V8::Locker lock while
56 * setting the stack limit and you must set a non-default stack limit separately
57 * for each thread.
58 *
59 * The arguments for set_max_semi_space_size, set_max_old_space_size,
60 * set_max_executable_size, set_code_range_size specify limits in MB.
61 *
62 * The argument for set_max_semi_space_size_in_kb is in KB.
63 */
65 public:
66 /**
67 * Configures the constraints with reasonable default values based on the
68 * provided heap size limit. The heap size includes both the young and
69 * the old generation.
70 *
71 * \param initial_heap_size_in_bytes The initial heap size or zero.
72 * By default V8 starts with a small heap and dynamically grows it to
73 * match the set of live objects. This may lead to ineffective
74 * garbage collections at startup if the live set is large.
75 * Setting the initial heap size avoids such garbage collections.
76 * Note that this does not affect young generation garbage collections.
77 *
78 * \param maximum_heap_size_in_bytes The hard limit for the heap size.
79 * When the heap size approaches this limit, V8 will perform series of
80 * garbage collections and invoke the NearHeapLimitCallback. If the garbage
81 * collections do not help and the callback does not increase the limit,
82 * then V8 will crash with V8::FatalProcessOutOfMemory.
83 */
84 void ConfigureDefaultsFromHeapSize(size_t initial_heap_size_in_bytes,
85 size_t maximum_heap_size_in_bytes);
86
87 /**
88 * Configures the constraints with reasonable default values based on the
89 * capabilities of the current device the VM is running on.
90 *
91 * \param physical_memory The total amount of physical memory on the current
92 * device, in bytes.
93 * \param virtual_memory_limit The amount of virtual memory on the current
94 * device, in bytes, or zero, if there is no limit.
95 */
96 void ConfigureDefaults(uint64_t physical_memory,
97 uint64_t virtual_memory_limit);
98
99 /**
100 * The address beyond which the VM's stack may not grow.
101 */
102 uint32_t* stack_limit() const { return stack_limit_; }
103 void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
104
105 /**
106 * The amount of virtual memory reserved for generated code. This is relevant
107 * for 64-bit architectures that rely on code range for calls in code.
108 *
109 * When V8_COMPRESS_POINTERS_IN_SHARED_CAGE is defined, there is a shared
110 * process-wide code range that is lazily initialized. This value is used to
111 * configure that shared code range when the first Isolate is
112 * created. Subsequent Isolates ignore this value.
113 */
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
117 /**
118 * The maximum size of the old generation.
119 * When the old generation approaches this limit, V8 will perform series of
120 * garbage collections and invoke the NearHeapLimitCallback.
121 * If the garbage collections do not help and the callback does not
122 * increase the limit, then V8 will crash with V8::FatalProcessOutOfMemory.
123 */
125 return max_old_generation_size_;
126 }
128 max_old_generation_size_ = limit;
129 }
130
131 /**
132 * The maximum size of the young generation, which consists of two semi-spaces
133 * and a large object space. This affects frequency of Scavenge garbage
134 * collections and should be typically much smaller that the old generation.
135 */
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
172/**
173 * Memory pressure level for the MemoryPressureNotification.
174 * kNone hints V8 that there is no memory pressure.
175 * kModerate hints V8 to speed up incremental garbage collection at the cost of
176 * of higher latency due to garbage collection pauses.
177 * kCritical hints V8 to free memory as soon as possible. Garbage collection
178 * pauses at this level will be large.
179 */
181
182/**
183 * Signal for dependants of contexts. Useful for
184 * `ContextDisposedNotification()` to implement different strategies.
185 */
187 /** Context has no dependants. These are usually top-level contexts. */
189 /** Context has some dependants, i.e., it may depend on other contexts. This
190 is usually the case for inner contexts. */
192};
193
194/**
195 * Indicator for the stack state.
196 */
197using StackState = cppgc::EmbedderStackState;
198
199/**
200 * The set of V8 isolates in a process is partitioned into groups. Each group
201 * has its own sandbox (if V8 was configured with support for the sandbox) and
202 * pointer-compression cage (if configured with pointer compression).
203 *
204 * By default, all isolates are placed in the same group. This is the most
205 * efficient configuration in terms of speed and memory use. However, with
206 * pointer compression enabled, total heap usage of isolates in a group
207 * cannot exceed 4 GB, not counting array buffers and other off-heap storage.
208 * Using multiple isolate groups can allow embedders to allocate more than 4GB
209 * of objects with pointer compression enabled, if the embedder's use case can
210 * span multiple isolates.
211 *
212 * Creating an isolate group reserves a range of virtual memory addresses. A
213 * group's memory mapping will be released when the last isolate in the group is
214 * disposed, and there are no more live IsolateGroup objects that refer to it.
215 *
216 * Note that Isolate groups are reference counted, and
217 * the IsolateGroup type is a reference to one.
218 *
219 * Note that it's not going to be possible to pass shared JS objects
220 * across IsolateGroup boundary.
221 *
222 */
224 public:
225 /**
226 * Get the default isolate group. If this V8's build configuration only
227 * supports a single group, this is a reference to that single group.
228 * Otherwise this is a group like any other, distinguished only
229 * in that it is the first group.
230 */
232
233 /**
234 * Return true if new isolate groups can be created at run-time, or false if
235 * all isolates must be in the same group.
236 */
237 static bool CanCreateNewGroups();
238
239 /**
240 * Create a new isolate group. If this V8's build configuration only supports
241 * a single group, abort.
242 */
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
262 /**
263 * Whether the sandbox of the isolate group contains a given pointer.
264 * Will always return true if the sandbox is not enabled.
265 */
266 bool SandboxContains(void* pointer) const;
268#else
269 V8_INLINE bool SandboxContains(void* pointer) const { return true; }
270#endif
271
272 private:
273 friend class Isolate;
274 friend class ArrayBuffer::Allocator;
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
282/**
283 * Isolate represents an isolated instance of the V8 engine. V8 isolates have
284 * completely separate states. Objects from one isolate must not be used in
285 * other isolates. The embedder can create multiple isolates and use them in
286 * parallel in multiple threads. An isolate can be entered by at most one
287 * thread at any given time. The Locker/Unlocker API must be used to
288 * synchronize.
289 */
291 public:
292 /**
293 * Initial configuration parameters for a new Isolate.
294 */
298
300
301 /**
302 * Allows the host application to provide the address of a function that is
303 * notified each time code is added, moved or removed.
304 */
305 JitCodeEventHandler code_event_handler = nullptr;
306
307 /**
308 * ResourceConstraints to use for the new Isolate.
309 */
311
312 /**
313 * Explicitly specify a startup snapshot blob. The embedder owns the blob.
314 * The embedder *must* ensure that the snapshot is from a trusted source.
315 */
316 const StartupData* snapshot_blob = nullptr;
317
318 /**
319 * Enables the host application to provide a mechanism for recording
320 * statistics counters.
321 */
322 CounterLookupCallback counter_lookup_callback = nullptr;
323
324 /**
325 * Enables the host application to provide a mechanism for recording
326 * histograms. The CreateHistogram function returns a
327 * histogram which will later be passed to the AddHistogramSample
328 * function.
329 */
330 CreateHistogramCallback create_histogram_callback = nullptr;
331 AddHistogramSampleCallback add_histogram_sample_callback = nullptr;
332
333 /**
334 * The ArrayBuffer::Allocator to use for allocating and freeing the backing
335 * store of ArrayBuffers.
336 *
337 * If the shared_ptr version is used, the Isolate instance and every
338 * |BackingStore| allocated using this allocator hold a std::shared_ptr
339 * to the allocator, in order to facilitate lifetime
340 * management for the allocator instance.
341 */
344
345 /**
346 * Specifies an optional nullptr-terminated array of raw addresses in the
347 * embedder that V8 can match against during serialization and use for
348 * deserialization. This array and its content must stay valid for the
349 * entire lifetime of the isolate.
350 */
351 const intptr_t* external_references = nullptr;
352
353 /**
354 * Whether calling Atomics.wait (a function that may block) is allowed in
355 * this isolate. This can also be configured via SetAllowAtomicsWait.
356 */
358
359 /**
360 * The following parameters describe the offsets for addressing type info
361 * for wrapped API objects and are used by the fast C API
362 * (for details see v8-fast-api-calls.h).
363 */
364 V8_DEPRECATE_SOON("This field is unused.")
366 V8_DEPRECATE_SOON("This field is unused.")
368
369 /**
370 * Callbacks to invoke in case of fatal or OOM errors.
371 */
372 FatalErrorCallback fatal_error_callback = nullptr;
373 OOMErrorCallback oom_error_callback = nullptr;
374
375 /**
376 * A CppHeap used to construct the Isolate. V8 takes ownership of the
377 * CppHeap passed this way.
378 */
379 CppHeap* cpp_heap = nullptr;
380 };
381
382 /**
383 * Stack-allocated class which sets the isolate for all operations
384 * executed within a local scope.
385 */
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
402 /**
403 * Assert that no Javascript code is invoked.
404 */
406 public:
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
424 /**
425 * Introduce exception to DisallowJavascriptExecutionScope.
426 */
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
445 /**
446 * Do not run microtasks while this scope is active, even if microtasks are
447 * automatically executed otherwise.
448 */
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
469 /**
470 * Types of garbage collections that can be requested via
471 * RequestGarbageCollectionForTesting.
472 */
476 };
477
478 /**
479 * Features reported via the SetUseCounterCallback callback. Do not change
480 * assigned numbers of existing items; add new features to the end of this
481 * list.
482 * Dead features can be marked `V8_DEPRECATE_SOON`, then `V8_DEPRECATED`, and
483 * then finally be renamed to `kOBSOLETE_...` to stop embedders from using
484 * them.
485 */
578 kInvalidatedArrayConstructorProtector V8_DEPRECATE_SOON(
579 "The ArrayConstructorProtector has been removed") = 91,
615 kWasmGC = 127,
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),
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
706 /**
707 * Allocates a new isolate but does not initialize it. Does not change the
708 * currently entered isolate.
709 *
710 * Only Isolate::GetData() and Isolate::SetData(), which access the
711 * embedder-controlled parts of the isolate, as well as Isolate::GetGroup(),
712 * are allowed to be called on the uninitialized isolate. To initialize the
713 * isolate, call `Isolate::Initialize()` or initialize a `SnapshotCreator`.
714 *
715 * When an isolate is no longer used its resources should be freed
716 * by calling Dispose(). Using the delete operator is not allowed.
717 *
718 * V8::Initialize() must have run prior to this.
719 */
720 static Isolate* Allocate();
721 static Isolate* Allocate(const IsolateGroup& group);
722
723 /**
724 * Return the group for this isolate.
725 */
727
728 /**
729 * Initialize an Isolate previously allocated by Isolate::Allocate().
730 */
731 static void Initialize(Isolate* isolate, const CreateParams& params);
732
733 /**
734 * Creates a new isolate. Does not change the currently entered
735 * isolate.
736 *
737 * When an isolate is no longer used its resources should be freed
738 * by calling Dispose(). Using the delete operator is not allowed.
739 *
740 * V8::Initialize() must have run prior to this.
741 */
742 static Isolate* New(const CreateParams& params);
743 static Isolate* New(const IsolateGroup& group, const CreateParams& params);
744
745 /**
746 * Returns the entered isolate for the current thread or NULL in
747 * case there is no current isolate.
748 *
749 * This method must not be invoked before V8::Initialize() was invoked.
750 */
752
753 /**
754 * Returns the entered isolate for the current thread or NULL in
755 * case there is no current isolate.
756 *
757 * No checks are performed by this method.
758 */
760
761 /**
762 * Return true if this isolate is currently active.
763 **/
764 bool IsCurrent() const;
765
766 /**
767 * Clears the set of objects held strongly by the heap. This set of
768 * objects are originally built when a WeakRef is created or
769 * successfully dereferenced.
770 *
771 * This is invoked automatically after microtasks are run. See
772 * MicrotasksPolicy for when microtasks are run.
773 *
774 * This needs to be manually invoked only if the embedder is manually running
775 * microtasks via a custom MicrotaskQueue class's PerformCheckpoint. In that
776 * case, it is the embedder's responsibility to make this call at a time which
777 * does not interrupt synchronous ECMAScript code execution.
778 */
780
781 /**
782 * Custom callback used by embedders to help V8 determine if it should abort
783 * when it throws and no internal handler is predicted to catch the
784 * exception. If --abort-on-uncaught-exception is used on the command line,
785 * then V8 will abort if either:
786 * - no custom callback is set.
787 * - the custom callback set returns true.
788 * Otherwise, the custom callback will not be called and V8 will not abort.
789 */
790 using AbortOnUncaughtExceptionCallback = bool (*)(Isolate*);
792 AbortOnUncaughtExceptionCallback callback);
793
794 /**
795 * This specifies the callback called by the upcoming dynamic
796 * import() language feature to load modules.
797 */
799 HostImportModuleDynamicallyCallback callback);
800
801 /**
802 * This specifies the callback called by the upcoming dynamic
803 * import() and import.source() language feature to load modules.
804 *
805 * This API is experimental and is expected to be changed or removed in the
806 * future. The callback is currently only called when for source-phase
807 * imports. Evaluation-phase imports use the existing
808 * HostImportModuleDynamicallyCallback callback.
809 */
811 HostImportModuleWithPhaseDynamicallyCallback callback);
812
813 /**
814 * This specifies the callback called by the upcoming import.meta
815 * language feature to retrieve host-defined meta data for a module.
816 */
818 HostInitializeImportMetaObjectCallback callback);
819
820 /**
821 * This specifies the callback called by the upcoming ShadowRealm
822 * construction language feature to retrieve host created globals.
823 */
825 HostCreateShadowRealmContextCallback callback);
826
827 /**
828 * Set the callback that checks whether a Error.isError should return true for
829 * a JSApiWrapper object, i.e. whether it represents a native JS error. For
830 * example, in an HTML embedder, DOMExceptions are considered native errors.
831 */
833 IsJSApiWrapperNativeErrorCallback callback);
834
835 /**
836 * This specifies the callback called when the stack property of Error
837 * is accessed.
838 */
839 void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback);
840
841 /**
842 * Get the stackTraceLimit property of Error.
843 */
845
846#if defined(V8_OS_WIN)
847 /**
848 * This specifies the callback called when an ETW tracing session starts.
849 */
850 V8_DEPRECATE_SOON("Use SetFilterETWSessionByURL2Callback instead")
854#endif // V8_OS_WIN
855
856 /**
857 * Optional notification that the system is running low on memory.
858 * V8 uses these notifications to guide heuristics.
859 * It is allowed to call this function from another thread while
860 * the isolate is executing long running JavaScript code.
861 */
863
864 /**
865 * Optional request from the embedder to tune v8 towards energy efficiency
866 * rather than speed if `battery_saver_mode_enabled` is true, because the
867 * embedder is in battery saver mode. If false, the correct tuning is left
868 * to v8 to decide.
869 */
870 void SetBatterySaverMode(bool battery_saver_mode_enabled);
871
872 /**
873 * Optional request from the embedder to tune v8 towards memory efficiency
874 * rather than speed if `memory_saver_mode_enabled` is true, because the
875 * embedder is in memory saver mode. If false, the correct tuning is left
876 * to v8 to decide.
877 */
878 void SetMemorySaverMode(bool memory_saver_mode_enabled);
879
880 /**
881 * Drop non-essential caches. Should only be called from testing code.
882 * The method can potentially block for a long time and does not necessarily
883 * trigger GC.
884 */
886
887 /**
888 * Methods below this point require holding a lock (using Locker) in
889 * a multi-threaded environment.
890 */
891
892 /**
893 * Sets this isolate as the entered one for the current thread.
894 * Saves the previously entered one (if any), so that it can be
895 * restored when exiting. Re-entering an isolate is allowed.
896 */
897 void Enter();
898
899 /**
900 * Exits this isolate by restoring the previously entered one in the
901 * current thread. The isolate may still stay the same, if it was
902 * entered more than once.
903 *
904 * Requires: this == Isolate::GetCurrent().
905 */
906 void Exit();
907
908 /**
909 * Deinitializes and frees the isolate. The isolate must not be entered by any
910 * thread to be disposable.
911 */
912 void Dispose();
913
914 /**
915 * Deinitializes the isolate, but does not free the address. The isolate must
916 * not be entered by any thread to be deinitializable. Embedders must call
917 * Isolate::Free() to free the isolate afterwards.
918 */
920
921 /**
922 * Frees the memory allocated for the isolate. Can only be called after the
923 * Isolate has already been deinitialized with Isolate::Deinitialize(). After
924 * the isolate is freed, the next call to Isolate::New() or
925 * Isolate::Allocate() might return the same address that just get freed.
926 */
927 static void Free(Isolate* isolate);
928
929 /**
930 * Dumps activated low-level V8 internal stats. This can be used instead
931 * of performing a full isolate disposal.
932 */
934
935 /**
936 * Discards all V8 thread-specific data for the Isolate. Should be used
937 * if a thread is terminating and it has used an Isolate that will outlive
938 * the thread -- all thread-specific data for an Isolate is discarded when
939 * an Isolate is disposed so this call is pointless if an Isolate is about
940 * to be Disposed.
941 */
943
944 /**
945 * Associate embedder-specific data with the isolate. |slot| has to be
946 * between 0 and GetNumberOfDataSlots() - 1.
947 */
948 V8_INLINE void SetData(uint32_t slot, void* data);
949
950 /**
951 * Retrieve embedder-specific data from the isolate.
952 * Returns NULL if SetData has never been called for the given |slot|.
953 */
954 V8_INLINE void* GetData(uint32_t slot);
955
956 /**
957 * Returns the maximum number of available embedder data slots. Valid slots
958 * are in the range of 0 - GetNumberOfDataSlots() - 1.
959 */
960 V8_INLINE static uint32_t GetNumberOfDataSlots();
961
962 /**
963 * Return data that was previously attached to the isolate snapshot via
964 * SnapshotCreator, and removes the reference to it.
965 * Repeated call with the same index returns an empty MaybeLocal.
966 */
967 template <class T>
969
970 /**
971 * Returns the value that was set or restored by
972 * SetContinuationPreservedEmbedderData(), if any.
973 */
974 V8_DEPRECATED("Use GetContinuationPreservedEmbedderDataV2 instead")
976
977 /**
978 * Sets a value that will be stored on continuations and reset while the
979 * continuation runs.
980 */
981 V8_DEPRECATED("Use SetContinuationPreservedEmbedderDataV2 instead")
983
984 /**
985 * Returns the value set by `SetContinuationPreservedEmbedderDataV2()` or
986 * restored during microtask execution for the currently running continuation,
987 * if any. Returns undefiend if no continuation preserved embedder data was
988 * set.
989 */
991
992 /**
993 * Sets a value that will be stored on continuations and restored while the
994 * continuation runs. If `data` is empty, the continuation preserved embedder
995 * data is set to undefined.
996 */
998
999 /**
1000 * Get statistics about the heap memory usage.
1001 */
1002 void GetHeapStatistics(HeapStatistics* heap_statistics);
1003
1004 /**
1005 * Returns the number of spaces in the heap.
1006 */
1008
1009 /**
1010 * Get the memory usage of a space in the heap.
1011 *
1012 * \param space_statistics The HeapSpaceStatistics object to fill in
1013 * statistics.
1014 * \param index The index of the space to get statistics from, which ranges
1015 * from 0 to NumberOfHeapSpaces() - 1.
1016 * \returns true on success.
1017 */
1019 size_t index);
1020
1021 /**
1022 * Returns the number of types of objects tracked in the heap at GC.
1023 */
1025
1026 /**
1027 * Get statistics about objects in the heap.
1028 *
1029 * \param object_statistics The HeapObjectStatistics object to fill in
1030 * statistics of objects of given type, which were live in the previous GC.
1031 * \param type_index The index of the type of object to fill details about,
1032 * which ranges from 0 to NumberOfTrackedHeapObjectTypes() - 1.
1033 * \returns true on success.
1034 */
1036 size_t type_index);
1037
1038 /**
1039 * Get statistics about code and its metadata in the heap.
1040 *
1041 * \param object_statistics The HeapCodeStatistics object to fill in
1042 * statistics of code, bytecode and their metadata.
1043 * \returns true on success.
1044 */
1046
1047 /**
1048 * This API is experimental and may change significantly.
1049 *
1050 * Enqueues a memory measurement request and invokes the delegate with the
1051 * results.
1052 *
1053 * \param delegate the delegate that defines which contexts to measure and
1054 * reports the results.
1055 *
1056 * \param execution promptness executing the memory measurement.
1057 * The kEager value is expected to be used only in tests.
1058 */
1060 std::unique_ptr<MeasureMemoryDelegate> delegate,
1062
1063 /**
1064 * Get a call stack sample from the isolate.
1065 * \param state Execution state.
1066 * \param frames Caller allocated buffer to store stack frames.
1067 * \param frames_limit Maximum number of frames to capture. The buffer must
1068 * be large enough to hold the number of frames.
1069 * \param sample_info The sample info is filled up by the function
1070 * provides number of actual captured stack frames and
1071 * the current VM state.
1072 * \note GetStackSample should only be called when the JS thread is paused or
1073 * interrupted. Otherwise the behavior is undefined.
1074 */
1075 void GetStackSample(const RegisterState& state, void** frames,
1076 size_t frames_limit, SampleInfo* sample_info);
1077
1078 /**
1079 * Adjusts the amount of registered external memory.
1080 *
1081 * \param change_in_bytes the change in externally allocated memory that is
1082 * kept alive by JavaScript objects.
1083 * \returns the adjusted value.
1084 */
1085 V8_DEPRECATE_SOON("Use ExternalMemoryAccounter instead.")
1086 int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
1087
1088 /**
1089 * Returns heap profiler for this isolate. Will return NULL until the isolate
1090 * is initialized.
1091 */
1093
1094 /**
1095 * Tells the VM whether the embedder is idle or not.
1096 */
1097 void SetIdle(bool is_idle);
1098
1099 /** Returns the ArrayBuffer::Allocator used in this isolate. */
1101
1102 /** Returns true if this isolate has a current context. */
1104
1105 /**
1106 * Returns the context of the currently running JavaScript, or the context
1107 * on the top of the stack if no JavaScript is running.
1108 */
1110
1111 /**
1112 * Returns either the last context entered through V8's C++ API, or the
1113 * context of the currently running microtask while processing microtasks.
1114 * If a context is entered while executing a microtask, that context is
1115 * returned.
1116 */
1118
1119 /**
1120 * Returns the Context that corresponds to the Incumbent realm in HTML spec.
1121 * https://html.spec.whatwg.org/multipage/webappapis.html#incumbent
1122 */
1124
1125 /**
1126 * Returns the host defined options set for currently running script or
1127 * module, if available.
1128 */
1130
1131 /**
1132 * Schedules a v8::Exception::Error with the given message.
1133 * See ThrowException for more details. Templatized to provide compile-time
1134 * errors in case of too long strings (see v8::String::NewFromUtf8Literal).
1135 */
1136 template <int N>
1137 Local<Value> ThrowError(const char (&message)[N]) {
1138 return ThrowError(String::NewFromUtf8Literal(this, message));
1139 }
1141
1142 /**
1143 * Schedules an exception to be thrown when returning to JavaScript. When an
1144 * exception has been scheduled it is illegal to invoke any JavaScript
1145 * operation; the caller must return immediately and only after the exception
1146 * has been handled does it become legal to invoke JavaScript operations.
1147 */
1149
1150 /**
1151 * Returns true if an exception was thrown but not processed yet by an
1152 * exception handler on JavaScript side or by v8::TryCatch handler.
1153 *
1154 * This is an experimental feature and may still change significantly.
1155 */
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
1163 /**
1164 * Enables the host application to receive a notification before a
1165 * garbage collection.
1166 *
1167 * \param callback The callback to be invoked. The callback is allowed to
1168 * allocate but invocation is not re-entrant: a callback triggering
1169 * garbage collection will not be called again. JS execution is prohibited
1170 * from these callbacks. A single callback may only be registered once.
1171 * \param gc_type_filter A filter in case it should be applied.
1172 */
1173 void AddGCPrologueCallback(GCCallback callback,
1174 GCType gc_type_filter = kGCTypeAll);
1175
1176 /**
1177 * \copydoc AddGCPrologueCallback(GCCallback, GCType)
1178 *
1179 * \param data Additional data that should be passed to the callback.
1180 */
1181 void AddGCPrologueCallback(GCCallbackWithData callback, void* data = nullptr,
1182 GCType gc_type_filter = kGCTypeAll);
1183
1184 /**
1185 * This function removes a callback which was added by
1186 * `AddGCPrologueCallback`.
1187 *
1188 * \param callback the callback to remove.
1189 */
1190 void RemoveGCPrologueCallback(GCCallback callback);
1191
1192 /**
1193 * \copydoc AddGCPrologueCallback(GCCallback)
1194 *
1195 * \param data Additional data that was used to install the callback.
1196 */
1197 void RemoveGCPrologueCallback(GCCallbackWithData, void* data = nullptr);
1198
1199 /**
1200 * Enables the host application to receive a notification after a
1201 * garbage collection.
1202 *
1203 * \copydetails AddGCPrologueCallback(GCCallback, GCType)
1204 */
1205 void AddGCEpilogueCallback(GCCallback callback,
1206 GCType gc_type_filter = kGCTypeAll);
1207
1208 /**
1209 * \copydoc AddGCEpilogueCallback(GCCallback, GCType)
1210 *
1211 * \param data Additional data that should be passed to the callback.
1212 */
1213 void AddGCEpilogueCallback(GCCallbackWithData callback, void* data = nullptr,
1214 GCType gc_type_filter = kGCTypeAll);
1215
1216 /**
1217 * This function removes a callback which was added by
1218 * `AddGCEpilogueCallback`.
1219 *
1220 * \param callback the callback to remove.
1221 */
1222 void RemoveGCEpilogueCallback(GCCallback callback);
1223
1224 /**
1225 * \copydoc RemoveGCEpilogueCallback(GCCallback)
1226 *
1227 * \param data Additional data that was used to install the callback.
1228 */
1229 void RemoveGCEpilogueCallback(GCCallbackWithData callback,
1230 void* data = nullptr);
1231
1232 /**
1233 * Sets an embedder roots handle that V8 should consider when performing
1234 * non-unified heap garbage collections. The intended use case is for setting
1235 * a custom handler after invoking `AttachCppHeap()`.
1236 *
1237 * V8 does not take ownership of the handler.
1238 */
1240
1241 using ReleaseCppHeapCallback = void (*)(std::unique_ptr<CppHeap>);
1242
1243 /**
1244 * Sets a callback on the isolate that gets called when the CppHeap gets
1245 * detached. The callback can then either take ownership of the CppHeap, or
1246 * the CppHeap gets deallocated.
1247 */
1248 void SetReleaseCppHeapCallbackForTesting(ReleaseCppHeapCallback callback);
1249
1250 /**
1251 * \returns the C++ heap managed by V8. Only available if such a heap has been
1252 * attached using `AttachCppHeap()`.
1253 */
1255
1257
1258 /**
1259 * Set the callback that tells V8 how much memory is currently allocated
1260 * externally of the V8 heap. Ideally this memory is somehow connected to V8
1261 * objects and may get freed-up when the corresponding V8 objects get
1262 * collected by a V8 garbage collection.
1263 */
1265 GetExternallyAllocatedMemoryInBytesCallback callback);
1266
1267 /**
1268 * Forcefully terminate the current thread of JavaScript execution
1269 * in the given isolate.
1270 *
1271 * This method can be used by any thread even if that thread has not
1272 * acquired the V8 lock with a Locker object.
1273 */
1275
1276 /**
1277 * Is V8 terminating JavaScript execution.
1278 *
1279 * Returns true if JavaScript execution is currently terminating
1280 * because of a call to TerminateExecution. In that case there are
1281 * still JavaScript frames on the stack and the termination
1282 * exception is still active.
1283 */
1285
1286 /**
1287 * Resume execution capability in the given isolate, whose execution
1288 * was previously forcefully terminated using TerminateExecution().
1289 *
1290 * When execution is forcefully terminated using TerminateExecution(),
1291 * the isolate can not resume execution until all JavaScript frames
1292 * have propagated the uncatchable exception which is generated. This
1293 * method allows the program embedding the engine to handle the
1294 * termination event and resume execution capability, even if
1295 * JavaScript frames remain on the stack.
1296 *
1297 * This method can be used by any thread even if that thread has not
1298 * acquired the V8 lock with a Locker object.
1299 */
1301
1302 /**
1303 * Request V8 to interrupt long running JavaScript code and invoke
1304 * the given |callback| passing the given |data| to it. After |callback|
1305 * returns control will be returned to the JavaScript code.
1306 * There may be a number of interrupt requests in flight.
1307 * Can be called from another thread without acquiring a |Locker|.
1308 * Registered |callback| must not reenter interrupted Isolate.
1309 */
1310 void RequestInterrupt(InterruptCallback callback, void* data);
1311
1312 /**
1313 * Returns true if there is ongoing background work within V8 that will
1314 * eventually post a foreground task, like asynchronous WebAssembly
1315 * compilation.
1316 */
1318
1319 /**
1320 * Request garbage collection in this Isolate. It is only valid to call this
1321 * function if --expose_gc was specified.
1322 *
1323 * This should only be used for testing purposes and not to enforce a garbage
1324 * collection schedule. It has strong negative impact on the garbage
1325 * collection performance. Use MemoryPressureNotification() instead to
1326 * influence the garbage collection schedule.
1327 */
1329
1330 /**
1331 * Request garbage collection with a specific embedderstack state in this
1332 * Isolate. It is only valid to call this function if --expose_gc was
1333 * specified.
1334 *
1335 * This should only be used for testing purposes and not to enforce a garbage
1336 * collection schedule. It has strong negative impact on the garbage
1337 * collection performance. Use MemoryPressureNotification() instead to
1338 * influence the garbage collection schedule.
1339 */
1341 StackState stack_state);
1342
1343 /**
1344 * Set the callback to invoke for logging event.
1345 */
1346 void SetEventLogger(LogEventCallback that);
1347
1348 /**
1349 * Adds a callback to notify the host application right before a script
1350 * is about to run. If a script re-enters the runtime during executing, the
1351 * BeforeCallEnteredCallback is invoked for each re-entrance.
1352 * Executing scripts inside the callback will re-trigger the callback.
1353 */
1354 void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
1355
1356 /**
1357 * Removes callback that was installed by AddBeforeCallEnteredCallback.
1358 */
1359 void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
1360
1361 /**
1362 * Adds a callback to notify the host application when a script finished
1363 * running. If a script re-enters the runtime during executing, the
1364 * CallCompletedCallback is only invoked when the outer-most script
1365 * execution ends. Executing scripts inside the callback do not trigger
1366 * further callbacks.
1367 */
1368 void AddCallCompletedCallback(CallCompletedCallback callback);
1369
1370 /**
1371 * Removes callback that was installed by AddCallCompletedCallback.
1372 */
1373 void RemoveCallCompletedCallback(CallCompletedCallback callback);
1374
1375 /**
1376 * Set the PromiseHook callback for various promise lifecycle
1377 * events.
1378 */
1379 void SetPromiseHook(PromiseHook hook);
1380
1381 /**
1382 * Set callback to notify about promise reject with no handler, or
1383 * revocation of such a previous notification once the handler is added.
1384 */
1385 void SetPromiseRejectCallback(PromiseRejectCallback callback);
1386
1387 /**
1388 * This is a part of experimental Api and might be changed without further
1389 * notice.
1390 * Do not use it.
1391 *
1392 * Set callback to notify about a new exception being thrown.
1393 */
1394 void SetExceptionPropagationCallback(ExceptionPropagationCallback callback);
1395
1396 /**
1397 * Runs the default MicrotaskQueue until it gets empty and perform other
1398 * microtask checkpoint steps, such as calling ClearKeptObjects. Asserts that
1399 * the MicrotasksPolicy is not kScoped. Any exceptions thrown by microtask
1400 * callbacks are swallowed.
1401 */
1403
1404 /**
1405 * Enqueues the callback to the default MicrotaskQueue
1406 */
1408
1409 /**
1410 * Enqueues the callback to the default MicrotaskQueue
1411 */
1412 void EnqueueMicrotask(MicrotaskCallback callback, void* data = nullptr);
1413
1414 /**
1415 * Controls how Microtasks are invoked. See MicrotasksPolicy for details.
1416 */
1418
1419 /**
1420 * Returns the policy controlling how Microtasks are invoked.
1421 */
1423
1424 /**
1425 * Adds a callback to notify the host application after
1426 * microtasks were run on the default MicrotaskQueue. The callback is
1427 * triggered by explicit RunMicrotasks call or automatic microtasks execution
1428 * (see SetMicrotaskPolicy).
1429 *
1430 * Callback will trigger even if microtasks were attempted to run,
1431 * but the microtasks queue was empty and no single microtask was actually
1432 * executed.
1433 *
1434 * Executing scripts inside the callback will not re-trigger microtasks and
1435 * the callback.
1436 */
1438 MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
1439
1440 /**
1441 * Removes callback that was installed by AddMicrotasksCompletedCallback.
1442 */
1444 MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
1445
1446 /**
1447 * Sets a callback for counting the number of times a feature of V8 is used.
1448 */
1449 void SetUseCounterCallback(UseCounterCallback callback);
1450
1451 /**
1452 * Enables the host application to provide a mechanism for recording
1453 * statistics counters.
1454 */
1455 void SetCounterFunction(CounterLookupCallback);
1456
1457 /**
1458 * Enables the host application to provide a mechanism for recording
1459 * histograms. The CreateHistogram function returns a
1460 * histogram which will later be passed to the AddHistogramSample
1461 * function.
1462 */
1463 void SetCreateHistogramFunction(CreateHistogramCallback);
1464 void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
1465
1466 /**
1467 * Enables the host application to provide a mechanism for recording
1468 * event based metrics. In order to use this interface
1469 * include/v8-metrics.h
1470 * needs to be included and the recorder needs to be derived from the
1471 * Recorder base class defined there.
1472 * This method can only be called once per isolate and must happen during
1473 * isolate initialization before background threads are spawned.
1474 */
1476 const std::shared_ptr<metrics::Recorder>& metrics_recorder);
1477
1478 /**
1479 * Enables the host application to provide a mechanism for recording a
1480 * predefined set of data as crash keys to be used in postmortem debugging in
1481 * case of a crash.
1482 */
1483 void SetAddCrashKeyCallback(AddCrashKeyCallback);
1484
1485 /**
1486 * Optional notification that the system is running low on memory.
1487 * V8 uses these notifications to attempt to free memory.
1488 */
1490
1491 /**
1492 * Optional notification that a context has been disposed. V8 uses these
1493 * notifications to guide the GC heuristic and cancel FinalizationRegistry
1494 * cleanup tasks. Returns the number of context disposals - including this one
1495 * - since the last time V8 had a chance to clean up.
1496 *
1497 * The optional parameter |dependant_context| specifies whether the disposed
1498 * context was depending on state from other contexts or not.
1499 */
1500 V8_DEPRECATE_SOON("Use version that passes ContextDependants.")
1501 int ContextDisposedNotification(bool dependant_context = true);
1502
1503 /**
1504 * Optional notification that a context has been disposed. V8 uses these
1505 * notifications to guide heuristics on e.g. GC or compilers.
1506 *
1507 * \param dependants A signal on whether this context possibly had any
1508 * dependants.
1509 */
1511
1512 /**
1513 * Optional notification that the isolate switched to the foreground.
1514 * V8 uses these notifications to guide heuristics.
1515 */
1516 V8_DEPRECATE_SOON("Use SetPriority(Priority::kUserBlocking) instead")
1518
1519 /**
1520 * Optional notification that the isolate switched to the background.
1521 * V8 uses these notifications to guide heuristics.
1522 */
1523 V8_DEPRECATE_SOON("Use SetPriority(Priority::kBestEffort) instead")
1525
1526 /**
1527 * Optional notification that the isolate changed `priority`.
1528 * V8 uses the priority value to guide heuristics.
1529 */
1530 void SetPriority(Priority priority);
1531
1532 /**
1533 * Optional notification to tell V8 whether the embedder is currently loading
1534 * resources. If the embedder uses this notification, it should call
1535 * SetIsLoading(true) when loading starts and SetIsLoading(false) when it
1536 * ends.
1537 * It's valid to call SetIsLoading(true) again while loading, which will
1538 * update the timestamp when V8 considers the load started. Calling
1539 * SetIsLoading(false) while not loading does nothing.
1540 * V8 uses these notifications to guide heuristics.
1541 * This is an unfinished experimental feature. Semantics and implementation
1542 * may change frequently.
1543 */
1544 void SetIsLoading(bool is_loading);
1545
1546 /**
1547 * Optional notification to tell V8 whether the embedder is currently frozen.
1548 * V8 uses these notifications to guide heuristics.
1549 * This is an unfinished experimental feature. Semantics and implementation
1550 * may change frequently.
1551 */
1552 void Freeze(bool is_frozen);
1553
1554 /**
1555 * Optional notification to tell V8 the current isolate is used for debugging
1556 * and requires higher heap limit.
1557 */
1559
1560 /**
1561 * Restores the original heap limit after IncreaseHeapLimitForDebugging().
1562 */
1564
1565 /**
1566 * Returns true if the heap limit was increased for debugging and the
1567 * original heap limit was not restored yet.
1568 */
1570
1571 /**
1572 * Allows the host application to provide the address of a function that is
1573 * notified each time code is added, moved or removed.
1574 *
1575 * \param options options for the JIT code event handler.
1576 * \param event_handler the JIT code event handler, which will be invoked
1577 * each time code is added, moved or removed.
1578 * \note \p event_handler won't get notified of existent code.
1579 * \note since code removal notifications are not currently issued, the
1580 * \p event_handler may get notifications of code that overlaps earlier
1581 * code notifications. This happens when code areas are reused, and the
1582 * earlier overlapping code areas should therefore be discarded.
1583 * \note the events passed to \p event_handler and the strings they point to
1584 * are not guaranteed to live past each call. The \p event_handler must
1585 * copy strings and other parameters it needs to keep around.
1586 * \note the set of events declared in JitCodeEvent::EventType is expected to
1587 * grow over time, and the JitCodeEvent structure is expected to accrue
1588 * new members. The \p event_handler function must ignore event codes
1589 * it does not recognize to maintain future compatibility.
1590 * \note Use Isolate::CreateParams to get events for code executed during
1591 * Isolate setup.
1592 */
1594 JitCodeEventHandler event_handler);
1595
1596 /**
1597 * Modifies the stack limit for this Isolate.
1598 *
1599 * \param stack_limit An address beyond which the Vm's stack may not grow.
1600 *
1601 * \note If you are using threads then you should hold the V8::Locker lock
1602 * while setting the stack limit and you must set a non-default stack
1603 * limit separately for each thread.
1604 */
1605 void SetStackLimit(uintptr_t stack_limit);
1606
1607 /**
1608 * Returns a memory range that can potentially contain jitted code. Code for
1609 * V8's 'builtins' will not be in this range if embedded builtins is enabled.
1610 *
1611 * On Win64, embedders are advised to install function table callbacks for
1612 * these ranges, as default SEH won't be able to unwind through jitted code.
1613 * The first page of the code range is reserved for the embedder and is
1614 * committed, writable, and executable, to be used to store unwind data, as
1615 * documented in
1616 * https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64.
1617 *
1618 * Might be empty on other platforms.
1619 *
1620 * https://code.google.com/p/v8/issues/detail?id=3598
1621 */
1622 void GetCodeRange(void** start, size_t* length_in_bytes);
1623
1624 /**
1625 * As GetCodeRange, but for embedded builtins (these live in a distinct
1626 * memory region from other V8 Code objects).
1627 */
1628 void GetEmbeddedCodeRange(const void** start, size_t* length_in_bytes);
1629
1630 /**
1631 * Returns the JSEntryStubs necessary for use with the Unwinder API.
1632 */
1634
1635 static constexpr size_t kMinCodePagesBufferSize = 32;
1636
1637 /**
1638 * Copies the code heap pages currently in use by V8 into |code_pages_out|.
1639 * |code_pages_out| must have at least kMinCodePagesBufferSize capacity and
1640 * must be empty.
1641 *
1642 * Signal-safe, does not allocate, does not access the V8 heap.
1643 * No code on the stack can rely on pages that might be missing.
1644 *
1645 * Returns the number of pages available to be copied, which might be greater
1646 * than |capacity|. In this case, only |capacity| pages will be copied into
1647 * |code_pages_out|. The caller should provide a bigger buffer on the next
1648 * call in order to get all available code pages, but this is not required.
1649 */
1650 size_t CopyCodePages(size_t capacity, MemoryRange* code_pages_out);
1651
1652 /** Set the callback to invoke in case of fatal errors. */
1653 void SetFatalErrorHandler(FatalErrorCallback that);
1654
1655 /** Set the callback to invoke in case of OOM errors. */
1656 void SetOOMErrorHandler(OOMErrorCallback that);
1657
1658 /**
1659 * Add a callback to invoke in case the heap size is close to the heap limit.
1660 * If multiple callbacks are added, only the most recently added callback is
1661 * invoked.
1662 */
1663 void AddNearHeapLimitCallback(NearHeapLimitCallback callback, void* data);
1664
1665 /**
1666 * Remove the given callback and restore the heap limit to the
1667 * given limit. If the given limit is zero, then it is ignored.
1668 * If the current heap size is greater than the given limit,
1669 * then the heap limit is restored to the minimal limit that
1670 * is possible for the current heap size.
1671 */
1672 void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback,
1673 size_t heap_limit);
1674
1675 /**
1676 * If the heap limit was changed by the NearHeapLimitCallback, then the
1677 * initial heap limit will be restored once the heap size falls below the
1678 * given threshold percentage of the initial heap limit.
1679 * The threshold percentage is a number in (0.0, 1.0) range.
1680 */
1681 void AutomaticallyRestoreInitialHeapLimit(double threshold_percent = 0.5);
1682
1683 /**
1684 * Set the callback to invoke to check if code generation from
1685 * strings should be allowed.
1686 */
1688 ModifyCodeGenerationFromStringsCallback2 callback);
1689
1690 /**
1691 * Set the callback to invoke to check if wasm code generation should
1692 * be allowed.
1693 */
1695 AllowWasmCodeGenerationCallback callback);
1696
1697 /**
1698 * Embedder over{ride|load} injection points for wasm APIs. The expectation
1699 * is that the embedder sets them at most once.
1700 */
1701 void SetWasmModuleCallback(ExtensionCallback callback);
1702 void SetWasmInstanceCallback(ExtensionCallback callback);
1703
1704 void SetWasmStreamingCallback(WasmStreamingCallback callback);
1705
1707 WasmAsyncResolvePromiseCallback callback);
1708
1709 void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
1710
1712 WasmImportedStringsEnabledCallback callback);
1713
1715 WasmCustomDescriptorsEnabledCallback callback);
1716
1718 SharedArrayBufferConstructorEnabledCallback callback);
1719
1720 void SetWasmJSPIEnabledCallback(WasmJSPIEnabledCallback callback);
1721
1722 /**
1723 * This function can be called by the embedder to signal V8 that the dynamic
1724 * enabling of features has finished. V8 can now set up dynamically added
1725 * features.
1726 */
1728
1729 /**
1730 * Check if V8 is dead and therefore unusable. This is the case after
1731 * fatal errors such as out-of-memory situations.
1732 */
1733 bool IsDead();
1734
1735 /**
1736 * Adds a message listener (errors only).
1737 *
1738 * The same message listener can be added more than once and in that
1739 * case it will be called more than once for each message.
1740 *
1741 * If data is specified, it will be passed to the callback when it is called.
1742 * Otherwise, the exception object will be passed to the callback instead.
1743 */
1744 bool AddMessageListener(MessageCallback callback,
1745 Local<Value> data = Local<Value>());
1746
1747 /**
1748 * Adds a message listener.
1749 *
1750 * The same message listener can be added more than once and in that
1751 * case it will be called more than once for each message.
1752 *
1753 * If data is specified, it will be passed to the callback when it is called.
1754 * Otherwise, the exception object will be passed to the callback instead.
1755 *
1756 * A listener can listen for particular error levels by providing a mask.
1757 */
1758 bool AddMessageListenerWithErrorLevel(MessageCallback callback,
1759 int message_levels,
1760 Local<Value> data = Local<Value>());
1761
1762 /**
1763 * Remove all message listeners from the specified callback function.
1764 */
1765 void RemoveMessageListeners(MessageCallback callback);
1766
1767 /** Callback function for reporting failed access checks.*/
1768 void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
1769
1770 /**
1771 * Tells V8 to capture current stack trace when uncaught exception occurs
1772 * and report it to the message listeners. The option is off by default.
1773 */
1775 bool capture, int frame_limit = 10,
1777
1778 /**
1779 * Check if this isolate is in use.
1780 * True if at least one thread Enter'ed this isolate.
1781 */
1782 bool IsInUse();
1783
1784 /**
1785 * Set whether calling Atomics.wait (a function that may block) is allowed in
1786 * this isolate. This can also be configured via
1787 * CreateParams::allow_atomics_wait.
1788 */
1789 void SetAllowAtomicsWait(bool allow);
1790
1791 /**
1792 * Time zone redetection indicator for
1793 * DateTimeConfigurationChangeNotification.
1794 *
1795 * kSkip indicates V8 that the notification should not trigger redetecting
1796 * host time zone. kRedetect indicates V8 that host time zone should be
1797 * redetected, and used to set the default time zone.
1798 *
1799 * The host time zone detection may require file system access or similar
1800 * operations unlikely to be available inside a sandbox. If v8 is run inside a
1801 * sandbox, the host time zone has to be detected outside the sandbox before
1802 * calling DateTimeConfigurationChangeNotification function.
1803 */
1805
1806 /**
1807 * Notification that the embedder has changed the time zone, daylight savings
1808 * time or other date / time configuration parameters. V8 keeps a cache of
1809 * various values used for date / time computation. This notification will
1810 * reset those cached values for the current context so that date / time
1811 * configuration changes would be reflected.
1812 *
1813 * This API should not be called more than needed as it will negatively impact
1814 * the performance of date operations.
1815 */
1817 TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip);
1818
1819 /**
1820 * Notification that the embedder has changed the locale. V8 keeps a cache of
1821 * various values used for locale computation. This notification will reset
1822 * those cached values for the current context so that locale configuration
1823 * changes would be reflected.
1824 *
1825 * This API should not be called more than needed as it will negatively impact
1826 * the performance of locale operations.
1827 */
1829
1830 /**
1831 * Returns the default locale in a string if Intl support is enabled.
1832 * Otherwise returns an empty string.
1833 */
1834 std::string GetDefaultLocale();
1835
1836 /**
1837 * Returns a canonical and case-regularized form of locale if Intl support is
1838 * enabled. If the locale is not syntactically well-formed, throws a
1839 * RangeError.
1840 *
1841 * If Intl support is not enabled, returns Nothing<std::string>().
1842 *
1843 * Corresponds to the combination of the abstract operations
1844 * IsStructurallyValidLanguageTag and CanonicalizeUnicodeLocaleId. See:
1845 * https://tc39.es/ecma402/#sec-isstructurallyvalidlanguagetag
1846 * https://tc39.es/ecma402/#sec-canonicalizeunicodelocaleid
1847 */
1848 V8_WARN_UNUSED_RESULT Maybe<std::string>
1850
1851 /**
1852 * Returns the hash seed for that isolate, for testing purposes.
1853 */
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
1872 internal::ValueHelper::InternalRepresentationType GetDataFromSnapshotOnce(
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
1889 using I = internal::Internals;
1890 return I::kNumIsolateDataSlots;
1891}
1892
1893template <class T>
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_
AllowJavascriptExecutionScope & operator=(const AllowJavascriptExecutionScope &)=delete
AllowJavascriptExecutionScope(const AllowJavascriptExecutionScope &)=delete
DisallowJavascriptExecutionScope(Isolate *isolate, OnFailure on_failure)
DisallowJavascriptExecutionScope(const DisallowJavascriptExecutionScope &)=delete
DisallowJavascriptExecutionScope & operator=(const DisallowJavascriptExecutionScope &)=delete
Scope(Isolate *isolate)
Definition v8-isolate.h:388
Scope(const Scope &)=delete
Scope & operator=(const Scope &)=delete
SuppressMicrotaskExecutionScope & operator=(const SuppressMicrotaskExecutionScope &)=delete
SuppressMicrotaskExecutionScope(Isolate *isolate, MicrotaskQueue *microtask_queue=nullptr)
SuppressMicrotaskExecutionScope(const SuppressMicrotaskExecutionScope &)=delete
IsolateGroup & operator=(IsolateGroup &&other)
static IsolateGroup Create()
bool operator!=(const IsolateGroup &other) const
Definition v8-isolate.h:257
bool operator==(const IsolateGroup &other) const
Definition v8-isolate.h:253
IsolateGroup & operator=(const IsolateGroup &)
IsolateGroup(const IsolateGroup &)
V8_INLINE bool SandboxContains(void *pointer) const
Definition v8-isolate.h:269
IsolateGroup(IsolateGroup &&other)
static bool CanCreateNewGroups()
static IsolateGroup GetDefault()
void SetJitCodeEventHandler(JitCodeEventOptions options, JitCodeEventHandler event_handler)
void SetCounterFunction(CounterLookupCallback)
void DiscardThreadSpecificMetadata()
void SetWasmInstanceCallback(ExtensionCallback callback)
void SetReleaseCppHeapCallbackForTesting(ReleaseCppHeapCallback callback)
void SetIdle(bool is_idle)
void SetOOMErrorHandler(OOMErrorCallback that)
IsolateGroup GetGroup() const
Local< Context > GetEnteredOrMicrotaskContext()
void SetAddCrashKeyCallback(AddCrashKeyCallback)
bool HasPendingException()
V8_WARN_UNUSED_RESULT Maybe< std::string > ValidateAndCanonicalizeUnicodeLocaleId(std::string_view locale)
void AddGCPrologueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
void SetSharedArrayBufferConstructorEnabledCallback(SharedArrayBufferConstructorEnabledCallback callback)
void SetWasmAsyncResolvePromiseCallback(WasmAsyncResolvePromiseCallback callback)
void SetBatterySaverMode(bool battery_saver_mode_enabled)
void SetWasmJSPIEnabledCallback(WasmJSPIEnabledCallback callback)
void SetHostInitializeImportMetaObjectCallback(HostInitializeImportMetaObjectCallback callback)
void LowMemoryNotification()
void SetWasmModuleCallback(ExtensionCallback callback)
void SetHostImportModuleDynamicallyCallback(HostImportModuleDynamicallyCallback callback)
void EnqueueMicrotask(MicrotaskCallback callback, void *data=nullptr)
void Deinitialize()
bool IsDead()
static void Initialize(Isolate *isolate, const CreateParams &params)
static Isolate * New(const IsolateGroup &group, const CreateParams &params)
CppHeap * GetCppHeap() const
void GetEmbeddedCodeRange(const void **start, size_t *length_in_bytes)
void SetStackLimit(uintptr_t stack_limit)
void DumpAndResetStats()
@ kMinorGarbageCollection
Definition v8-isolate.h:475
@ kFullGarbageCollection
Definition v8-isolate.h:474
@ kWasmMutableGlobals
Definition v8-isolate.h:656
@ kErrorCaptureStackTrace
Definition v8-isolate.h:530
@ kArrayBufferTransfer
Definition v8-isolate.h:642
@ kInvalidatedStringLengthOverflowLookupChainProtector
Definition v8-isolate.h:592
@ kStringLocaleCompare
Definition v8-isolate.h:549
@ kPromiseConstructorReturnedUndefined
Definition v8-isolate.h:525
@ kResizableArrayBuffer
Definition v8-isolate.h:633
@ kRegExpPrototypeStickyGetter
Definition v8-isolate.h:498
@ kRegExpPrototypeToString
Definition v8-isolate.h:499
@ kOBSOLETE_RegExpUnicodeSetIncompatibilitiesWithUnicodeMode
Definition v8-isolate.h:607
@ kOBSOLETE_LineOrParagraphSeparatorAsLineTerminator
Definition v8-isolate.h:528
@ kWebAssemblyInstantiation
Definition v8-isolate.h:533
@ kOBSOLETE_ArrayProtectorDirtied
Definition v8-isolate.h:511
@ kOBSOLETE_DateGetTimezoneOffset
Definition v8-isolate.h:561
@ kOBSOLETE_IntlPattern
Definition v8-isolate.h:502
@ kInvalidatedRegExpSpeciesLookupChainProtector
Definition v8-isolate.h:589
@ kArrayPrototypeConstructorModified
Definition v8-isolate.h:513
@ kLocaleInfoObsoletedGetters
Definition v8-isolate.h:609
@ kDefineGetterOrSetterWouldThrow
Definition v8-isolate.h:521
@ kRegExpExecCalledOnSlowRegExp
Definition v8-isolate.h:566
@ kOBSOLETE_LegacyFunctionDeclaration
Definition v8-isolate.h:516
@ kInvalidatedMapIteratorLookupChainProtector
Definition v8-isolate.h:583
@ kDateToLocaleDateString
Definition v8-isolate.h:554
@ kArraySpeciesModified
Definition v8-isolate.h:512
@ kInvalidatedNoProfilingProtector
Definition v8-isolate.h:612
@ kCompileHintsMagicAll
Definition v8-isolate.h:611
@ kInvalidatedArrayIteratorLookupChainProtector
Definition v8-isolate.h:580
@ kObjectPrototypeHasElements
Definition v8-isolate.h:571
@ kDateTimeFormatRange
Definition v8-isolate.h:573
@ kInvalidatedNoUndetectableObjectsProtector
Definition v8-isolate.h:620
@ kWasmNonTrappingFloatToInt
Definition v8-isolate.h:663
@ kOBSOLETE_IntlResolved
Definition v8-isolate.h:503
@ kDateToLocaleTimeString
Definition v8-isolate.h:555
@ kNumberToLocaleString
Definition v8-isolate.h:552
@ kWasmImportedStrings
Definition v8-isolate.h:616
@ kWasmModuleCompilation
Definition v8-isolate.h:619
@ kArrayPrototypeHasElements
Definition v8-isolate.h:570
@ kWasmJavaScriptPromiseIntegration
Definition v8-isolate.h:621
@ kOBSOLETE_LegacyConst
Definition v8-isolate.h:489
@ kInvalidatedArraySpeciesLookupChainProtector
Definition v8-isolate.h:581
@ kOBSOLETE_StoreBufferOverflow
Definition v8-isolate.h:491
@ kBreakIteratorTypeWord
Definition v8-isolate.h:575
@ kOBSOLETE_RegExpPrototypeSourceGetter
Definition v8-isolate.h:517
@ kFunctionPrototypeCaller
Definition v8-isolate.h:602
@ kOBSOLETE_RegExpMatchAllWithNonGlobalRegExp
Definition v8-isolate.h:565
@ kHtmlWrapperMethods
Definition v8-isolate.h:669
@ kOBSOLETE_AtomicsWake
Definition v8-isolate.h:540
@ kExplicitResourceManagement
Definition v8-isolate.h:654
@ kRegExpMatchIsTrueishOnNonJSRegExp
Definition v8-isolate.h:559
@ kArrayInstanceConstructorModified
Definition v8-isolate.h:515
@ kStringToLocaleLowerCase
Definition v8-isolate.h:551
@ kInvalidatedPromiseHookProtector
Definition v8-isolate.h:585
@ kUint8ArrayToFromBase64AndHex
Definition v8-isolate.h:657
@ kAsyncStackTaggingCreateTaskCall
Definition v8-isolate.h:604
@ kDateTimeFormatDateTimeStyle
Definition v8-isolate.h:574
@ kRegExpMatchIsFalseishOnJSRegExp
Definition v8-isolate.h:560
@ kInvalidatedMegaDOMProtector
Definition v8-isolate.h:600
@ kOBSOLETE_ArrayPrototypeSortJSArrayModifiedPrototype
Definition v8-isolate.h:535
@ kOBSOLETE_OptimizedFunctionWithOneShotBytecode
Definition v8-isolate.h:558
@ kAttemptOverrideReadOnlyOnPrototypeStrict
Definition v8-isolate.h:557
@ kNumberFormatStyleUnit
Definition v8-isolate.h:572
@ kGrowableSharedArrayBuffer
Definition v8-isolate.h:634
@ kOBSOLETE_PromiseAccept
Definition v8-isolate.h:505
@ kWasmTypeReflection
Definition v8-isolate.h:625
@ kExtendingNonExtensibleWithPrivate
Definition v8-isolate.h:645
@ kPromiseWithResolvers
Definition v8-isolate.h:643
@ kDateToLocaleString
Definition v8-isolate.h:553
@ kSourceMappingUrlMagicCommentAtSign
Definition v8-isolate.h:617
@ kInvalidatedPromiseSpeciesLookupChainProtector
Definition v8-isolate.h:587
@ kOBSOLETE_StringToLocaleUpperCase
Definition v8-isolate.h:550
@ kInvalidatedSetIteratorLookupChainProtector
Definition v8-isolate.h:590
@ kOBSOLETE_StrongMode
Definition v8-isolate.h:497
@ kTurboFanOsrCompileStarted
Definition v8-isolate.h:603
@ kOBSOLETE_PromiseChain
Definition v8-isolate.h:504
@ kHtmlCommentInExternalScript
Definition v8-isolate.h:507
@ kCallSiteAPIGetFunctionSloppyCall
Definition v8-isolate.h:563
@ kAssigmentExpressionLHSIsCallInSloppy
Definition v8-isolate.h:523
@ kOBSOLETE_ObjectObserve
Definition v8-isolate.h:493
@ kFunctionConstructorReturnedUndefined
Definition v8-isolate.h:522
@ kOBSOLETE_RegExpPrototypeOldFlagGetter
Definition v8-isolate.h:518
@ kOBSOLETE_ConstructorNonUndefinedPrimitiveReturn
Definition v8-isolate.h:526
@ kOBSOLETE_IntlV8Parse
Definition v8-isolate.h:501
@ kInvalidatedIsConcatSpreadableLookupChainProtector
Definition v8-isolate.h:582
@ kWasmSignExtensionOps
Definition v8-isolate.h:664
@ kOBSOLETE_PromiseDefer
Definition v8-isolate.h:506
@ kFunctionTokenOffsetTooLongForToString
Definition v8-isolate.h:536
@ kOBSOLETE_MarkDequeOverflow
Definition v8-isolate.h:490
@ kOBSOLETE_LabeledExpressionStatement
Definition v8-isolate.h:527
@ kInvalidatedNoDateTimeConfigurationChangeProtector
Definition v8-isolate.h:662
@ kOBSOLETE_ArrayInstanceProtoModified
Definition v8-isolate.h:514
@ kRelativeTimeFormat
Definition v8-isolate.h:545
@ kOBSOLETE_SlotsBufferOverflow
Definition v8-isolate.h:492
@ kDecimalWithLeadingZeroInStrictMode
Definition v8-isolate.h:519
@ kRegExpPrototypeUnicodeGetter
Definition v8-isolate.h:500
@ kDocumentAllLegacyCall
Definition v8-isolate.h:629
@ kInvalidatedStringWrapperToPrimitiveProtector
Definition v8-isolate.h:628
@ kInvalidatedTypedArraySpeciesLookupChainProtector
Definition v8-isolate.h:593
@ kOBSOLETE_ImportAssertionDeprecatedSyntax
Definition v8-isolate.h:608
@ kRegExpStaticPropertiesWithLastMatch
Definition v8-isolate.h:667
@ kDocumentAllLegacyConstruct
Definition v8-isolate.h:630
@ kRegExpReplaceCalledOnSlowRegExp
Definition v8-isolate.h:567
@ kWasmImportedStringsUtf8
Definition v8-isolate.h:632
@ kRegExpStaticProperties
Definition v8-isolate.h:666
@ kOBSOLETE_AtomicsNotify
Definition v8-isolate.h:539
@ kCallSiteAPIGetThisSloppyCall
Definition v8-isolate.h:564
@ kSharedArrayBufferConstructed
Definition v8-isolate.h:569
@ kAssigmentExpressionLHSIsCallInStrict
Definition v8-isolate.h:524
@ kInvalidatedNoElementsProtector
Definition v8-isolate.h:584
@ kVarRedeclaredCatchBinding
Definition v8-isolate.h:595
@ kErrorPrepareStackTrace
Definition v8-isolate.h:531
@ kDeoptimizerDisableSpeculation
Definition v8-isolate.h:534
@ kInvalidatedNumberStringNotRegexpLikeProtector
Definition v8-isolate.h:606
@ kBreakIteratorTypeLine
Definition v8-isolate.h:576
@ kInvalidatedArrayBufferDetachingProtector
Definition v8-isolate.h:577
@ kWasmExceptionHandling
Definition v8-isolate.h:599
@ kErrorStackTraceLimit
Definition v8-isolate.h:532
@ kFunctionPrototypeArguments
Definition v8-isolate.h:601
@ kInvalidatedStringIteratorLookupChainProtector
Definition v8-isolate.h:591
@ kSloppyModeBlockScopedFunctionRedefinition
Definition v8-isolate.h:509
@ kInvalidatedPromiseResolveLookupChainProtector
Definition v8-isolate.h:586
@ kAttemptOverrideReadOnlyOnPrototypeSloppy
Definition v8-isolate.h:556
@ kInvalidatedPromiseThenLookupChainProtector
Definition v8-isolate.h:588
@ kUseCounterFeatureCount
Definition v8-isolate.h:675
@ kWasmCustomDescriptors
Definition v8-isolate.h:670
@ kInvalidatedTypedArrayLengthLookupChainProtector
Definition v8-isolate.h:651
@ kLocaleInfoFunctions
Definition v8-isolate.h:610
void GetStackSample(const RegisterState &state, void **frames, size_t frames_limit, SampleInfo *sample_info)
void AddCallCompletedCallback(CallCompletedCallback callback)
void SetExceptionPropagationCallback(ExceptionPropagationCallback callback)
static Isolate * GetCurrent()
void SetContinuationPreservedEmbedderData(Local< Value > data)
bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics *object_statistics, size_t type_index)
static V8_INLINE uint32_t GetNumberOfDataSlots()
std::string GetDefaultLocale()
void SetPromiseRejectCallback(PromiseRejectCallback callback)
ArrayBuffer::Allocator * GetArrayBufferAllocator()
void SetCreateHistogramFunction(CreateHistogramCallback)
static void Free(Isolate *isolate)
void GetHeapStatistics(HeapStatistics *heap_statistics)
void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback)
bool AddMessageListenerWithErrorLevel(MessageCallback callback, int message_levels, Local< Value > data=Local< Value >())
Isolate()=delete
void AddGCEpilogueCallback(GCCallback callback, GCType gc_type_filter=kGCTypeAll)
Local< Context > GetIncumbentContext()
void SetIsLoading(bool is_loading)
MicrotasksPolicy GetMicrotasksPolicy() const
bool IsInUse()
Local< Value > GetContinuationPreservedEmbedderData()
void RequestGarbageCollectionForTesting(GarbageCollectionType type)
bool InContext()
JSEntryStubs GetJSEntryStubs()
void RemoveGCPrologueCallback(GCCallback callback)
size_t NumberOfHeapSpaces()
bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics *object_statistics)
static constexpr size_t kMinCodePagesBufferSize
void RemoveGCEpilogueCallback(GCCallbackWithData callback, void *data=nullptr)
void ClearCachesForTesting()
void AddGCPrologueCallback(GCCallback callback, GCType gc_type_filter=kGCTypeAll)
void Dispose()
void DateTimeConfigurationChangeNotification(TimeZoneDetection time_zone_detection=TimeZoneDetection::kSkip)
void * operator new(size_t size)=delete
static Isolate * TryGetCurrent()
void AutomaticallyRestoreInitialHeapLimit(double threshold_percent=0.5)
void RequestInterrupt(InterruptCallback callback, void *data)
V8_INLINE void SetData(uint32_t slot, void *data)
void GetCodeRange(void **start, size_t *length_in_bytes)
void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
void ContextDisposedNotification(ContextDependants dependants)
void RestoreOriginalHeapLimit()
void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback)
void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback, size_t heap_limit)
void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)
void operator delete(void *, size_t)=delete
void RemoveCallCompletedCallback(CallCompletedCallback callback)
void SetAllowAtomicsWait(bool allow)
void Enter()
void SetAllowWasmCodeGenerationCallback(AllowWasmCodeGenerationCallback callback)
uint64_t GetHashSeed()
Local< Value > ThrowError(const char(&message)[N])
void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback)
void operator delete[](void *, size_t)=delete
void SetPromiseHook(PromiseHook hook)
void SetEmbedderRootsHandler(EmbedderRootsHandler *handler)
void SetWasmCustomDescriptorsEnabledCallback(WasmCustomDescriptorsEnabledCallback callback)
Local< Value > ThrowError(Local< String > message)
void SetGetExternallyAllocatedMemoryInBytesCallback(GetExternallyAllocatedMemoryInBytesCallback callback)
void SetCaptureStackTraceForUncaughtExceptions(bool capture, int frame_limit=10, StackTrace::StackTraceOptions options=StackTrace::kOverview)
V8_INLINE void * GetData(uint32_t slot)
void SetIsJSApiWrapperNativeErrorCallback(IsJSApiWrapperNativeErrorCallback callback)
void SetMicrotasksPolicy(MicrotasksPolicy policy)
HeapProfiler * GetHeapProfiler()
void RequestGarbageCollectionForTesting(GarbageCollectionType type, StackState stack_state)
void TerminateExecution()
V8_INLINE MaybeLocal< T > GetDataFromSnapshotOnce(size_t index)
bool MeasureMemory(std::unique_ptr< MeasureMemoryDelegate > delegate, MeasureMemoryExecution execution=MeasureMemoryExecution::kDefault)
void * operator new[](size_t size)=delete
void SetMetricsRecorder(const std::shared_ptr< metrics::Recorder > &metrics_recorder)
bool IsHeapLimitIncreasedForDebugging()
void IsolateInBackgroundNotification()
size_t NumberOfTrackedHeapObjectTypes()
Local< Value > ThrowException(Local< Value > exception)
void SetMemorySaverMode(bool memory_saver_mode_enabled)
Local< Context > GetCurrentContext()
void SetWasmImportedStringsEnabledCallback(WasmImportedStringsEnabledCallback callback)
int GetStackTraceLimit()
void ClearKeptObjects()
Isolate(const Isolate &)=delete
size_t CopyCodePages(size_t capacity, MemoryRange *code_pages_out)
bool GetHeapSpaceStatistics(HeapSpaceStatistics *space_statistics, size_t index)
void RemoveGCPrologueCallback(GCCallbackWithData, void *data=nullptr)
void SetUseCounterCallback(UseCounterCallback callback)
void LocaleConfigurationChangeNotification()
bool AddMessageListener(MessageCallback callback, Local< Value > data=Local< Value >())
~Isolate()=delete
void CancelTerminateExecution()
void SetPriority(Priority priority)
void AddMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)
void MemoryPressureNotification(MemoryPressureLevel level)
void Freeze(bool is_frozen)
void AddGCEpilogueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
void SetEventLogger(LogEventCallback that)
void AddNearHeapLimitCallback(NearHeapLimitCallback callback, void *data)
static Isolate * Allocate(const IsolateGroup &group)
void EnqueueMicrotask(Local< Function > microtask)
int ContextDisposedNotification(bool dependant_context=true)
Isolate & operator=(const Isolate &)=delete
void IncreaseHeapLimitForDebugging()
void SetContinuationPreservedEmbedderDataV2(Local< Data > data)
bool IsExecutionTerminating()
static Isolate * New(const CreateParams &params)
void RemoveGCEpilogueCallback(GCCallback callback)
void SetWasmStreamingCallback(WasmStreamingCallback callback)
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
void SetHostImportModuleWithPhaseDynamicallyCallback(HostImportModuleWithPhaseDynamicallyCallback callback)
Local< Data > GetContinuationPreservedEmbedderDataV2()
void InstallConditionalFeatures(Local< Context > context)
static Isolate * Allocate()
bool IsCurrent() const
void SetAddHistogramSampleFunction(AddHistogramSampleCallback)
void SetHostCreateShadowRealmContextCallback(HostCreateShadowRealmContextCallback callback)
void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
void SetModifyCodeGenerationFromStringsCallback(ModifyCodeGenerationFromStringsCallback2 callback)
void PerformMicrotaskCheckpoint()
void SetAbortOnUncaughtExceptionCallback(AbortOnUncaughtExceptionCallback callback)
bool HasPendingBackgroundTasks()
void RemoveMessageListeners(MessageCallback callback)
void IsolateInForegroundNotification()
MaybeLocal< Data > GetCurrentHostDefinedOptions()
void SetFatalErrorHandler(FatalErrorCallback that)
friend class Local
friend class MaybeLocal
void set_max_young_generation_size_in_bytes(size_t limit)
Definition v8-isolate.h:139
void set_stack_limit(uint32_t *value)
Definition v8-isolate.h:103
void set_initial_young_generation_size_in_bytes(size_t initial_size)
Definition v8-isolate.h:153
size_t max_old_generation_size_in_bytes() const
Definition v8-isolate.h:124
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
size_t initial_young_generation_size_in_bytes() const
Definition v8-isolate.h:150
void set_code_range_size_in_bytes(size_t limit)
Definition v8-isolate.h:115
size_t code_range_size_in_bytes() const
Definition v8-isolate.h:114
size_t max_young_generation_size_in_bytes() const
Definition v8-isolate.h:136
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
uint32_t * stack_limit() const
Definition v8-isolate.h:102
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)
friend class PersistentValueMapBase
static const uint32_t kNumIsolateDataSlots
static V8_INLINE void * GetEmbedderData(const v8::Isolate *isolate, uint32_t slot)
static V8_INLINE void SetEmbedderData(v8::Isolate *isolate, uint32_t slot, void *data)
static constexpr InternalRepresentationType kEmpty
EmbedderStackState
Definition common.h:15
uintptr_t Address
Definition v8-internal.h:52
MemoryPressureLevel
Definition v8-isolate.h:180
ContextDependants
Definition v8-isolate.h:186
GCCallbackFlags
@ kGCTypeAll
JitCodeEventOptions
MeasureMemoryExecution
MicrotasksPolicy
AddHistogramSampleCallback add_histogram_sample_callback
Definition v8-isolate.h:331
CreateHistogramCallback create_histogram_callback
Definition v8-isolate.h:330
OOMErrorCallback oom_error_callback
Definition v8-isolate.h:373
JitCodeEventHandler code_event_handler
Definition v8-isolate.h:305
const intptr_t * external_references
Definition v8-isolate.h:351
ArrayBuffer::Allocator * array_buffer_allocator
Definition v8-isolate.h:342
ResourceConstraints constraints
Definition v8-isolate.h:310
FatalErrorCallback fatal_error_callback
Definition v8-isolate.h:372
const StartupData * snapshot_blob
Definition v8-isolate.h:316
CounterLookupCallback counter_lookup_callback
Definition v8-isolate.h:322
std::shared_ptr< ArrayBuffer::Allocator > array_buffer_allocator_shared
Definition v8-isolate.h:343
Definition v8-unwinder.h:82
#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