v8  8.6.395 (node 15.0.1)
V8 is Google's open source JavaScript engine
EmbedderHeapTracer Class Referenceabstract

#include <v8.h>

Collaboration diagram for EmbedderHeapTracer:

Data Structures

class  TracedGlobalHandleVisitor
 
struct  TraceSummary
 

Public Types

enum  TraceFlags : uint64_t { kNoFlags = 0 , kReduceMemory = 1 << 0 , kForced = 1 << 2 }
 
using EmbedderStackState = cppgc::EmbedderStackState
 

Public Member Functions

virtual ~EmbedderHeapTracer ()=default
 
void IterateTracedGlobalHandles (TracedGlobalHandleVisitor *visitor)
 
void SetStackStart (void *stack_start)
 
void NotifyEmptyEmbedderStack ()
 
virtual void RegisterV8References (const std::vector< std::pair< void *, void * > > &embedder_fields)=0
 
void RegisterEmbedderReference (const TracedReferenceBase< v8::Data > &ref)
 
virtual void TracePrologue (TraceFlags flags)
 
virtual bool AdvanceTracing (double deadline_in_ms)=0
 
virtual bool IsTracingDone ()=0
 
virtual void TraceEpilogue (TraceSummary *trace_summary)
 
virtual void EnterFinalPause (EmbedderStackState stack_state)=0
 
void FinalizeTracing ()
 
virtual bool IsRootForNonTracingGC (const v8::TracedReference< v8::Value > &handle)
 
virtual bool IsRootForNonTracingGC (const v8::TracedGlobal< v8::Value > &handle)
 
virtual void ResetHandleInNonTracingGC (const v8::TracedReference< v8::Value > &handle)
 
void GarbageCollectionForTesting (EmbedderStackState stack_state)
 
void IncreaseAllocatedSize (size_t bytes)
 
void DecreaseAllocatedSize (size_t bytes)
 
v8::Isolateisolate () const
 

Protected Attributes

v8::Isolateisolate_ = nullptr
 

Friends

class internal::LocalEmbedderHeapTracer
 

Detailed Description

Interface for tracing through the embedder heap. During a V8 garbage collection, V8 collects hidden fields of all potential wrappers, and at the end of its marking phase iterates the collection and asks the embedder to trace through its heap and use reporter to report each JavaScript object reachable from any of the given wrappers.

Definition at line 7892 of file v8.h.

Member Typedef Documentation

◆ EmbedderStackState

Definition at line 7894 of file v8.h.

Member Enumeration Documentation

◆ TraceFlags

enum TraceFlags : uint64_t
Enumerator
kNoFlags 
kReduceMemory 
kForced 

Definition at line 7896 of file v8.h.

Constructor & Destructor Documentation

◆ ~EmbedderHeapTracer()

virtual ~EmbedderHeapTracer ( )
virtualdefault

Member Function Documentation

◆ AdvanceTracing()

virtual bool AdvanceTracing ( double  deadline_in_ms)
pure virtual

Called to advance tracing in the embedder.

The embedder is expected to trace its heap starting from wrappers reported by RegisterV8References method, and report back all reachable wrappers. Furthermore, the embedder is expected to stop tracing by the given deadline. A deadline of infinity means that tracing should be finished.

Returns |true| if tracing is done, and false otherwise.

◆ DecreaseAllocatedSize()

void DecreaseAllocatedSize ( size_t  bytes)

◆ EnterFinalPause()

virtual void EnterFinalPause ( EmbedderStackState  stack_state)
pure virtual

Called upon entering the final marking pause. No more incremental marking steps will follow this call.

◆ FinalizeTracing()

void FinalizeTracing ( )

◆ GarbageCollectionForTesting()

void GarbageCollectionForTesting ( EmbedderStackState  stack_state)

◆ IncreaseAllocatedSize()

void IncreaseAllocatedSize ( size_t  bytes)

◆ isolate()

v8::Isolate* isolate ( ) const
inline

Definition at line 8062 of file v8.h.

References EmbedderHeapTracer::isolate_.

◆ IsRootForNonTracingGC() [1/2]

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

◆ IsRootForNonTracingGC() [2/2]

virtual bool IsRootForNonTracingGC ( const v8::TracedReference< v8::Value > &  handle)
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 |ResetHandleInNonTracingGC|.

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.

◆ IsTracingDone()

virtual bool IsTracingDone ( )
pure virtual

◆ IterateTracedGlobalHandles()

void IterateTracedGlobalHandles ( TracedGlobalHandleVisitor visitor)

Iterates all TracedGlobal handles created for the v8::Isolate the tracer is attached to.

◆ NotifyEmptyEmbedderStack()

void NotifyEmptyEmbedderStack ( )

Called by the embedder to notify V8 of an empty execution stack.

◆ RegisterEmbedderReference()

void RegisterEmbedderReference ( const TracedReferenceBase< v8::Data > &  ref)

◆ RegisterV8References()

virtual void RegisterV8References ( const std::vector< std::pair< void *, void * > > &  embedder_fields)
pure virtual

Called by v8 to register internal fields of found wrappers.

The embedder is expected to store them somewhere and trace reachable wrappers from them when called through |AdvanceTracing|.

◆ ResetHandleInNonTracingGC()

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

Used in combination with |IsRootForNonTracingGC|. 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.

◆ SetStackStart()

void SetStackStart ( void *  stack_start)

Called by the embedder to set the start of the stack which is e.g. used by V8 to determine whether handles are used from stack or heap.

◆ TraceEpilogue()

virtual void TraceEpilogue ( TraceSummary trace_summary)
inlinevirtual

Called at the end of a GC cycle.

Note that allocation is not allowed within |TraceEpilogue|. Can be overriden to fill a |TraceSummary| that is used by V8 to schedule future garbage collections.

Definition at line 7990 of file v8.h.

◆ TracePrologue()

virtual void TracePrologue ( TraceFlags  flags)
inlinevirtual

Called at the beginning of a GC cycle.

Definition at line 7963 of file v8.h.

Friends And Related Function Documentation

◆ internal::LocalEmbedderHeapTracer

friend class internal::LocalEmbedderHeapTracer
friend

Definition at line 8067 of file v8.h.

Field Documentation

◆ isolate_

v8::Isolate* isolate_ = nullptr
protected

Definition at line 8065 of file v8.h.

Referenced by EmbedderHeapTracer::isolate().


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