v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
isolate.h File Reference
#include <atomic>
#include <cstddef>
#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"
Include dependency graph for isolate.h:

Go to the source code of this file.

Classes

class  v8::internal::HiddenFactory
 
class  v8::internal::Isolate
 
class  v8::internal::Isolate::PerIsolateThreadData
 
struct  v8::internal::Isolate::PromiseHandler
 
class  v8::internal::Isolate::ExceptionScope
 
struct  v8::internal::Isolate::PromiseHookFields
 
class  v8::internal::Isolate::EnableRoAllocationForSnapshotScope
 
class  v8::internal::Isolate::ThreadDataTable
 
struct  v8::internal::Isolate::ThreadDataTable::Hasher
 
class  v8::internal::Isolate::EntryStackItem
 
class  v8::internal::SaveContext
 
class  v8::internal::SaveAndSwitchContext
 
class  v8::internal::NullContextScope
 
class  v8::internal::AssertNoContextChange
 
class  v8::internal::ExecutionAccess
 
class  v8::internal::StackLimitCheck
 
class  v8::internal::StackTraceFailureMessage
 
class  v8::internal::MutexGuardIfOffThread< Isolate >
 
class  v8::internal::SetCurrentIsolateScope
 

Namespaces

namespace  v8_inspector
 
namespace  v8
 
namespace  v8::base
 
namespace  v8::bigint
 
namespace  v8::debug
 
namespace  v8::internal
 
namespace  v8::internal::heap
 
namespace  v8::internal::maglev
 
namespace  v8::internal::baseline
 
namespace  v8::internal::interpreter
 
namespace  v8::internal::compiler
 
namespace  v8::internal::compiler::turboshaft
 
namespace  v8::internal::win64_unwindinfo
 
namespace  v8::internal::metrics
 
namespace  v8::internal::wasm
 
namespace  v8::internal::detail
 

Macros

#define RETURN_FAILURE_IF_EXCEPTION(isolate)
 
#define RETURN_FAILURE_IF_EXCEPTION_DETECTOR(isolate, detector)
 
#define RETURN_VALUE_IF_EXCEPTION(isolate, value)
 
#define RETURN_VALUE_IF_EXCEPTION_DETECTOR(isolate, detector, value)
 
#define RETURN_EXCEPTION_IF_EXCEPTION(isolate)
 
#define MAYBE_RETURN_ON_EXCEPTION_VALUE(isolate, call, value)
 
#define RETURN_RESULT_OR_FAILURE(isolate, call)
 
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
 
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
 
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
 
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call)
 
#define THROW_NEW_ERROR_RETURN_VALUE(isolate, call, value)
 
#define THROW_NEW_ERROR(isolate, call)
 
#define RETURN_ON_EXCEPTION_VALUE(isolate, call, value)
 
#define RETURN_FAILURE_ON_EXCEPTION(isolate, call)
 
#define RETURN_ON_EXCEPTION(isolate, call)
 
#define RETURN_FAILURE(isolate, should_throw, call)
 
#define MAYBE_RETURN(call, value)
 
#define MAYBE_RETURN_NULL(call)
 
#define API_ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
 
#define MAYBE_RETURN_ON_EXCEPTION_VALUE(isolate, call, value)
 
#define MAYBE_RETURN_FAILURE_ON_EXCEPTION(isolate, call)
 
#define MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
 
#define MAYBE_ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
 
#define FOR_WITH_HANDLE_SCOPE(isolate, loop_var_type, init, loop_var, limit_check, increment, body)
 
#define WHILE_WITH_HANDLE_SCOPE(isolate, limit_check, body)
 
#define FIELD_ACCESSOR(type, name)
 
#define ISOLATE_INIT_DEBUG_ARRAY_LIST(V)
 
#define ISOLATE_INIT_ARRAY_LIST(V)
 
#define ISOLATE_INIT_LIST(V)
 
#define THREAD_LOCAL_TOP_ACCESSOR(type, name)
 
#define THREAD_LOCAL_TOP_ADDRESS(type, name)
 
#define GLOBAL_ACCESSOR(type, name, initialvalue)
 
#define GLOBAL_ARRAY_ACCESSOR(type, name, length)
 
#define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name)
 
#define GLOBAL_BACKING_STORE(type, name, initialvalue)
 
#define GLOBAL_ARRAY_BACKING_STORE(type, name, length)
 
#define STACK_CHECK(isolate, result_value)
 

Typedefs

using v8::internal::DebugObjectCache = std::vector<Handle<HeapObject>>
 

Functions

void v8::internal::DefaultWasmAsyncResolvePromiseCallback (v8::Isolate *isolate, v8::Local< v8::Context > context, v8::Local< v8::Promise::Resolver > resolver, v8::Local< v8::Value > result, WasmAsyncSuccess success)
 
void v8::internal::DisableEmbeddedBlobRefcounting ()
 
void v8::internal::FreeCurrentEmbeddedBlob ()
 
 v8::internal::__attribute__ ((tls_model(V8_TLS_MODEL))) extern thread_local Isolate *g_current_isolate_ V8_CONSTINIT
 

Macro Definition Documentation

◆ API_ASSIGN_RETURN_ON_EXCEPTION_VALUE

#define API_ASSIGN_RETURN_ON_EXCEPTION_VALUE ( isolate,
dst,
call,
value )
Value:
do { \
if (!(call).ToLocal(&dst)) { \
DCHECK((isolate)->has_exception()); \
return value; \
} \
} while (false)
std::unique_ptr< ValueMirror > value

Definition at line 415 of file isolate.h.

◆ ASSIGN_RETURN_FAILURE_ON_EXCEPTION

#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate,
dst,
call )
Value:
do { \
auto* __isolate__ = (isolate); \
ASSIGN_RETURN_ON_EXCEPTION_VALUE(__isolate__, dst, call, \
ReadOnlyRoots(__isolate__).exception()); \
} while (false)
Isolate * isolate

Definition at line 284 of file isolate.h.

◆ ASSIGN_RETURN_ON_EXCEPTION

#define ASSIGN_RETURN_ON_EXCEPTION ( isolate,
dst,
call )
Value:
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, kNullMaybeHandle)
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
Definition isolate.h:276

Definition at line 291 of file isolate.h.

◆ ASSIGN_RETURN_ON_EXCEPTION_VALUE

#define ASSIGN_RETURN_ON_EXCEPTION_VALUE ( isolate,
dst,
call,
value )
Value:
do { \
if (!(call).ToHandle(&dst)) { \
DCHECK((isolate)->has_exception()); \
return value; \
} \
} while (false)

Definition at line 276 of file isolate.h.

◆ FIELD_ACCESSOR

#define FIELD_ACCESSOR ( type,
name )
Value:
inline void set_##name(type v) { name##_ = v; } \
inline type name() const { return name##_; }
const char * name
Definition builtins.cc:39
#define _
ZoneVector< InstructionOperand > * set_

Definition at line 484 of file isolate.h.

◆ FOR_WITH_HANDLE_SCOPE

#define FOR_WITH_HANDLE_SCOPE ( isolate,
loop_var_type,
init,
loop_var,
limit_check,
increment,
body )
Value:
do { \
loop_var_type init; \
loop_var_type for_with_handle_limit = loop_var; \
Isolate* for_with_handle_isolate = isolate; \
while (limit_check) { \
for_with_handle_limit += 1024; \
HandleScope loop_scope(for_with_handle_isolate); \
for (; limit_check && loop_var < for_with_handle_limit; increment) { \
body \
} \
} \
} while (false)
double increment

Definition at line 457 of file isolate.h.

◆ GLOBAL_ACCESSOR

#define GLOBAL_ACCESSOR ( type,
name,
initialvalue )
Value:
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; \
}
#define OFFSET_OF(type, field)
Definition macros.h:57

Definition at line 1141 of file isolate.h.

◆ GLOBAL_ARRAY_ACCESSOR

#define GLOBAL_ARRAY_ACCESSOR ( type,
name,
length )
Value:
inline type* name() { \
DCHECK(OFFSET_OF(Isolate, name##_) == name##_debug_offset_); \
return &(name##_)[0]; \
}

Definition at line 1164 of file isolate.h.

◆ GLOBAL_ARRAY_BACKING_STORE

#define GLOBAL_ARRAY_BACKING_STORE ( type,
name,
length )
Value:
type name##_[length];

Definition at line 2716 of file isolate.h.

◆ GLOBAL_BACKING_STORE

#define GLOBAL_BACKING_STORE ( type,
name,
initialvalue )
Value:
type name##_;

Definition at line 2712 of file isolate.h.

◆ ISOLATE_INIT_ARRAY_LIST

#define ISOLATE_INIT_ARRAY_LIST ( V)
Value:
/* SerializerDeserializer state. */ \
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)
#define V(Name)

Definition at line 503 of file isolate.h.

◆ ISOLATE_INIT_DEBUG_ARRAY_LIST

#define ISOLATE_INIT_DEBUG_ARRAY_LIST ( V)

Definition at line 499 of file isolate.h.

◆ ISOLATE_INIT_LIST

#define ISOLATE_INIT_LIST ( V)

Definition at line 513 of file isolate.h.

◆ MAYBE_ASSIGN_RETURN_FAILURE_ON_EXCEPTION

#define MAYBE_ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate,
dst,
call )
Value:
do { \
Isolate* __isolate__ = (isolate); \
if (!(call).To(&dst)) { \
DCHECK(__isolate__->has_exception()); \
return ReadOnlyRoots(__isolate__).exception(); \
} \
} while (false)

Definition at line 448 of file isolate.h.

◆ MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE

#define MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE ( isolate,
dst,
call,
value )
Value:
do { \
if (!(call).To(&dst)) { \
DCHECK((isolate)->has_exception()); \
return value; \
} \
} while (false)

Definition at line 440 of file isolate.h.

◆ MAYBE_RETURN

#define MAYBE_RETURN ( call,
value )
Value:
do { \
if ((call).IsNothing()) return value; \
} while (false)

Definition at line 408 of file isolate.h.

◆ MAYBE_RETURN_FAILURE_ON_EXCEPTION

#define MAYBE_RETURN_FAILURE_ON_EXCEPTION ( isolate,
call )
Value:
do { \
Isolate* __isolate__ = (isolate); \
if ((call).IsNothing()) { \
DCHECK((__isolate__)->has_exception()); \
return ReadOnlyRoots(__isolate__).exception(); \
} \
} while (false)

Definition at line 431 of file isolate.h.

◆ MAYBE_RETURN_NULL

#define MAYBE_RETURN_NULL ( call)
Value:
MAYBE_RETURN(call, kNullMaybeHandle)
#define MAYBE_RETURN(call, value)
Definition isolate.h:408

Definition at line 413 of file isolate.h.

◆ MAYBE_RETURN_ON_EXCEPTION_VALUE [1/2]

#define MAYBE_RETURN_ON_EXCEPTION_VALUE ( isolate,
call,
value )
Value:
do { \
if ((call).IsNothing()) { \
DCHECK((isolate)->has_exception()); \
return value; \
} \
} while (false)

Definition at line 238 of file isolate.h.

◆ MAYBE_RETURN_ON_EXCEPTION_VALUE [2/2]

#define MAYBE_RETURN_ON_EXCEPTION_VALUE ( isolate,
call,
value )
Value:
do { \
if ((call).IsNothing()) { \
DCHECK((isolate)->has_exception()); \
return value; \
} \
} while (false)

Definition at line 238 of file isolate.h.

◆ NATIVE_CONTEXT_FIELD_ACCESSOR

#define NATIVE_CONTEXT_FIELD_ACCESSOR ( index,
type,
name )
Value:
inline Handle<UNPAREN(type)> name(); \
inline bool is_##name(Tagged<UNPAREN(type)> value);
#define UNPAREN(X)
Definition macros.h:53

Definition at line 1172 of file isolate.h.

◆ RETURN_EXCEPTION_IF_EXCEPTION

#define RETURN_EXCEPTION_IF_EXCEPTION ( isolate)
Value:
RETURN_VALUE_IF_EXCEPTION(isolate, kNullMaybeHandle)
#define RETURN_VALUE_IF_EXCEPTION(isolate, value)
Definition isolate.h:224

Definition at line 235 of file isolate.h.

◆ RETURN_FAILURE

#define RETURN_FAILURE ( isolate,
should_throw,
call )
Value:
do { \
if ((should_throw) == kDontThrow) { \
return Just(false); \
} else { \
isolate->Throw(*isolate->factory()->call); \
return Nothing<bool>(); \
} \
} while (false)

Definition at line 398 of file isolate.h.

◆ RETURN_FAILURE_IF_EXCEPTION

#define RETURN_FAILURE_IF_EXCEPTION ( isolate)
Value:
do { \
Isolate* __isolate__ = (isolate); \
if (__isolate__->has_exception()) { \
return ReadOnlyRoots(__isolate__).exception(); \
} \
} while (false)

Definition at line 205 of file isolate.h.

◆ RETURN_FAILURE_IF_EXCEPTION_DETECTOR

#define RETURN_FAILURE_IF_EXCEPTION_DETECTOR ( isolate,
detector )
Value:
do { \
Isolate* __isolate__ = (isolate); \
if (__isolate__->has_exception()) { \
detector.AcceptSideEffects(); \
return ReadOnlyRoots(__isolate__).exception(); \
} \
} while (false)

Definition at line 213 of file isolate.h.

◆ RETURN_FAILURE_ON_EXCEPTION

#define RETURN_FAILURE_ON_EXCEPTION ( isolate,
call )
Value:
do { \
Isolate* __isolate__ = (isolate); \
RETURN_ON_EXCEPTION_VALUE(__isolate__, call, \
ReadOnlyRoots(__isolate__).exception()); \
} 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.

Definition at line 368 of file isolate.h.

◆ RETURN_ON_EXCEPTION

#define RETURN_ON_EXCEPTION ( isolate,
call )
Value:
RETURN_ON_EXCEPTION_VALUE(isolate, call, kNullMaybeHandle)
#define RETURN_ON_EXCEPTION_VALUE(isolate, call, value)
Definition isolate.h:340

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.

Definition at line 395 of file isolate.h.

◆ RETURN_ON_EXCEPTION_VALUE

#define RETURN_ON_EXCEPTION_VALUE ( isolate,
call,
value )
Value:
do { \
if ((call).is_null()) { \
DCHECK((isolate)->has_exception()); \
return value; \
} \
} while (false)

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.

Definition at line 340 of file isolate.h.

◆ RETURN_RESULT_OR_FAILURE

#define RETURN_RESULT_OR_FAILURE ( isolate,
call )
Value:
do { \
DirectHandle<Object> __result__; \
Isolate* __isolate__ = (isolate); \
if (!(call).ToHandle(&__result__)) { \
DCHECK(__isolate__->has_exception()); \
return ReadOnlyRoots(__isolate__).exception(); \
} \
DCHECK(!__isolate__->has_exception()); \
return *__result__; \
} while (false)

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.

Definition at line 264 of file isolate.h.

◆ RETURN_VALUE_IF_EXCEPTION

#define RETURN_VALUE_IF_EXCEPTION ( isolate,
value )
Value:
do { \
Isolate* __isolate__ = (isolate); \
if (__isolate__->has_exception()) { \
return value; \
} \
} while (false)

Definition at line 224 of file isolate.h.

◆ RETURN_VALUE_IF_EXCEPTION_DETECTOR

#define RETURN_VALUE_IF_EXCEPTION_DETECTOR ( isolate,
detector,
value )
Value:
RETURN_VALUE_IF_EXCEPTION(isolate, (detector.AcceptSideEffects(), value))

Definition at line 232 of file isolate.h.

◆ STACK_CHECK

#define STACK_CHECK ( isolate,
result_value )
Value:
do { \
StackLimitCheck stack_check(isolate); \
if (V8_UNLIKELY(stack_check.InterruptRequested()) && \
V8_UNLIKELY(stack_check.HandleStackOverflowAndTerminationRequest())) { \
return result_value; \
} \
} while (false)
#define V8_UNLIKELY(condition)
Definition v8config.h:660

Definition at line 3067 of file isolate.h.

◆ THREAD_LOCAL_TOP_ACCESSOR

#define THREAD_LOCAL_TOP_ACCESSOR ( type,
name )
Value:
inline void set_##name(type v) { thread_local_top()->name##_ = v; } \
inline type name() const { return thread_local_top()->name##_; }

Definition at line 570 of file isolate.h.

◆ THREAD_LOCAL_TOP_ADDRESS

#define THREAD_LOCAL_TOP_ADDRESS ( type,
name )
Value:
inline type* name##_address() { return &thread_local_top()->name##_; }

Definition at line 574 of file isolate.h.

◆ THROW_NEW_ERROR

#define THROW_NEW_ERROR ( isolate,
call )
Value:
THROW_NEW_ERROR_RETURN_VALUE(isolate, call, kNullMaybeHandle)
#define THROW_NEW_ERROR_RETURN_VALUE(isolate, call, value)
Definition isolate.h:300

Definition at line 307 of file isolate.h.

◆ THROW_NEW_ERROR_RETURN_FAILURE

#define THROW_NEW_ERROR_RETURN_FAILURE ( isolate,
call )
Value:
do { \
auto* __isolate__ = (isolate); \
return __isolate__->Throw(*__isolate__->factory()->call); \
} while (false)

Definition at line 294 of file isolate.h.

◆ THROW_NEW_ERROR_RETURN_VALUE

#define THROW_NEW_ERROR_RETURN_VALUE ( isolate,
call,
value )
Value:
do { \
auto* __isolate__ = (isolate); \
__isolate__->Throw(*__isolate__->factory()->call); \
return value; \
} while (false)

Definition at line 300 of file isolate.h.

◆ WHILE_WITH_HANDLE_SCOPE

#define WHILE_WITH_HANDLE_SCOPE ( isolate,
limit_check,
body )
Value:
do { \
Isolate* for_with_handle_isolate = isolate; \
while (limit_check) { \
HandleScope loop_scope(for_with_handle_isolate); \
for (int for_with_handle_it = 0; \
limit_check && for_with_handle_it < 1024; ++for_with_handle_it) { \
body \
} \
} \
} while (false)

Definition at line 472 of file isolate.h.