33class DictionaryTemplate;
39class JSArrayBufferView;
40class JSFinalizationRegistry;
51template <
typename T,
internal::ExternalPo
interTag tag>
54template <
internal::ExternalPo
interTag tag>
59template <
internal::ExternalPo
interTag tag,
typename T>
64template <
internal::ExternalPo
interTag tag>
80 static void Register(std::unique_ptr<Extension>);
94#define TO_LOCAL_LIST(V) \
95 V(ToLocal, AccessorPair, debug::AccessorPair) \
96 V(ToLocal, NativeContext, Context) \
97 V(ToLocal, Object, Value) \
98 V(ToLocal, Module, Module) \
99 V(ToLocal, Name, Name) \
100 V(ToLocal, String, String) \
101 V(ToLocal, Symbol, Symbol) \
102 V(ToLocal, JSRegExp, RegExp) \
103 V(ToLocal, JSReceiver, Object) \
104 V(ToLocal, JSObject, Object) \
105 V(ToLocal, JSFunction, Function) \
106 V(ToLocal, JSArray, Array) \
107 V(ToLocal, JSMap, Map) \
108 V(ToLocal, JSSet, Set) \
109 V(ToLocal, JSProxy, Proxy) \
110 V(ToLocal, JSArrayBuffer, ArrayBuffer) \
111 V(ToLocal, JSArrayBufferView, ArrayBufferView) \
112 V(ToLocal, JSDataView, DataView) \
113 V(ToLocal, JSRabGsabDataView, DataView) \
114 V(ToLocal, JSTypedArray, TypedArray) \
115 V(ToLocalShared, JSArrayBuffer, SharedArrayBuffer) \
116 V(ToLocal, FunctionTemplateInfo, FunctionTemplate) \
117 V(ToLocal, ObjectTemplateInfo, ObjectTemplate) \
118 V(ToLocal, DictionaryTemplateInfo, DictionaryTemplate) \
119 V(SignatureToLocal, FunctionTemplateInfo, Signature) \
120 V(MessageToLocal, Object, Message) \
121 V(PromiseToLocal, JSObject, Promise) \
122 V(StackTraceToLocal, StackTraceInfo, StackTrace) \
123 V(StackFrameToLocal, StackFrameInfo, StackFrame) \
124 V(NumberToLocal, Object, Number) \
125 V(IntegerToLocal, Object, Integer) \
126 V(Uint32ToLocal, Object, Uint32) \
127 V(ToLocal, BigInt, BigInt) \
128 V(ExternalToLocal, JSObject, External) \
129 V(CallableToLocal, JSReceiver, Function) \
130 V(ToLocalPrimitive, Object, Primitive) \
131 V(FixedArrayToLocal, FixedArray, FixedArray) \
132 V(PrimitiveArrayToLocal, FixedArray, PrimitiveArray) \
133 V(ToLocal, ScriptOrModule, ScriptOrModule) \
134 IF_WASM(V, ToLocal, WasmMemoryMapDescriptor, WasmMemoryMapDescriptor) \
135 IF_WASM(V, ToLocal, WasmModuleObject, WasmModuleObject)
137#define TO_LOCAL_NAME_LIST(V) \
140 V(SignatureToLocal) \
143 V(StackTraceToLocal) \
144 V(StackFrameToLocal) \
150 V(ToLocalPrimitive) \
151 V(FixedArrayToLocal) \
152 V(PrimitiveArrayToLocal)
154#define OPEN_HANDLE_LIST(V) \
155 V(Template, TemplateInfoWithProperties) \
156 V(FunctionTemplate, FunctionTemplateInfo) \
157 V(ObjectTemplate, ObjectTemplateInfo) \
158 V(DictionaryTemplate, DictionaryTemplateInfo) \
159 V(Signature, FunctionTemplateInfo) \
162 V(RegExp, JSRegExp) \
163 V(Object, JSReceiver) \
167 V(ArrayBuffer, JSArrayBuffer) \
168 V(ArrayBufferView, JSArrayBufferView) \
169 V(TypedArray, JSTypedArray) \
170 V(Uint8Array, JSTypedArray) \
171 V(Uint8ClampedArray, JSTypedArray) \
172 V(Int8Array, JSTypedArray) \
173 V(Uint16Array, JSTypedArray) \
174 V(Int16Array, JSTypedArray) \
175 V(Uint32Array, JSTypedArray) \
176 V(Int32Array, JSTypedArray) \
177 V(Float16Array, JSTypedArray) \
178 V(Float32Array, JSTypedArray) \
179 V(Float64Array, JSTypedArray) \
180 V(DataView, JSDataViewOrRabGsabDataView) \
181 V(SharedArrayBuffer, JSArrayBuffer) \
185 V(Script, JSFunction) \
186 V(UnboundModuleScript, SharedFunctionInfo) \
187 V(UnboundScript, SharedFunctionInfo) \
189 V(Function, JSReceiver) \
190 V(CompileHintsCollector, Script) \
191 V(Message, JSMessageObject) \
192 V(Context, NativeContext) \
193 V(External, Object) \
194 V(StackTrace, StackTraceInfo) \
195 V(StackFrame, StackFrameInfo) \
197 V(debug::GeneratorObject, JSGeneratorObject) \
198 V(debug::ScriptSource, HeapObject) \
199 V(debug::Script, Script) \
200 V(debug::EphemeronTable, EphemeronHashTable) \
201 V(debug::AccessorPair, AccessorPair) \
202 V(Promise, JSPromise) \
203 V(Primitive, Object) \
204 V(PrimitiveArray, FixedArray) \
206 V(ScriptOrModule, ScriptOrModule) \
207 V(FixedArray, FixedArray) \
208 V(ModuleRequest, ModuleRequest) \
209 IF_WASM(V, WasmMemoryMapDescriptor, WasmMemoryMapDescriptor) \
210 IF_WASM(V, WasmMemoryObject, WasmMemoryObject)
215 const char* message) {
222 const char* location,
const OOMDetails& details);
230#define DECLARE_TO_LOCAL(Name) \
231 template <template <typename> typename HandleType, typename T, \
232 typename = std::enable_if_t<std::is_convertible_v< \
233 HandleType<T>, v8::internal::DirectHandle<T>>>> \
234 static inline auto Name(HandleType<T> obj);
238#define DECLARE_TO_LOCAL_TYPED_ARRAY(Type, typeName, TYPE, ctype) \
239 static inline Local<v8::Type##Array> ToLocal##Type##Array( \
240 v8::internal::DirectHandle<v8::internal::JSTypedArray> obj);
244#define DECLARE_OPEN_HANDLE(From, To) \
245 static inline v8::internal::Handle<v8::internal::To> OpenHandle( \
246 const From* that, bool allow_empty_handle = false); \
247 static inline v8::internal::DirectHandle<v8::internal::To> OpenDirectHandle( \
248 const From* that, bool allow_empty_handle = false); \
249 static inline v8::internal::IndirectHandle<v8::internal::To> \
250 OpenIndirectHandle(const From* that, bool allow_empty_handle = false);
254#undef DECLARE_OPEN_HANDLE
255#undef DECLARE_TO_LOCAL_TYPED_ARRAY
256#undef DECLARE_TO_LOCAL
258 template <
class From,
class To>
273 template <
class From,
class To>
278 template <
class From,
class To>
286 const char* location,
const char* message);
288#define DECLARE_TO_LOCAL_PRIVATE(Name, From, To) \
289 static inline Local<v8::To> Name##_helper( \
290 v8::internal::DirectHandle<v8::internal::From> obj);
293#undef DECLARE_TO_LOCAL_PRIVATE
315class PersistentHandles;
331 : hsi_(hsi), saved_entered_context_count_(hsi->EnteredContextCount()) {}
334 DCHECK_LE(saved_entered_context_count_, hsi_->EnteredContextCount());
335 while (saved_entered_context_count_ < hsi_->EnteredContextCount())
336 hsi_->LeaveContext();
487 if (
reinterpret_cast<Address>(block_start) <
488 reinterpret_cast<Address>(prev_limit) &&
489 reinterpret_cast<Address>(prev_limit) <=
490 reinterpret_cast<Address>(block_limit)) {
491#ifdef ENABLE_LOCAL_HANDLE_ZAPPING
492 internal::HandleScope::ZapRange(prev_limit, block_limit);
498#ifdef ENABLE_LOCAL_HANDLE_ZAPPING
499 internal::HandleScope::ZapRange(block_start, block_limit);
547#ifdef ENABLE_SLOW_DCHECKS
#define DECLARE_TO_LOCAL_TYPED_ARRAY(Type, typeName, TYPE, ctype)
#define TO_LOCAL_NAME_LIST(V)
#define DECLARE_TO_LOCAL(Name)
#define OPEN_HANDLE_LIST(V)
#define DECLARE_OPEN_HANDLE(From, To)
#define DECLARE_TO_LOCAL_PRIVATE(Name, From, To)
ApiFunction(v8::internal::Address addr)
v8::internal::Address address()
v8::internal::Address addr_
static RegisteredExtension * first_extension()
std::unique_ptr< Extension > extension_
Extension * extension() const
static void Register(std::unique_ptr< Extension >)
static void UnregisterAll()
RegisteredExtension(Extension *)
RegisteredExtension * next() const
RegisteredExtension * next_
static RegisteredExtension * first_extension_
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
static Local< To > Convert(v8::internal::DirectHandle< From > obj)
static v8::internal::DirectHandle< To > OpenDirectHandle(v8::Local< From > handle)
static v8::internal::Handle< v8::internal::Object > OpenPersistent(const v8::PersistentBase< T > &persistent)
static void ReportOOMFailure(v8::internal::Isolate *isolate, const char *location, const OOMDetails &details)
static V8_INLINE bool ApiCheck(bool condition, const char *location, const char *message)
static v8::internal::DirectHandle< v8::internal::Object > OpenPersistent(v8::Persistent< T > *persistent)
V8_NOINLINE static V8_PRESERVE_MOST void ReportApiFailure(const char *location, const char *message)
V8_INLINE internal::Address *const & slot() const
EnteredContextRewindScope(HandleScopeImplementer *hsi)
~EnteredContextRewindScope()
size_t saved_entered_context_count_
HandleScopeImplementer * hsi_
DetachableVector< Address * > blocks_
bool LastEnteredContextWas(Tagged< NativeContext > context)
DetachableVector< Tagged< NativeContext > > entered_contexts_
void FreeThreadResources()
internal::Address * GetSpareOrNewBlock()
V8_EXPORT_PRIVATE void Iterate(v8::internal::RootVisitor *v)
static const size_t kEnteredContextsOffset
HandleScopeData handle_scope_data_
char * ArchiveThread(char *to)
friend class HandleScopeImplementerOffsets
void BeginPersistentScope()
HandleScopeImplementer(Isolate *isolate)
void ReturnBlock(Address *block)
bool HasPersistentScope() const
void IterateThis(RootVisitor *v)
void DeleteExtensions(internal::Address *prev_limit)
HandleScopeImplementer & operator=(const HandleScopeImplementer &)=delete
Isolate * isolate() const
size_t EnteredContextCount() const
DirectHandle< NativeContext > LastEnteredContext()
DetachableVector< Address * > * blocks()
char * ArchiveThreadHelper(char *to)
DetachableVector< Tagged< Context > > saved_contexts_
char * RestoreThread(char *from)
~HandleScopeImplementer()
HandleScopeImplementer(const HandleScopeImplementer &)=delete
void EnterContext(Tagged< NativeContext > context)
char * RestoreThreadHelper(char *from)
void SaveContext(Tagged< Context > context)
std::unique_ptr< PersistentHandles > DetachPersistent(Address *first_block)
Tagged< Context > RestoreContext()
static int ArchiveSpacePerThread()
std::optional< Address * > last_handle_before_persistent_block_
V8_INLINE HandleScopeData * handle_scope_data()
ThreadLocalTop * thread_local_top()
V8_WARN_UNUSED_RESULT V8_INLINE bool ToHandle(DirectHandle< S > *out) const
bool CallDepthIsZero() const
#define DECLARE_CONTEXTUAL_VARIABLE_WITH_DEFAULT(VarName,...)
#define EXPORT_TEMPLATE_DECLARE(export)
void DeleteArray(T *array)
void InvokeFinalizationRegistryCleanupFromTask(DirectHandle< NativeContext > native_context, DirectHandle< JSFinalizationRegistry > finalization_registry)
void InvokeFunctionCallbackOptimized(const v8::FunctionCallbackInfo< v8::Value > &info)
const int kHandleBlockSize
bool V8_EXPORT ValidateCallbackInfo(const FunctionCallbackInfo< void > &info)
int32_t ConvertDouble(double d)
typename detail::FlattenUnionHelper< Union<>, Ts... >::type UnionOf
void InvokeFunctionCallbackGeneric(const v8::FunctionCallbackInfo< v8::Value > &info)
void InvokeAccessorGetterCallback(v8::Local< v8::Name > property, const v8::PropertyCallbackInfo< v8::Value > &info)
T * NewArray(size_t size)
!IsContextMap !IsContextMap native_context
bool ToLocal(v8::internal::MaybeDirectHandle< v8::internal::Object > maybe, Local< T > *local)
v8::internal::DirectHandle< i::UnionOf< i::Smi, i::Foreign > > FromCData(v8::internal::Isolate *isolate, T obj)
v8::Local< T > ToApiHandle(v8::internal::DirectHandle< v8::internal::Object > obj)
T ToCData(i::Isolate *isolate, v8::internal::Tagged< v8::internal::Object > obj)
#define DCHECK_LE(v1, v2)
#define DCHECK_NOT_NULL(val)
#define DCHECK(condition)
#define V8_EXPORT_PRIVATE
#define V8_UNLIKELY(condition)