#include <v8-profiler.h>
Classes | |
class | Node |
Public Member Functions | |
virtual Node * | V8Node (const v8::Local< v8::Value > &value)=0 |
virtual Node * | V8Node (const v8::Local< v8::Data > &value) |
virtual Node * | AddNode (std::unique_ptr< Node > node)=0 |
virtual void | AddEdge (Node *from, Node *to, const char *name=nullptr)=0 |
virtual | ~EmbedderGraph ()=default |
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).
|
virtualdefault |
|
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.
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.
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.
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>.