| 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 id; |
| 201 uint32_t size; |
| 202 uint32_t count; |
| 203 base::TimeTicks timestamp; |
| 204 }; |
| 205 |
| 197 explicit HeapObjectsMap(Heap* heap); | 206 explicit HeapObjectsMap(Heap* heap); |
| 198 | 207 |
| 199 Heap* heap() const { return heap_; } | 208 Heap* heap() const { return heap_; } |
| 200 | 209 |
| 201 SnapshotObjectId FindEntry(Address addr); | 210 SnapshotObjectId FindEntry(Address addr); |
| 202 SnapshotObjectId FindOrAddEntry(Address addr, | 211 SnapshotObjectId FindOrAddEntry(Address addr, |
| 203 unsigned int size, | 212 unsigned int size, |
| 204 bool accessed = true); | 213 bool accessed = true); |
| 205 bool MoveObject(Address from, Address to, int size); | 214 bool MoveObject(Address from, Address to, int size); |
| 206 void UpdateObjectSize(Address addr, int size); | 215 void UpdateObjectSize(Address addr, int size); |
| 207 SnapshotObjectId last_assigned_id() const { | 216 SnapshotObjectId last_assigned_id() const { |
| 208 return next_id_ - kObjectIdStep; | 217 return next_id_ - kObjectIdStep; |
| 209 } | 218 } |
| 210 | 219 |
| 211 void StopHeapObjectsTracking(); | 220 void StopHeapObjectsTracking(); |
| 212 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); | 221 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); |
| 222 const List<TimeInterval>& samples() const { return time_intervals_; } |
| 213 size_t GetUsedMemorySize() const; | 223 size_t GetUsedMemorySize() const; |
| 214 | 224 |
| 215 SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); | 225 SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); |
| 216 | 226 |
| 217 static const int kObjectIdStep = 2; | 227 static const int kObjectIdStep = 2; |
| 218 static const SnapshotObjectId kInternalRootObjectId; | 228 static const SnapshotObjectId kInternalRootObjectId; |
| 219 static const SnapshotObjectId kGcRootsObjectId; | 229 static const SnapshotObjectId kGcRootsObjectId; |
| 220 static const SnapshotObjectId kGcRootsFirstSubrootId; | 230 static const SnapshotObjectId kGcRootsFirstSubrootId; |
| 221 static const SnapshotObjectId kFirstAvailableObjectId; | 231 static const SnapshotObjectId kFirstAvailableObjectId; |
| 222 | 232 |
| 223 int FindUntrackedObjects(); | 233 int FindUntrackedObjects(); |
| 224 | 234 |
| 225 void UpdateHeapObjectsMap(); | 235 void UpdateHeapObjectsMap(); |
| 226 void RemoveDeadEntries(); | 236 void RemoveDeadEntries(); |
| 227 | 237 |
| 228 private: | 238 private: |
| 229 struct EntryInfo { | 239 struct EntryInfo { |
| 230 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size) | 240 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size) |
| 231 : id(id), addr(addr), size(size), accessed(true) { } | 241 : id(id), addr(addr), size(size), accessed(true) { } |
| 232 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed) | 242 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed) |
| 233 : id(id), addr(addr), size(size), accessed(accessed) { } | 243 : id(id), addr(addr), size(size), accessed(accessed) { } |
| 234 SnapshotObjectId id; | 244 SnapshotObjectId id; |
| 235 Address addr; | 245 Address addr; |
| 236 unsigned int size; | 246 unsigned int size; |
| 237 bool accessed; | 247 bool accessed; |
| 238 }; | 248 }; |
| 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 | 249 |
| 246 SnapshotObjectId next_id_; | 250 SnapshotObjectId next_id_; |
| 247 HashMap entries_map_; | 251 HashMap entries_map_; |
| 248 List<EntryInfo> entries_; | 252 List<EntryInfo> entries_; |
| 249 List<TimeInterval> time_intervals_; | 253 List<TimeInterval> time_intervals_; |
| 250 Heap* heap_; | 254 Heap* heap_; |
| 251 | 255 |
| 252 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); | 256 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); |
| 253 }; | 257 }; |
| 254 | 258 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } | 581 int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } |
| 578 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); | 582 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); |
| 579 void SerializeEdges(); | 583 void SerializeEdges(); |
| 580 void SerializeImpl(); | 584 void SerializeImpl(); |
| 581 void SerializeNode(HeapEntry* entry); | 585 void SerializeNode(HeapEntry* entry); |
| 582 void SerializeNodes(); | 586 void SerializeNodes(); |
| 583 void SerializeSnapshot(); | 587 void SerializeSnapshot(); |
| 584 void SerializeTraceTree(); | 588 void SerializeTraceTree(); |
| 585 void SerializeTraceNode(AllocationTraceNode* node); | 589 void SerializeTraceNode(AllocationTraceNode* node); |
| 586 void SerializeTraceNodeInfos(); | 590 void SerializeTraceNodeInfos(); |
| 591 void SerializeSamples(); |
| 587 void SerializeString(const unsigned char* s); | 592 void SerializeString(const unsigned char* s); |
| 588 void SerializeStrings(); | 593 void SerializeStrings(); |
| 589 | 594 |
| 590 static const int kEdgeFieldsCount; | 595 static const int kEdgeFieldsCount; |
| 591 static const int kNodeFieldsCount; | 596 static const int kNodeFieldsCount; |
| 592 | 597 |
| 593 HeapSnapshot* snapshot_; | 598 HeapSnapshot* snapshot_; |
| 594 HashMap strings_; | 599 HashMap strings_; |
| 595 int next_node_id_; | 600 int next_node_id_; |
| 596 int next_string_id_; | 601 int next_string_id_; |
| 597 OutputStreamWriter* writer_; | 602 OutputStreamWriter* writer_; |
| 598 | 603 |
| 599 friend class HeapSnapshotJSONSerializerEnumerator; | 604 friend class HeapSnapshotJSONSerializerEnumerator; |
| 600 friend class HeapSnapshotJSONSerializerIterator; | 605 friend class HeapSnapshotJSONSerializerIterator; |
| 601 | 606 |
| 602 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 607 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 603 }; | 608 }; |
| 604 | 609 |
| 605 | 610 |
| 606 } } // namespace v8::internal | 611 } } // namespace v8::internal |
| 607 | 612 |
| 608 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ | 613 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ |
| OLD | NEW |