// Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef INCLUDE_V8_ISOLATE_H_ #define INCLUDE_V8_ISOLATE_H_ #include <stddef.h> #include <stdint.h> #include <memory> #include <string> #include <utility> #include "cppgc/common.h" #include "v8-array-buffer.h" // NOLINT(build/include_directory) #include "v8-callbacks.h" // NOLINT(build/include_directory) #include "v8-data.h" // NOLINT(build/include_directory) #include "v8-debug.h" // NOLINT(build/include_directory) #include "v8-embedder-heap.h" // NOLINT(build/include_directory) #include "v8-exception.h" // NOLINT(build/include_directory) #include "v8-function-callback.h" // NOLINT(build/include_directory) #include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8-microtask.h" // NOLINT(build/include_directory) #include "v8-persistent-handle.h" // NOLINT(build/include_directory) #include "v8-primitive.h" // NOLINT(build/include_directory) #include "v8-statistics.h" // NOLINT(build/include_directory) #include "v8-unwinder.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) namespace v8 { class CppHeap; class HeapProfiler; class MicrotaskQueue; class StartupData; class ScriptOrModule; class SharedArrayBuffer; namespace internal { class MicrotaskQueue; class ThreadLocalTop; } // namespace internal namespace metrics { class Recorder; } // namespace metrics /** * A set of constraints that specifies the limits of the runtime's memory use. * You must set the heap size before initializing the VM - the size cannot be * adjusted after the VM is initialized. * * If you are using threads then you should hold the V8::Locker lock while * setting the stack limit and you must set a non-default stack limit separately * for each thread. * * The arguments for set_max_semi_space_size, set_max_old_space_size, * set_max_executable_size, set_code_range_size specify limits in MB. * * The argument for set_max_semi_space_size_in_kb is in KB. */ class V8_EXPORT ResourceConstraints { … }; /** * Option flags passed to the SetRAILMode function. * See documentation https://developers.google.com/web/tools/chrome-devtools/ * profile/evaluate-performance/rail */ enum RAILMode : unsigned { … }; /** * Memory pressure level for the MemoryPressureNotification. * kNone hints V8 that there is no memory pressure. * kModerate hints V8 to speed up incremental garbage collection at the cost of * of higher latency due to garbage collection pauses. * kCritical hints V8 to free memory as soon as possible. Garbage collection * pauses at this level will be large. */ enum class MemoryPressureLevel { … }; /** * Indicator for the stack state. */ StackState; /** * Isolate represents an isolated instance of the V8 engine. V8 isolates have * completely separate states. Objects from one isolate must not be used in * other isolates. The embedder can create multiple isolates and use them in * parallel in multiple threads. An isolate can be entered by at most one * thread at any given time. The Locker/Unlocker API must be used to * synchronize. */ class V8_EXPORT Isolate { … }; void Isolate::SetData(uint32_t slot, void* data) { … } void* Isolate::GetData(uint32_t slot) { … } uint32_t Isolate::GetNumberOfDataSlots() { … } template <class T> MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) { … } } // namespace v8 #endif // INCLUDE_V8_ISOLATE_H_