Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: src/allocation-tracker.h

Issue 177983003: [Heap profiler] Add construction stack trace to heap object (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/allocation-tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_ALLOCATION_TRACKER_H_ 28 #ifndef V8_ALLOCATION_TRACKER_H_
29 #define V8_ALLOCATION_TRACKER_H_ 29 #define V8_ALLOCATION_TRACKER_H_
30 30
31 #include <map>
32
31 namespace v8 { 33 namespace v8 {
32 namespace internal { 34 namespace internal {
33 35
34 class HeapObjectsMap; 36 class HeapObjectsMap;
35 37
36 class AllocationTraceTree; 38 class AllocationTraceTree;
37 39
38 class AllocationTraceNode { 40 class AllocationTraceNode {
39 public: 41 public:
40 AllocationTraceNode(AllocationTraceTree* tree, 42 AllocationTraceNode(AllocationTraceTree* tree,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 void Print(AllocationTracker* tracker); 76 void Print(AllocationTracker* tracker);
75 77
76 private: 78 private:
77 unsigned next_node_id_; 79 unsigned next_node_id_;
78 AllocationTraceNode root_; 80 AllocationTraceNode root_;
79 81
80 DISALLOW_COPY_AND_ASSIGN(AllocationTraceTree); 82 DISALLOW_COPY_AND_ASSIGN(AllocationTraceTree);
81 }; 83 };
82 84
83 85
86 class AddressToTraceMap {
87 public:
88 void AddRange(Address addr, int size, unsigned node_id);
89 unsigned GetTraceNodeId(Address addr);
90 void MoveObject(Address from, Address to, int size);
91 void Clear();
92 size_t size() { return ranges_.size(); }
93 void Print();
94
95 private:
96 struct RangeStack {
97 RangeStack(Address start, unsigned node_id)
98 : start(start), trace_node_id(node_id) {}
99 Address start;
100 unsigned trace_node_id;
101 };
102 // [start, end) -> trace
103 typedef std::map<Address, RangeStack> RangeMap;
104
105 void RemoveRange(Address start, Address end);
106
107 RangeMap ranges_;
108 };
109
84 class AllocationTracker { 110 class AllocationTracker {
85 public: 111 public:
86 struct FunctionInfo { 112 struct FunctionInfo {
87 FunctionInfo(); 113 FunctionInfo();
88 const char* name; 114 const char* name;
89 SnapshotObjectId function_id; 115 SnapshotObjectId function_id;
90 const char* script_name; 116 const char* script_name;
91 int script_id; 117 int script_id;
92 int line; 118 int line;
93 int column; 119 int column;
94 }; 120 };
95 121
96 AllocationTracker(HeapObjectsMap* ids, StringsStorage* names); 122 AllocationTracker(HeapObjectsMap* ids, StringsStorage* names);
97 ~AllocationTracker(); 123 ~AllocationTracker();
98 124
99 void PrepareForSerialization(); 125 void PrepareForSerialization();
100 void AllocationEvent(Address addr, int size); 126 void AllocationEvent(Address addr, int size);
101 127
102 AllocationTraceTree* trace_tree() { return &trace_tree_; } 128 AllocationTraceTree* trace_tree() { return &trace_tree_; }
103 const List<FunctionInfo*>& function_info_list() const { 129 const List<FunctionInfo*>& function_info_list() const {
104 return function_info_list_; 130 return function_info_list_;
105 } 131 }
132 AddressToTraceMap* address_to_trace() { return &address_to_trace_; }
106 133
107 private: 134 private:
108 unsigned AddFunctionInfo(SharedFunctionInfo* info, SnapshotObjectId id); 135 unsigned AddFunctionInfo(SharedFunctionInfo* info, SnapshotObjectId id);
109 static void DeleteFunctionInfo(FunctionInfo** info); 136 static void DeleteFunctionInfo(FunctionInfo** info);
110 unsigned functionInfoIndexForVMState(StateTag state); 137 unsigned functionInfoIndexForVMState(StateTag state);
111 138
112 class UnresolvedLocation { 139 class UnresolvedLocation {
113 public: 140 public:
114 UnresolvedLocation(Script* script, int start, FunctionInfo* info); 141 UnresolvedLocation(Script* script, int start, FunctionInfo* info);
115 ~UnresolvedLocation(); 142 ~UnresolvedLocation();
(...skipping 11 matching lines...) Expand all
127 154
128 static const int kMaxAllocationTraceLength = 64; 155 static const int kMaxAllocationTraceLength = 64;
129 HeapObjectsMap* ids_; 156 HeapObjectsMap* ids_;
130 StringsStorage* names_; 157 StringsStorage* names_;
131 AllocationTraceTree trace_tree_; 158 AllocationTraceTree trace_tree_;
132 unsigned allocation_trace_buffer_[kMaxAllocationTraceLength]; 159 unsigned allocation_trace_buffer_[kMaxAllocationTraceLength];
133 List<FunctionInfo*> function_info_list_; 160 List<FunctionInfo*> function_info_list_;
134 HashMap id_to_function_info_index_; 161 HashMap id_to_function_info_index_;
135 List<UnresolvedLocation*> unresolved_locations_; 162 List<UnresolvedLocation*> unresolved_locations_;
136 unsigned info_index_for_other_state_; 163 unsigned info_index_for_other_state_;
164 AddressToTraceMap address_to_trace_;
137 165
138 DISALLOW_COPY_AND_ASSIGN(AllocationTracker); 166 DISALLOW_COPY_AND_ASSIGN(AllocationTracker);
139 }; 167 };
140 168
141 } } // namespace v8::internal 169 } } // namespace v8::internal
142 170
143 #endif // V8_ALLOCATION_TRACKER_H_ 171 #endif // V8_ALLOCATION_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | src/allocation-tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698