v8  9.4.146 (node 16.13.0)
V8 is Google's open source JavaScript engine
EmbedderRootsHandler Class Referenceabstract

#include <v8.h>

Public Member Functions

virtual ~EmbedderRootsHandler ()=default
 
virtual bool IsRoot (const v8::TracedReference< v8::Value > &handle)=0
 
virtual bool IsRoot (const v8::TracedGlobal< v8::Value > &handle)=0
 
virtual void ResetRoot (const v8::TracedReference< v8::Value > &handle)=0
 

Detailed Description

Handler for embedder roots on non-unified heap garbage collections.

Definition at line 7994 of file v8.h.

Constructor & Destructor Documentation

◆ ~EmbedderRootsHandler()

virtual ~EmbedderRootsHandler ( )
virtualdefault

Member Function Documentation

◆ IsRoot() [1/2]

virtual bool IsRoot ( const v8::TracedGlobal< v8::Value > &  handle)
pure virtual

◆ IsRoot() [2/2]

virtual bool IsRoot ( const v8::TracedReference< v8::Value > &  handle)
pure virtual

Returns true if the TracedGlobal handle should be considered as root for the currently running non-tracing garbage collection and false otherwise. The default implementation will keep all TracedGlobal references as roots.

If this returns false, then V8 may decide that the object referred to by such a handle is reclaimed. In that case:

  • No action is required if handles are used with destructors, i.e., by just using |TracedGlobal|.
  • When run without destructors, i.e., by using |TracedReference|, V8 calls |ResetRoot|.

Note that the |handle| is different from the handle that the embedder holds for retaining the object. The embedder may use |WrapperClassId()| to distinguish cases where it wants handles to be treated as roots from not being treated as roots.

◆ ResetRoot()

virtual void ResetRoot ( const v8::TracedReference< v8::Value > &  handle)
pure virtual

Used in combination with |IsRoot|. Called by V8 when an object that is backed by a handle is reclaimed by a non-tracing garbage collection. It is up to the embedder to reset the original handle.

Note that the |handle| is different from the handle that the embedder holds for retaining the object. It is up to the embedder to find the original handle via the object or class id.


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