v8  7.4.288(node12.0.0)
V8 is Google's open source JavaScript engine
PersistentBase< T > Class Template Reference

#include <v8.h>

Inheritance diagram for 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 bool IsEmpty () const
 
V8_INLINE void Empty ()
 
V8_INLINE Local< T > Get (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 P * ClearWeak ()
 
V8_INLINE void ClearWeak ()
 
V8_INLINE void AnnotateStrongRetainer (const char *label)
 
 V8_DEPRECATE_SOON ("Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", V8_INLINE void RegisterExternalReference(Isolate *isolate) const)
 
 V8_DEPRECATED ("Weak objects are always considered independent. " "Use TracedGlobal when trying to use EmbedderHeapTracer. " "Use a strong handle when trying to keep an object alive.", V8_INLINE void MarkIndependent())
 
 V8_DEPRECATE_SOON ("Use TracedGlobal.", V8_INLINE void MarkActive())
 
 V8_DEPRECATED ("See MarkIndependent.", V8_INLINE bool IsIndependent() const)
 
 V8_DEPRECATED ("Garbage collection internal state should not be relied on.", V8_INLINE bool IsNearDeath() const)
 
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)
 

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
 
template<class F1 , class F2 >
class PersistentValueVector
 
class Object
 

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 91 of file v8.h.

Constructor & Destructor Documentation

◆ PersistentBase()

PersistentBase ( const PersistentBase< T > &  other)
delete

Member Function Documentation

◆ AnnotateStrongRetainer()

void 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 9856 of file v8.h.

Referenced by PersistentValueMapBase< K, V, Traits >::AnnotateStrongRetainer().

◆ ClearWeak() [1/2]

V8_INLINE P* ClearWeak ( )

◆ ClearWeak() [2/2]

P * ClearWeak ( )
inline

Definition at line 537 of file v8.h.

◆ Empty()

V8_INLINE void Empty ( )
inline

Definition at line 478 of file v8.h.

◆ Get()

V8_INLINE Local<T> Get ( Isolate isolate) const
inline

Definition at line 480 of file v8.h.

◆ IsEmpty()

V8_INLINE bool IsEmpty ( ) const
inline

Definition at line 477 of file v8.h.

◆ IsWeak()

bool IsWeak ( ) const

Returns true if the handle's reference is weak.

Definition at line 9796 of file v8.h.

Referenced by PersistentValueMapBase< K, V, Traits >::Release().

◆ operator!=() [1/2]

V8_INLINE bool operator!= ( const PersistentBase< S > &  that) const
inline

Definition at line 503 of file v8.h.

◆ operator!=() [2/2]

V8_INLINE bool operator!= ( const Local< S > &  that) const
inline

Definition at line 508 of file v8.h.

◆ operator=()

void operator= ( const PersistentBase< T > &  )
delete

◆ operator==() [1/2]

V8_INLINE bool operator== ( const PersistentBase< S > &  that) const
inline

Definition at line 485 of file v8.h.

Referenced by PersistentBase< v8::Promise >::operator!=().

◆ operator==() [2/2]

V8_INLINE bool operator== ( const Local< S > &  that) const
inline

Definition at line 494 of file v8.h.

◆ Reset() [1/5]

void Reset ( )

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

Definition at line 9805 of file v8.h.

Referenced by PersistentValueMapBase< K, V, Traits >::RemoveWeak(), Global< T >::~Global(), and Persistent< v8::Promise >::~Persistent().

◆ Reset() [2/5]

V8_INLINE void 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]

V8_INLINE void 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() [4/5]

void Reset ( Isolate isolate,
const Local< S > &  other 
)

Definition at line 9814 of file v8.h.

◆ Reset() [5/5]

void Reset ( Isolate isolate,
const PersistentBase< S > &  other 
)

Definition at line 9824 of file v8.h.

◆ SetWeak() [1/2]

V8_INLINE void 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!

Definition at line 9835 of file v8.h.

◆ SetWeak() [2/2]

void 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. A related function Isolate::NumberOfPhantomHandleResetsSinceLastCall returns how many phantom handles were reset by the garbage collector.

Definition at line 9844 of file v8.h.

◆ SetWrapperClassId()

void SetWrapperClassId ( uint16_t  class_id)

Assigns a wrapper class ID to the handle.

Definition at line 9887 of file v8.h.

◆ V8_DEPRECATE_SOON() [1/2]

V8_DEPRECATE_SOON ( "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference ,
V8_INLINE void RegisterExternalReference(Isolate *isolate) const   
)

Allows the embedder to tell the v8 garbage collector that a certain object is alive. Only allowed when the embedder is asked to trace its heap by EmbedderHeapTracer.

◆ V8_DEPRECATE_SOON() [2/2]

V8_DEPRECATE_SOON ( "Use TracedGlobal."  ,
V8_INLINE void   MarkActive() 
)

Marks the reference to this object as active. The scavenge garbage collection should not reclaim the objects marked as active, even if the object held by the handle is otherwise unreachable.

This bit is cleared after the each garbage collection pass.

◆ V8_DEPRECATED() [1/3]

V8_DEPRECATED ( "Weak objects are always considered independent. " "Use TracedGlobal when trying to use EmbedderHeapTracer. " "Use a strong handle when trying to keep an object alive."  ,
V8_INLINE void   MarkIndependent() 
)

Marks the reference to this object independent. Garbage collector is free to ignore any object groups containing this object. Weak callback for an independent handle should not assume that it will be preceded by a global GC prologue callback or followed by a global GC epilogue callback.

◆ V8_DEPRECATED() [2/3]

V8_DEPRECATED ( "See MarkIndependent."  ,
V8_INLINE bool IsIndependent() const   
)

◆ V8_DEPRECATED() [3/3]

V8_DEPRECATED ( "Garbage collection internal state should not be relied on."  ,
V8_INLINE bool IsNearDeath() const   
)

Checks if the handle holds the only reference to an object.

◆ WrapperClassId()

uint16_t WrapperClassId ( ) const

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

Definition at line 9897 of file v8.h.

Friends And Related Function Documentation

◆ Global

friend class Global
friend

Definition at line 606 of file v8.h.

◆ Isolate

friend class Isolate
friend

Definition at line 601 of file v8.h.

◆ Local

friend class Local
friend

Definition at line 603 of file v8.h.

◆ Object

friend class Object
friend

Definition at line 612 of file v8.h.

◆ Persistent

friend class Persistent
friend

Definition at line 604 of file v8.h.

◆ PersistentBase

friend class PersistentBase
friend

Definition at line 607 of file v8.h.

◆ PersistentValueMapBase

friend class PersistentValueMapBase
friend

Definition at line 610 of file v8.h.

◆ PersistentValueVector

friend class PersistentValueVector
friend

Definition at line 611 of file v8.h.

◆ ReturnValue

friend class ReturnValue
friend

Definition at line 608 of file v8.h.

◆ Utils

friend class Utils
friend

Definition at line 602 of file v8.h.


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