5 #ifndef V8_PROFILER_ALLOCATION_TRACKER_H_ 6 #define V8_PROFILER_ALLOCATION_TRACKER_H_ 11 #include "include/v8-profiler.h" 12 #include "src/base/hashmap.h" 13 #include "src/handles.h" 14 #include "src/vector.h" 20 class AllocationTraceTree;
21 class AllocationTracker;
23 class SharedFunctionInfo;
29 unsigned function_info_index);
33 void AddAllocation(
unsigned size);
35 unsigned function_info_index()
const {
return function_info_index_; }
36 unsigned allocation_size()
const {
return total_size_; }
37 unsigned allocation_count()
const {
return allocation_count_; }
38 unsigned id()
const {
return id_; }
39 const std::vector<AllocationTraceNode*>& children()
const {
47 unsigned function_info_index_;
49 unsigned allocation_count_;
51 std::vector<AllocationTraceNode*> children_;
63 unsigned next_node_id() {
return next_node_id_++; }
67 unsigned next_node_id_;
76 void AddRange(
Address addr,
int size,
unsigned node_id);
77 unsigned GetTraceNodeId(
Address addr);
80 size_t size() {
return ranges_.size(); }
85 RangeStack(
Address start,
unsigned node_id)
86 : start(start), trace_node_id(node_id) {}
88 unsigned trace_node_id;
91 typedef std::map<Address, RangeStack> RangeMap;
104 const char* script_name;
113 void PrepareForSerialization();
114 void AllocationEvent(
Address addr,
int size);
117 const std::vector<FunctionInfo*>& function_info_list()
const {
118 return function_info_list_;
120 AddressToTraceMap* address_to_trace() {
return &address_to_trace_; }
123 unsigned AddFunctionInfo(SharedFunctionInfo* info, SnapshotObjectId
id);
124 unsigned functionInfoIndexForVMState(StateTag state);
126 class UnresolvedLocation {
128 UnresolvedLocation(Script* script,
int start, FunctionInfo* info);
129 ~UnresolvedLocation();
135 Handle<Script> script_;
140 static const int kMaxAllocationTraceLength = 64;
141 HeapObjectsMap* ids_;
142 StringsStorage* names_;
143 AllocationTraceTree trace_tree_;
144 unsigned allocation_trace_buffer_[kMaxAllocationTraceLength];
145 std::vector<FunctionInfo*> function_info_list_;
146 base::HashMap id_to_function_info_index_;
147 std::vector<UnresolvedLocation*> unresolved_locations_;
148 unsigned info_index_for_other_state_;
149 AddressToTraceMap address_to_trace_;
151 DISALLOW_COPY_AND_ASSIGN(AllocationTracker);
157 #endif // V8_PROFILER_ALLOCATION_TRACKER_H_