v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8::PersistentBase< T > Class Template Reference

#include <v8-persistent-handle.h>

Inheritance diagram for v8::PersistentBase< T >:
Collaboration diagram for v8::PersistentBase< T >:

Public Member Functions

V8_INLINE void Reset ()
 
template<class S >
V8_INLINE void Reset (Isolate *isolate, const Local< S > &other)
 
template<class S >
V8_INLINE void Reset (Isolate *isolate, const PersistentBase< S > &other)
 
V8_INLINE Local< TGet (Isolate *isolate) const
 
template<class S >
V8_INLINE bool operator== (const PersistentBase< S > &that) const
 
template<class S >
V8_INLINE bool operator== (const Local< S > &that) const
 
template<class S >
V8_INLINE bool operator!= (const PersistentBase< S > &that) const
 
template<class S >
V8_INLINE bool operator!= (const Local< S > &that) const
 
template<typename P >
V8_INLINE void SetWeak (P *parameter, typename WeakCallbackInfo< P >::Callback callback, WeakCallbackType type)
 
V8_INLINE void SetWeak ()
 
template<typename P >
V8_INLINE PClearWeak ()
 
V8_INLINE void ClearWeak ()
 
V8_INLINE void AnnotateStrongRetainer (const char *label)
 
V8_INLINE bool IsWeak () const
 
V8_INLINE void SetWrapperClassId (uint16_t class_id)
 
V8_INLINE uint16_t WrapperClassId () const
 
 PersistentBase (const PersistentBase &other)=delete
 
void operator= (const PersistentBase &)=delete
 
template<class S >
void Reset (Isolate *isolate, const Local< S > &other)
 
template<class S >
void Reset (Isolate *isolate, const PersistentBase< S > &other)
 
template<typename P >
PClearWeak ()
 
- Public Member Functions inherited from v8::api_internal::IndirectHandleBase
V8_INLINE bool IsEmpty () const
 
V8_INLINE void Clear ()
 

Private Member Functions

V8_INLINE PersistentBase ()=default
 
V8_INLINE PersistentBase (internal::Address *location)
 

Static Private Member Functions

static V8_INLINE internal::AddressNew (Isolate *isolate, T *that)
 

Friends

class Isolate
 
class Utils
 
template<class F >
class Local
 
template<class F1 , class F2 >
class Persistent
 
template<class F >
class Global
 
template<class F >
class PersistentBase
 
template<class F >
class ReturnValue
 
template<class F1 , class F2 , class F3 >
class PersistentValueMapBase
 
class Object
 
class internal::ValueHelper
 

Additional Inherited Members

- Protected Member Functions inherited from v8::api_internal::IndirectHandleBase
V8_INLINE IndirectHandleBase ()=default
 
V8_INLINE IndirectHandleBase (const IndirectHandleBase &other)=default
 
V8_INLINE IndirectHandleBaseoperator= (const IndirectHandleBase &that)=default
 
V8_INLINE IndirectHandleBase (internal::Address *location)
 
V8_INLINE internal::Address ptr () const
 
V8_INLINE internal::Address *const & slot () const
 
V8_INLINE internal::Address *& slot ()
 
template<typename T , bool check_null = false>
V8_INLINE Tvalue () const
 
V8_INLINE internal::ValueHelper::InternalRepresentationType repr () const
 

Detailed Description

template<class T>
class v8::PersistentBase< T >

An object reference that is independent of any handle scope. Where a Local handle only lives as long as the HandleScope in which it was allocated, a PersistentBase handle remains valid until it is explicitly disposed using Reset().

A persistent handle contains a reference to a storage cell within the V8 engine which holds an object value and which is updated by the garbage collector whenever the object is moved. A new storage cell can be created using the constructor or PersistentBase::Reset and existing handles can be disposed using PersistentBase::Reset.

Definition at line 93 of file v8-persistent-handle.h.

Constructor & Destructor Documentation

◆ PersistentBase() [1/3]

template<class T >
v8::PersistentBase< T >::PersistentBase ( const PersistentBase< T > & other)
delete

◆ PersistentBase() [2/3]

template<class T >
V8_INLINE v8::PersistentBase< T >::PersistentBase ( )
privatedefault

◆ PersistentBase() [3/3]

template<class T >
V8_INLINE v8::PersistentBase< T >::PersistentBase ( internal::Address * location)
inlineexplicitprivate

Definition at line 214 of file v8-persistent-handle.h.

Member Function Documentation

◆ AnnotateStrongRetainer()

template<class T >
void v8::PersistentBase< T >::AnnotateStrongRetainer ( const char * label)

Annotates the strong handle with the given label, which is then used by the heap snapshot generator as a name of the edge from the root to the handle. The function does not take ownership of the label and assumes that the label is valid as long as the handle is valid.

Definition at line 511 of file v8-persistent-handle.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearWeak() [1/3]

template<class T >
template<typename P >
V8_INLINE P * v8::PersistentBase< T >::ClearWeak ( )
Here is the caller graph for this function:

◆ ClearWeak() [2/3]

template<class T >
V8_INLINE void v8::PersistentBase< T >::ClearWeak ( )
inline

Definition at line 167 of file v8-persistent-handle.h.

Here is the call graph for this function:

◆ ClearWeak() [3/3]

template<class T >
template<typename P >
P * v8::PersistentBase< T >::ClearWeak ( )

Definition at line 506 of file v8-persistent-handle.h.

Here is the call graph for this function:

◆ Get()

template<class T >
V8_INLINE Local< T > v8::PersistentBase< T >::Get ( Isolate * isolate) const
inline

Definition at line 115 of file v8-persistent-handle.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsWeak()

template<class T >
bool v8::PersistentBase< T >::IsWeak ( ) const

Returns true if the handle's reference is weak.

Definition at line 442 of file v8-persistent-handle.h.

Here is the caller graph for this function:

◆ New()

template<class T >
internal::Address * v8::PersistentBase< T >::New ( Isolate * isolate,
T * that )
staticprivate

Definition at line 424 of file v8-persistent-handle.h.

Here is the call graph for this function:

◆ operator!=() [1/2]

template<class T >
template<class S >
V8_INLINE bool v8::PersistentBase< T >::operator!= ( const Local< S > & that) const
inline

Definition at line 135 of file v8-persistent-handle.h.

Here is the call graph for this function:

◆ operator!=() [2/2]

template<class T >
template<class S >
V8_INLINE bool v8::PersistentBase< T >::operator!= ( const PersistentBase< S > & that) const
inline

Definition at line 130 of file v8-persistent-handle.h.

Here is the call graph for this function:

◆ operator=()

template<class T >
void v8::PersistentBase< T >::operator= ( const PersistentBase< T > & )
delete

◆ operator==() [1/2]

template<class T >
template<class S >
V8_INLINE bool v8::PersistentBase< T >::operator== ( const Local< S > & that) const
inline

Definition at line 125 of file v8-persistent-handle.h.

Here is the call graph for this function:

◆ operator==() [2/2]

template<class T >
template<class S >
V8_INLINE bool v8::PersistentBase< T >::operator== ( const PersistentBase< S > & that) const
inline

Definition at line 120 of file v8-persistent-handle.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reset() [1/5]

template<class T >
void v8::PersistentBase< T >::Reset ( )

If non-empty, destroy the underlying storage cell IsEmpty() will return true after this call.

Definition at line 449 of file v8-persistent-handle.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reset() [2/5]

template<class T >
template<class S >
V8_INLINE void v8::PersistentBase< T >::Reset ( Isolate * isolate,
const Local< S > & other )

If non-empty, destroy the underlying storage cell and create a new one with the contents of other if other is non empty

◆ Reset() [3/5]

template<class T >
template<class S >
void v8::PersistentBase< T >::Reset ( Isolate * isolate,
const Local< S > & other )

If non-empty, destroy the underlying storage cell and create a new one with the contents of other if other is non empty

Definition at line 461 of file v8-persistent-handle.h.

◆ Reset() [4/5]

template<class T >
template<class S >
V8_INLINE void v8::PersistentBase< T >::Reset ( Isolate * isolate,
const PersistentBase< S > & other )

If non-empty, destroy the underlying storage cell and create a new one with the contents of other if other is non empty

◆ Reset() [5/5]

template<class T >
template<class S >
void v8::PersistentBase< T >::Reset ( Isolate * isolate,
const PersistentBase< S > & other )

If non-empty, destroy the underlying storage cell and create a new one with the contents of other if other is non empty

Definition at line 474 of file v8-persistent-handle.h.

◆ SetWeak() [1/2]

template<class T >
void v8::PersistentBase< T >::SetWeak ( )

Turns this handle into a weak phantom handle without finalization callback. The handle will be reset automatically when the garbage collector detects that the object is no longer reachable.

Definition at line 500 of file v8-persistent-handle.h.

Here is the call graph for this function:

◆ SetWeak() [2/2]

template<class T >
template<typename P >
V8_INLINE void v8::PersistentBase< T >::SetWeak ( P * parameter,
typename WeakCallbackInfo< P >::Callback callback,
WeakCallbackType type )

Install a finalization callback on this object. NOTE: There is no guarantee as to when or even if the callback is invoked. The invocation is performed solely on a best effort basis. As always, GC-based finalization should not be relied upon for any critical form of resource management!

The callback is supposed to reset the handle. No further V8 API may be called in this callback. In case additional work involving V8 needs to be done, a second callback can be scheduled using WeakCallbackInfo<void>::SetSecondPassCallback.

Definition at line 484 of file v8-persistent-handle.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetWrapperClassId()

template<class T >
void v8::PersistentBase< T >::SetWrapperClassId ( uint16_t class_id)

Assigns a wrapper class ID to the handle.

Definition at line 516 of file v8-persistent-handle.h.

◆ WrapperClassId()

template<class T >
uint16_t v8::PersistentBase< T >::WrapperClassId ( ) const

Returns the class ID previously assigned to this handle or 0 if no class ID was previously assigned.

Definition at line 524 of file v8-persistent-handle.h.

Friends And Related Symbol Documentation

◆ Global

template<class T >
template<class F >
friend class Global
friend

Definition at line 202 of file v8-persistent-handle.h.

◆ internal::ValueHelper

template<class T >
friend class internal::ValueHelper
friend

Definition at line 210 of file v8-persistent-handle.h.

◆ Isolate

template<class T >
friend class Isolate
friend

Definition at line 195 of file v8-persistent-handle.h.

◆ Local

template<class T >
template<class F >
friend class Local
friend

Definition at line 198 of file v8-persistent-handle.h.

◆ Object

template<class T >
friend class Object
friend

Definition at line 209 of file v8-persistent-handle.h.

◆ Persistent

template<class T >
template<class F1 , class F2 >
friend class Persistent
friend

Persistent is a way to create a strong pointer from an off-heap object to another on-heap object. As long as the Persistent handle is alive the GC will keep the object pointed to alive. The Persistent handle is always a GC root from the point of view of the GC. Persistent must be constructed and destructed in the same thread.

Definition at line 200 of file v8-persistent-handle.h.

◆ PersistentBase

template<class T >
template<class F >
friend class PersistentBase
friend

Definition at line 204 of file v8-persistent-handle.h.

◆ PersistentValueMapBase

template<class T >
template<class F1 , class F2 , class F3 >
friend class PersistentValueMapBase
friend

Definition at line 208 of file v8-persistent-handle.h.

◆ ReturnValue

template<class T >
template<class F >
friend class ReturnValue
friend

Definition at line 206 of file v8-persistent-handle.h.

◆ Utils

template<class T >
friend class Utils
friend

Definition at line 196 of file v8-persistent-handle.h.


The documentation for this class was generated from the following files: