V8 Project
v8::internal::HeapSnapshot Class Reference

#include <heap-snapshot-generator.h>

+ Collaboration diagram for v8::internal::HeapSnapshot:

Public Member Functions

 HeapSnapshot (HeapProfiler *profiler, const char *title, unsigned uid)
 
void Delete ()
 
HeapProfilerprofiler ()
 
const char * title ()
 
unsigned uid ()
 
size_t RawSnapshotSize () const
 
HeapEntry * root ()
 
HeapEntry * gc_roots ()
 
HeapEntry * gc_subroot (int index)
 
List< HeapEntry > & entries ()
 
List< HeapGraphEdge > & edges ()
 
List< HeapGraphEdge * > & children ()
 
void RememberLastJSObjectId ()
 
SnapshotObjectId max_snapshot_js_object_id () const
 
HeapEntry * AddEntry (HeapEntry::Type type, const char *name, SnapshotObjectId id, size_t size, unsigned trace_node_id)
 
void AddSyntheticRootEntries ()
 
HeapEntry * GetEntryById (SnapshotObjectId id)
 
List< HeapEntry * > * GetSortedEntriesList ()
 
void FillChildren ()
 
void Print (int max_depth)
 
void PrintEntriesSize ()
 

Private Member Functions

HeapEntry * AddRootEntry ()
 
HeapEntry * AddGcRootsEntry ()
 
HeapEntry * AddGcSubrootEntry (int tag, SnapshotObjectId id)
 
 DISALLOW_COPY_AND_ASSIGN (HeapSnapshot)
 

Private Attributes

HeapProfilerprofiler_
 
const char * title_
 
unsigned uid_
 
int root_index_
 
int gc_roots_index_
 
int gc_subroot_indexes_ [VisitorSynchronization::kNumberOfSyncTags]
 
List< HeapEntry > entries_
 
List< HeapGraphEdgeedges_
 
List< HeapGraphEdge * > children_
 
List< HeapEntry * > sorted_entries_
 
SnapshotObjectId max_snapshot_js_object_id_
 

Friends

class HeapSnapshotTester
 

Detailed Description

Definition at line 144 of file heap-snapshot-generator.h.

Constructor & Destructor Documentation

◆ HeapSnapshot()

v8::internal::HeapSnapshot::HeapSnapshot ( HeapProfiler profiler,
const char *  title,
unsigned  uid 
)

Definition at line 183 of file heap-snapshot-generator.cc.

186  : profiler_(profiler),
187  title_(title),
188  uid_(uid),
189  root_index_(HeapEntry::kNoEntry),
190  gc_roots_index_(HeapEntry::kNoEntry),
193  sizeof(HeapGraphEdge) ==
194  SnapshotSizeConstants<kPointerSize>::kExpectedHeapGraphEdgeSize);
196  sizeof(HeapEntry) ==
197  SnapshotSizeConstants<kPointerSize>::kExpectedHeapEntrySize);
198  USE(SnapshotSizeConstants<4>::kExpectedHeapGraphEdgeSize);
199  USE(SnapshotSizeConstants<4>::kExpectedHeapEntrySize);
200  USE(SnapshotSizeConstants<8>::kExpectedHeapGraphEdgeSize);
201  USE(SnapshotSizeConstants<8>::kExpectedHeapEntrySize);
202  for (int i = 0; i < VisitorSynchronization::kNumberOfSyncTags; ++i) {
203  gc_subroot_indexes_[i] = HeapEntry::kNoEntry;
204  }
205 }
int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags]
void USE(T)
Definition: macros.h:322
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))

References gc_subroot_indexes_, v8::internal::VisitorSynchronization::kNumberOfSyncTags, v8::internal::STATIC_ASSERT(), and USE().

+ Here is the call graph for this function:

Member Function Documentation

◆ AddEntry()

HeapEntry * v8::internal::HeapSnapshot::AddEntry ( HeapEntry::Type  type,
const char *  name,
SnapshotObjectId  id,
size_t  size,
unsigned  trace_node_id 
)

Definition at line 267 of file heap-snapshot-generator.cc.

271  {
272  HeapEntry entry(this, type, name, id, size, trace_node_id);
273  entries_.Add(entry);
274  return &entries_.last();
275 }
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:17
T & last() const
Definition: list.h:70
enable harmony numeric enable harmony object literal extensions Optimize object size
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::List< T, AllocationPolicy >::Add(), entries_, v8::internal::List< T, AllocationPolicy >::last(), name, and size.

Referenced by v8::internal::V8HeapExplorer::AddEntry(), AddGcRootsEntry(), AddGcSubrootEntry(), AddRootEntry(), and v8::internal::BasicHeapEntriesAllocator::AllocateEntry().

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

◆ AddGcRootsEntry()

HeapEntry * v8::internal::HeapSnapshot::AddGcRootsEntry ( )
private

Definition at line 245 of file heap-snapshot-generator.cc.

245  {
246  DCHECK(gc_roots_index_ == HeapEntry::kNoEntry);
247  HeapEntry* entry = AddEntry(HeapEntry::kSynthetic,
248  "(GC roots)",
250  0,
251  0);
252  gc_roots_index_ = entry->index();
253  return entry;
254 }
static const SnapshotObjectId kGcRootsObjectId
HeapEntry * AddEntry(HeapEntry::Type type, const char *name, SnapshotObjectId id, size_t size, unsigned trace_node_id)
#define DCHECK(condition)
Definition: logging.h:205

References AddEntry(), DCHECK, gc_roots_index_, and v8::internal::HeapObjectsMap::kGcRootsObjectId.

Referenced by AddSyntheticRootEntries().

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

◆ AddGcSubrootEntry()

HeapEntry * v8::internal::HeapSnapshot::AddGcSubrootEntry ( int  tag,
SnapshotObjectId  id 
)
private

Definition at line 257 of file heap-snapshot-generator.cc.

257  {
258  DCHECK(gc_subroot_indexes_[tag] == HeapEntry::kNoEntry);
260  HeapEntry* entry = AddEntry(HeapEntry::kSynthetic,
261  VisitorSynchronization::kTagNames[tag], id, 0, 0);
262  gc_subroot_indexes_[tag] = entry->index();
263  return entry;
264 }
static const char *const kTagNames[kNumberOfSyncTags]
Definition: objects.h:10712

References AddEntry(), DCHECK, gc_subroot_indexes_, v8::internal::VisitorSynchronization::kNumberOfSyncTags, and v8::internal::VisitorSynchronization::kTagNames.

Referenced by AddSyntheticRootEntries().

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

◆ AddRootEntry()

HeapEntry * v8::internal::HeapSnapshot::AddRootEntry ( )
private

Definition at line 231 of file heap-snapshot-generator.cc.

231  {
232  DCHECK(root_index_ == HeapEntry::kNoEntry);
233  DCHECK(entries_.is_empty()); // Root entry must be the first one.
234  HeapEntry* entry = AddEntry(HeapEntry::kSynthetic,
235  "",
237  0,
238  0);
239  root_index_ = entry->index();
240  DCHECK(root_index_ == 0);
241  return entry;
242 }
static const SnapshotObjectId kInternalRootObjectId

References AddEntry(), DCHECK, entries_, v8::internal::HeapObjectsMap::kInternalRootObjectId, and root_index_.

Referenced by AddSyntheticRootEntries().

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

◆ AddSyntheticRootEntries()

void v8::internal::HeapSnapshot::AddSyntheticRootEntries ( )

Definition at line 219 of file heap-snapshot-generator.cc.

219  {
220  AddRootEntry();
221  AddGcRootsEntry();
223  for (int tag = 0; tag < VisitorSynchronization::kNumberOfSyncTags; tag++) {
224  AddGcSubrootEntry(tag, id);
226  }
228 }
static const SnapshotObjectId kFirstAvailableObjectId
static const SnapshotObjectId kGcRootsFirstSubrootId
HeapEntry * AddGcSubrootEntry(int tag, SnapshotObjectId id)
uint32_t SnapshotObjectId
Definition: v8-profiler.h:16

References AddGcRootsEntry(), AddGcSubrootEntry(), AddRootEntry(), DCHECK, v8::internal::HeapObjectsMap::kFirstAvailableObjectId, v8::internal::HeapObjectsMap::kGcRootsFirstSubrootId, v8::internal::VisitorSynchronization::kNumberOfSyncTags, and v8::internal::HeapObjectsMap::kObjectIdStep.

Referenced by v8::internal::HeapSnapshotGenerator::GenerateSnapshot().

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

◆ children()

List<HeapGraphEdge*>& v8::internal::HeapSnapshot::children ( )
inline

Definition at line 162 of file heap-snapshot-generator.h.

162 { return children_; }
List< HeapGraphEdge * > children_

References children_.

Referenced by FillChildren(), and v8::internal::HeapSnapshotJSONSerializer::SerializeEdges().

+ Here is the caller graph for this function:

◆ Delete()

void v8::internal::HeapSnapshot::Delete ( )

Definition at line 208 of file heap-snapshot-generator.cc.

208  {
209  profiler_->RemoveSnapshot(this);
210  delete this;
211 }
void RemoveSnapshot(HeapSnapshot *snapshot)

References profiler_, and v8::internal::HeapProfiler::RemoveSnapshot().

+ Here is the call graph for this function:

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::HeapSnapshot::DISALLOW_COPY_AND_ASSIGN ( HeapSnapshot  )
private

◆ edges()

List<HeapGraphEdge>& v8::internal::HeapSnapshot::edges ( )
inline

Definition at line 161 of file heap-snapshot-generator.h.

161 { return edges_; }

References edges_.

Referenced by FillChildren(), and v8::internal::HeapSnapshotJSONSerializer::SerializeSnapshot().

+ Here is the caller graph for this function:

◆ entries()

List<HeapEntry>& v8::internal::HeapSnapshot::entries ( )
inline

◆ FillChildren()

void v8::internal::HeapSnapshot::FillChildren ( )

Definition at line 278 of file heap-snapshot-generator.cc.

278  {
279  DCHECK(children().is_empty());
280  children().Allocate(edges().length());
281  int children_index = 0;
282  for (int i = 0; i < entries().length(); ++i) {
283  HeapEntry* entry = &entries()[i];
284  children_index = entry->set_children_index(children_index);
285  }
286  DCHECK(edges().length() == children_index);
287  for (int i = 0; i < edges().length(); ++i) {
288  HeapGraphEdge* edge = &edges()[i];
289  edge->ReplaceToIndexWithEntry(this);
290  edge->from()->add_child(edge);
291  }
292 }
List< HeapGraphEdge * > & children()
List< HeapGraphEdge > & edges()

References children(), DCHECK, edges(), and entries().

Referenced by v8::internal::HeapSnapshotGenerator::GenerateSnapshot().

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

◆ gc_roots()

HeapEntry* v8::internal::HeapSnapshot::gc_roots ( )
inline

Definition at line 156 of file heap-snapshot-generator.h.

156 { return &entries_[gc_roots_index_]; }

References entries_, and gc_roots_index_.

Referenced by v8::internal::V8HeapExplorer::SetGcRootsReference(), and v8::internal::V8HeapExplorer::SetRootGcRootsReference().

+ Here is the caller graph for this function:

◆ gc_subroot()

HeapEntry* v8::internal::HeapSnapshot::gc_subroot ( int  index)
inline

Definition at line 157 of file heap-snapshot-generator.h.

157  {
158  return &entries_[gc_subroot_indexes_[index]];
159  }

References entries_, and gc_subroot_indexes_.

Referenced by v8::internal::V8HeapExplorer::SetGcRootsReference(), and v8::internal::V8HeapExplorer::SetGcSubrootReference().

+ Here is the caller graph for this function:

◆ GetEntryById()

HeapEntry * v8::internal::HeapSnapshot::GetEntryById ( SnapshotObjectId  id)

Definition at line 307 of file heap-snapshot-generator.cc.

307  {
308  List<HeapEntry*>* entries_by_id = GetSortedEntriesList();
309  // Perform a binary search by id.
310  int index = SortedListBSearch(*entries_by_id, FindEntryById(id));
311  if (index == -1)
312  return NULL;
313  return entries_by_id->at(index);
314 }
List< HeapEntry * > * GetSortedEntriesList()
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
int SortedListBSearch(const List< T > &list, P cmp)
Definition: list-inl.h:219

References v8::internal::List< T, AllocationPolicy >::at(), GetSortedEntriesList(), NULL, and v8::internal::SortedListBSearch().

+ Here is the call graph for this function:

◆ GetSortedEntriesList()

List< HeapEntry * > * v8::internal::HeapSnapshot::GetSortedEntriesList ( )

Definition at line 325 of file heap-snapshot-generator.cc.

325  {
326  if (sorted_entries_.is_empty()) {
327  sorted_entries_.Allocate(entries_.length());
328  for (int i = 0; i < entries_.length(); ++i) {
330  }
332  }
333  return &sorted_entries_;
334 }
void Sort(int(*cmp)(const T *x, const T *y))
Definition: list-inl.h:194
static int SortByIds(const T *entry1_ptr, const T *entry2_ptr)

References entries_, v8::internal::List< T, AllocationPolicy >::Sort(), v8::internal::SortByIds(), and sorted_entries_.

Referenced by GetEntryById().

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

◆ max_snapshot_js_object_id()

SnapshotObjectId v8::internal::HeapSnapshot::max_snapshot_js_object_id ( ) const
inline

Definition at line 164 of file heap-snapshot-generator.h.

164  {
166  }

References max_snapshot_js_object_id_.

◆ Print()

void v8::internal::HeapSnapshot::Print ( int  max_depth)

Definition at line 337 of file heap-snapshot-generator.cc.

337  {
338  root()->Print("", "", max_depth, 0);
339 }

References root().

+ Here is the call graph for this function:

◆ PrintEntriesSize()

void v8::internal::HeapSnapshot::PrintEntriesSize ( )

◆ profiler()

HeapProfiler* v8::internal::HeapSnapshot::profiler ( )
inline

Definition at line 151 of file heap-snapshot-generator.h.

151 { return profiler_; }

References profiler_.

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:

◆ RawSnapshotSize()

size_t v8::internal::HeapSnapshot::RawSnapshotSize ( ) const

Definition at line 342 of file heap-snapshot-generator.cc.

342  {
343  return
344  sizeof(*this) +
349 }
size_t GetMemoryUsedByList(const List< T, P > &list)
Definition: list.h:184

References children_, edges_, entries_, v8::internal::GetMemoryUsedByList(), and sorted_entries_.

+ Here is the call graph for this function:

◆ RememberLastJSObjectId()

void v8::internal::HeapSnapshot::RememberLastJSObjectId ( )

Definition at line 214 of file heap-snapshot-generator.cc.

214  {
216 }
SnapshotObjectId last_assigned_id() const
HeapObjectsMap * heap_object_map() const
Definition: heap-profiler.h:38

References v8::internal::HeapProfiler::heap_object_map(), v8::internal::HeapObjectsMap::last_assigned_id(), max_snapshot_js_object_id_, and profiler_.

Referenced by v8::internal::HeapSnapshotGenerator::GenerateSnapshot().

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

◆ root()

HeapEntry* v8::internal::HeapSnapshot::root ( )
inline

Definition at line 155 of file heap-snapshot-generator.h.

155 { return &entries_[root_index_]; }

References entries_, and root_index_.

Referenced by Print(), v8::internal::HeapSnapshotJSONSerializer::SerializeImpl(), v8::internal::V8HeapExplorer::SetRootGcRootsReference(), v8::internal::NativeObjectsExplorer::SetRootNativeRootsReference(), and v8::internal::V8HeapExplorer::SetUserGlobalReference().

+ Here is the caller graph for this function:

◆ title()

const char* v8::internal::HeapSnapshot::title ( )
inline

Definition at line 152 of file heap-snapshot-generator.h.

152 { return title_; }

References title_.

Referenced by v8::internal::HeapSnapshotJSONSerializer::SerializeSnapshot().

+ Here is the caller graph for this function:

◆ uid()

unsigned v8::internal::HeapSnapshot::uid ( )
inline

Definition at line 153 of file heap-snapshot-generator.h.

153 { return uid_; }

References uid_.

Referenced by v8::internal::HeapSnapshotJSONSerializer::SerializeSnapshot().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ HeapSnapshotTester

friend class HeapSnapshotTester
friend

Definition at line 198 of file heap-snapshot-generator.h.

Member Data Documentation

◆ children_

List<HeapGraphEdge*> v8::internal::HeapSnapshot::children_
private

Definition at line 194 of file heap-snapshot-generator.h.

Referenced by children(), and RawSnapshotSize().

◆ edges_

List<HeapGraphEdge> v8::internal::HeapSnapshot::edges_
private

Definition at line 193 of file heap-snapshot-generator.h.

Referenced by edges(), and RawSnapshotSize().

◆ entries_

List<HeapEntry> v8::internal::HeapSnapshot::entries_
private

◆ gc_roots_index_

int v8::internal::HeapSnapshot::gc_roots_index_
private

Definition at line 190 of file heap-snapshot-generator.h.

Referenced by AddGcRootsEntry(), and gc_roots().

◆ gc_subroot_indexes_

int v8::internal::HeapSnapshot::gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags]
private

Definition at line 191 of file heap-snapshot-generator.h.

Referenced by AddGcSubrootEntry(), gc_subroot(), and HeapSnapshot().

◆ max_snapshot_js_object_id_

SnapshotObjectId v8::internal::HeapSnapshot::max_snapshot_js_object_id_
private

Definition at line 196 of file heap-snapshot-generator.h.

Referenced by max_snapshot_js_object_id(), and RememberLastJSObjectId().

◆ profiler_

HeapProfiler* v8::internal::HeapSnapshot::profiler_
private

Definition at line 186 of file heap-snapshot-generator.h.

Referenced by Delete(), profiler(), and RememberLastJSObjectId().

◆ root_index_

int v8::internal::HeapSnapshot::root_index_
private

Definition at line 189 of file heap-snapshot-generator.h.

Referenced by AddRootEntry(), and root().

◆ sorted_entries_

List<HeapEntry*> v8::internal::HeapSnapshot::sorted_entries_
private

Definition at line 195 of file heap-snapshot-generator.h.

Referenced by GetSortedEntriesList(), and RawSnapshotSize().

◆ title_

const char* v8::internal::HeapSnapshot::title_
private

Definition at line 187 of file heap-snapshot-generator.h.

Referenced by title().

◆ uid_

unsigned v8::internal::HeapSnapshot::uid_
private

Definition at line 188 of file heap-snapshot-generator.h.

Referenced by uid().


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