#ifndef V8_EXECUTION_ISOLATE_H_
#define V8_EXECUTION_ISOLATE_H_
#include <atomic>
#include <cstddef>
#include <deque>
#include <functional>
#include <list>
#include <memory>
#include <optional>
#include <queue>
#include <unordered_map>
#include <vector>
#include "include/v8-context.h"
#include "include/v8-internal.h"
#include "include/v8-isolate.h"
#include "include/v8-metrics.h"
#include "include/v8-snapshot.h"
#include "src/base/macros.h"
#include "src/base/platform/mutex.h"
#include "src/base/platform/platform-posix.h"
#include "src/builtins/builtins.h"
#include "src/common/globals.h"
#include "src/common/ptr-compr.h"
#include "src/common/thread-local-storage.h"
#include "src/debug/interface-types.h"
#include "src/execution/execution.h"
#include "src/execution/futex-emulation.h"
#include "src/execution/isolate-data.h"
#include "src/execution/messages.h"
#include "src/execution/mutex-guard-if-off-thread.h"
#include "src/execution/stack-guard.h"
#include "src/handles/handles.h"
#include "src/handles/traced-handles.h"
#include "src/heap/factory.h"
#include "src/heap/heap.h"
#include "src/heap/read-only-heap.h"
#include "src/init/isolate-group.h"
#include "src/objects/code.h"
#include "src/objects/contexts.h"
#include "src/objects/debug-objects.h"
#include "src/objects/js-objects.h"
#include "src/objects/tagged.h"
#include "src/runtime/runtime.h"
#include "src/sandbox/code-pointer-table.h"
#include "src/sandbox/external-pointer-table.h"
#include "src/sandbox/trusted-pointer-table.h"
#include "src/utils/allocation.h"
#ifdef DEBUG
#include "src/runtime/runtime-utils.h"
#endif
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/stacks.h"
#endif
#ifdef V8_INTL_SUPPORT
#include "unicode/uversion.h"
namespace U_ICU_NAMESPACE {
class UMemory;
}
#endif
#if USE_SIMULATOR
#include "src/execution/encoded-c-signature.h"
namespace v8 {
namespace internal {
class SimulatorData;
}
}
#endif
#ifdef V8_DUMPLING
#include "src/dumpling/dumpling-manager.h"
#endif
namespace v8_inspector {
class V8Inspector;
}
namespace v8 {
class EmbedderState;
namespace base {
class RandomNumberGenerator;
}
namespace bigint {
class Processor;
}
namespace debug {
class ConsoleDelegate;
class AsyncEventDelegate;
}
namespace internal {
#ifdef V8_ENABLE_OHOS_ASYNC_STACK
MaybeHandle<JSPromise> TryGetPromiseFromTask(Isolate* isolate,
DirectHandle<Object> microtask);
#endif
void DefaultWasmAsyncResolvePromiseCallback(
v8::Isolate* isolate, v8::Local<v8::Context> context,
v8::Local<v8::Promise::Resolver> resolver,
v8::Local<v8::Value> compilation_result, WasmAsyncSuccess success);
namespace heap {
class HeapTester;
}
namespace maglev {
class MaglevConcurrentDispatcher;
}
class AddressToIndexHashMap;
class AstStringConstants;
class Bootstrapper;
class BuiltinsConstantsTableBuilder;
class BuiltinsEffectsAnalyzer;
class CancelableTaskManager;
class Logger;
class CodeTracer;
class CommonFrame;
class CompilationCache;
class CompilationStatistics;
class Counters;
class Debug;
class Deoptimizer;
class DescriptorLookupCache;
class EmbeddedFileWriterInterface;
class EternalHandles;
class GlobalHandles;
class GlobalSafepoint;
class HandleScopeImplementer;
class HeapObjectToIndexHashMap;
class HeapProfiler;
class InnerPointerToCodeCache;
class LazyCompileDispatcher;
class LocalIsolate;
class V8FileLogger;
class MaterializedObjectStore;
class Microtask;
class MicrotaskQueue;
class OptimizingCompileDispatcher;
class OptimizingCompileTaskExecutor;
class PersistentHandles;
class PersistentHandlesList;
class ReadOnlyArtifacts;
class RegExpStack;
class RootVisitor;
class SetupIsolateDelegate;
class SharedStructTypeRegistry;
class Simulator;
class SnapshotData;
class StackFrame;
class StringForwardingTable;
class StringTable;
class StubCache;
class ThreadManager;
class ThreadState;
class ThreadVisitor;
class TieringManager;
class TracingCpuProfilerImpl;
class UnicodeCache;
struct ManagedPtrDestructor;
template <StateTag Tag>
class VMState;
namespace baseline {
class BaselineBatchCompiler;
}
namespace interpreter {
class Interpreter;
}
namespace compiler {
class NodeObserver;
class PerIsolateCompilerCache;
namespace turboshaft {
class WasmRevecVerifier;
}
}
namespace win64_unwindinfo {
class BuiltinUnwindInfo;
}
namespace metrics {
class Recorder;
}
namespace wasm {
#if V8_ENABLE_DRUMBRAKE
class WasmExecutionTimer;
#endif
class WasmCodeLookupCache;
class WasmOrphanedGlobalHandle;
}
#define RETURN_FAILURE_IF_EXCEPTION(isolate) \
do { \
Isolate* __isolate__ = (isolate); \
if (__isolate__->has_exception()) { \
return ReadOnlyRoots(__isolate__).exception(); \
} \
} while (false)
#define RETURN_FAILURE_IF_EXCEPTION_DETECTOR(isolate, detector) \
do { \
Isolate* __isolate__ = (isolate); \
if (__isolate__->has_exception()) { \
detector.AcceptSideEffects(); \
return ReadOnlyRoots(__isolate__).exception(); \
} \
} while (false)
#define RETURN_VALUE_IF_EXCEPTION(isolate, value) \
do { \
Isolate* __isolate__ = (isolate); \
if (__isolate__->has_exception()) { \
return value; \
} \
} while (false)
#define RETURN_VALUE_IF_EXCEPTION_DETECTOR(isolate, detector, value) \
RETURN_VALUE_IF_EXCEPTION(isolate, (detector.AcceptSideEffects(), value))
#define RETURN_EXCEPTION_IF_EXCEPTION(isolate) \
RETURN_VALUE_IF_EXCEPTION(isolate, internal::kNullMaybe)
* RETURN_RESULT_OR_FAILURE is used in functions with return type Object (such
* as "RUNTIME_FUNCTION(...) {...}" or "BUILTIN(...) {...}" ) to return either
* the contents of a MaybeHandle<X>, or the "exception" sentinel value.
* Example usage:
*
* RUNTIME_FUNCTION(Runtime_Func) {
* ...
* RETURN_RESULT_OR_FAILURE(
* isolate,
* FunctionWithReturnTypeMaybeHandleX(...));
* }
*
* If inside a function with return type MaybeHandle<X> use RETURN_ON_EXCEPTION
* instead.
* If inside a function with return type Handle<X>, or Maybe<X> use
* RETURN_ON_EXCEPTION_VALUE instead.
*/
#define RETURN_RESULT_OR_FAILURE(isolate, call) \
do { \
decltype((call).ToHandleChecked()) __result__; \
Isolate* __isolate__ = (isolate); \
if (!(call).To(&__result__)) { \
DCHECK(__isolate__->has_exception()); \
return ReadOnlyRoots(__isolate__).exception(); \
} \
DCHECK(!__isolate__->has_exception()); \
return *__result__; \
} while (false)
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value) \
do { \
if (!(call).To(&dst)) { \
DCHECK((isolate)->has_exception()); \
return value; \
} \
} while (false)
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call) \
do { \
auto* __isolate__ = (isolate); \
ASSIGN_RETURN_ON_EXCEPTION_VALUE(__isolate__, dst, call, \
ReadOnlyRoots(__isolate__).exception()); \
} while (false)
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call) \
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, internal::kNullMaybe)
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call) \
do { \
auto* __isolate__ = (isolate); \
return __isolate__->Throw(*__isolate__->factory()->call); \
} while (false)
#define THROW_NEW_ERROR_RETURN_VALUE(isolate, call, value) \
do { \
auto* __isolate__ = (isolate); \
__isolate__->Throw(*__isolate__->factory()->call); \
return value; \
} while (false)
#define THROW_NEW_ERROR(isolate, call) \
THROW_NEW_ERROR_RETURN_VALUE(isolate, call, internal::kNullMaybe)
* RETURN_ON_EXCEPTION_VALUE conditionally returns the given value when the
* given MaybeHandle is empty. It is typically used in functions with return
* type Maybe<X> or Handle<X>. Example usage:
*
* Handle<X> Func() {
* ...
* RETURN_ON_EXCEPTION_VALUE(
* isolate,
* FunctionWithReturnTypeMaybeHandleX(...),
* Handle<X>());
* // code to handle non exception
* ...
* }
*
* Maybe<bool> Func() {
* ..
* RETURN_ON_EXCEPTION_VALUE(
* isolate,
* FunctionWithReturnTypeMaybeHandleX(...),
* Nothing<bool>);
* // code to handle non exception
* return Just(true);
* }
*
* If inside a function with return type MaybeHandle<X>, use RETURN_ON_EXCEPTION
* instead.
* If inside a function with return type Object, use
* RETURN_FAILURE_ON_EXCEPTION instead.
*/
#define RETURN_ON_EXCEPTION_VALUE(isolate, call, value) \
do { \
if ((call).IsEmpty()) { \
DCHECK((isolate)->has_exception()); \
return value; \
} \
} while (false)
* RETURN_FAILURE_ON_EXCEPTION conditionally returns the "exception" sentinel if
* the given MaybeHandle is empty; so it can only be used in functions with
* return type Object, such as RUNTIME_FUNCTION(...) {...} or BUILTIN(...)
* {...}. Example usage:
*
* RUNTIME_FUNCTION(Runtime_Func) {
* ...
* RETURN_FAILURE_ON_EXCEPTION(
* isolate,
* FunctionWithReturnTypeMaybeHandleX(...));
* // code to handle non exception
* ...
* }
*
* If inside a function with return type MaybeHandle<X>, use RETURN_ON_EXCEPTION
* instead.
* If inside a function with return type Maybe<X> or Handle<X>, use
* RETURN_ON_EXCEPTION_VALUE instead.
*/
#define RETURN_FAILURE_ON_EXCEPTION(isolate, call) \
do { \
Isolate* __isolate__ = (isolate); \
RETURN_ON_EXCEPTION_VALUE(__isolate__, call, \
ReadOnlyRoots(__isolate__).exception()); \
} while (false);
* RETURN_ON_EXCEPTION conditionally returns an empty MaybeHandle<T> if the
* given MaybeHandle is empty. Use it to return immediately from a function with
* return type MaybeHandle when an exception was thrown. Example usage:
*
* MaybeHandle<X> Func() {
* ...
* RETURN_ON_EXCEPTION(
* isolate,
* FunctionWithReturnTypeMaybeHandleY(...),
* X);
* // code to handle non exception
* ...
* }
*
* If inside a function with return type Object, use
* RETURN_FAILURE_ON_EXCEPTION instead.
* If inside a function with return type
* Maybe<X> or Handle<X>, use RETURN_ON_EXCEPTION_VALUE instead.
*/
#define RETURN_ON_EXCEPTION(isolate, call) \
RETURN_ON_EXCEPTION_VALUE(isolate, call, internal::kNullMaybe)
#define RETURN_FAILURE(isolate, should_throw, call) \
do { \
if ((should_throw) == kDontThrow) { \
return Just(false); \
} else { \
isolate->Throw(*isolate->factory()->call); \
return Nothing<bool>(); \
} \
} while (false)
#define MAYBE_RETURN(call, value) \
do { \
if ((call).IsEmpty()) return value; \
} while (false)
#define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, internal::kNullMaybe)
#define API_ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value) \
do { \
if (!(call).ToLocal(&dst)) { \
DCHECK((isolate)->has_exception()); \
return value; \
} \
} while (false)
#define MOVE_RETURN_ON_EXCEPTION(isolate, dst, call) \
do { \
if (!(call).MoveTo(&dst)) { \
DCHECK((isolate)->has_exception()); \
return internal::kNullMaybe; \
} \
} while (false)
#define FOR_WITH_HANDLE_SCOPE(isolate, init, loop_var, limit_check, increment) \
SCOPED_VARIABLE(Isolate* for_with_handle_isolate = (isolate)) \
SCOPED_VARIABLE(init) \
SCOPED_VARIABLE(bool should_exit = !(limit_check)) \
\
\
\
\
\
\
for (auto for_with_handle_limit = loop_var + 1024; \
!should_exit && (should_exit = true); for_with_handle_limit += 1024) \
for (HandleScope loop_scope(for_with_handle_isolate); \
(limit_check) && \
(loop_var < for_with_handle_limit || (should_exit = false)); \
increment)
#define WHILE_WITH_HANDLE_SCOPE(isolate, limit_check) \
SCOPED_VARIABLE(Isolate* while_with_handle_isolate = (isolate)) \
SCOPED_VARIABLE(bool should_exit = !(limit_check)) \
\
\
\
\
\
\
for (int while_with_handle_it = 0; !should_exit && (should_exit = true); \
while_with_handle_it = 0) \
for (HandleScope loop_scope(while_with_handle_isolate); \
(limit_check) && \
(while_with_handle_it < 1024 || (should_exit = false)); \
++while_with_handle_it)
#define FIELD_ACCESSOR(type, name) \
inline void set_##name(type v) { name##_ = v; } \
inline type name() const { return name##_; }
V8_EXPORT_PRIVATE void DisableEmbeddedBlobRefcounting();
V8_EXPORT_PRIVATE void FreeCurrentEmbeddedBlob();
#ifdef DEBUG
#define ISOLATE_INIT_DEBUG_ARRAY_LIST(V) \
V(int, code_kind_statistics, kCodeKindCount)
#else
#define ISOLATE_INIT_DEBUG_ARRAY_LIST(V)
#endif
#define ISOLATE_INIT_ARRAY_LIST(V) \
\
V(int32_t, jsregexp_static_offsets_vector, kJSRegexpStaticOffsetsVectorSize) \
V(int, bad_char_shift_table, kUC16AlphabetSize) \
V(int, good_suffix_shift_table, (kBMMaxShift + 1)) \
V(int, suffix_table, (kBMMaxShift + 1)) \
ISOLATE_INIT_DEBUG_ARRAY_LIST(V)
using DebugObjectCache = std::vector<Handle<HeapObject>>;
#ifdef OHOS_JS_ENGINE
#define ISOLATE_INIT_LIST_JS_ENGINE(V) \
V(OOMErrorCallbackWithIsolate, oom_behavior_with_isolate, nullptr)
#else
#define ISOLATE_INIT_LIST_JS_ENGINE(V)
#endif
#define ISOLATE_INIT_LIST(V) \
\
V(FatalErrorCallback, exception_behavior, nullptr) \
V(OOMErrorCallbackWithData, oom_behavior, nullptr) \
V(void*, oom_callback_data, nullptr) \
V(LogEventCallback, event_logger, nullptr) \
V(ModifyCodeGenerationFromStringsCallback2, modify_code_gen_callback, \
nullptr) \
V(AllowWasmCodeGenerationCallback, allow_wasm_code_gen_callback, nullptr) \
V(ExtensionCallback, wasm_module_callback, &NoExtension) \
V(ExtensionCallback, wasm_instance_callback, &NoExtension) \
V(SharedArrayBufferConstructorEnabledCallback, \
sharedarraybuffer_constructor_enabled_callback, nullptr) \
V(WasmStreamingCallback, wasm_streaming_callback, nullptr) \
V(WasmAsyncResolvePromiseCallback, wasm_async_resolve_promise_callback, \
DefaultWasmAsyncResolvePromiseCallback) \
V(WasmLoadSourceMapCallback, wasm_load_source_map_callback, nullptr) \
V(WasmCustomDescriptorsEnabledCallback, \
wasm_custom_descriptors_enabled_callback, nullptr) \
V(IsJSApiWrapperNativeErrorCallback, \
is_js_api_wrapper_native_error_callback, nullptr) \
\
V(Relocatable*, relocatable_top, nullptr) \
V(DebugObjectCache*, string_stream_debug_object_cache, nullptr) \
V(Tagged<Object>, string_stream_current_security_token, Tagged<Object>()) \
V(const intptr_t*, api_external_references, nullptr) \
V(AddressToIndexHashMap*, external_reference_map, nullptr) \
V(HeapObjectToIndexHashMap*, root_index_map, nullptr) \
V(MicrotaskQueue*, default_microtask_queue, nullptr) \
V(CodeTracer*, code_tracer, nullptr) \
V(PromiseRejectCallback, promise_reject_callback, nullptr) \
V(ExceptionPropagationCallback, exception_propagation_callback, nullptr) \
V(const v8::StartupData*, snapshot_blob, nullptr) \
V(int, code_and_metadata_size, 0) \
V(int, bytecode_and_metadata_size, 0) \
V(int, external_script_source_size, 0) \
\
V(size_t, num_cpu_profilers, 0) \
\
V(bool, formatting_stack_trace, false) \
V(bool, disable_bytecode_flushing, false) \
V(int, last_console_context_id, 0) \
V(v8_inspector::V8Inspector*, inspector, nullptr) \
V(compiler::NodeObserver*, node_observer, nullptr) \
V(bool, javascript_execution_assert, true) \
V(bool, javascript_execution_throws, true) \
V(bool, javascript_execution_dump, true) \
V(uint32_t, javascript_execution_counter, 0) \
V(bool, deoptimization_assert, true) \
V(bool, compilation_assert, true) \
V(bool, no_exception_assert, true) \
V(uint32_t, wasm_switch_to_the_central_stack_counter, 0)
#define THREAD_LOCAL_TOP_ACCESSOR(type, name) \
inline void set_##name(type v) { thread_local_top()->name##_ = v; } \
inline type name() const { return thread_local_top()->name##_; }
#define THREAD_LOCAL_TOP_ADDRESS(type, name) \
inline type* name##_address() { return &thread_local_top()->name##_; }
#ifdef OHOS_JS_ENGINE
class EnumTimesCache {
public:
explicit EnumTimesCache() {}
~EnumTimesCache() = default;
size_t LookUp(uint64_t objPtr, int &objCnt) {
for (size_t index = 0; index < cache_deque_.size(); index++) {
if (cache_deque_[index].first == objPtr) {
objCnt = cache_deque_[index].second;
return index;
}
}
return kOperateEnumTimeCacheInvalidPos;
}
void RemoveCurrentElem(uint64_t objPtr) {
int objCnt = 0;
size_t index = LookUp(objPtr, objCnt);
if (index != kOperateEnumTimeCacheInvalidPos) {
cache_deque_.erase(cache_deque_.begin() + index);
}
}
int Put(uint64_t objPtr) {
int objCnt = 0;
size_t index = LookUp(objPtr, objCnt);
if (index == kOperateEnumTimeCacheInvalidPos) {
if (cache_deque_.size() > kSlowEnumTimesCacheCapacity) {
cache_deque_.pop_front();
}
cache_deque_.push_back(std::make_pair(objPtr, 0));
} else {
objCnt++;
cache_deque_[index] = {objPtr, objCnt};
}
return objCnt;
}
private:
std::deque<std::pair<uint64_t, int>> cache_deque_;
};
#endif
__attribute__((tls_model(V8_TLS_MODEL))) extern thread_local Isolate*
g_current_isolate_ V8_CONSTINIT;
class V8_EXPORT_PRIVATE HiddenFactory : private Factory {};
class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
class ThreadDataTable;
class EntryStackItem;
#ifdef V8_ENABLE_OHOS_ASYNC_STACK
public:
void DfxSetPromiseId(DirectHandle<JSPromise> promise, uint64_t id);
uint64_t DfxGetPromiseId(DirectHandle<JSPromise> promise);
bool DfxClearPromiseId(DirectHandle<JSPromise> promise);
#endif
public:
Isolate(const Isolate&) = delete;
Isolate& operator=(const Isolate&) = delete;
using HandleScopeType = HandleScope;
void* operator new(size_t) = delete;
void operator delete(void*) = delete;
class PerIsolateThreadData {
public:
PerIsolateThreadData(Isolate* isolate, ThreadId thread_id)
: isolate_(isolate),
thread_id_(thread_id),
stack_limit_(0),
thread_state_(nullptr)
#if USE_SIMULATOR
,
simulator_(nullptr)
#endif
{
}
~PerIsolateThreadData();
PerIsolateThreadData(const PerIsolateThreadData&) = delete;
PerIsolateThreadData& operator=(const PerIsolateThreadData&) = delete;
Isolate* isolate() const { return isolate_; }
ThreadId thread_id() const { return thread_id_; }
FIELD_ACCESSOR(uintptr_t, stack_limit)
FIELD_ACCESSOR(ThreadState*, thread_state)
#if USE_SIMULATOR
FIELD_ACCESSOR(Simulator*, simulator)
#endif
bool Matches(Isolate* isolate, ThreadId thread_id) const {
return isolate_ == isolate && thread_id_ == thread_id;
}
private:
Isolate* isolate_;
ThreadId thread_id_;
uintptr_t stack_limit_;
ThreadState* thread_state_;
#if USE_SIMULATOR
Simulator* simulator_;
#endif
friend class Isolate;
friend class ThreadDataTable;
friend class EntryStackItem;
};
struct PromiseHandler {
Tagged<SharedFunctionInfo> function_info;
bool async;
};
static void InitializeOncePerProcess();
static Isolate* New();
static Isolate* New(IsolateGroup* isolate_group);
static void Deinitialize(Isolate* isolate);
static void Free(Isolate* isolate);
static void Delete(Isolate* isolate);
void SetUpFromReadOnlyArtifacts(ReadOnlyArtifacts* artifacts);
void set_read_only_heap(ReadOnlyHeap* ro_heap) { read_only_heap_ = ro_heap; }
v8::PageAllocator* page_allocator() const;
V8_INLINE static PerIsolateThreadData* CurrentPerIsolateThreadData();
V8_TLS_DECLARE_GETTER(TryGetCurrent, Isolate*, g_current_isolate_)
V8_INLINE static Isolate* Current();
static void SetCurrent(Isolate* isolate);
inline bool IsCurrent() const;
void InitializeLoggingAndCounters();
bool InitializeCounters();
bool InitWithoutSnapshot();
bool InitWithSnapshot(SnapshotData* startup_snapshot_data,
SnapshotData* read_only_snapshot_data,
SnapshotData* shared_heap_snapshot_data,
bool can_rehash);
bool IsInUse() { return entry_stack_ != nullptr; }
void ReleaseSharedPtrs();
void ClearSerializerData();
void UpdateLogObjectRelocation();
void Enter();
void Exit();
PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread();
PerIsolateThreadData* FindPerThreadDataForThisThread();
PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id);
void DiscardPerThreadDataForThisThread();
base::RecursiveMutex* break_access() { return &break_access_; }
base::Mutex* feedback_vector_access() { return &feedback_vector_access_; }
base::Mutex* internalized_string_access() {
return &internalized_string_access_;
}
base::Mutex* full_transition_array_access() {
return &full_transition_array_access_;
}
base::Mutex* shared_function_info_access() {
return &shared_function_info_access_;
}
base::Mutex* map_updater_access() { return &map_updater_access_; }
base::Mutex* boilerplate_migration_access() {
return &boilerplate_migration_access_;
}
ReadOnlyArtifacts* read_only_artifacts() const {
ReadOnlyArtifacts* artifacts = isolate_group()->read_only_artifacts();
DCHECK_NOT_NULL(artifacts);
return artifacts;
}
StringTable* string_table() const {
return OwnsStringTables() ? string_table_.get()
: shared_space_isolate()->string_table_.get();
}
StringForwardingTable* string_forwarding_table() const {
return OwnsStringTables()
? string_forwarding_table_.get()
: shared_space_isolate()->string_forwarding_table_.get();
}
SharedStructTypeRegistry* shared_struct_type_registry() const {
return is_shared_space_isolate()
? shared_struct_type_registry_.get()
: shared_space_isolate()->shared_struct_type_registry_.get();
}
Address get_address_from_id(IsolateAddressId id);
Tagged<Context> context() const { return thread_local_top()->context_; }
inline void set_context(Tagged<Context> context);
Tagged<Context>* context_address() { return &thread_local_top()->context_; }
Tagged<Context> topmost_script_having_context() const {
return thread_local_top()->topmost_script_having_context_;
}
inline void set_topmost_script_having_context(Tagged<Context> context);
inline void clear_topmost_script_having_context();
Tagged<Context>* topmost_script_having_context_address() {
return &thread_local_top()->topmost_script_having_context_;
}
inline void set_thread_id(ThreadId id) {
thread_local_top()->thread_id_.store(id, std::memory_order_relaxed);
}
inline ThreadId thread_id() const {
return thread_local_top()->thread_id_.load(std::memory_order_relaxed);
}
void InstallConditionalFeatures(DirectHandle<NativeContext> context);
#if V8_ENABLE_WEBASSEMBLY
void WasmInitJSPIFeature();
#endif
bool IsSharedArrayBufferConstructorEnabled(
DirectHandle<NativeContext> context);
bool IsWasmCustomDescriptorsEnabled(DirectHandle<NativeContext> context);
bool IsCompileHintsMagicEnabled(Handle<NativeContext> context);
THREAD_LOCAL_TOP_ADDRESS(Tagged<Context>, pending_handler_context)
THREAD_LOCAL_TOP_ADDRESS(Address, pending_handler_entrypoint)
THREAD_LOCAL_TOP_ADDRESS(Address, pending_handler_constant_pool)
THREAD_LOCAL_TOP_ADDRESS(Address, pending_handler_fp)
THREAD_LOCAL_TOP_ADDRESS(Address, pending_handler_sp)
THREAD_LOCAL_TOP_ADDRESS(uintptr_t, num_frames_above_pending_handler)
v8::TryCatch* try_catch_handler() {
return thread_local_top()->try_catch_handler_;
}
THREAD_LOCAL_TOP_ADDRESS(Tagged<Object>, exception)
inline Tagged<Object> exception();
inline void set_exception(Tagged<Object> exception_obj);
inline void clear_exception();
inline void clear_internal_exception();
inline bool has_exception();
THREAD_LOCAL_TOP_ADDRESS(Tagged<Object>, pending_message)
inline void clear_pending_message();
inline Tagged<Object> pending_message();
inline bool has_pending_message();
inline void set_pending_message(Tagged<Object> message_obj);
#ifdef DEBUG
inline Tagged<Object> VerifyBuiltinsResult(Tagged<Object> result);
inline ObjectPair VerifyBuiltinsResult(ObjectPair pair);
#endif
enum class ExceptionHandlerType {
kJavaScriptHandler,
kExternalTryCatch,
kNone
};
ExceptionHandlerType TopExceptionHandlerType(Tagged<Object> exception);
inline bool is_catchable_by_javascript(Tagged<Object> exception);
inline bool is_catchable_by_wasm(Tagged<Object> exception);
inline bool is_execution_terminating();
static Address c_entry_fp(ThreadLocalTop* thread) {
return thread->c_entry_fp_;
}
static Address handler(ThreadLocalTop* thread) { return thread->handler_; }
Address c_function() { return thread_local_top()->c_function_; }
inline Address* c_entry_fp_address() {
return &thread_local_top()->c_entry_fp_;
}
static uint32_t c_entry_fp_offset() {
return static_cast<uint32_t>(OFFSET_OF(Isolate, isolate_data_) +
OFFSET_OF(IsolateData, thread_local_top_) +
OFFSET_OF(ThreadLocalTop, c_entry_fp_) -
isolate_root_bias());
}
inline Address* handler_address() { return &thread_local_top()->handler_; }
inline Address* c_function_address() {
return &thread_local_top()->c_function_;
}
#if defined(DEBUG) || defined(VERIFY_HEAP)
void RegisterDeserializerStarted() { ++num_active_deserializers_; }
void RegisterDeserializerFinished() {
CHECK_GE(--num_active_deserializers_, 0);
}
bool has_active_deserializer() const {
return num_active_deserializers_.load(std::memory_order_acquire) > 0;
}
#else
void RegisterDeserializerStarted() {}
void RegisterDeserializerFinished() {}
bool has_active_deserializer() const { UNREACHABLE(); }
#endif
Address js_entry_sp() { return thread_local_top()->js_entry_sp_; }
inline Address* js_entry_sp_address() {
return &thread_local_top()->js_entry_sp_;
}
std::vector<MemoryRange>* GetCodePages() const;
void SetCodePages(std::vector<MemoryRange>* new_code_pages);
inline Handle<JSGlobalObject> global_object();
inline Handle<JSGlobalProxy> global_proxy();
static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); }
void FreeThreadResources() { thread_local_top()->Free(); }
bool WalkCallStackAndPromiseTree(
MaybeDirectHandle<JSPromise> rejected_promise,
const std::function<void(PromiseHandler)>& callback);
class V8_NODISCARD ExceptionScope {
public:
inline explicit ExceptionScope(Isolate* isolate);
inline ~ExceptionScope();
private:
Isolate* isolate_;
Handle<Object> exception_;
};
void SetCaptureStackTraceForUncaughtExceptions(
bool capture, int frame_limit, StackTrace::StackTraceOptions options);
bool get_capture_stack_trace_for_uncaught_exceptions() const;
void SetAbortOnUncaughtExceptionCallback(
v8::Isolate::AbortOnUncaughtExceptionCallback callback);
enum PrintStackMode { kPrintStackConcise, kPrintStackVerbose };
void PrintCurrentStackTrace(std::ostream& out,
PrintCurrentStackTraceFilterCallback
should_include_frame_callback = nullptr);
void PrintStack(StringStream* accumulator,
PrintStackMode mode = kPrintStackVerbose);
void PrintStack(FILE* out, PrintStackMode mode = kPrintStackVerbose);
DirectHandle<String> StackTraceString();
V8_NOINLINE void PushStackTraceAndDie(
void* ptr1 = nullptr, void* ptr2 = nullptr, void* ptr3 = nullptr,
void* ptr4 = nullptr, void* ptr5 = nullptr, void* ptr6 = nullptr);
V8_NOINLINE void PushParamsAndDie(void* ptr1 = nullptr, void* ptr2 = nullptr,
void* ptr3 = nullptr, void* ptr4 = nullptr,
void* ptr5 = nullptr, void* ptr6 = nullptr);
V8_NOINLINE void PushStackTraceAndContinue(
void* ptr1 = nullptr, void* ptr2 = nullptr, void* ptr3 = nullptr,
void* ptr4 = nullptr, void* ptr5 = nullptr, void* ptr6 = nullptr);
V8_NOINLINE void PushParamsAndContinue(
void* ptr1 = nullptr, void* ptr2 = nullptr, void* ptr3 = nullptr,
void* ptr4 = nullptr, void* ptr5 = nullptr, void* ptr6 = nullptr);
DirectHandle<StackTraceInfo> CaptureDetailedStackTrace(
int limit, StackTrace::StackTraceOptions options);
MaybeDirectHandle<JSObject> CaptureAndSetErrorStack(
DirectHandle<JSObject> error_object, FrameSkipMode mode,
Handle<Object> caller);
Handle<StackTraceInfo> GetDetailedStackTrace(
DirectHandle<JSReceiver> error_object);
Handle<FixedArray> GetSimpleStackTrace(DirectHandle<JSReceiver> error_object);
DirectHandle<String> CurrentScriptNameOrSourceURL();
int CurrentScriptId();
MaybeDirectHandle<Script> CurrentReferrerScript();
bool GetStackTraceLimit(Isolate* isolate, int* result);
Address GetAbstractPC(int* line, int* column);
bool MayAccess(DirectHandle<NativeContext> accessing_context,
DirectHandle<JSObject> receiver);
void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback);
V8_WARN_UNUSED_RESULT MaybeDirectHandle<Object> ReportFailedAccessCheck(
DirectHandle<JSObject> receiver);
Tagged<Object> Throw(Tagged<Object> exception,
MessageLocation* location = nullptr);
Tagged<Object> ThrowAt(DirectHandle<JSObject> exception,
MessageLocation* location);
Tagged<Object> ThrowIllegalOperation();
void FatalProcessOutOfHeapMemory(const char* location) {
heap()->FatalProcessOutOfMemory(location);
}
void set_console_delegate(debug::ConsoleDelegate* delegate) {
console_delegate_ = delegate;
}
debug::ConsoleDelegate* console_delegate() { return console_delegate_; }
void set_async_event_delegate(debug::AsyncEventDelegate* delegate) {
async_event_delegate_ = delegate;
PromiseHookStateUpdated();
}
void OnAsyncFunctionSuspended(DirectHandle<JSPromise> promise,
DirectHandle<JSPromise> parent);
void OnPromiseThen(DirectHandle<JSPromise> promise);
void OnPromiseBefore(DirectHandle<JSPromise> promise);
void OnPromiseAfter(DirectHandle<JSPromise> promise);
void OnStackTraceCaptured(DirectHandle<StackTraceInfo> stack_trace);
void OnTerminationDuringRunMicrotasks();
Tagged<Object> ReThrow(Tagged<Object> exception);
Tagged<Object> ReThrow(Tagged<Object> exception, Tagged<Object> message);
Tagged<Object> UnwindAndFindHandler();
enum CatchType {
NOT_CAUGHT,
CAUGHT_BY_JAVASCRIPT,
CAUGHT_BY_EXTERNAL,
CAUGHT_BY_PROMISE,
CAUGHT_BY_ASYNC_AWAIT,
};
CatchType PredictExceptionCatcher();
void ReportPendingMessages(bool report = true);
bool ComputeLocation(MessageLocation* target);
bool ComputeLocationFromException(MessageLocation* target,
DirectHandle<Object> exception);
bool ComputeLocationFromSimpleStackTrace(MessageLocation* target,
DirectHandle<Object> exception);
bool ComputeLocationFromDetailedStackTrace(MessageLocation* target,
DirectHandle<Object> exception);
Handle<JSMessageObject> CreateMessage(DirectHandle<Object> exception,
MessageLocation* location);
DirectHandle<JSMessageObject> CreateMessageOrAbort(
DirectHandle<Object> exception, MessageLocation* location);
Handle<JSMessageObject> CreateMessageFromException(
DirectHandle<Object> exception);
Tagged<Object> StackOverflow();
Tagged<Object> TerminateExecution();
void CancelTerminateExecution();
void RequestInterrupt(InterruptCallback callback, void* data);
void InvokeApiInterruptCallbacks();
void RequestInvalidateNoProfilingProtector();
void Iterate(RootVisitor* v);
void Iterate(RootVisitor* v, ThreadLocalTop* t);
char* Iterate(RootVisitor* v, char* t);
void IterateThread(ThreadVisitor* v, char* t);
inline Handle<NativeContext> native_context();
inline Tagged<NativeContext> raw_native_context();
inline DirectHandle<NativeContext> GetIncumbentContext();
DirectHandle<NativeContext> GetIncumbentContextSlow();
void RegisterTryCatchHandler(v8::TryCatch* that);
void UnregisterTryCatchHandler(v8::TryCatch* that);
char* ArchiveThread(char* to);
char* RestoreThread(char* from);
static const int kUC16AlphabetSize = 256;
static const int kBMMaxShift = 250;
#define GLOBAL_ACCESSOR(type, name, initialvalue) \
inline type name() const { \
DCHECK_EQ(OFFSET_OF(Isolate, name##_), name##_debug_offset_); \
return name##_; \
} \
inline void set_##name(type value) { \
DCHECK_EQ(OFFSET_OF(Isolate, name##_), name##_debug_offset_); \
name##_ = value; \
}
ISOLATE_INIT_LIST(GLOBAL_ACCESSOR)
ISOLATE_INIT_LIST_JS_ENGINE(GLOBAL_ACCESSOR)
#undef GLOBAL_ACCESSOR
void SetDetailedSourcePositionsForProfiling(bool value) {
if (value) {
CollectSourcePositionsForAllBytecodeArrays();
}
detailed_source_positions_for_profiling_ = value;
}
bool detailed_source_positions_for_profiling() const {
return detailed_source_positions_for_profiling_;
}
#define GLOBAL_ARRAY_ACCESSOR(type, name, length) \
inline type* name() { \
DCHECK(OFFSET_OF(Isolate, name##_) == name##_debug_offset_); \
return &(name##_)[0]; \
}
ISOLATE_INIT_ARRAY_LIST(GLOBAL_ARRAY_ACCESSOR)
#undef GLOBAL_ARRAY_ACCESSOR
#define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \
inline Handle<UNPAREN(type)> name(); \
inline bool is_##name(Tagged<UNPAREN(type)> value);
NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR)
#undef NATIVE_CONTEXT_FIELD_ACCESSOR
Bootstrapper* bootstrapper() { return bootstrapper_; }
Counters* counters() { return async_counters().get(); }
const std::shared_ptr<Counters>& async_counters() {
DCHECK_NOT_NULL(async_counters_.get());
return async_counters_;
}
const std::shared_ptr<metrics::Recorder>& metrics_recorder() {
return metrics_recorder_;
}
TieringManager* tiering_manager() { return tiering_manager_; }
CompilationCache* compilation_cache() { return compilation_cache_; }
#ifdef OHOS_JS_ENGINE
EnumTimesCache* enum_times_cache() { return enum_times_cache_; }
#endif
V8FileLogger* v8_file_logger() const {
DCHECK_NOT_NULL(v8_file_logger_);
return v8_file_logger_;
}
StackGuard* stack_guard() { return isolate_data()->stack_guard(); }
Heap* heap() { return &heap_; }
const Heap* heap() const { return &heap_; }
ReadOnlyHeap* read_only_heap() const { return read_only_heap_; }
static Isolate* FromHeap(const Heap* heap) {
return reinterpret_cast<Isolate*>(reinterpret_cast<Address>(heap) -
OFFSET_OF(Isolate, heap_));
}
const IsolateData* isolate_data() const { return &isolate_data_; }
IsolateData* isolate_data() { return &isolate_data_; }
Address cage_base() const {
DCHECK_IMPLIES(!COMPRESS_POINTERS_BOOL,
isolate_data()->cage_base() == kNullAddress);
return isolate_data()->cage_base();
}
Address code_cage_base() const {
#ifdef V8_EXTERNAL_CODE_SPACE
return code_cage_base_;
#else
return cage_base();
#endif
}
#ifdef V8_ENABLE_SANDBOX
Address trusted_cage_base() const {
return isolate_data()->trusted_cage_base_;
}
#endif
IsolateGroup* isolate_group() const { return isolate_group_; }
#ifdef V8_COMPRESS_POINTERS
VirtualMemoryCage* GetPtrComprCage() const {
return isolate_group()->GetPtrComprCage();
}
VirtualMemoryCage* GetPtrComprCodeCageForTesting();
#endif
Address isolate_root() const { return isolate_data()->isolate_root(); }
constexpr static size_t isolate_root_bias() {
return OFFSET_OF(Isolate, isolate_data_) + IsolateData::kIsolateRootBias;
}
static Isolate* FromRootAddress(Address isolate_root) {
return reinterpret_cast<Isolate*>(isolate_root - isolate_root_bias());
}
RootsTable& roots_table() { return isolate_data()->roots(); }
const RootsTable& roots_table() const { return isolate_data()->roots(); }
base::AddressRegion root_register_addressable_region() const {
return base::AddressRegion(reinterpret_cast<Address>(&isolate_data_),
sizeof(IsolateData));
}
Tagged<Object> root(RootIndex index) const {
return Tagged<Object>(roots_table()[index]);
}
Handle<Object> root_handle(RootIndex index) {
return Handle<Object>(&roots_table()[index]);
}
ExternalReferenceTable* external_reference_table() {
DCHECK(isolate_data()->external_reference_table()->is_initialized());
return isolate_data()->external_reference_table();
}
ExternalReferenceTable* external_reference_table_unsafe() {
return isolate_data()->external_reference_table();
}
Address* builtin_entry_table() { return isolate_data_.builtin_entry_table(); }
V8_INLINE JSDispatchHandle
builtin_dispatch_handle(JSBuiltinDispatchHandleRoot::Idx idx) {
#if V8_STATIC_DISPATCH_HANDLES_BOOL
return JSDispatchTable::GetStaticHandleForReadOnlySegmentEntry(idx);
#else
return isolate_data_.builtin_dispatch_table()[idx];
#endif
}
V8_INLINE JSDispatchHandle builtin_dispatch_handle(Builtin builtin) {
return builtin_dispatch_handle(
JSBuiltinDispatchHandleRoot::to_idx(builtin));
}
JSDispatchTable::Space* GetJSDispatchTableSpaceFor(Address owning_slot) {
DCHECK(!ReadOnlyHeap::Contains(owning_slot));
return heap()->js_dispatch_table_space();
}
V8_INLINE Address* builtin_table() { return isolate_data_.builtin_table(); }
V8_INLINE Address* builtin_tier0_table() {
return isolate_data_.builtin_tier0_table();
}
bool IsBuiltinTableHandleLocation(Address* handle_location);
StubCache* load_stub_cache() const { return load_stub_cache_; }
StubCache* store_stub_cache() const { return store_stub_cache_; }
StubCache* define_own_stub_cache() const { return define_own_stub_cache_; }
Deoptimizer* GetAndClearCurrentDeoptimizer() {
Deoptimizer* result = current_deoptimizer_;
CHECK_NOT_NULL(result);
current_deoptimizer_ = nullptr;
return result;
}
void set_current_deoptimizer(Deoptimizer* deoptimizer) {
DCHECK_NULL(current_deoptimizer_);
DCHECK_NOT_NULL(deoptimizer);
current_deoptimizer_ = deoptimizer;
}
bool deoptimizer_lazy_throw() const { return deoptimizer_lazy_throw_; }
void set_deoptimizer_lazy_throw(bool value) {
deoptimizer_lazy_throw_ = value;
}
void InitializeThreadLocal();
ThreadLocalTop* thread_local_top() {
return &isolate_data_.thread_local_top_;
}
ThreadLocalTop const* thread_local_top() const {
return &isolate_data_.thread_local_top_;
}
constexpr static uint32_t context_offset() {
return static_cast<uint32_t>(
OFFSET_OF(Isolate, isolate_data_) +
OFFSET_OF(IsolateData, thread_local_top_) +
OFFSET_OF(ThreadLocalTop, context_) -
isolate_root_bias());
}
constexpr static uint32_t central_stack_sp_offset() {
return static_cast<uintptr_t>(OFFSET_OF(Isolate, isolate_data_) +
OFFSET_OF(IsolateData, thread_local_top_) +
OFFSET_OF(ThreadLocalTop, central_stack_sp_) -
isolate_root_bias());
}
constexpr static uint32_t central_stack_limit_offset() {
return static_cast<uintptr_t>(
OFFSET_OF(Isolate, isolate_data_) +
OFFSET_OF(IsolateData, thread_local_top_) +
OFFSET_OF(ThreadLocalTop, central_stack_limit_) - isolate_root_bias());
}
static uint32_t error_message_param_offset() {
return static_cast<uint32_t>(OFFSET_OF(Isolate, isolate_data_) +
OFFSET_OF(IsolateData, error_message_param_) -
isolate_root_bias());
}
uint8_t error_message_param() { return isolate_data_.error_message_param_; }
THREAD_LOCAL_TOP_ADDRESS(uint8_t, is_on_central_stack_flag)
MaterializedObjectStore* materialized_object_store() const {
return materialized_object_store_;
}
DescriptorLookupCache* descriptor_lookup_cache() const {
return descriptor_lookup_cache_;
}
V8_INLINE HandleScopeData* handle_scope_data() {
return &isolate_data_.handle_scope_data_;
}
HandleScopeImplementer* handle_scope_implementer() const {
DCHECK(handle_scope_implementer_);
return handle_scope_implementer_;
}
UnicodeCache* unicode_cache() const { return unicode_cache_; }
InnerPointerToCodeCache* inner_pointer_to_code_cache() {
return inner_pointer_to_code_cache_;
}
#if V8_ENABLE_WEBASSEMBLY
wasm::WasmCodeLookupCache* wasm_code_look_up_cache() {
return wasm_code_look_up_cache_;
}
wasm::WasmOrphanedGlobalHandle* NewWasmOrphanedGlobalHandle();
wasm::StackPool& stack_pool() { return stack_pool_; }
#endif
GlobalHandles* global_handles() const { return global_handles_; }
TracedHandles* traced_handles() { return &traced_handles_; }
EternalHandles* eternal_handles() const { return eternal_handles_; }
ThreadManager* thread_manager() const { return thread_manager_; }
bigint::Processor* bigint_processor() { return bigint_processor_; }
#ifndef V8_INTL_SUPPORT
unibrow::Mapping<unibrow::Ecma262UnCanonicalize>* jsregexp_uncanonicalize() {
return &jsregexp_uncanonicalize_;
}
unibrow::Mapping<unibrow::CanonicalizationRange>* jsregexp_canonrange() {
return &jsregexp_canonrange_;
}
unibrow::Mapping<unibrow::Ecma262Canonicalize>*
regexp_macro_assembler_canonicalize() {
return ®exp_macro_assembler_canonicalize_;
}
#endif
RuntimeState* runtime_state() { return &runtime_state_; }
Builtins* builtins() { return &builtins_; }
BuiltinsEffectsAnalyzer* builtins_effects_analyzer() {
return builtins_effects_analyzer_;
}
void set_builtins_effects_analyzer(
BuiltinsEffectsAnalyzer* builtins_effects_analyzer) {
DCHECK((builtins_effects_analyzer_ == nullptr) ^
(builtins_effects_analyzer == nullptr));
builtins_effects_analyzer_ = builtins_effects_analyzer;
}
RegExpStack* regexp_stack() const { return regexp_stack_; }
int32_t* regexp_static_result_offsets_vector() const {
return isolate_data()->regexp_static_result_offsets_vector();
}
void set_regexp_static_result_offsets_vector(int32_t* value) {
DCHECK_EQ(value == nullptr,
regexp_static_result_offsets_vector() != nullptr);
isolate_data()->set_regexp_static_result_offsets_vector(value);
}
Address address_of_regexp_static_result_offsets_vector() const {
return isolate_data()->regexp_static_result_offsets_vector_address();
}
std::unordered_set<int32_t*>& active_dynamic_regexp_result_vectors() {
return active_dynamic_regexp_result_vectors_;
}
std::vector<int>* regexp_indices() { return ®exp_indices_; }
size_t total_regexp_code_generated() const {
return total_regexp_code_generated_;
}
void IncreaseTotalRegexpCodeGenerated(DirectHandle<HeapObject> code);
Debug* debug() const { return debug_; }
bool is_profiling() const {
return isolate_data_.execution_mode_ &
IsolateExecutionModeFlag::kIsProfiling;
}
void SetIsProfiling(bool enabled) {
if (enabled) {
CollectSourcePositionsForAllBytecodeArrays();
RequestInvalidateNoProfilingProtector();
}
isolate_data_.execution_mode_.set(IsolateExecutionModeFlag::kIsProfiling,
enabled);
UpdateLogObjectRelocation();
}
bool should_check_side_effects() const {
return isolate_data_.execution_mode_ &
IsolateExecutionModeFlag::kCheckSideEffects;
}
DebugInfo::ExecutionMode debug_execution_mode() const {
return should_check_side_effects() ? DebugInfo::kSideEffects
: DebugInfo::kBreakpoints;
}
void set_debug_execution_mode(DebugInfo::ExecutionMode debug_execution_mode) {
bool check_side_effects = debug_execution_mode == DebugInfo::kSideEffects;
isolate_data_.execution_mode_.set(
IsolateExecutionModeFlag::kCheckSideEffects, check_side_effects);
}
Logger* logger() const { return logger_; }
#ifdef DEBUG
static size_t non_disposed_isolates() { return non_disposed_isolates_; }
bool has_turbofan_string_builders() { return has_turbofan_string_builders_; }
void set_has_turbofan_string_builders() {
has_turbofan_string_builders_ = true;
}
#endif
v8::internal::Factory* factory() {
return (v8::internal::Factory*)this;
}
static const int kJSRegexpStaticOffsetsVectorSize = 128;
THREAD_LOCAL_TOP_ACCESSOR(ExternalCallbackScope*, external_callback_scope)
THREAD_LOCAL_TOP_ACCESSOR(StateTag, current_vm_state)
THREAD_LOCAL_TOP_ACCESSOR(EmbedderState*, current_embedder_state)
void SetData(uint32_t slot, void* data) {
DCHECK_LT(slot, Internals::kNumIsolateDataSlots);
isolate_data_.embedder_data_[slot] = data;
}
void* GetData(uint32_t slot) const {
DCHECK_LT(slot, Internals::kNumIsolateDataSlots);
return isolate_data_.embedder_data_[slot];
}
bool serializer_enabled() const { return serializer_enabled_; }
void enable_serializer() { serializer_enabled_ = true; }
bool snapshot_available() const {
return snapshot_blob_ != nullptr && snapshot_blob_->raw_size != 0;
}
bool IsDead() const { return has_fatal_error_; }
void SignalFatalError() { has_fatal_error_ = true; }
bool use_optimizer();
bool initialized_from_snapshot() { return initialized_from_snapshot_; }
bool NeedsSourcePositions() const;
bool IsLoggingCodeCreation() const;
bool AllowsCodeCompaction() const;
bool NeedsDetailedOptimizedCodeLineInfo() const;
bool is_best_effort_code_coverage() const {
return code_coverage_mode() == debug::CoverageMode::kBestEffort;
}
bool is_precise_count_code_coverage() const {
return code_coverage_mode() == debug::CoverageMode::kPreciseCount;
}
bool is_precise_binary_code_coverage() const {
return code_coverage_mode() == debug::CoverageMode::kPreciseBinary;
}
bool is_block_count_code_coverage() const {
return code_coverage_mode() == debug::CoverageMode::kBlockCount;
}
bool is_block_binary_code_coverage() const {
return code_coverage_mode() == debug::CoverageMode::kBlockBinary;
}
bool is_block_code_coverage() const {
return is_block_count_code_coverage() || is_block_binary_code_coverage();
}
bool is_binary_code_coverage() const {
return is_precise_binary_code_coverage() || is_block_binary_code_coverage();
}
bool is_count_code_coverage() const {
return is_precise_count_code_coverage() || is_block_count_code_coverage();
}
void SetFeedbackVectorsForProfilingTools(Tagged<Object> value);
void MaybeInitializeVectorListFromHeap();
double time_millis_since_init() const {
return heap_.MonotonicallyIncreasingTimeInMs() - time_millis_at_init_;
}
DateCache* date_cache() const { return date_cache_; }
void set_date_cache(DateCache* date_cache);
Tagged<Smi> date_cache_stamp() const {
return Smi::FromInt(isolate_data()->date_cache_stamp_);
}
Tagged<Smi> GetDateCacheStampAndRecordUsage() {
isolate_data()->is_date_cache_used_ = true;
return date_cache_stamp();
}
void IncreaseDateCacheStampAndInvalidateProtector();
#ifdef V8_INTL_SUPPORT
const std::string& DefaultLocale();
void ResetDefaultLocale();
void set_default_locale(const std::string& locale) {
DCHECK_EQ(default_locale_.length(), 0);
default_locale_ = locale;
}
enum class ICUObjectCacheType{
kDefaultCollator, kDefaultNumberFormat, kDefaultSimpleDateFormat,
kDefaultSimpleDateFormatForTime, kDefaultSimpleDateFormatForDate};
static constexpr int kICUObjectCacheTypeCount = 5;
icu::UMemory* get_cached_icu_object(ICUObjectCacheType cache_type,
DirectHandle<Object> locales);
void set_icu_object_in_cache(ICUObjectCacheType cache_type,
DirectHandle<Object> locales,
std::shared_ptr<icu::UMemory> obj);
void clear_cached_icu_object(ICUObjectCacheType cache_type);
void clear_cached_icu_objects();
#endif
enum class KnownPrototype { kNone, kObject, kArray, kString };
KnownPrototype IsArrayOrObjectOrStringPrototype(Tagged<JSObject> object);
void UpdateNoElementsProtectorOnSetElement(DirectHandle<JSObject> object);
void UpdateNoElementsProtectorOnSetLength(DirectHandle<JSObject> object) {
UpdateNoElementsProtectorOnSetElement(object);
}
void UpdateProtectorsOnSetPrototype(DirectHandle<JSObject> object,
DirectHandle<Object> new_prototype);
void UpdateNoElementsProtectorOnSetPrototype(DirectHandle<JSObject> object) {
UpdateNoElementsProtectorOnSetElement(object);
}
void UpdateTypedArraySpeciesLookupChainProtectorOnSetPrototype(
DirectHandle<JSObject> object);
void UpdateNumberStringNotRegexpLikeProtectorOnSetPrototype(
DirectHandle<JSObject> object);
void UpdateNoElementsProtectorOnNormalizeElements(
DirectHandle<JSObject> object) {
UpdateNoElementsProtectorOnSetElement(object);
}
void UpdateStringWrapperToPrimitiveProtectorOnSetPrototype(
DirectHandle<JSObject> object, DirectHandle<Object> new_prototype);
inline bool IsInitialArrayPrototype(Tagged<JSArray> array);
std::unique_ptr<PersistentHandles> NewPersistentHandles();
PersistentHandlesList* persistent_handles_list() const {
return persistent_handles_list_.get();
}
#ifdef V8_ENABLE_SPARKPLUG
baseline::BaselineBatchCompiler* baseline_batch_compiler() const {
DCHECK_NOT_NULL(baseline_batch_compiler_);
return baseline_batch_compiler_;
}
#endif
#ifdef V8_ENABLE_MAGLEV
maglev::MaglevConcurrentDispatcher* maglev_concurrent_dispatcher() {
DCHECK_NOT_NULL(maglev_concurrent_dispatcher_);
return maglev_concurrent_dispatcher_;
}
#endif
bool concurrent_recompilation_enabled() {
DCHECK(optimizing_compile_dispatcher_ == nullptr ||
v8_flags.concurrent_recompilation);
return optimizing_compile_dispatcher_ != nullptr;
}
void IncreaseConcurrentOptimizationPriority(
CodeKind kind, Tagged<SharedFunctionInfo> function);
OptimizingCompileDispatcher* optimizing_compile_dispatcher() {
DCHECK_NOT_NULL(optimizing_compile_dispatcher_);
return optimizing_compile_dispatcher_;
}
OptimizingCompileDispatcher* SetOptimizingCompileDispatcherForTesting(
OptimizingCompileDispatcher* dispatcher);
void AbortConcurrentOptimization(BlockingBehavior blocking_behavior);
int id() const { return id_; }
bool was_locker_ever_used() const {
return was_locker_ever_used_.load(std::memory_order_relaxed);
}
void set_was_locker_ever_used() {
was_locker_ever_used_.store(true, std::memory_order_relaxed);
}
std::shared_ptr<CompilationStatistics> GetTurboStatistics();
#ifdef V8_ENABLE_MAGLEV
std::shared_ptr<CompilationStatistics> GetMaglevStatistics();
#endif
CodeTracer* GetCodeTracer();
void DumpAndResetStats();
void DumpAndResetBuiltinsProfileData();
void set_force_slow_path(bool v) { force_slow_path_ = v; }
bool force_slow_path() const { return force_slow_path_; }
bool* force_slow_path_address() { return &force_slow_path_; }
bool jitless() const { return jitless_; }
void set_stack_size(size_t v) { stack_size_ = v; }
size_t stack_size() { return stack_size_; }
base::RandomNumberGenerator* random_number_generator();
base::RandomNumberGenerator* fuzzer_rng();
int GenerateIdentityHash(uint32_t mask);
int NextOptimizationId() {
int id = next_optimization_id_.load();
while (true) {
int next_id = id + 1;
if (!Smi::IsValid(next_id)) next_id = 0;
if (next_optimization_id_.compare_exchange_strong(id, next_id)) {
return id;
}
}
}
unsigned NextModuleAsyncEvaluationOrdinal() {
return next_module_async_evaluation_ordinal_++;
}
void AddCallCompletedCallback(CallCompletedCallback callback);
void RemoveCallCompletedCallback(CallCompletedCallback callback);
void FireCallCompletedCallback(MicrotaskQueue* microtask_queue) {
if (!thread_local_top()->CallDepthIsZero()) return;
FireCallCompletedCallbackInternal(microtask_queue);
}
void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
inline void FireBeforeCallEnteredCallback();
void SetPromiseRejectCallback(PromiseRejectCallback callback);
void ReportPromiseReject(DirectHandle<JSPromise> promise,
DirectHandle<Object> value,
v8::PromiseRejectEvent event);
void SetTerminationOnExternalTryCatch();
DirectHandle<Symbol> SymbolFor(RootIndex dictionary_index,
Handle<String> name, bool private_symbol);
void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback);
void CountUsage(v8::Isolate::UseCounterFeature feature);
void CountUsage(base::Vector<const v8::Isolate::UseCounterFeature> features);
static std::string GetTurboCfgFileName(Isolate* isolate);
int GetNextScriptId();
uint32_t next_unique_sfi_id() const {
return next_unique_sfi_id_.load(std::memory_order_relaxed);
}
uint32_t GetAndIncNextUniqueSfiId() {
return next_unique_sfi_id_.fetch_add(1, std::memory_order_relaxed);
}
#ifdef V8_ENABLE_JAVASCRIPT_PROMISE_HOOKS
void SetHasContextPromiseHooks(bool context_promise_hook) {
promise_hook_flags_ = PromiseHookFields::HasContextPromiseHook::update(
promise_hook_flags_, context_promise_hook);
PromiseHookStateUpdated();
}
#endif
bool HasContextPromiseHooks() const {
return PromiseHookFields::HasContextPromiseHook::decode(
promise_hook_flags_);
}
Address promise_hook_flags_address() {
return reinterpret_cast<Address>(&promise_hook_flags_);
}
Address promise_hook_address() {
return reinterpret_cast<Address>(&promise_hook_);
}
Address async_event_delegate_address() {
return reinterpret_cast<Address>(&async_event_delegate_);
}
Address javascript_execution_assert_address() {
return reinterpret_cast<Address>(&javascript_execution_assert_);
}
void IncrementJavascriptExecutionCounter() {
javascript_execution_counter_++;
}
Address handle_scope_implementer_address() {
return reinterpret_cast<Address>(&handle_scope_implementer_);
}
void SetReleaseCppHeapCallback(v8::Isolate::ReleaseCppHeapCallback callback);
void RunReleaseCppHeapCallback(std::unique_ptr<v8::CppHeap> cpp_heap);
void SetPromiseHook(PromiseHook hook);
void RunPromiseHook(PromiseHookType type, DirectHandle<JSPromise> promise,
DirectHandle<Object> parent);
void RunAllPromiseHooks(PromiseHookType type, DirectHandle<JSPromise> promise,
DirectHandle<Object> parent);
void UpdatePromiseHookProtector();
void PromiseHookStateUpdated();
void AddDetachedContext(DirectHandle<Context> context);
void CheckDetachedContextsAfterGC();
void DetachGlobal(DirectHandle<NativeContext> env);
std::vector<Tagged<Object>>* startup_object_cache() {
return &startup_object_cache_;
}
std::vector<Tagged<Object>>* shared_heap_object_cache() {
if (OwnsStringTables()) {
return &shared_heap_object_cache_;
} else {
return &shared_space_isolate()->shared_heap_object_cache_;
}
}
bool IsGeneratingEmbeddedBuiltins() const {
return builtins_constants_table_builder() != nullptr;
}
BuiltinsConstantsTableBuilder* builtins_constants_table_builder() const {
return builtins_constants_table_builder_;
}
#ifdef V8_DUMPLING
DumplingManager* dumpling_manager() { return &dumpling_manager_; }
#endif
size_t HashIsolateForEmbeddedBlob();
static const uint8_t* CurrentEmbeddedBlobCode();
static uint32_t CurrentEmbeddedBlobCodeSize();
static const uint8_t* CurrentEmbeddedBlobData();
static uint32_t CurrentEmbeddedBlobDataSize();
static bool CurrentEmbeddedBlobIsBinaryEmbedded();
const uint8_t* embedded_blob_code() const;
uint32_t embedded_blob_code_size() const;
const uint8_t* embedded_blob_data() const;
uint32_t embedded_blob_data_size() const;
bool is_short_builtin_calls_enabled() const {
return V8_SHORT_BUILTIN_CALLS_BOOL && is_short_builtin_calls_enabled_;
}
static base::AddressRegion GetShortBuiltinsCallRegion();
void set_array_buffer_allocator(v8::ArrayBuffer::Allocator* allocator) {
array_buffer_allocator_ = allocator;
}
v8::ArrayBuffer::Allocator* array_buffer_allocator() const {
return array_buffer_allocator_;
}
void set_array_buffer_allocator_shared(
std::shared_ptr<v8::ArrayBuffer::Allocator> allocator) {
array_buffer_allocator_shared_ = std::move(allocator);
}
std::shared_ptr<v8::ArrayBuffer::Allocator> array_buffer_allocator_shared()
const {
return array_buffer_allocator_shared_;
}
size_t* array_buffer_max_size_address() {
if (array_buffer_max_size_ == 0) {
array_buffer_max_size_ = array_buffer_allocator_->MaxAllocationSize();
}
return &array_buffer_max_size_;
}
FutexWaitListNode* futex_wait_list_node() { return &futex_wait_list_node_; }
CancelableTaskManager* cancelable_task_manager() {
return cancelable_task_manager_;
}
const AstStringConstants* ast_string_constants() const {
return ast_string_constants_;
}
interpreter::Interpreter* interpreter() const { return interpreter_; }
compiler::PerIsolateCompilerCache* compiler_cache() const {
return compiler_cache_;
}
void set_compiler_utils(compiler::PerIsolateCompilerCache* cache,
Zone* zone) {
compiler_cache_ = cache;
compiler_zone_ = zone;
}
AccountingAllocator* allocator() { return allocator_; }
LazyCompileDispatcher* lazy_compile_dispatcher() const {
return lazy_compile_dispatcher_.get();
}
bool IsInCreationContext(Tagged<JSObject> object, uint32_t index);
void ClearKeptObjects();
void SetHostImportModuleDynamicallyCallback(
HostImportModuleDynamicallyCallback callback);
void SetHostImportModuleWithPhaseDynamicallyCallback(
HostImportModuleWithPhaseDynamicallyCallback callback);
MaybeDirectHandle<JSPromise> RunHostImportModuleDynamicallyCallback(
MaybeDirectHandle<Script> maybe_referrer, Handle<Object> specifier,
ModuleImportPhase phase,
MaybeDirectHandle<Object> maybe_import_options_argument);
void SetHostInitializeImportMetaObjectCallback(
HostInitializeImportMetaObjectCallback callback);
MaybeHandle<JSObject> RunHostInitializeImportMetaObjectCallback(
DirectHandle<SourceTextModule> module);
void SetHostCreateShadowRealmContextCallback(
HostCreateShadowRealmContextCallback callback);
MaybeDirectHandle<NativeContext> RunHostCreateShadowRealmContextCallback();
bool IsJSApiWrapperNativeError(DirectHandle<JSReceiver> obj);
void RegisterEmbeddedFileWriter(EmbeddedFileWriterInterface* writer) {
embedded_file_writer_ = writer;
}
int LookupOrAddExternallyCompiledFilename(const char* filename);
const char* GetExternallyCompiledFilename(int index) const;
int GetExternallyCompiledFilenameCount() const;
void PrepareBuiltinSourcePositionMap();
#if defined(V8_OS_WIN64)
void SetBuiltinUnwindData(
Builtin builtin,
const win64_unwindinfo::BuiltinUnwindInfo& unwinding_info);
#endif
void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback);
MaybeDirectHandle<Object> RunPrepareStackTraceCallback(
DirectHandle<NativeContext>, DirectHandle<JSObject> Error,
DirectHandle<JSArray> sites);
bool HasPrepareStackTraceCallback() const;
void SetAddCrashKeyCallback(AddCrashKeyCallback callback);
void AddCrashKey(CrashKeyId id, const std::string& value) {
if (add_crash_key_callback_) {
add_crash_key_callback_(id, value);
}
}
v8::CrashKey AddCrashKeyString(const char key[], CrashKeySize size,
std::string_view value);
void SetCrashKeyString(CrashKey crash_key, std::string_view value);
void SetCrashKeyStringCallbacks(
AllocateCrashKeyStringCallback allocate_callback,
SetCrashKeyStringCallback set_callback);
bool HasCrashKeyStringCallbacks();
#if defined(V8_ENABLE_ETW_STACK_WALKING)
void SetFilterETWSessionByURLCallback(FilterETWSessionByURLCallback callback);
void SetFilterETWSessionByURL2Callback(
FilterETWSessionByURL2Callback callback);
FilterETWSessionByURLResult RunFilterETWSessionByURLCallback(
const std::string& payload);
bool IsETWTracingEnabled() const { return etw_tracing_enabled_; }
void SetETWTracingEnabled(bool enabled) { etw_tracing_enabled_ = enabled; }
bool ETWIsInRundown() const { return etw_in_rundown_; }
void SetETWIsInRundown(bool is_rundown) { etw_in_rundown_ = is_rundown; }
void set_etw_trace_interpreted_frames() {
etw_trace_interpreted_frames_ = true;
}
bool interpreted_frames_native_stack() const {
return v8_flags.interpreted_frames_native_stack ||
etw_trace_interpreted_frames_;
}
#else
bool interpreted_frames_native_stack() const {
return v8_flags.interpreted_frames_native_stack;
}
#endif
#if defined(OHOS_MEM_USAGE_REPORT)
void SetMURCallback(MURCallback callback);
bool RunMURCallback(int id);
#endif
void SetIsLoading(bool is_loading);
void set_code_coverage_mode(debug::CoverageMode coverage_mode) {
code_coverage_mode_.store(coverage_mode, std::memory_order_relaxed);
}
debug::CoverageMode code_coverage_mode() const {
return code_coverage_mode_.load(std::memory_order_relaxed);
}
void SetPriority(v8::Isolate::Priority priority);
v8::Isolate::Priority priority() { return priority_; }
bool is_backgrounded() {
return priority_ == v8::Isolate::Priority::kBestEffort;
}
bool EfficiencyModeEnabled() {
if (V8_UNLIKELY(v8_flags.efficiency_mode.value().has_value())) {
return *v8_flags.efficiency_mode.value();
}
return priority_ != v8::Isolate::Priority::kUserBlocking;
}
bool BatterySaverModeEnabled() {
if (V8_UNLIKELY(v8_flags.battery_saver_mode.value().has_value())) {
return *v8_flags.battery_saver_mode.value();
}
return V8_UNLIKELY(battery_saver_mode_enabled_);
}
bool MemorySaverModeEnabled() {
if (v8_flags.optimize_for_size) {
return true;
}
if (V8_UNLIKELY(v8_flags.memory_saver_mode.value().has_value())) {
return *v8_flags.memory_saver_mode.value();
}
return V8_UNLIKELY(memory_saver_mode_enabled_);
}
PRINTF_FORMAT(2, 3) void PrintWithTimestamp(const char* format, ...);
void set_allow_atomics_wait(bool set) { allow_atomics_wait_ = set; }
bool allow_atomics_wait() { return allow_atomics_wait_; }
bool flush_denormals() const { return flush_denormals_; }
void RegisterManagedPtrDestructor(ManagedPtrDestructor* finalizer);
void UnregisterManagedPtrDestructor(ManagedPtrDestructor* finalizer);
size_t elements_deletion_counter() { return elements_deletion_counter_; }
void set_elements_deletion_counter(size_t value) {
elements_deletion_counter_ = value;
}
#if V8_ENABLE_WEBASSEMBLY
void AddSharedWasmMemory(DirectHandle<WasmMemoryObject> memory_object);
#endif
const v8::Context::BackupIncumbentScope* top_backup_incumbent_scope() const {
return thread_local_top()->top_backup_incumbent_scope_;
}
void set_top_backup_incumbent_scope(
const v8::Context::BackupIncumbentScope* top_backup_incumbent_scope) {
thread_local_top()->top_backup_incumbent_scope_ =
top_backup_incumbent_scope;
}
void SetIdle(bool is_idle);
void CollectSourcePositionsForAllBytecodeArrays();
void AddCodeMemoryChunk(MutablePageMetadata* chunk);
void RemoveCodeMemoryChunk(MutablePageMetadata* chunk);
void AddCodeRange(Address begin, size_t length_in_bytes);
bool RequiresCodeRange() const;
static Address load_from_stack_count_address(const char* function_name);
static Address store_to_stack_count_address(const char* function_name);
v8::metrics::Recorder::ContextId GetOrRegisterRecorderContextId(
DirectHandle<NativeContext> context);
MaybeLocal<v8::Context> GetContextFromRecorderContextId(
v8::metrics::Recorder::ContextId id);
void UpdateLongTaskStats();
v8::metrics::LongTaskStats* GetCurrentLongTaskStats();
LocalIsolate* main_thread_local_isolate() {
return main_thread_local_isolate_.get();
}
Isolate* AsIsolate() { return this; }
LocalIsolate* AsLocalIsolate() { return main_thread_local_isolate(); }
Isolate* GetMainThreadIsolateUnsafe() { return this; }
LocalHeap* main_thread_local_heap();
#ifdef V8_COMPRESS_POINTERS
ExternalPointerTable& external_pointer_table() {
return isolate_data_.external_pointer_table_;
}
const ExternalPointerTable& external_pointer_table() const {
return isolate_data_.external_pointer_table_;
}
Address external_pointer_table_address() {
return reinterpret_cast<Address>(&isolate_data_.external_pointer_table_);
}
ExternalPointerTable& shared_external_pointer_table() {
return *isolate_data_.shared_external_pointer_table_;
}
const ExternalPointerTable& shared_external_pointer_table() const {
return *isolate_data_.shared_external_pointer_table_;
}
ExternalPointerTable::Space* shared_external_pointer_space() {
return shared_external_pointer_space_;
}
Address shared_external_pointer_table_address_address() {
return reinterpret_cast<Address>(
&isolate_data_.shared_external_pointer_table_);
}
CppHeapPointerTable& cpp_heap_pointer_table() {
return isolate_data_.cpp_heap_pointer_table_;
}
const CppHeapPointerTable& cpp_heap_pointer_table() const {
return isolate_data_.cpp_heap_pointer_table_;
}
#endif
#ifdef V8_ENABLE_SANDBOX
TrustedPointerTable& trusted_pointer_table() {
return isolate_data_.trusted_pointer_table_;
}
const TrustedPointerTable& trusted_pointer_table() const {
return isolate_data_.trusted_pointer_table_;
}
Address trusted_pointer_table_base_address() const {
return isolate_data_.trusted_pointer_table_.base_address();
}
TrustedPointerTable& shared_trusted_pointer_table() {
return *isolate_data_.shared_trusted_pointer_table_;
}
const TrustedPointerTable& shared_trusted_pointer_table() const {
return *isolate_data_.shared_trusted_pointer_table_;
}
TrustedPointerTable::Space* shared_trusted_pointer_space() {
return shared_trusted_pointer_space_;
}
Address shared_trusted_pointer_table_base_address() {
return reinterpret_cast<Address>(
&isolate_data_.shared_trusted_pointer_table_);
}
TrustedPointerPublishingScope* trusted_pointer_publishing_scope() const {
return isolate_data_.trusted_pointer_publishing_scope_;
}
void set_trusted_pointer_publishing_scope(
TrustedPointerPublishingScope* scope) {
DCHECK_NE((trusted_pointer_publishing_scope() == nullptr),
(scope == nullptr));
isolate_data_.trusted_pointer_publishing_scope_ = scope;
}
Address code_pointer_table_base_address() {
return isolate_data_.code_pointer_table_base_address_;
}
#endif
Address continuation_preserved_embedder_data_address() {
return reinterpret_cast<Address>(
&isolate_data_.continuation_preserved_embedder_data_);
}
struct PromiseHookFields {
using HasContextPromiseHook = base::BitField<bool, 0, 1>;
using HasIsolatePromiseHook = HasContextPromiseHook::Next<bool, 1>;
using HasAsyncEventDelegate = HasIsolatePromiseHook::Next<bool, 1>;
using IsDebugActive = HasAsyncEventDelegate::Next<bool, 1>;
};
bool is_shared_space_isolate() const {
DCHECK(is_shared_space_isolate_initialized_);
return is_shared_space_isolate_;
}
Isolate* shared_space_isolate() const {
DCHECK(has_shared_space());
Isolate* isolate = shared_space_isolate_.value();
DCHECK(has_shared_space());
return isolate;
}
bool has_shared_space() const { return shared_space_isolate_.value(); }
GlobalSafepoint* global_safepoint() const { return global_safepoint_.get(); }
#if V8_ENABLE_DRUMBRAKE
void initialize_wasm_execution_timer();
wasm::WasmExecutionTimer* wasm_execution_timer() const {
return wasm_execution_timer_.get();
}
#endif
bool owns_shareable_data() { return owns_shareable_data_; }
bool log_object_relocation() const { return log_object_relocation_; }
bool OwnsStringTables() const {
return !v8_flags.shared_string_table || is_shared_space_isolate();
}
#if USE_SIMULATOR
SimulatorData* simulator_data() { return simulator_data_; }
#endif
#ifdef V8_ENABLE_WEBASSEMBLY
bool IsOnCentralStack();
std::vector<std::unique_ptr<wasm::StackMemory>>& wasm_stacks() {
return wasm_stacks_;
}
template <wasm::JumpBuffer::StackState new_state_of_old_stack,
wasm::JumpBuffer::StackState expected_target_state>
void SwitchStacks(wasm::StackMemory* from, wasm::StackMemory* to, Address sp,
Address fp, Address pc);
void RetireWasmStack(wasm::StackMemory* stack);
#else
bool IsOnCentralStack() { return true; }
#endif
void LocalsBlockListCacheRehash();
void LocalsBlockListCacheSet(DirectHandle<ScopeInfo> scope_info,
DirectHandle<ScopeInfo> outer_scope_info,
DirectHandle<StringSet> locals_blocklist);
Tagged<UnionOf<TheHole, StringSet>> LocalsBlockListCacheGet(
DirectHandle<ScopeInfo> scope_info);
void VerifyStaticRoots();
class EnableRoAllocationForSnapshotScope final {
public:
explicit EnableRoAllocationForSnapshotScope(Isolate* isolate)
: isolate_(isolate) {
CHECK(!isolate_->enable_ro_allocation_for_snapshot_);
isolate_->enable_ro_allocation_for_snapshot_ = true;
}
~EnableRoAllocationForSnapshotScope() {
CHECK(isolate_->enable_ro_allocation_for_snapshot_);
isolate_->enable_ro_allocation_for_snapshot_ = false;
}
private:
Isolate* const isolate_;
};
bool enable_ro_allocation_for_snapshot() const {
return enable_ro_allocation_for_snapshot_;
}
void set_battery_saver_mode_enabled(bool battery_saver_mode_enabled) {
battery_saver_mode_enabled_ = battery_saver_mode_enabled;
}
void set_memory_saver_mode_enabled(bool memory_saver_mode_enabled) {
memory_saver_mode_enabled_ = memory_saver_mode_enabled;
}
void ReportExceptionFunctionCallback(
DirectHandle<JSReceiver> receiver,
DirectHandle<FunctionTemplateInfo> function,
v8::ExceptionContext callback_kind);
void ReportExceptionPropertyCallback(DirectHandle<JSReceiver> holder,
DirectHandle<Name> name,
v8::ExceptionContext callback_kind);
void SetExceptionPropagationCallback(ExceptionPropagationCallback callback);
#ifdef V8_ENABLE_WASM_SIMD256_REVEC
void set_wasm_revec_verifier_for_test(
compiler::turboshaft::WasmRevecVerifier* verifier) {
wasm_revec_verifier_for_test_ = verifier;
}
compiler::turboshaft::WasmRevecVerifier* wasm_revec_verifier_for_test()
const {
return wasm_revec_verifier_for_test_;
}
#endif
bool IsFrozen() const { return is_frozen_; }
void Freeze(bool is_frozen) {
is_frozen_ = is_frozen;
if (v8_flags.memory_reducer_respects_frozen_state && IsFrozen()) {
heap()->FinalizeIncrementalMarkingAtomicallyIfRunning(
i::GarbageCollectionReason::kFrozen);
heap()->EnsureSweepingCompleted(
Heap::SweepingForcedFinalizationMode::kUnifiedHeap,
CompleteSweepingReason::kFreeze);
}
}
static void IterateRegistersAndStackOfSimulator(
::heap::base::StackVisitor* visitor);
std::shared_ptr<v8::TaskRunner> task_runner() const { return task_runner_; }
void PrintNumberStringCacheStats(const char* comment, bool final_summary);
private:
explicit Isolate(IsolateGroup* isolate_group);
~Isolate();
static Isolate* Allocate(IsolateGroup* isolate_group);
bool Init(SnapshotData* startup_snapshot_data,
SnapshotData* read_only_snapshot_data,
SnapshotData* shared_heap_snapshot_data, bool can_rehash);
void CheckIsolateLayout();
void InitializeCodeRanges();
void AddCodeMemoryRange(MemoryRange range);
Isolate* ForSandbox() { return this; }
static void RemoveContextIdCallback(const v8::WeakCallbackInfo<void>& data);
void FireCallCompletedCallbackInternal(MicrotaskQueue* microtask_queue);
class ThreadDataTable {
public:
ThreadDataTable() = default;
PerIsolateThreadData* Lookup(ThreadId thread_id);
void Insert(PerIsolateThreadData* data);
void Remove(PerIsolateThreadData* data);
void RemoveAllThreads();
private:
struct Hasher {
std::size_t operator()(const ThreadId& t) const {
return std::hash<int>()(t.ToInteger());
}
};
std::unordered_map<ThreadId, PerIsolateThreadData*, Hasher> table_;
};
class EntryStackItem {
public:
EntryStackItem(PerIsolateThreadData* previous_thread_data,
Isolate* previous_isolate, EntryStackItem* previous_item)
: entry_count(1),
previous_thread_data(previous_thread_data),
previous_isolate(previous_isolate),
previous_item(previous_item) {}
EntryStackItem(const EntryStackItem&) = delete;
EntryStackItem& operator=(const EntryStackItem&) = delete;
int entry_count;
PerIsolateThreadData* previous_thread_data;
Isolate* previous_isolate;
EntryStackItem* previous_item;
};
void Deinit();
static void SetIsolateThreadLocals(Isolate* isolate,
PerIsolateThreadData* data);
void FillCache();
bool PropagateExceptionToExternalTryCatch(ExceptionHandlerType top_handler);
void NotifyExceptionPropagationCallback();
bool HasIsolatePromiseHooks() const {
return PromiseHookFields::HasIsolatePromiseHook::decode(
promise_hook_flags_);
}
bool HasAsyncEventDelegate() const {
return PromiseHookFields::HasAsyncEventDelegate::decode(
promise_hook_flags_);
}
void AddCrashKeysForIsolateAndHeapPointers();
#if V8_ENABLE_WEBASSEMBLY
bool IsOnCentralStack(Address addr);
#else
bool IsOnCentralStack(Address addr) { return true; }
#endif
IsolateData isolate_data_;
bool is_shared_space_isolate_{false};
#if DEBUG
bool is_shared_space_isolate_initialized_{false};
#endif
IsolateGroup* isolate_group_;
Heap heap_;
ReadOnlyHeap* read_only_heap_ = nullptr;
std::unique_ptr<StringTable> string_table_;
std::unique_ptr<StringForwardingTable> string_forwarding_table_;
const int id_;
std::atomic<EntryStackItem*> entry_stack_ = nullptr;
int stack_trace_nesting_level_ = 0;
std::atomic<bool> was_locker_ever_used_{false};
StringStream* incomplete_message_ = nullptr;
Address isolate_addresses_[kIsolateAddressCount + 1] = {};
Bootstrapper* bootstrapper_ = nullptr;
TieringManager* tiering_manager_ = nullptr;
CompilationCache* compilation_cache_ = nullptr;
#ifdef OHOS_JS_ENGINE
EnumTimesCache* enum_times_cache_ = nullptr;
#endif
std::shared_ptr<Counters> async_counters_;
base::RecursiveMutex break_access_;
base::Mutex feedback_vector_access_;
base::Mutex internalized_string_access_;
base::Mutex full_transition_array_access_;
base::Mutex shared_function_info_access_;
base::Mutex map_updater_access_;
base::Mutex boilerplate_migration_access_;
V8FileLogger* v8_file_logger_ = nullptr;
StubCache* load_stub_cache_ = nullptr;
StubCache* store_stub_cache_ = nullptr;
StubCache* define_own_stub_cache_ = nullptr;
Deoptimizer* current_deoptimizer_ = nullptr;
bool deoptimizer_lazy_throw_ = false;
MaterializedObjectStore* materialized_object_store_ = nullptr;
bool capture_stack_trace_for_uncaught_exceptions_ = false;
int stack_trace_for_uncaught_exceptions_frame_limit_ = 0;
StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_ =
StackTrace::kOverview;
DescriptorLookupCache* descriptor_lookup_cache_ = nullptr;
HandleScopeImplementer* handle_scope_implementer_ = nullptr;
UnicodeCache* unicode_cache_ = nullptr;
AccountingAllocator* allocator_ = nullptr;
InnerPointerToCodeCache* inner_pointer_to_code_cache_ = nullptr;
GlobalHandles* global_handles_ = nullptr;
TracedHandles traced_handles_;
EternalHandles* eternal_handles_ = nullptr;
ThreadManager* thread_manager_ = nullptr;
bigint::Processor* bigint_processor_ = nullptr;
RuntimeState runtime_state_;
Builtins builtins_;
BuiltinsEffectsAnalyzer* builtins_effects_analyzer_ = nullptr;
SetupIsolateDelegate* setup_delegate_ = nullptr;
#if defined(DEBUG) || defined(VERIFY_HEAP)
std::atomic<int> num_active_deserializers_;
#endif
#ifndef V8_INTL_SUPPORT
unibrow::Mapping<unibrow::Ecma262UnCanonicalize> jsregexp_uncanonicalize_;
unibrow::Mapping<unibrow::CanonicalizationRange> jsregexp_canonrange_;
unibrow::Mapping<unibrow::Ecma262Canonicalize>
regexp_macro_assembler_canonicalize_;
#endif
RegExpStack* regexp_stack_ = nullptr;
std::vector<int> regexp_indices_;
std::unordered_set<int32_t*> active_dynamic_regexp_result_vectors_;
DateCache* date_cache_ = nullptr;
base::RandomNumberGenerator* random_number_generator_ = nullptr;
base::RandomNumberGenerator* fuzzer_rng_ = nullptr;
v8::Isolate::ReleaseCppHeapCallback release_cpp_heap_callback_ = nullptr;
PromiseHook promise_hook_ = nullptr;
HostImportModuleDynamicallyCallback host_import_module_dynamically_callback_ =
nullptr;
HostImportModuleWithPhaseDynamicallyCallback
host_import_module_with_phase_dynamically_callback_ = nullptr;
std::atomic<debug::CoverageMode> code_coverage_mode_{
debug::CoverageMode::kBestEffort};
std::atomic<bool> battery_saver_mode_enabled_ = false;
std::atomic<bool> memory_saver_mode_enabled_ = false;
MaybeDirectHandle<FixedArray> GetImportAttributesFromArgument(
MaybeDirectHandle<Object> maybe_import_options_argument);
HostInitializeImportMetaObjectCallback
host_initialize_import_meta_object_callback_ = nullptr;
HostCreateShadowRealmContextCallback
host_create_shadow_realm_context_callback_ = nullptr;
#ifdef V8_INTL_SUPPORT
std::string default_locale_;
struct ICUObjectCacheEntry {
std::string locales;
std::shared_ptr<icu::UMemory> obj;
ICUObjectCacheEntry() = default;
ICUObjectCacheEntry(std::string locales, std::shared_ptr<icu::UMemory> obj)
: locales(locales), obj(std::move(obj)) {}
};
ICUObjectCacheEntry icu_object_cache_[kICUObjectCacheTypeCount];
#endif
bool serializer_enabled_ = false;
bool has_fatal_error_ = false;
bool initialized_from_snapshot_ = false;
bool is_short_builtin_calls_enabled_ = false;
std::atomic<v8::Isolate::Priority> priority_ =
v8::Isolate::Priority::kUserBlocking;
bool owns_shareable_data_ = true;
bool log_object_relocation_ = false;
#ifdef V8_EXTERNAL_CODE_SPACE
Address code_cage_base_ = 0;
#endif
double time_millis_at_init_ = 0;
#ifdef DEBUG
static std::atomic<size_t> non_disposed_isolates_;
JSObject::SpillInformation js_spill_information_;
std::atomic<bool> has_turbofan_string_builders_ = false;
#endif
Debug* debug_ = nullptr;
Logger* logger_ = nullptr;
const AstStringConstants* ast_string_constants_ = nullptr;
interpreter::Interpreter* interpreter_ = nullptr;
compiler::PerIsolateCompilerCache* compiler_cache_ = nullptr;
Zone* compiler_zone_ = nullptr;
std::unique_ptr<LazyCompileDispatcher> lazy_compile_dispatcher_;
#ifdef V8_ENABLE_SPARKPLUG
baseline::BaselineBatchCompiler* baseline_batch_compiler_ = nullptr;
#endif
#ifdef V8_ENABLE_MAGLEV
maglev::MaglevConcurrentDispatcher* maglev_concurrent_dispatcher_ = nullptr;
#endif
using InterruptEntry = std::pair<InterruptCallback, void*>;
std::queue<InterruptEntry> api_interrupts_queue_;
#define GLOBAL_BACKING_STORE(type, name, initialvalue) type name##_;
ISOLATE_INIT_LIST(GLOBAL_BACKING_STORE)
ISOLATE_INIT_LIST_JS_ENGINE(GLOBAL_BACKING_STORE)
#undef GLOBAL_BACKING_STORE
#define GLOBAL_ARRAY_BACKING_STORE(type, name, length) type name##_[length];
ISOLATE_INIT_ARRAY_LIST(GLOBAL_ARRAY_BACKING_STORE)
#undef GLOBAL_ARRAY_BACKING_STORE
#ifdef DEBUG
#define ISOLATE_FIELD_OFFSET(type, name, ignored) \
static const intptr_t name##_debug_offset_;
ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
ISOLATE_INIT_LIST_JS_ENGINE(ISOLATE_FIELD_OFFSET)
ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
#undef ISOLATE_FIELD_OFFSET
#endif
bool detailed_source_positions_for_profiling_;
bool preprocessing_exception_ = false;
OptimizingCompileDispatcher* optimizing_compile_dispatcher_ = nullptr;
std::unique_ptr<PersistentHandlesList> persistent_handles_list_;
bool force_slow_path_ = false;
bool enable_ro_allocation_for_snapshot_ = false;
bool initialized_ = false;
bool jitless_ = false;
std::atomic<int> next_optimization_id_ = 0;
void InitializeNextUniqueSfiId(uint32_t id) {
uint32_t expected = 0;
bool successfully_exchanged = next_unique_sfi_id_.compare_exchange_strong(
expected, id, std::memory_order_relaxed, std::memory_order_relaxed);
CHECK(successfully_exchanged);
}
std::atomic<uint32_t> next_unique_sfi_id_;
unsigned next_module_async_evaluation_ordinal_;
std::vector<BeforeCallEnteredCallback> before_call_entered_callbacks_;
std::vector<CallCompletedCallback> call_completed_callbacks_;
v8::Isolate::UseCounterCallback use_counter_callback_ = nullptr;
std::shared_ptr<CompilationStatistics> turbo_statistics_;
#ifdef V8_ENABLE_MAGLEV
std::shared_ptr<CompilationStatistics> maglev_statistics_;
#endif
std::shared_ptr<metrics::Recorder> metrics_recorder_;
uintptr_t last_recorder_context_id_ = 0;
std::unordered_map<uintptr_t, v8::Global<v8::Context>>
recorder_context_id_map_;
size_t last_long_task_stats_counter_ = 0;
v8::metrics::LongTaskStats long_task_stats_;
std::vector<Tagged<Object>> startup_object_cache_;
std::vector<Tagged<Object>> shared_heap_object_cache_;
BuiltinsConstantsTableBuilder* builtins_constants_table_builder_ = nullptr;
void InitializeDefaultEmbeddedBlob();
void CreateAndSetEmbeddedBlob();
void InitializeIsShortBuiltinCallsEnabled();
void MaybeRemapEmbeddedBuiltinsIntoCodeRange();
void TearDownEmbeddedBlob();
void SetEmbeddedBlob(const uint8_t* code, uint32_t code_size,
const uint8_t* data, uint32_t data_size);
void ClearEmbeddedBlob();
void InitializeBuiltinJSDispatchTable();
const uint8_t* embedded_blob_code_ = nullptr;
uint32_t embedded_blob_code_size_ = 0;
const uint8_t* embedded_blob_data_ = nullptr;
uint32_t embedded_blob_data_size_ = 0;
v8::ArrayBuffer::Allocator* array_buffer_allocator_ = nullptr;
std::shared_ptr<v8::ArrayBuffer::Allocator> array_buffer_allocator_shared_;
size_t array_buffer_max_size_ = 0;
std::shared_ptr<v8::TaskRunner> task_runner_;
FutexWaitListNode futex_wait_list_node_;
CancelableTaskManager* cancelable_task_manager_ = nullptr;
debug::ConsoleDelegate* console_delegate_ = nullptr;
debug::AsyncEventDelegate* async_event_delegate_ = nullptr;
uint32_t promise_hook_flags_ = 0;
uint32_t current_async_task_id_ = 0;
std::unique_ptr<LocalIsolate> main_thread_local_isolate_;
v8::Isolate::AbortOnUncaughtExceptionCallback
abort_on_uncaught_exception_callback_ = nullptr;
bool allow_atomics_wait_ = true;
bool flush_denormals_ = false;
base::Mutex managed_ptr_destructors_mutex_;
ManagedPtrDestructor* managed_ptr_destructors_head_ = nullptr;
size_t total_regexp_code_generated_ = 0;
size_t elements_deletion_counter_ = 0;
std::unique_ptr<TracingCpuProfilerImpl> tracing_cpu_profiler_;
EmbeddedFileWriterInterface* embedded_file_writer_ = nullptr;
PrepareStackTraceCallback prepare_stack_trace_callback_ = nullptr;
#if defined(V8_ENABLE_ETW_STACK_WALKING)
FilterETWSessionByURLCallback filter_etw_session_by_url_callback_ = nullptr;
FilterETWSessionByURL2Callback filter_etw_session_by_url2_callback_ = nullptr;
bool etw_tracing_enabled_;
bool etw_trace_interpreted_frames_;
bool etw_in_rundown_;
#endif
#if defined(OHOS_MEM_USAGE_REPORT)
MURCallback mur_callback_ = nullptr;
#endif
base::Mutex thread_data_table_mutex_;
ThreadDataTable thread_data_table_;
std::optional<Isolate*> shared_space_isolate_;
std::unique_ptr<SharedStructTypeRegistry> shared_struct_type_registry_;
#ifdef V8_COMPRESS_POINTERS
ExternalPointerTable::Space* shared_external_pointer_space_ = nullptr;
#endif
#ifdef V8_ENABLE_SANDBOX
TrustedPointerTable::Space* shared_trusted_pointer_space_ = nullptr;
#endif
std::unique_ptr<GlobalSafepoint> global_safepoint_;
Isolate* global_safepoint_prev_client_isolate_ = nullptr;
Isolate* global_safepoint_next_client_isolate_ = nullptr;
std::atomic<std::vector<MemoryRange>*> code_pages_{nullptr};
std::vector<MemoryRange> code_pages_buffer1_;
std::vector<MemoryRange> code_pages_buffer2_;
base::Mutex code_pages_mutex_;
size_t stack_size_;
#ifdef V8_ENABLE_WEBASSEMBLY
wasm::WasmCodeLookupCache* wasm_code_look_up_cache_ = nullptr;
std::vector<std::unique_ptr<wasm::StackMemory>> wasm_stacks_;
#if V8_ENABLE_DRUMBRAKE
std::unique_ptr<wasm::WasmExecutionTimer> wasm_execution_timer_;
#endif
wasm::WasmOrphanedGlobalHandle* wasm_orphaned_handle_ = nullptr;
wasm::StackPool stack_pool_;
#endif
AddCrashKeyCallback add_crash_key_callback_ = nullptr;
AllocateCrashKeyStringCallback allocate_crash_key_string_callback_;
SetCrashKeyStringCallback set_crash_key_string_callback_;
#ifdef V8_ENABLE_WASM_SIMD256_REVEC
compiler::turboshaft::WasmRevecVerifier* wasm_revec_verifier_for_test_ =
nullptr;
#endif
void* operator new(size_t, void* ptr) { return ptr; }
#ifdef V8_DUMPLING
DumplingManager dumpling_manager_;
#endif
#if USE_SIMULATOR
SimulatorData* simulator_data_ = nullptr;
#endif
#ifdef V8_ENABLE_CHECKS
ThreadId current_thread_id_;
int current_thread_counter_ = 0;
#endif
#ifdef V8_ENABLE_OHOS_ASYNC_STACK
std::unordered_map<int, uint64_t> promise_to_dfx_async_id_;
#endif
bool is_frozen_ = false;
friend class GlobalSafepoint;
friend class heap::HeapTester;
friend class IsolateForPointerCompression;
friend class IsolateForSandbox;
friend class IsolateGroup;
friend class TestSerializer;
friend class SharedHeapNoClientsTest;
};
extern thread_local Isolate::PerIsolateThreadData*
g_current_per_isolate_thread_data_ V8_CONSTINIT;
#undef FIELD_ACCESSOR
#undef THREAD_LOCAL_TOP_ACCESSOR
#undef THREAD_LOCAL_TOP_ADDRESS
class V8_EXPORT_PRIVATE SaveContext {
public:
explicit SaveContext(Isolate* isolate);
~SaveContext();
private:
Isolate* const isolate_;
Handle<Context> context_;
Handle<Context> topmost_script_having_context_;
};
class V8_EXPORT_PRIVATE SaveAndSwitchContext : public SaveContext {
public:
SaveAndSwitchContext(Isolate* isolate, Tagged<Context> new_context);
};
class V8_NODISCARD NullContextScope : public SaveAndSwitchContext {
public:
explicit NullContextScope(Isolate* isolate)
: SaveAndSwitchContext(isolate, Context()) {}
};
class AssertNoContextChange {
#ifdef DEBUG
public:
explicit AssertNoContextChange(Isolate* isolate);
~AssertNoContextChange() {
CHECK_EQ(isolate_->context(), *context_);
if (!isolate_->topmost_script_having_context().is_null()) {
CHECK_EQ(isolate_->topmost_script_having_context(),
*topmost_script_having_context_);
}
}
private:
Isolate* isolate_;
Handle<Context> context_;
Handle<Context> topmost_script_having_context_;
#else
public:
explicit AssertNoContextChange(Isolate* isolate) {}
#endif
};
class ExecutionAccess {
public:
explicit ExecutionAccess(Isolate* isolate) : isolate_(isolate) {
Lock(isolate);
}
~ExecutionAccess() { Unlock(isolate_); }
static void Lock(Isolate* isolate) { isolate->break_access()->Lock(); }
static void Unlock(Isolate* isolate) { isolate->break_access()->Unlock(); }
static bool TryLock(Isolate* isolate) {
return isolate->break_access()->TryLock();
}
private:
Isolate* isolate_;
};
class StackLimitCheck {
public:
explicit StackLimitCheck(Isolate* isolate) : isolate_(isolate) {}
bool HasOverflowed() const {
StackGuard* stack_guard = isolate_->stack_guard();
return GetCurrentStackPosition() < stack_guard->real_climit();
}
static bool HasOverflowed(LocalIsolate* local_isolate);
bool JsHasOverflowed(uintptr_t gap = 0) const;
bool WasmHasOverflowed(uintptr_t gap = 0) const;
V8_INLINE bool InterruptRequested() {
StackGuard* stack_guard = isolate_->stack_guard();
return GetCurrentStackPosition() < stack_guard->climit();
}
V8_EXPORT_PRIVATE bool HandleStackOverflowAndTerminationRequest();
private:
Isolate* const isolate_;
};
#define STACK_CHECK(isolate, result_value) \
do { \
StackLimitCheck stack_check(isolate); \
if (V8_UNLIKELY(stack_check.InterruptRequested()) && \
V8_UNLIKELY(stack_check.HandleStackOverflowAndTerminationRequest())) { \
return result_value; \
} \
} while (false)
class StackTraceFailureMessage {
public:
enum StackTraceMode { kIncludeStackTrace, kDontIncludeStackTrace };
explicit StackTraceFailureMessage(Isolate* isolate, StackTraceMode mode,
const Address* ptrs, size_t ptrs_count);
explicit StackTraceFailureMessage(Isolate* isolate, StackTraceMode mode,
std::initializer_list<Address> ptrs)
: StackTraceFailureMessage(isolate, mode, ptrs.begin(), ptrs.size()) {}
explicit StackTraceFailureMessage(Isolate* isolate, StackTraceMode mode,
std::initializer_list<void*> ptrs)
: StackTraceFailureMessage(isolate, mode,
reinterpret_cast<const Address*>(ptrs.begin()),
ptrs.size()) {}
V8_NOINLINE void Print() volatile;
static const uintptr_t kStartMarker = 0xdecade30;
static const uintptr_t kMiddleMarker = 0xdecade33;
static const uintptr_t kEndMarker = 0xdecade36;
static const int kStacktraceBufferSize = 32 * KB;
uintptr_t start_marker_ = kStartMarker;
Isolate* isolate_;
Address ptrs_[64] = {};
uintptr_t middle_marker_ = kMiddleMarker;
Address code_objects_[4] = {};
char js_stack_trace_[kStacktraceBufferSize] = {};
uintptr_t end_marker_ = kEndMarker;
};
template <>
class V8_NODISCARD MutexGuardIfOffThread<Isolate> final {
public:
MutexGuardIfOffThread(base::Mutex* mutex, Isolate* isolate) {
DCHECK_NOT_NULL(mutex);
DCHECK_NOT_NULL(isolate);
DCHECK_EQ(ThreadId::Current(), isolate->thread_id());
}
MutexGuardIfOffThread(const MutexGuardIfOffThread&) = delete;
MutexGuardIfOffThread& operator=(const MutexGuardIfOffThread&) = delete;
};
class V8_NODISCARD SetCurrentIsolateScope final {
public:
explicit inline SetCurrentIsolateScope(Isolate* isolate);
inline ~SetCurrentIsolateScope();
private:
V8_NO_UNIQUE_ADDRESS PtrComprCageAccessScope ptr_compr_cage_access_scope_;
Isolate* const previous_isolate_;
};
}
}
#endif