V8 Project
allocation-tracker.h
Go to the documentation of this file.
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_ALLOCATION_TRACKER_H_
6 #define V8_ALLOCATION_TRACKER_H_
7 
8 #include <map>
9 
10 namespace v8 {
11 namespace internal {
12 
13 class HeapObjectsMap;
14 
15 class AllocationTraceTree;
16 
18  public:
20  unsigned function_info_index);
24  void AddAllocation(unsigned size);
25 
26  unsigned function_info_index() const { return function_info_index_; }
27  unsigned allocation_size() const { return total_size_; }
28  unsigned allocation_count() const { return allocation_count_; }
29  unsigned id() const { return id_; }
30  Vector<AllocationTraceNode*> children() const { return children_.ToVector(); }
31 
32  void Print(int indent, AllocationTracker* tracker);
33 
34  private:
37  unsigned total_size_;
39  unsigned id_;
41 
43 };
44 
45 
47  public:
51  AllocationTraceNode* root() { return &root_; }
52  unsigned next_node_id() { return next_node_id_++; }
53  void Print(AllocationTracker* tracker);
54 
55  private:
56  unsigned next_node_id_;
58 
60 };
61 
62 
64  public:
65  void AddRange(Address addr, int size, unsigned node_id);
66  unsigned GetTraceNodeId(Address addr);
67  void MoveObject(Address from, Address to, int size);
68  void Clear();
69  size_t size() { return ranges_.size(); }
70  void Print();
71 
72  private:
73  struct RangeStack {
74  RangeStack(Address start, unsigned node_id)
75  : start(start), trace_node_id(node_id) {}
77  unsigned trace_node_id;
78  };
79  // [start, end) -> trace
80  typedef std::map<Address, RangeStack> RangeMap;
81 
82  void RemoveRange(Address start, Address end);
83 
85 };
86 
88  public:
89  struct FunctionInfo {
90  FunctionInfo();
91  const char* name;
93  const char* script_name;
94  int script_id;
95  int line;
96  int column;
97  };
98 
101 
103  void AllocationEvent(Address addr, int size);
104 
107  return function_info_list_;
108  }
110 
111  private:
113  static void DeleteFunctionInfo(FunctionInfo** info);
114  unsigned functionInfoIndexForVMState(StateTag state);
115 
117  public:
118  UnresolvedLocation(Script* script, int start, FunctionInfo* info);
120  void Resolve();
121 
122  private:
123  static void HandleWeakScript(
125 
129  };
130  static void DeleteUnresolvedLocation(UnresolvedLocation** location);
131 
132  static const int kMaxAllocationTraceLength = 64;
142 
144 };
145 
146 } } // namespace v8::internal
147 
148 #endif // V8_ALLOCATION_TRACKER_H_
void MoveObject(Address from, Address to, int size)
void AddRange(Address addr, int size, unsigned node_id)
void RemoveRange(Address start, Address end)
unsigned GetTraceNodeId(Address addr)
std::map< Address, RangeStack > RangeMap
DISALLOW_COPY_AND_ASSIGN(AllocationTraceNode)
AllocationTraceNode * FindOrAddChild(unsigned function_info_index)
Vector< AllocationTraceNode * > children() const
AllocationTraceNode(AllocationTraceTree *tree, unsigned function_info_index)
void Print(int indent, AllocationTracker *tracker)
List< AllocationTraceNode * > children_
AllocationTraceNode * FindChild(unsigned function_info_index)
void Print(AllocationTracker *tracker)
DISALLOW_COPY_AND_ASSIGN(AllocationTraceTree)
AllocationTraceNode * AddPathFromEnd(const Vector< unsigned > &path)
static void HandleWeakScript(const v8::WeakCallbackData< v8::Value, void > &data)
UnresolvedLocation(Script *script, int start, FunctionInfo *info)
DISALLOW_COPY_AND_ASSIGN(AllocationTracker)
unsigned AddFunctionInfo(SharedFunctionInfo *info, SnapshotObjectId id)
unsigned functionInfoIndexForVMState(StateTag state)
unsigned allocation_trace_buffer_[kMaxAllocationTraceLength]
const List< FunctionInfo * > & function_info_list() const
AllocationTraceTree * trace_tree()
List< UnresolvedLocation * > unresolved_locations_
static void DeleteFunctionInfo(FunctionInfo **info)
AddressToTraceMap * address_to_trace()
List< FunctionInfo * > function_info_list_
AllocationTracker(HeapObjectsMap *ids, StringsStorage *names)
static void DeleteUnresolvedLocation(UnresolvedLocation **location)
void AllocationEvent(Address addr, int 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 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
enable harmony numeric enable harmony object literal extensions Optimize object size
byte * Address
Definition: globals.h:101
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20
uint32_t SnapshotObjectId
Definition: v8-profiler.h:16
RangeStack(Address start, unsigned node_id)