OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_ | 5 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_ |
6 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ | 6 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ |
7 | 7 |
8 #include "src/strings-storage.h" | 8 #include "src/strings-storage.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 SnapshotObjectId max_snapshot_js_object_id_; | 187 SnapshotObjectId max_snapshot_js_object_id_; |
188 | 188 |
189 friend class HeapSnapshotTester; | 189 friend class HeapSnapshotTester; |
190 | 190 |
191 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); | 191 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); |
192 }; | 192 }; |
193 | 193 |
194 | 194 |
195 class HeapObjectsMap { | 195 class HeapObjectsMap { |
196 public: | 196 public: |
| 197 struct TimeInterval { |
| 198 explicit TimeInterval(SnapshotObjectId id) |
| 199 : id(id), size(0), count(0), timestamp(base::TimeTicks::Now()) {} |
| 200 SnapshotObjectId last_assigned_id() const { return id - kObjectIdStep; } |
| 201 SnapshotObjectId id; |
| 202 uint32_t size; |
| 203 uint32_t count; |
| 204 base::TimeTicks timestamp; |
| 205 }; |
| 206 |
197 explicit HeapObjectsMap(Heap* heap); | 207 explicit HeapObjectsMap(Heap* heap); |
198 | 208 |
199 Heap* heap() const { return heap_; } | 209 Heap* heap() const { return heap_; } |
200 | 210 |
201 SnapshotObjectId FindEntry(Address addr); | 211 SnapshotObjectId FindEntry(Address addr); |
202 SnapshotObjectId FindOrAddEntry(Address addr, | 212 SnapshotObjectId FindOrAddEntry(Address addr, |
203 unsigned int size, | 213 unsigned int size, |
204 bool accessed = true); | 214 bool accessed = true); |
205 bool MoveObject(Address from, Address to, int size); | 215 bool MoveObject(Address from, Address to, int size); |
206 void UpdateObjectSize(Address addr, int size); | 216 void UpdateObjectSize(Address addr, int size); |
207 SnapshotObjectId last_assigned_id() const { | 217 SnapshotObjectId last_assigned_id() const { |
208 return next_id_ - kObjectIdStep; | 218 return next_id_ - kObjectIdStep; |
209 } | 219 } |
210 | 220 |
211 void StopHeapObjectsTracking(); | 221 void StopHeapObjectsTracking(); |
212 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); | 222 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); |
| 223 const List<TimeInterval>& samples() const { return time_intervals_; } |
213 size_t GetUsedMemorySize() const; | 224 size_t GetUsedMemorySize() const; |
214 | 225 |
215 SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); | 226 SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); |
216 | 227 |
217 static const int kObjectIdStep = 2; | 228 static const int kObjectIdStep = 2; |
218 static const SnapshotObjectId kInternalRootObjectId; | 229 static const SnapshotObjectId kInternalRootObjectId; |
219 static const SnapshotObjectId kGcRootsObjectId; | 230 static const SnapshotObjectId kGcRootsObjectId; |
220 static const SnapshotObjectId kGcRootsFirstSubrootId; | 231 static const SnapshotObjectId kGcRootsFirstSubrootId; |
221 static const SnapshotObjectId kFirstAvailableObjectId; | 232 static const SnapshotObjectId kFirstAvailableObjectId; |
222 | 233 |
223 int FindUntrackedObjects(); | 234 int FindUntrackedObjects(); |
224 | 235 |
225 void UpdateHeapObjectsMap(); | 236 void UpdateHeapObjectsMap(); |
226 void RemoveDeadEntries(); | 237 void RemoveDeadEntries(); |
227 | 238 |
228 private: | 239 private: |
229 struct EntryInfo { | 240 struct EntryInfo { |
230 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size) | 241 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size) |
231 : id(id), addr(addr), size(size), accessed(true) { } | 242 : id(id), addr(addr), size(size), accessed(true) { } |
232 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed) | 243 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed) |
233 : id(id), addr(addr), size(size), accessed(accessed) { } | 244 : id(id), addr(addr), size(size), accessed(accessed) { } |
234 SnapshotObjectId id; | 245 SnapshotObjectId id; |
235 Address addr; | 246 Address addr; |
236 unsigned int size; | 247 unsigned int size; |
237 bool accessed; | 248 bool accessed; |
238 }; | 249 }; |
239 struct TimeInterval { | |
240 explicit TimeInterval(SnapshotObjectId id) : id(id), size(0), count(0) { } | |
241 SnapshotObjectId id; | |
242 uint32_t size; | |
243 uint32_t count; | |
244 }; | |
245 | 250 |
246 SnapshotObjectId next_id_; | 251 SnapshotObjectId next_id_; |
247 HashMap entries_map_; | 252 HashMap entries_map_; |
248 List<EntryInfo> entries_; | 253 List<EntryInfo> entries_; |
249 List<TimeInterval> time_intervals_; | 254 List<TimeInterval> time_intervals_; |
250 Heap* heap_; | 255 Heap* heap_; |
251 | 256 |
252 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); | 257 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); |
253 }; | 258 }; |
254 | 259 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } | 582 int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } |
578 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); | 583 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); |
579 void SerializeEdges(); | 584 void SerializeEdges(); |
580 void SerializeImpl(); | 585 void SerializeImpl(); |
581 void SerializeNode(HeapEntry* entry); | 586 void SerializeNode(HeapEntry* entry); |
582 void SerializeNodes(); | 587 void SerializeNodes(); |
583 void SerializeSnapshot(); | 588 void SerializeSnapshot(); |
584 void SerializeTraceTree(); | 589 void SerializeTraceTree(); |
585 void SerializeTraceNode(AllocationTraceNode* node); | 590 void SerializeTraceNode(AllocationTraceNode* node); |
586 void SerializeTraceNodeInfos(); | 591 void SerializeTraceNodeInfos(); |
| 592 void SerializeSamples(); |
587 void SerializeString(const unsigned char* s); | 593 void SerializeString(const unsigned char* s); |
588 void SerializeStrings(); | 594 void SerializeStrings(); |
589 | 595 |
590 static const int kEdgeFieldsCount; | 596 static const int kEdgeFieldsCount; |
591 static const int kNodeFieldsCount; | 597 static const int kNodeFieldsCount; |
592 | 598 |
593 HeapSnapshot* snapshot_; | 599 HeapSnapshot* snapshot_; |
594 HashMap strings_; | 600 HashMap strings_; |
595 int next_node_id_; | 601 int next_node_id_; |
596 int next_string_id_; | 602 int next_string_id_; |
597 OutputStreamWriter* writer_; | 603 OutputStreamWriter* writer_; |
598 | 604 |
599 friend class HeapSnapshotJSONSerializerEnumerator; | 605 friend class HeapSnapshotJSONSerializerEnumerator; |
600 friend class HeapSnapshotJSONSerializerIterator; | 606 friend class HeapSnapshotJSONSerializerIterator; |
601 | 607 |
602 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 608 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
603 }; | 609 }; |
604 | 610 |
605 | 611 |
606 } } // namespace v8::internal | 612 } } // namespace v8::internal |
607 | 613 |
608 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ | 614 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ |
OLD | NEW |