V8 Project
v8::internal::AllocationTracker Class Reference

#include <allocation-tracker.h>

+ Collaboration diagram for v8::internal::AllocationTracker:

Classes

struct  FunctionInfo
 
class  UnresolvedLocation
 

Public Member Functions

 AllocationTracker (HeapObjectsMap *ids, StringsStorage *names)
 
 ~AllocationTracker ()
 
void PrepareForSerialization ()
 
void AllocationEvent (Address addr, int size)
 
AllocationTraceTreetrace_tree ()
 
const List< FunctionInfo * > & function_info_list () const
 
AddressToTraceMapaddress_to_trace ()
 

Private Member Functions

unsigned AddFunctionInfo (SharedFunctionInfo *info, SnapshotObjectId id)
 
unsigned functionInfoIndexForVMState (StateTag state)
 
 DISALLOW_COPY_AND_ASSIGN (AllocationTracker)
 

Static Private Member Functions

static void DeleteFunctionInfo (FunctionInfo **info)
 
static void DeleteUnresolvedLocation (UnresolvedLocation **location)
 

Private Attributes

HeapObjectsMapids_
 
StringsStoragenames_
 
AllocationTraceTree trace_tree_
 
unsigned allocation_trace_buffer_ [kMaxAllocationTraceLength]
 
List< FunctionInfo * > function_info_list_
 
HashMap id_to_function_info_index_
 
List< UnresolvedLocation * > unresolved_locations_
 
unsigned info_index_for_other_state_
 
AddressToTraceMap address_to_trace_
 

Static Private Attributes

static const int kMaxAllocationTraceLength = 64
 

Detailed Description

Definition at line 87 of file allocation-tracker.h.

Constructor & Destructor Documentation

◆ AllocationTracker()

v8::internal::AllocationTracker::AllocationTracker ( HeapObjectsMap ids,
StringsStorage names 
)

Definition at line 195 of file allocation-tracker.cc.

197  : ids_(ids),
198  names_(names),
201  FunctionInfo* info = new FunctionInfo();
202  info->name = "(root)";
203  function_info_list_.Add(info);
204 }
List< FunctionInfo * > function_info_list_
static bool PointersMatch(void *key1, void *key2)
Definition: hashmap.h:80

References function_info_list_, and v8::internal::AllocationTracker::FunctionInfo::name.

◆ ~AllocationTracker()

v8::internal::AllocationTracker::~AllocationTracker ( )

Definition at line 207 of file allocation-tracker.cc.

207  {
210 }
List< UnresolvedLocation * > unresolved_locations_
static void DeleteFunctionInfo(FunctionInfo **info)
static void DeleteUnresolvedLocation(UnresolvedLocation **location)

References DeleteFunctionInfo(), DeleteUnresolvedLocation(), function_info_list_, and unresolved_locations_.

+ Here is the call graph for this function:

Member Function Documentation

◆ AddFunctionInfo()

unsigned v8::internal::AllocationTracker::AddFunctionInfo ( SharedFunctionInfo info,
SnapshotObjectId  id 
)
private

Definition at line 265 of file allocation-tracker.cc.

266  {
267  HashMap::Entry* entry = id_to_function_info_index_.Lookup(
268  reinterpret_cast<void*>(id), SnapshotObjectIdHash(id), true);
269  if (entry->value == NULL) {
270  FunctionInfo* info = new FunctionInfo();
271  info->name = names_->GetFunctionName(shared->DebugName());
272  info->function_id = id;
273  if (shared->script()->IsScript()) {
274  Script* script = Script::cast(shared->script());
275  if (script->name()->IsName()) {
276  Name* name = Name::cast(script->name());
277  info->script_name = names_->GetName(name);
278  }
279  info->script_id = script->id()->value();
280  // Converting start offset into line and column may cause heap
281  // allocations so we postpone them until snapshot serialization.
282  unresolved_locations_.Add(new UnresolvedLocation(
283  script,
284  shared->start_position(),
285  info));
286  }
287  entry->value = reinterpret_cast<void*>(function_info_list_.length());
288  function_info_list_.Add(info);
289  }
290  return static_cast<unsigned>(reinterpret_cast<intptr_t>((entry->value)));
291 }
const char * GetFunctionName(Name *name)
const char * GetName(Name *name)
Entry * Lookup(void *key, uint32_t hash, bool insert, AllocationPolicy allocator=AllocationPolicy())
Definition: hashmap.h:114
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
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
static uint32_t SnapshotObjectIdHash(SnapshotObjectId id)

References v8::internal::SharedFunctionInfo::DebugName(), v8::internal::AllocationTracker::FunctionInfo::function_id, function_info_list_, v8::internal::StringsStorage::GetFunctionName(), v8::internal::StringsStorage::GetName(), id_to_function_info_index_, v8::internal::TemplateHashMapImpl< AllocationPolicy >::Lookup(), v8::internal::AllocationTracker::FunctionInfo::name, name, names_, NULL, v8::internal::AllocationTracker::FunctionInfo::script_id, v8::internal::AllocationTracker::FunctionInfo::script_name, v8::internal::SnapshotObjectIdHash(), v8::internal::SharedFunctionInfo::start_position(), and unresolved_locations_.

Referenced by AllocationEvent().

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

◆ address_to_trace()

AddressToTraceMap* v8::internal::AllocationTracker::address_to_trace ( )
inline

Definition at line 109 of file allocation-tracker.h.

109 { return &address_to_trace_; }

References address_to_trace_.

◆ AllocationEvent()

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

Definition at line 224 of file allocation-tracker.cc.

224  {
225  DisallowHeapAllocation no_allocation;
226  Heap* heap = ids_->heap();
227 
228  // Mark the new block as FreeSpace to make sure the heap is iterable
229  // while we are capturing stack trace.
231  DCHECK_EQ(HeapObject::FromAddress(addr)->Size(), size);
233 
234  Isolate* isolate = heap->isolate();
235  int length = 0;
236  StackTraceFrameIterator it(isolate);
237  while (!it.done() && length < kMaxAllocationTraceLength) {
238  JavaScriptFrame* frame = it.frame();
239  SharedFunctionInfo* shared = frame->function()->shared();
241  shared->address(), shared->Size(), false);
242  allocation_trace_buffer_[length++] = AddFunctionInfo(shared, id);
243  it.Advance();
244  }
245  if (length == 0) {
246  unsigned index = functionInfoIndexForVMState(isolate->current_vm_state());
247  if (index != 0) {
248  allocation_trace_buffer_[length++] = index;
249  }
250  }
251  AllocationTraceNode* top_node = trace_tree_.AddPathFromEnd(
252  Vector<unsigned>(allocation_trace_buffer_, length));
253  top_node->AddAllocation(size);
254 
255  address_to_trace_.AddRange(addr, size, top_node->id());
256 }
void AddRange(Address addr, int size, unsigned node_id)
AllocationTraceNode * AddPathFromEnd(const Vector< unsigned > &path)
unsigned AddFunctionInfo(SharedFunctionInfo *info, SnapshotObjectId id)
unsigned functionInfoIndexForVMState(StateTag state)
unsigned allocation_trace_buffer_[kMaxAllocationTraceLength]
static FreeListNode * FromAddress(Address address)
Definition: spaces.h:1406
static bool IsFreeListNode(HeapObject *object)
Definition: spaces-inl.h:303
void set_size(Heap *heap, int size_in_bytes)
Definition: spaces.cc:1955
static HeapObject * FromAddress(Address address)
Definition: objects-inl.h:1464
SnapshotObjectId FindOrAddEntry(Address addr, unsigned int size, bool accessed=true)
enable harmony numeric enable harmony object literal extensions Optimize object size
#define DCHECK(condition)
Definition: logging.h:205
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110
uint32_t SnapshotObjectId
Definition: v8-profiler.h:16

References v8::internal::AllocationTraceNode::AddAllocation(), AddFunctionInfo(), v8::internal::AllocationTraceTree::AddPathFromEnd(), v8::internal::AddressToTraceMap::AddRange(), v8::internal::HeapObject::address(), address_to_trace_, v8::internal::StackTraceFrameIterator::Advance(), allocation_trace_buffer_, DCHECK, DCHECK_EQ, v8::internal::HeapObjectsMap::FindOrAddEntry(), v8::internal::FreeListNode::FromAddress(), v8::internal::HeapObject::FromAddress(), v8::internal::JavaScriptFrame::function(), functionInfoIndexForVMState(), v8::internal::HeapObjectsMap::heap(), v8::internal::AllocationTraceNode::id(), ids_, v8::internal::FreeListNode::IsFreeListNode(), v8::internal::Heap::isolate(), kMaxAllocationTraceLength, v8::internal::FreeListNode::set_size(), size, v8::internal::HeapObject::Size(), and trace_tree_.

+ Here is the call graph for this function:

◆ DeleteFunctionInfo()

void v8::internal::AllocationTracker::DeleteFunctionInfo ( FunctionInfo **  info)
staticprivate

Definition at line 190 of file allocation-tracker.cc.

190  {
191  delete *info;
192 }

Referenced by ~AllocationTracker().

+ Here is the caller graph for this function:

◆ DeleteUnresolvedLocation()

void v8::internal::AllocationTracker::DeleteUnresolvedLocation ( UnresolvedLocation **  location)
staticprivate

Definition at line 102 of file allocation-tracker.cc.

103  {
104  delete *location;
105 }

Referenced by ~AllocationTracker().

+ Here is the caller graph for this function:

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::AllocationTracker::DISALLOW_COPY_AND_ASSIGN ( AllocationTracker  )
private

◆ function_info_list()

const List<FunctionInfo*>& v8::internal::AllocationTracker::function_info_list ( ) const
inline

Definition at line 106 of file allocation-tracker.h.

106  {
107  return function_info_list_;
108  }

References function_info_list_.

Referenced by v8::internal::AllocationTraceNode::Print(), v8::internal::HeapSnapshotJSONSerializer::SerializeSnapshot(), and v8::internal::HeapSnapshotJSONSerializer::SerializeTraceNodeInfos().

+ Here is the caller graph for this function:

◆ functionInfoIndexForVMState()

unsigned v8::internal::AllocationTracker::functionInfoIndexForVMState ( StateTag  state)
private

Definition at line 294 of file allocation-tracker.cc.

294  {
295  if (state != OTHER) return 0;
296  if (info_index_for_other_state_ == 0) {
297  FunctionInfo* info = new FunctionInfo();
298  info->name = "(V8 API)";
300  function_info_list_.Add(info);
301  }
303 }

References function_info_list_, info_index_for_other_state_, v8::internal::AllocationTracker::FunctionInfo::name, and v8::internal::OTHER.

Referenced by AllocationEvent().

+ Here is the caller graph for this function:

◆ PrepareForSerialization()

void v8::internal::AllocationTracker::PrepareForSerialization ( )

Definition at line 213 of file allocation-tracker.cc.

213  {
214  List<UnresolvedLocation*> copy(unresolved_locations_.length());
215  copy.AddAll(unresolved_locations_);
216  unresolved_locations_.Clear();
217  for (int i = 0; i < copy.length(); i++) {
218  copy[i]->Resolve();
219  delete copy[i];
220  }
221 }

References v8::internal::List< T, AllocationPolicy >::AddAll(), and unresolved_locations_.

+ Here is the call graph for this function:

◆ trace_tree()

AllocationTraceTree* v8::internal::AllocationTracker::trace_tree ( )
inline

Definition at line 105 of file allocation-tracker.h.

105 { return &trace_tree_; }

References trace_tree_.

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

+ Here is the caller graph for this function:

Member Data Documentation

◆ address_to_trace_

AddressToTraceMap v8::internal::AllocationTracker::address_to_trace_
private

Definition at line 141 of file allocation-tracker.h.

Referenced by address_to_trace(), and AllocationEvent().

◆ allocation_trace_buffer_

unsigned v8::internal::AllocationTracker::allocation_trace_buffer_[kMaxAllocationTraceLength]
private

Definition at line 136 of file allocation-tracker.h.

Referenced by AllocationEvent().

◆ function_info_list_

List<FunctionInfo*> v8::internal::AllocationTracker::function_info_list_
private

◆ id_to_function_info_index_

HashMap v8::internal::AllocationTracker::id_to_function_info_index_
private

Definition at line 138 of file allocation-tracker.h.

Referenced by AddFunctionInfo().

◆ ids_

HeapObjectsMap* v8::internal::AllocationTracker::ids_
private

Definition at line 133 of file allocation-tracker.h.

Referenced by AllocationEvent().

◆ info_index_for_other_state_

unsigned v8::internal::AllocationTracker::info_index_for_other_state_
private

Definition at line 140 of file allocation-tracker.h.

Referenced by functionInfoIndexForVMState().

◆ kMaxAllocationTraceLength

const int v8::internal::AllocationTracker::kMaxAllocationTraceLength = 64
staticprivate

Definition at line 132 of file allocation-tracker.h.

Referenced by AllocationEvent().

◆ names_

StringsStorage* v8::internal::AllocationTracker::names_
private

Definition at line 134 of file allocation-tracker.h.

Referenced by AddFunctionInfo().

◆ trace_tree_

AllocationTraceTree v8::internal::AllocationTracker::trace_tree_
private

Definition at line 135 of file allocation-tracker.h.

Referenced by AllocationEvent(), and trace_tree().

◆ unresolved_locations_

List<UnresolvedLocation*> v8::internal::AllocationTracker::unresolved_locations_
private

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