v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
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_PROFILER_ALLOCATION_TRACKER_H_
6#define V8_PROFILER_ALLOCATION_TRACKER_H_
7
8#include <map>
9#include <unordered_map>
10#include <vector>
11
13#include "include/v8-profiler.h"
14#include "include/v8-unwinder.h"
15#include "src/base/hashmap.h"
16#include "src/base/vector.h"
18#include "src/handles/handles.h"
19#include "src/objects/script.h"
20#include "src/objects/string.h"
21
22namespace v8 {
23namespace internal {
24
25// Forward declarations.
26class AllocationTraceTree;
27class AllocationTracker;
28class HeapObjectsMap;
29class SharedFunctionInfo;
30class StringsStorage;
31
33 public:
35 unsigned function_info_index);
41 void AddAllocation(unsigned size);
42
43 unsigned function_info_index() const { return function_info_index_; }
44 unsigned allocation_size() const { return total_size_; }
45 unsigned allocation_count() const { return allocation_count_; }
46 unsigned id() const { return id_; }
47 const std::vector<AllocationTraceNode*>& children() const {
48 return children_;
49 }
50
51 void Print(int indent, AllocationTracker* tracker);
52
53 private:
56 unsigned total_size_;
58 unsigned id_;
59 std::vector<AllocationTraceNode*> children_;
60};
61
62
78
80 public:
81 void AddRange(Address addr, int size, unsigned node_id);
82 unsigned GetTraceNodeId(Address addr);
83 void MoveObject(Address from, Address to, int size);
84 void Clear();
85 size_t size() { return ranges_.size(); }
86 void Print();
87
88 private:
89 struct RangeStack {
90 RangeStack(Address start, unsigned node_id)
91 : start(start), trace_node_id(node_id) {}
92 Address start;
93 unsigned trace_node_id;
94 };
95 // [start, end) -> trace
96 using RangeMap = std::map<Address, RangeStack>;
97
98 void RemoveRange(Address start, Address end);
99
101};
102
104 public:
115
120
121 void AllocationEvent(Address addr, int size);
122
124 const std::vector<FunctionInfo*>& function_info_list() const {
125 return function_info_list_;
126 }
128
129 private:
131 Isolate* isolate);
133 Isolate* isolate);
135 Isolate* isolate, int start);
137
138 static const int kMaxAllocationTraceLength = 64;
143 std::vector<FunctionInfo*> function_info_list_;
147 using ScriptId = int;
161 using ScriptsDataMap = std::unordered_map<ScriptId, ScriptData>;
163};
164
165} // namespace internal
166} // namespace v8
167
168#endif // V8_PROFILER_ALLOCATION_TRACKER_H_
std::map< Address, RangeStack > RangeMap
std::vector< AllocationTraceNode * > children_
const std::vector< AllocationTraceNode * > & children() const
AllocationTraceNode * FindOrAddChild(unsigned function_info_index)
AllocationTraceNode & operator=(const AllocationTraceNode &)=delete
AllocationTraceNode(AllocationTraceTree *tree, unsigned function_info_index)
void Print(int indent, AllocationTracker *tracker)
AllocationTraceNode * FindChild(unsigned function_info_index)
AllocationTraceNode(const AllocationTraceNode &)=delete
AllocationTraceNode * AddPathFromEnd(base::Vector< const unsigned > path)
V8_EXPORT_PRIVATE void Print(AllocationTracker *tracker)
AllocationTraceTree & operator=(const AllocationTraceTree &)=delete
AllocationTraceTree(const AllocationTraceTree &)=delete
static void HandleWeakScript(const v8::WeakCallbackInfo< ScriptData > &)
ScriptData(Tagged< Script >, Isolate *, AllocationTracker *)
AllocationTraceTree * trace_tree()
unsigned functionInfoIndexForVMState(StateTag state)
std::unordered_map< ScriptId, ScriptData > ScriptsDataMap
unsigned allocation_trace_buffer_[kMaxAllocationTraceLength]
unsigned AddFunctionInfo(Tagged< SharedFunctionInfo > info, SnapshotObjectId id, Isolate *isolate)
std::vector< FunctionInfo * > function_info_list_
Script::PositionInfo GetScriptPositionInfo(Tagged< Script > script, Isolate *isolate, int start)
AddressToTraceMap * address_to_trace()
AllocationTracker & operator=(const AllocationTracker &)=delete
String::LineEndsVector & GetOrCreateLineEnds(Tagged< Script > script, Isolate *isolate)
AllocationTracker(HeapObjectsMap *ids, StringsStorage *names)
AllocationTracker(const AllocationTracker &)=delete
void AllocationEvent(Address addr, int size)
const std::vector< FunctionInfo * > & function_info_list() const
int start
int end
uint32_t SnapshotObjectId
Definition v8-profiler.h:31
StateTag
Definition v8-unwinder.h:36
#define V8_EXPORT_PRIVATE
Definition macros.h:460
RangeStack(Address start, unsigned node_id)