Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
v8::EmbedderGraph Class Referenceabstract

#include <v8-profiler.h>

Classes

class  Node
 

Public Member Functions

virtual NodeV8Node (const v8::Local< v8::Value > &value)=0
 
virtual NodeV8Node (const v8::Local< v8::Data > &value)
 
virtual NodeAddNode (std::unique_ptr< Node > node)=0
 
virtual void AddEdge (Node *from, Node *to, const char *name=nullptr)=0
 
virtual ~EmbedderGraph ()=default
 

Detailed Description

An object graph consisting of embedder objects and V8 objects. Edges of the graph are strong references between the objects. The embedder can build this graph during heap snapshot generation to include the embedder objects in the heap snapshot. Usage: 1) Define derived class of EmbedderGraph::Node for embedder objects. 2) Set the build embedder graph callback on the heap profiler using HeapProfiler::AddBuildEmbedderGraphCallback. 3) In the callback use graph->AddEdge(node1, node2) to add an edge from node1 to node2. 4) To represent references from/to V8 object, construct V8 nodes using graph->V8Node(value).

Constructor & Destructor Documentation

◆ ~EmbedderGraph()

virtual v8::EmbedderGraph::~EmbedderGraph ( )
virtualdefault

Member Function Documentation

◆ AddEdge()

virtual void v8::EmbedderGraph::AddEdge ( Node from,
Node to,
const char *  name = nullptr 
)
pure virtual

Adds an edge that represents a strong reference from the given node |from| to the given node |to|. The nodes must be added to the graph before calling this function.

If name is nullptr, the edge will have auto-increment indexes, otherwise it will be named accordingly.

◆ AddNode()

virtual Node * v8::EmbedderGraph::AddNode ( std::unique_ptr< Node node)
pure virtual

Adds the given node to the graph and takes ownership of the node. Returns a raw pointer to the node that is valid while the graph is alive.

◆ V8Node() [1/2]

virtual Node * v8::EmbedderGraph::V8Node ( const v8::Local< v8::Data > &  value)
virtual

Returns a node corresponding to the given V8 value. Ownership is not transferred. The result pointer is valid while the graph is alive.

For API compatibility, this default implementation just checks that the data is a v8::Value and forward it to the variant that takes v8::Value, which is currently required to be implemented. In the future we'll remove the v8::Value variant, and make this variant that takes v8::Data abstract instead. If the embedder subclasses v8::EmbedderGraph and also use v8::TracedReference<v8::Data>, they must override this variant.

◆ V8Node() [2/2]

virtual Node * v8::EmbedderGraph::V8Node ( const v8::Local< v8::Value > &  value)
pure virtual

Returns a node corresponding to the given V8 value. Ownership is not transferred. The result pointer is valid while the graph is alive.

For now the variant that takes v8::Data is not marked as abstract for compatibility, but embedders who subclass EmbedderGraph are expected to implement it. Then in the implementation of the variant that takes v8::Value, they can simply forward the call to the one that takes v8::Local<v8::Data>.


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