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

Side by Side Diff: src/heap-snapshot-generator.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 | « src/heap-profiler.cc ('k') | src/heap-snapshot-generator.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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 kConsString = v8::HeapGraphNode::kConsString, 107 kConsString = v8::HeapGraphNode::kConsString,
108 kSlicedString = v8::HeapGraphNode::kSlicedString 108 kSlicedString = v8::HeapGraphNode::kSlicedString
109 }; 109 };
110 static const int kNoEntry; 110 static const int kNoEntry;
111 111
112 HeapEntry() { } 112 HeapEntry() { }
113 HeapEntry(HeapSnapshot* snapshot, 113 HeapEntry(HeapSnapshot* snapshot,
114 Type type, 114 Type type,
115 const char* name, 115 const char* name,
116 SnapshotObjectId id, 116 SnapshotObjectId id,
117 size_t self_size); 117 size_t self_size,
118 unsigned trace_node_id);
118 119
119 HeapSnapshot* snapshot() { return snapshot_; } 120 HeapSnapshot* snapshot() { return snapshot_; }
120 Type type() { return static_cast<Type>(type_); } 121 Type type() { return static_cast<Type>(type_); }
121 const char* name() { return name_; } 122 const char* name() { return name_; }
122 void set_name(const char* name) { name_ = name; } 123 void set_name(const char* name) { name_ = name; }
123 inline SnapshotObjectId id() { return id_; } 124 inline SnapshotObjectId id() { return id_; }
124 size_t self_size() { return self_size_; } 125 size_t self_size() { return self_size_; }
126 unsigned trace_node_id() const { return trace_node_id_; }
125 INLINE(int index() const); 127 INLINE(int index() const);
126 int children_count() const { return children_count_; } 128 int children_count() const { return children_count_; }
127 INLINE(int set_children_index(int index)); 129 INLINE(int set_children_index(int index));
128 void add_child(HeapGraphEdge* edge) { 130 void add_child(HeapGraphEdge* edge) {
129 children_arr()[children_count_++] = edge; 131 children_arr()[children_count_++] = edge;
130 } 132 }
131 Vector<HeapGraphEdge*> children() { 133 Vector<HeapGraphEdge*> children() {
132 return Vector<HeapGraphEdge*>(children_arr(), children_count_); } 134 return Vector<HeapGraphEdge*>(children_arr(), children_count_); }
133 135
134 void SetIndexedReference( 136 void SetIndexedReference(
135 HeapGraphEdge::Type type, int index, HeapEntry* entry); 137 HeapGraphEdge::Type type, int index, HeapEntry* entry);
136 void SetNamedReference( 138 void SetNamedReference(
137 HeapGraphEdge::Type type, const char* name, HeapEntry* entry); 139 HeapGraphEdge::Type type, const char* name, HeapEntry* entry);
138 140
139 void Print( 141 void Print(
140 const char* prefix, const char* edge_name, int max_depth, int indent); 142 const char* prefix, const char* edge_name, int max_depth, int indent);
141 143
142 private: 144 private:
143 INLINE(HeapGraphEdge** children_arr()); 145 INLINE(HeapGraphEdge** children_arr());
144 const char* TypeAsString(); 146 const char* TypeAsString();
145 147
146 unsigned type_: 4; 148 unsigned type_: 4;
147 int children_count_: 28; 149 int children_count_: 28;
148 int children_index_; 150 int children_index_;
149 size_t self_size_; 151 size_t self_size_;
150 SnapshotObjectId id_;
151 HeapSnapshot* snapshot_; 152 HeapSnapshot* snapshot_;
152 const char* name_; 153 const char* name_;
154 SnapshotObjectId id_;
155 // id of allocation stack trace top node
156 unsigned trace_node_id_;
153 }; 157 };
154 158
155 159
156 // HeapSnapshot represents a single heap snapshot. It is stored in 160 // HeapSnapshot represents a single heap snapshot. It is stored in
157 // HeapProfiler, which is also a factory for 161 // HeapProfiler, which is also a factory for
158 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap 162 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap
159 // to be able to return them even if they were collected. 163 // to be able to return them even if they were collected.
160 // HeapSnapshotGenerator fills in a HeapSnapshot. 164 // HeapSnapshotGenerator fills in a HeapSnapshot.
161 class HeapSnapshot { 165 class HeapSnapshot {
162 public: 166 public:
(...skipping 16 matching lines...) Expand all
179 List<HeapGraphEdge>& edges() { return edges_; } 183 List<HeapGraphEdge>& edges() { return edges_; }
180 List<HeapGraphEdge*>& children() { return children_; } 184 List<HeapGraphEdge*>& children() { return children_; }
181 void RememberLastJSObjectId(); 185 void RememberLastJSObjectId();
182 SnapshotObjectId max_snapshot_js_object_id() const { 186 SnapshotObjectId max_snapshot_js_object_id() const {
183 return max_snapshot_js_object_id_; 187 return max_snapshot_js_object_id_;
184 } 188 }
185 189
186 HeapEntry* AddEntry(HeapEntry::Type type, 190 HeapEntry* AddEntry(HeapEntry::Type type,
187 const char* name, 191 const char* name,
188 SnapshotObjectId id, 192 SnapshotObjectId id,
189 size_t size); 193 size_t size,
194 unsigned trace_node_id);
190 HeapEntry* AddRootEntry(); 195 HeapEntry* AddRootEntry();
191 HeapEntry* AddGcRootsEntry(); 196 HeapEntry* AddGcRootsEntry();
192 HeapEntry* AddGcSubrootEntry(int tag); 197 HeapEntry* AddGcSubrootEntry(int tag);
193 HeapEntry* AddNativesRootEntry(); 198 HeapEntry* AddNativesRootEntry();
194 HeapEntry* GetEntryById(SnapshotObjectId id); 199 HeapEntry* GetEntryById(SnapshotObjectId id);
195 List<HeapEntry*>* GetSortedEntriesList(); 200 List<HeapEntry*>* GetSortedEntriesList();
196 void FillChildren(); 201 void FillChildren();
197 202
198 void Print(int max_depth); 203 void Print(int max_depth);
199 void PrintEntriesSize(); 204 void PrintEntriesSize();
(...skipping 21 matching lines...) Expand all
221 class HeapObjectsMap { 226 class HeapObjectsMap {
222 public: 227 public:
223 explicit HeapObjectsMap(Heap* heap); 228 explicit HeapObjectsMap(Heap* heap);
224 229
225 Heap* heap() const { return heap_; } 230 Heap* heap() const { return heap_; }
226 231
227 SnapshotObjectId FindEntry(Address addr); 232 SnapshotObjectId FindEntry(Address addr);
228 SnapshotObjectId FindOrAddEntry(Address addr, 233 SnapshotObjectId FindOrAddEntry(Address addr,
229 unsigned int size, 234 unsigned int size,
230 bool accessed = true); 235 bool accessed = true);
231 void MoveObject(Address from, Address to, int size); 236 bool MoveObject(Address from, Address to, int size);
232 void UpdateObjectSize(Address addr, int size); 237 void UpdateObjectSize(Address addr, int size);
233 SnapshotObjectId last_assigned_id() const { 238 SnapshotObjectId last_assigned_id() const {
234 return next_id_ - kObjectIdStep; 239 return next_id_ - kObjectIdStep;
235 } 240 }
236 241
237 void StopHeapObjectsTracking(); 242 void StopHeapObjectsTracking();
238 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); 243 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
239 size_t GetUsedMemorySize() const; 244 size_t GetUsedMemorySize() const;
240 245
241 SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); 246 SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info);
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 friend class HeapSnapshotJSONSerializerEnumerator; 647 friend class HeapSnapshotJSONSerializerEnumerator;
643 friend class HeapSnapshotJSONSerializerIterator; 648 friend class HeapSnapshotJSONSerializerIterator;
644 649
645 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 650 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
646 }; 651 };
647 652
648 653
649 } } // namespace v8::internal 654 } } // namespace v8::internal
650 655
651 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ 656 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_
OLDNEW
« no previous file with comments | « src/heap-profiler.cc ('k') | src/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698