V8 Project
v8::RetainedObjectInfo Class Referenceabstract

Interface for providing information about embedder's objects held by global handles. More...

#include <v8-profiler.h>

+ Inheritance diagram for v8::RetainedObjectInfo:
+ Collaboration diagram for v8::RetainedObjectInfo:

Public Member Functions

virtual void Dispose ()=0
 Called by V8 when it no longer needs an instance. More...
 
virtual bool IsEquivalent (RetainedObjectInfo *other)=0
 Returns whether two instances are equivalent. More...
 
virtual intptr_t GetHash ()=0
 Returns hash value for the instance. More...
 
virtual const char * GetLabel ()=0
 Returns human-readable label. More...
 
virtual const char * GetGroupLabel ()
 Returns human-readable group label. More...
 
virtual intptr_t GetElementCount ()
 Returns element count in case if a global handle retains a subgraph by holding one of its nodes. More...
 
virtual intptr_t GetSizeInBytes ()
 Returns embedder's object size in bytes. More...
 

Protected Member Functions

 RetainedObjectInfo ()
 
virtual ~RetainedObjectInfo ()
 

Private Member Functions

 RetainedObjectInfo (const RetainedObjectInfo &)
 
RetainedObjectInfooperator= (const RetainedObjectInfo &)
 

Detailed Description

Interface for providing information about embedder's objects held by global handles.

This information is reported in two ways:

  1. When calling AddObjectGroup, an embedder may pass RetainedObjectInfo instance describing the group. To collect this information while taking a heap snapshot, V8 calls GC prologue and epilogue callbacks.
  2. When a heap snapshot is collected, V8 additionally requests RetainedObjectInfos for persistent handles that were not previously reported via AddObjectGroup.

Thus, if an embedder wants to provide information about native objects for heap snapshots, he can do it in a GC prologue handler, and / or by assigning wrapper class ids in the following way:

  1. Bind a callback to class id by calling SetWrapperClassInfoProvider.
  2. Call SetWrapperClassId on certain persistent handles.

V8 takes ownership of RetainedObjectInfo instances passed to it and keeps them alive only during snapshot collection. Afterwards, they are freed by calling the Dispose class function.

Definition at line 545 of file v8-profiler.h.

Constructor & Destructor Documentation

◆ RetainedObjectInfo() [1/2]

v8::RetainedObjectInfo::RetainedObjectInfo ( )
inlineprotected

Definition at line 586 of file v8-profiler.h.

586 {}

◆ ~RetainedObjectInfo()

virtual v8::RetainedObjectInfo::~RetainedObjectInfo ( )
inlineprotectedvirtual

Definition at line 587 of file v8-profiler.h.

587 {}

◆ RetainedObjectInfo() [2/2]

v8::RetainedObjectInfo::RetainedObjectInfo ( const RetainedObjectInfo )
private

Member Function Documentation

◆ Dispose()

virtual void v8::RetainedObjectInfo::Dispose ( )
pure virtual

Called by V8 when it no longer needs an instance.

Implemented in v8::internal::NativeGroupRetainedObjectInfo.

Referenced by v8::internal::GlobalHandles::AddObjectGroup(), v8::internal::GlobalHandles::ComputeObjectGroupsAndImplicitReferences(), v8::internal::NativeObjectsExplorer::GetListMaybeDisposeInfo(), v8::internal::NativeObjectsExplorer::~NativeObjectsExplorer(), and v8::internal::ObjectGroup::~ObjectGroup().

+ Here is the caller graph for this function:

◆ GetElementCount()

virtual intptr_t v8::RetainedObjectInfo::GetElementCount ( )
inlinevirtual

Returns element count in case if a global handle retains a subgraph by holding one of its nodes.

Definition at line 580 of file v8-profiler.h.

580 { return -1; }

Referenced by v8::internal::BasicHeapEntriesAllocator::AllocateEntry(), and v8::internal::HeapObjectsMap::GenerateId().

+ Here is the caller graph for this function:

◆ GetGroupLabel()

virtual const char* v8::RetainedObjectInfo::GetGroupLabel ( )
inlinevirtual

Returns human-readable group label.

It must be a null-terminated UTF-8 encoded string. V8 copies its contents during a call to GetGroupLabel. Heap snapshot generator will collect all the group names, create top level entries with these names and attach the objects to the corresponding top level group objects. There is a default implementation which is required because embedders don't have their own implementation yet.

Definition at line 574 of file v8-profiler.h.

574 { return GetLabel(); }
virtual const char * GetLabel()=0
Returns human-readable label.

Referenced by v8::internal::NativeObjectsExplorer::SetNativeRootReference().

+ Here is the caller graph for this function:

◆ GetHash()

virtual intptr_t v8::RetainedObjectInfo::GetHash ( )
pure virtual

Returns hash value for the instance.

Equivalent instances must have the same hash value.

Implemented in v8::internal::NativeGroupRetainedObjectInfo.

Referenced by v8::internal::HeapObjectsMap::GenerateId(), v8::internal::NativeObjectsExplorer::InfoHash(), and v8::internal::NativeGroupRetainedObjectInfo::IsEquivalent().

+ Here is the caller graph for this function:

◆ GetLabel()

virtual const char* v8::RetainedObjectInfo::GetLabel ( )
pure virtual

Returns human-readable label.

It must be a null-terminated UTF-8 encoded string. V8 copies its contents during a call to GetLabel.

Implemented in v8::internal::NativeGroupRetainedObjectInfo.

Referenced by v8::internal::BasicHeapEntriesAllocator::AllocateEntry(), v8::internal::HeapObjectsMap::GenerateId(), and v8::internal::NativeGroupRetainedObjectInfo::IsEquivalent().

+ Here is the caller graph for this function:

◆ GetSizeInBytes()

virtual intptr_t v8::RetainedObjectInfo::GetSizeInBytes ( )
inlinevirtual

Returns embedder's object size in bytes.

Definition at line 583 of file v8-profiler.h.

583 { return -1; }

Referenced by v8::internal::BasicHeapEntriesAllocator::AllocateEntry().

+ Here is the caller graph for this function:

◆ IsEquivalent()

virtual bool v8::RetainedObjectInfo::IsEquivalent ( RetainedObjectInfo other)
pure virtual

Returns whether two instances are equivalent.

Implemented in v8::internal::NativeGroupRetainedObjectInfo.

◆ operator=()

RetainedObjectInfo& v8::RetainedObjectInfo::operator= ( const RetainedObjectInfo )
private

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