V8 Project
v8::Persistent< T, M > Class Template Reference

A PersistentBase which allows copy and assignment. More...

#include <v8.h>

+ Inheritance diagram for v8::Persistent< T, M >:
+ Collaboration diagram for v8::Persistent< T, M >:

Public Member Functions

 Persistent ()
 A Persistent with no storage cell. More...
 
template<class S >
 Persistent (Isolate *isolate, Handle< S > that)
 Construct a Persistent from a Handle. More...
 
template<class S , class M2 >
 Persistent (Isolate *isolate, const Persistent< S, M2 > &that)
 Construct a Persistent from a Persistent. More...
 
 Persistent (const Persistent &that)
 The copy constructors and assignment operator create a Persistent exactly as the Persistent constructor, but the Copy function from the traits class is called, allowing the setting of flags based on the copied Persistent. More...
 
template<class S , class M2 >
 Persistent (const Persistent< S, M2 > &that)
 
Persistentoperator= (const Persistent &that)
 
template<class S , class M2 >
Persistentoperator= (const Persistent< S, M2 > &that)
 
 ~Persistent ()
 The destructor will dispose the Persistent based on the kResetInDestructor flags in the traits class. More...
 
template<class S >
Persistent< S > & As ()
 
TClearAndLeak ()
 
- Public Member Functions inherited from v8::PersistentBase< T >
void Reset ()
 If non-empty, destroy the underlying storage cell IsEmpty() will return true after this call. More...
 
template<class S >
void Reset (Isolate *isolate, const Handle< 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. More...
 
template<class S >
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. More...
 
bool IsEmpty () const
 
template<class S >
bool operator== (const PersistentBase< S > &that) const
 
template<class S >
bool operator== (const Handle< S > &that) const
 
template<class S >
bool operator!= (const PersistentBase< S > &that) const
 
template<class S >
bool operator!= (const Handle< S > &that) const
 
template<typename P >
void SetWeak (P *parameter, typename WeakCallbackData< T, P >::Callback callback)
 Install a finalization callback on this object. More...
 
template<typename S , typename P >
void SetWeak (P *parameter, typename WeakCallbackData< S, P >::Callback callback)
 
template<typename P >
PClearWeak ()
 
void ClearWeak ()
 
void MarkIndependent ()
 Marks the reference to this object independent. More...
 
void MarkPartiallyDependent ()
 Marks the reference to this object partially dependent. More...
 
bool IsIndependent () const
 
bool IsNearDeath () const
 Checks if the handle holds the only reference to an object. More...
 
bool IsWeak () const
 Returns true if the handle's reference is weak. More...
 
void SetWrapperClassId (uint16_t class_id)
 Assigns a wrapper class ID to the handle. More...
 
uint16_t WrapperClassId () const
 Returns the class ID previously assigned to this handle or 0 if no class ID was previously assigned. More...
 

Static Public Member Functions

template<class S >
static Persistent< T > & Cast (Persistent< S > &that)
 

Private Member Functions

template<class S >
 Persistent (S *that)
 
Toperator* () const
 
template<class S , class M2 >
void Copy (const Persistent< S, M2 > &that)
 

Friends

class Isolate
 
class Utils
 
template<class F >
class Handle
 
template<class F >
class Local
 
template<class F1 , class F2 >
class Persistent
 
template<class F >
class ReturnValue
 

Detailed Description

template<class T, class M>
class v8::Persistent< T, M >

A PersistentBase which allows copy and assignment.

Copy, assignment and destructor bevavior is controlled by the traits class M.

Note: Persistent class hierarchy is subject to future changes.

Definition at line 627 of file v8.h.

Constructor & Destructor Documentation

◆ Persistent() [1/6]

template<class T , class M >
v8::Persistent< T, M >::Persistent ( )
inline

A Persistent with no storage cell.

Definition at line 632 of file v8.h.

632 : PersistentBase<T>(0) { }

◆ Persistent() [2/6]

template<class T , class M >
template<class S >
v8::Persistent< T, M >::Persistent ( Isolate isolate,
Handle< S that 
)
inline

Construct a Persistent from a Handle.

When the Handle is non-empty, a new storage cell is created pointing to the same object, and no flags are set.

Definition at line 638 of file v8.h.

639  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
640  TYPE_CHECK(T, S);
641  }
static T * New(Isolate *isolate, T *that)
Definition: v8.h:6031
#define TYPE_CHECK(T, S)
Definition: v8.h:167
#define T(name, string, precedence)
Definition: token.cc:25
#define S(x)
Definition: version.cc:55

References S, T, and TYPE_CHECK.

◆ Persistent() [3/6]

template<class T , class M >
template<class S , class M2 >
v8::Persistent< T, M >::Persistent ( Isolate isolate,
const Persistent< S, M2 > &  that 
)
inline

Construct a Persistent from a Persistent.

When the Persistent is non-empty, a new storage cell is created pointing to the same object, and no flags are set.

Definition at line 648 of file v8.h.

649  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
650  TYPE_CHECK(T, S);
651  }

References S, T, and TYPE_CHECK.

◆ Persistent() [4/6]

template<class T , class M >
v8::Persistent< T, M >::Persistent ( const Persistent< T, M > &  that)
inline

The copy constructors and assignment operator create a Persistent exactly as the Persistent constructor, but the Copy function from the traits class is called, allowing the setting of flags based on the copied Persistent.

Definition at line 658 of file v8.h.

658  : PersistentBase<T>(0) {
659  Copy(that);
660  }
void Copy(const Persistent< S, M2 > &that)
Definition: v8.h:6042

References v8::Persistent< T, M >::Copy().

+ Here is the call graph for this function:

◆ Persistent() [5/6]

template<class T , class M >
template<class S , class M2 >
v8::Persistent< T, M >::Persistent ( const Persistent< S, M2 > &  that)
inline

Definition at line 662 of file v8.h.

662  : PersistentBase<T>(0) {
663  Copy(that);
664  }

References v8::Persistent< T, M >::Copy().

+ Here is the call graph for this function:

◆ ~Persistent()

template<class T , class M >
v8::Persistent< T, M >::~Persistent ( )
inline

The destructor will dispose the Persistent based on the kResetInDestructor flags in the traits class.

Since not calling dispose can result in a memory leak, it is recommended to always set this flag.

Definition at line 679 of file v8.h.

679  {
680  if (M::kResetInDestructor) this->Reset();
681  }
void Reset()
If non-empty, destroy the underlying storage cell IsEmpty() will return true after this call.
Definition: v8.h:6082

References v8::PersistentBase< T >::Reset().

+ Here is the call graph for this function:

◆ Persistent() [6/6]

template<class T , class M >
template<class S >
v8::Persistent< T, M >::Persistent ( S that)
inlineprivate

Definition at line 710 of file v8.h.

710 : PersistentBase<T>(that) { }

Member Function Documentation

◆ As()

template<class T , class M >
template<class S >
Persistent<S>& v8::Persistent< T, M >::As ( )
inline

Definition at line 695 of file v8.h.

695  { // NOLINT
696  return Persistent<S>::Cast(*this);
697  }
static Persistent< T > & Cast(Persistent< S > &that)
Definition: v8.h:685

References v8::Persistent< T, M >::Cast().

+ Here is the call graph for this function:

◆ Cast()

template<class T , class M >
template<class S >
static Persistent<T>& v8::Persistent< T, M >::Cast ( Persistent< S > &  that)
inlinestatic

Definition at line 685 of file v8.h.

685  { // NOLINT
686 #ifdef V8_ENABLE_CHECKS
687  // If we're going to perform the type check then we have to check
688  // that the handle isn't empty before doing the checked cast.
689  if (!that.IsEmpty()) T::Cast(*that);
690 #endif
691  return reinterpret_cast<Persistent<T>&>(that);
692  }

References v8::PersistentBase< T >::IsEmpty().

Referenced by v8::Persistent< T, M >::As().

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

◆ ClearAndLeak()

template<class T , class M >
T * v8::Persistent< T, M >::ClearAndLeak
inline

Definition at line 6161 of file v8.h.

6161  {
6162  T* old;
6163  old = this->val_;
6164  this->val_ = NULL;
6165  return old;
6166 }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL

References NULL, and T.

◆ Copy()

template<class T , class M >
template<class S , class M2 >
void v8::Persistent< T, M >::Copy ( const Persistent< S, M2 > &  that)
inlineprivate

Definition at line 6042 of file v8.h.

6042  {
6043  TYPE_CHECK(T, S);
6044  this->Reset();
6045  if (that.IsEmpty()) return;
6046  internal::Object** p = reinterpret_cast<internal::Object**>(that.val_);
6047  this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p));
6048  M::Copy(that, this);
6049 }
static internal::Object ** CopyPersistent(internal::Object **handle)
Definition: api.cc:504
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References v8::V8::CopyPersistent(), v8::PersistentBase< T >::IsEmpty(), S, T, TYPE_CHECK, and v8::PersistentBase< T >::val_.

Referenced by v8::Persistent< T, M >::operator=(), and v8::Persistent< T, M >::Persistent().

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

◆ operator*()

template<class T , class M >
T* v8::Persistent< T, M >::operator* ( ) const
inlineprivate

Definition at line 711 of file v8.h.

711 { return this->val_; }

References v8::PersistentBase< T >::val_.

◆ operator=() [1/2]

template<class T , class M >
Persistent& v8::Persistent< T, M >::operator= ( const Persistent< T, M > &  that)
inline

Definition at line 665 of file v8.h.

665  { // NOLINT
666  Copy(that);
667  return *this;
668  }

References v8::Persistent< T, M >::Copy().

+ Here is the call graph for this function:

◆ operator=() [2/2]

template<class T , class M >
template<class S , class M2 >
Persistent& v8::Persistent< T, M >::operator= ( const Persistent< S, M2 > &  that)
inline

Definition at line 670 of file v8.h.

670  { // NOLINT
671  Copy(that);
672  return *this;
673  }

References v8::Persistent< T, M >::Copy().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ Handle

template<class T , class M >
template<class F >
friend class Handle
friend

Definition at line 705 of file v8.h.

◆ Isolate

template<class T , class M >
friend class Isolate
friend

Definition at line 703 of file v8.h.

◆ Local

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

Definition at line 706 of file v8.h.

◆ Persistent

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

Definition at line 707 of file v8.h.

◆ ReturnValue

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

Definition at line 708 of file v8.h.

◆ Utils

template<class T , class M >
friend class Utils
friend

Definition at line 704 of file v8.h.


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