V8 Project
v8::internal::HeapProfiler Class Reference

#include <heap-profiler.h>

+ Collaboration diagram for v8::internal::HeapProfiler:

Public Member Functions

 HeapProfiler (Heap *heap)
 
 ~HeapProfiler ()
 
size_t GetMemorySizeUsedByProfiler ()
 
HeapSnapshotTakeSnapshot (const char *name, v8::ActivityControl *control, v8::HeapProfiler::ObjectNameResolver *resolver)
 
HeapSnapshotTakeSnapshot (String *name, v8::ActivityControl *control, v8::HeapProfiler::ObjectNameResolver *resolver)
 
void StartHeapObjectsTracking (bool track_allocations)
 
void StopHeapObjectsTracking ()
 
AllocationTrackerallocation_tracker () const
 
HeapObjectsMapheap_object_map () const
 
StringsStoragenames () const
 
SnapshotObjectId PushHeapObjectsStats (OutputStream *stream)
 
int GetSnapshotsCount ()
 
HeapSnapshotGetSnapshot (int index)
 
SnapshotObjectId GetSnapshotObjectId (Handle< Object > obj)
 
void DeleteAllSnapshots ()
 
void RemoveSnapshot (HeapSnapshot *snapshot)
 
void ObjectMoveEvent (Address from, Address to, int size)
 
void AllocationEvent (Address addr, int size)
 
void UpdateObjectSizeEvent (Address addr, int size)
 
void DefineWrapperClass (uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback)
 
v8::RetainedObjectInfoExecuteWrapperClassCallback (uint16_t class_id, Object **wrapper)
 
void SetRetainedObjectInfo (UniqueId id, RetainedObjectInfo *info)
 
bool is_tracking_object_moves () const
 
bool is_tracking_allocations () const
 
Handle< HeapObjectFindHeapObjectById (SnapshotObjectId id)
 
void ClearHeapObjectMap ()
 

Private Member Functions

Heapheap () const
 

Private Attributes

SmartPointer< HeapObjectsMapids_
 
List< HeapSnapshot * > snapshots_
 
SmartPointer< StringsStoragenames_
 
unsigned next_snapshot_uid_
 
List< v8::HeapProfiler::WrapperInfoCallbackwrapper_callbacks_
 
SmartPointer< AllocationTrackerallocation_tracker_
 
bool is_tracking_object_moves_
 

Detailed Description

Definition at line 17 of file heap-profiler.h.

Constructor & Destructor Documentation

◆ HeapProfiler()

v8::internal::HeapProfiler::HeapProfiler ( Heap heap)
explicit

Definition at line 15 of file heap-profiler.cc.

16  : ids_(new HeapObjectsMap(heap)),
17  names_(new StringsStorage(heap)),
20 }
SmartPointer< HeapObjectsMap > ids_
Definition: heap-profiler.h:73
SmartPointer< StringsStorage > names_
Definition: heap-profiler.h:75

◆ ~HeapProfiler()

v8::internal::HeapProfiler::~HeapProfiler ( )

Definition at line 28 of file heap-profiler.cc.

28  {
30  snapshots_.Clear();
31 }
List< HeapSnapshot * > snapshots_
Definition: heap-profiler.h:74
static void DeleteHeapSnapshot(HeapSnapshot **snapshot_ptr)

References v8::internal::DeleteHeapSnapshot(), and snapshots_.

+ Here is the call graph for this function:

Member Function Documentation

◆ allocation_tracker()

AllocationTracker* v8::internal::HeapProfiler::allocation_tracker ( ) const
inline

Definition at line 35 of file heap-profiler.h.

35  {
36  return allocation_tracker_.get();
37  }
SmartPointer< AllocationTracker > allocation_tracker_
Definition: heap-profiler.h:78

References allocation_tracker_.

Referenced by v8::internal::V8HeapExplorer::AddEntry(), v8::internal::HeapSnapshotJSONSerializer::Serialize(), v8::internal::HeapSnapshotJSONSerializer::SerializeSnapshot(), v8::internal::HeapSnapshotJSONSerializer::SerializeTraceNodeInfos(), and v8::internal::HeapSnapshotJSONSerializer::SerializeTraceTree().

+ Here is the caller graph for this function:

◆ AllocationEvent()

void v8::internal::HeapProfiler::AllocationEvent ( Address  addr,
int  size 
)

Definition at line 155 of file heap-profiler.cc.

155  {
156  DisallowHeapAllocation no_allocation;
157  if (!allocation_tracker_.is_empty()) {
158  allocation_tracker_->AllocationEvent(addr, size);
159  }
160 }
enable harmony numeric enable harmony object literal extensions Optimize object size
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110

References allocation_tracker_, and size.

◆ ClearHeapObjectMap()

void v8::internal::HeapProfiler::ClearHeapObjectMap ( )

Definition at line 192 of file heap-profiler.cc.

192  {
193  ids_.Reset(new HeapObjectsMap(heap()));
195 }
bool is_tracking_allocations() const
Definition: heap-profiler.h:62

References heap(), ids_, is_tracking_allocations(), and is_tracking_object_moves_.

+ Here is the call graph for this function:

◆ DefineWrapperClass()

void v8::internal::HeapProfiler::DefineWrapperClass ( uint16_t  class_id,
v8::HeapProfiler::WrapperInfoCallback  callback 
)

Definition at line 46 of file heap-profiler.cc.

47  {
49  if (wrapper_callbacks_.length() <= class_id) {
51  NULL, class_id - wrapper_callbacks_.length() + 1);
52  }
53  wrapper_callbacks_[class_id] = callback;
54 }
static const uint16_t kPersistentHandleNoClassId
Default value of persistent handle class ID.
Definition: v8-profiler.h:503
List< v8::HeapProfiler::WrapperInfoCallback > wrapper_callbacks_
Definition: heap-profiler.h:77
Vector< T > AddBlock(T value, int count, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:77
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
Definition: logging.h:205

References v8::internal::List< T, AllocationPolicy >::AddBlock(), DCHECK, v8::HeapProfiler::kPersistentHandleNoClassId, NULL, and wrapper_callbacks_.

+ Here is the call graph for this function:

◆ DeleteAllSnapshots()

void v8::internal::HeapProfiler::DeleteAllSnapshots ( )

Definition at line 34 of file heap-profiler.cc.

34  {
36  snapshots_.Clear();
37  names_.Reset(new StringsStorage(heap()));
38 }

References v8::internal::DeleteHeapSnapshot(), heap(), names_, and snapshots_.

Referenced by v8::HeapSnapshot::Delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ExecuteWrapperClassCallback()

v8::RetainedObjectInfo * v8::internal::HeapProfiler::ExecuteWrapperClassCallback ( uint16_t  class_id,
Object **  wrapper 
)

Definition at line 57 of file heap-profiler.cc.

58  {
59  if (wrapper_callbacks_.length() <= class_id) return NULL;
60  return wrapper_callbacks_[class_id](
61  class_id, Utils::ToLocal(Handle<Object>(wrapper)));
62 }
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)

References NULL, v8::Utils::ToLocal(), and wrapper_callbacks_.

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindHeapObjectById()

Handle< HeapObject > v8::internal::HeapProfiler::FindHeapObjectById ( SnapshotObjectId  id)

Definition at line 175 of file heap-profiler.cc.

175  {
176  HeapObject* object = NULL;
177  HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable);
178  // Make sure that object with the given id is still reachable.
179  for (HeapObject* obj = iterator.next();
180  obj != NULL;
181  obj = iterator.next()) {
182  if (ids_->FindEntry(obj->address()) == id) {
183  DCHECK(object == NULL);
184  object = obj;
185  // Can't break -- kFilterUnreachable requires full heap traversal.
186  }
187  }
188  return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>();
189 }

References DCHECK, heap(), ids_, and NULL.

+ Here is the call graph for this function:

◆ GetMemorySizeUsedByProfiler()

size_t v8::internal::HeapProfiler::GetMemorySizeUsedByProfiler ( )

Definition at line 118 of file heap-profiler.cc.

118  {
119  size_t size = sizeof(*this);
120  size += names_->GetUsedMemorySize();
121  size += ids_->GetUsedMemorySize();
123  for (int i = 0; i < snapshots_.length(); ++i) {
124  size += snapshots_[i]->RawSnapshotSize();
125  }
126  return size;
127 }
size_t GetMemoryUsedByList(const List< T, P > &list)
Definition: list.h:184

References v8::internal::GetMemoryUsedByList(), ids_, names_, size, and snapshots_.

+ Here is the call graph for this function:

◆ GetSnapshot()

HeapSnapshot * v8::internal::HeapProfiler::GetSnapshot ( int  index)

Definition at line 135 of file heap-profiler.cc.

135  {
136  return snapshots_.at(index);
137 }

References snapshots_.

◆ GetSnapshotObjectId()

SnapshotObjectId v8::internal::HeapProfiler::GetSnapshotObjectId ( Handle< Object obj)

Definition at line 140 of file heap-profiler.cc.

140  {
141  if (!obj->IsHeapObject())
143  return ids_->FindEntry(HeapObject::cast(*obj)->address());
144 }
static const SnapshotObjectId kUnknownObjectId
A constant for invalid SnapshotObjectId.
Definition: v8-profiler.h:431

References ids_, and v8::HeapProfiler::kUnknownObjectId.

◆ GetSnapshotsCount()

int v8::internal::HeapProfiler::GetSnapshotsCount ( )

Definition at line 130 of file heap-profiler.cc.

130  {
131  return snapshots_.length();
132 }

References snapshots_.

Referenced by v8::HeapSnapshot::Delete().

+ Here is the caller graph for this function:

◆ heap()

Heap* v8::internal::HeapProfiler::heap ( ) const
inlineprivate

Definition at line 70 of file heap-profiler.h.

70 { return ids_->heap(); }

References ids_.

Referenced by ClearHeapObjectMap(), DeleteAllSnapshots(), FindHeapObjectById(), SetRetainedObjectInfo(), StartHeapObjectsTracking(), StopHeapObjectsTracking(), and TakeSnapshot().

+ Here is the caller graph for this function:

◆ heap_object_map()

HeapObjectsMap* v8::internal::HeapProfiler::heap_object_map ( ) const
inline

Definition at line 38 of file heap-profiler.h.

38 { return ids_.get(); }

References ids_.

Referenced by v8::internal::HeapSnapshot::RememberLastJSObjectId().

+ Here is the caller graph for this function:

◆ is_tracking_allocations()

bool v8::internal::HeapProfiler::is_tracking_allocations ( ) const
inline

Definition at line 62 of file heap-profiler.h.

62  {
63  return !allocation_tracker_.is_empty();
64  }

References allocation_tracker_.

Referenced by ClearHeapObjectMap(), StartHeapObjectsTracking(), and StopHeapObjectsTracking().

+ Here is the caller graph for this function:

◆ is_tracking_object_moves()

bool v8::internal::HeapProfiler::is_tracking_object_moves ( ) const
inline

Definition at line 61 of file heap-profiler.h.

61 { return is_tracking_object_moves_; }

References is_tracking_object_moves_.

Referenced by v8::internal::Heap::OnMoveEvent(), and v8::internal::Heap::SelectScavengingVisitorsTable().

+ Here is the caller graph for this function:

◆ names()

StringsStorage* v8::internal::HeapProfiler::names ( ) const
inline

Definition at line 39 of file heap-profiler.h.

39 { return names_.get(); }

References names_.

◆ ObjectMoveEvent()

void v8::internal::HeapProfiler::ObjectMoveEvent ( Address  from,
Address  to,
int  size 
)

Definition at line 147 of file heap-profiler.cc.

147  {
148  bool known_object = ids_->MoveObject(from, to, size);
149  if (!known_object && !allocation_tracker_.is_empty()) {
150  allocation_tracker_->address_to_trace()->MoveObject(from, to, size);
151  }
152 }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes to(mksnapshot only)") DEFINE_STRING(raw_context_file

References allocation_tracker_, ids_, size, and to().

Referenced by v8::internal::Heap::OnMoveEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PushHeapObjectsStats()

SnapshotObjectId v8::internal::HeapProfiler::PushHeapObjectsStats ( OutputStream stream)

Definition at line 104 of file heap-profiler.cc.

104  {
105  return ids_->PushHeapObjectsStats(stream);
106 }

References ids_.

◆ RemoveSnapshot()

void v8::internal::HeapProfiler::RemoveSnapshot ( HeapSnapshot snapshot)

Definition at line 41 of file heap-profiler.cc.

41  {
42  snapshots_.RemoveElement(snapshot);
43 }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the snapshot(mksnapshot only)") DEFINE_STRING(raw_file

References snapshot(), and snapshots_.

Referenced by v8::internal::HeapSnapshot::Delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetRetainedObjectInfo()

void v8::internal::HeapProfiler::SetRetainedObjectInfo ( UniqueId  id,
RetainedObjectInfo info 
)

Definition at line 168 of file heap-profiler.cc.

169  {
170  // TODO(yurus, marja): Don't route this information through GlobalHandles.
172 }
void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo *info)
Isolate * isolate()
Definition: heap-inl.h:589
GlobalHandles * global_handles()
Definition: isolate.h:917

References v8::internal::Isolate::global_handles(), heap(), v8::internal::Heap::isolate(), and v8::internal::GlobalHandles::SetRetainedObjectInfo().

+ Here is the call graph for this function:

◆ StartHeapObjectsTracking()

void v8::internal::HeapProfiler::StartHeapObjectsTracking ( bool  track_allocations)

Definition at line 93 of file heap-profiler.cc.

93  {
94  ids_->UpdateHeapObjectsMap();
97  if (track_allocations) {
98  allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get()));
100  }
101 }
void DisableInlineAllocation()
Definition: heap.cc:5034

References allocation_tracker_, DCHECK, v8::internal::Heap::DisableInlineAllocation(), heap(), ids_, is_tracking_allocations(), is_tracking_object_moves_, and names_.

+ Here is the call graph for this function:

◆ StopHeapObjectsTracking()

void v8::internal::HeapProfiler::StopHeapObjectsTracking ( )

Definition at line 109 of file heap-profiler.cc.

109  {
110  ids_->StopHeapObjectsTracking();
111  if (is_tracking_allocations()) {
112  allocation_tracker_.Reset(NULL);
114  }
115 }
void EnableInlineAllocation()
Definition: heap.cc:5025

References allocation_tracker_, v8::internal::Heap::EnableInlineAllocation(), heap(), ids_, is_tracking_allocations(), and NULL.

+ Here is the call graph for this function:

◆ TakeSnapshot() [1/2]

HeapSnapshot * v8::internal::HeapProfiler::TakeSnapshot ( const char *  name,
v8::ActivityControl control,
v8::HeapProfiler::ObjectNameResolver resolver 
)

Definition at line 65 of file heap-profiler.cc.

68  {
69  HeapSnapshot* result = new HeapSnapshot(this, name, next_snapshot_uid_++);
70  {
71  HeapSnapshotGenerator generator(result, control, resolver, heap());
72  if (!generator.GenerateSnapshot()) {
73  delete result;
74  result = NULL;
75  } else {
76  snapshots_.Add(result);
77  }
78  }
79  ids_->RemoveDeadEntries();
81  return result;
82 }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name

References v8::internal::HeapSnapshotGenerator::GenerateSnapshot(), heap(), ids_, is_tracking_object_moves_, name, next_snapshot_uid_, NULL, and snapshots_.

Referenced by TakeSnapshot().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TakeSnapshot() [2/2]

HeapSnapshot * v8::internal::HeapProfiler::TakeSnapshot ( String name,
v8::ActivityControl control,
v8::HeapProfiler::ObjectNameResolver resolver 
)

Definition at line 85 of file heap-profiler.cc.

88  {
89  return TakeSnapshot(names_->GetName(name), control, resolver);
90 }
HeapSnapshot * TakeSnapshot(const char *name, v8::ActivityControl *control, v8::HeapProfiler::ObjectNameResolver *resolver)

References name, names_, and TakeSnapshot().

+ Here is the call graph for this function:

◆ UpdateObjectSizeEvent()

void v8::internal::HeapProfiler::UpdateObjectSizeEvent ( Address  addr,
int  size 
)

Definition at line 163 of file heap-profiler.cc.

163  {
164  ids_->UpdateObjectSize(addr, size);
165 }

References ids_, and size.

Member Data Documentation

◆ allocation_tracker_

SmartPointer<AllocationTracker> v8::internal::HeapProfiler::allocation_tracker_
private

◆ ids_

◆ is_tracking_object_moves_

bool v8::internal::HeapProfiler::is_tracking_object_moves_
private

◆ names_

SmartPointer<StringsStorage> v8::internal::HeapProfiler::names_
private

◆ next_snapshot_uid_

unsigned v8::internal::HeapProfiler::next_snapshot_uid_
private

Definition at line 76 of file heap-profiler.h.

Referenced by TakeSnapshot().

◆ snapshots_

List<HeapSnapshot*> v8::internal::HeapProfiler::snapshots_
private

◆ wrapper_callbacks_

List<v8::HeapProfiler::WrapperInfoCallback> v8::internal::HeapProfiler::wrapper_callbacks_
private

Definition at line 77 of file heap-profiler.h.

Referenced by DefineWrapperClass(), and ExecuteWrapperClassCallback().


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