OLD | NEW |
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 15 matching lines...) Expand all Loading... |
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_HEAP_SNAPSHOT_GENERATOR_H_ | 28 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_ |
29 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ | 29 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ |
30 | 30 |
31 #include "profile-generator-inl.h" | 31 #include "profile-generator-inl.h" |
32 | 32 |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
| 36 class AllocationTracker; |
| 37 class AllocationTraceNode; |
36 class HeapEntry; | 38 class HeapEntry; |
37 class HeapSnapshot; | 39 class HeapSnapshot; |
38 | 40 |
39 class HeapGraphEdge BASE_EMBEDDED { | 41 class HeapGraphEdge BASE_EMBEDDED { |
40 public: | 42 public: |
41 enum Type { | 43 enum Type { |
42 kContextVariable = v8::HeapGraphEdge::kContextVariable, | 44 kContextVariable = v8::HeapGraphEdge::kContextVariable, |
43 kElement = v8::HeapGraphEdge::kElement, | 45 kElement = v8::HeapGraphEdge::kElement, |
44 kProperty = v8::HeapGraphEdge::kProperty, | 46 kProperty = v8::HeapGraphEdge::kProperty, |
45 kInternal = v8::HeapGraphEdge::kInternal, | 47 kInternal = v8::HeapGraphEdge::kInternal, |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 public: | 291 public: |
290 explicit HeapSnapshotsCollection(Heap* heap); | 292 explicit HeapSnapshotsCollection(Heap* heap); |
291 ~HeapSnapshotsCollection(); | 293 ~HeapSnapshotsCollection(); |
292 | 294 |
293 Heap* heap() const { return ids_.heap(); } | 295 Heap* heap() const { return ids_.heap(); } |
294 | 296 |
295 bool is_tracking_objects() { return is_tracking_objects_; } | 297 bool is_tracking_objects() { return is_tracking_objects_; } |
296 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream) { | 298 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream) { |
297 return ids_.PushHeapObjectsStats(stream); | 299 return ids_.PushHeapObjectsStats(stream); |
298 } | 300 } |
299 void StartHeapObjectsTracking() { is_tracking_objects_ = true; } | 301 void StartHeapObjectsTracking(); |
300 void StopHeapObjectsTracking() { ids_.StopHeapObjectsTracking(); } | 302 void StopHeapObjectsTracking(); |
301 | 303 |
302 HeapSnapshot* NewSnapshot(const char* name, unsigned uid); | 304 HeapSnapshot* NewSnapshot(const char* name, unsigned uid); |
303 void SnapshotGenerationFinished(HeapSnapshot* snapshot); | 305 void SnapshotGenerationFinished(HeapSnapshot* snapshot); |
304 List<HeapSnapshot*>* snapshots() { return &snapshots_; } | 306 List<HeapSnapshot*>* snapshots() { return &snapshots_; } |
305 void RemoveSnapshot(HeapSnapshot* snapshot); | 307 void RemoveSnapshot(HeapSnapshot* snapshot); |
306 | 308 |
307 StringsStorage* names() { return &names_; } | 309 StringsStorage* names() { return &names_; } |
| 310 AllocationTracker* allocation_tracker() { return allocation_tracker_; } |
308 | 311 |
309 SnapshotObjectId FindObjectId(Address object_addr) { | 312 SnapshotObjectId FindObjectId(Address object_addr) { |
310 return ids_.FindEntry(object_addr); | 313 return ids_.FindEntry(object_addr); |
311 } | 314 } |
312 SnapshotObjectId GetObjectId(Address object_addr, int object_size) { | 315 SnapshotObjectId GetObjectId(Address object_addr, int object_size) { |
313 return ids_.FindOrAddEntry(object_addr, object_size); | 316 return ids_.FindOrAddEntry(object_addr, object_size); |
314 } | 317 } |
315 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); | 318 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); |
316 void ObjectMoveEvent(Address from, Address to, int size) { | 319 void ObjectMoveEvent(Address from, Address to, int size) { |
317 ids_.MoveObject(from, to, size); | 320 ids_.MoveObject(from, to, size); |
318 } | 321 } |
319 void NewObjectEvent(Address addr, int size) { ids_.NewObject(addr, size); } | 322 void NewObjectEvent(Address addr, int size); |
320 void UpdateObjectSizeEvent(Address addr, int size) { | 323 void UpdateObjectSizeEvent(Address addr, int size) { |
321 ids_.UpdateObjectSize(addr, size); | 324 ids_.UpdateObjectSize(addr, size); |
322 } | 325 } |
323 SnapshotObjectId last_assigned_id() const { | 326 SnapshotObjectId last_assigned_id() const { |
324 return ids_.last_assigned_id(); | 327 return ids_.last_assigned_id(); |
325 } | 328 } |
326 size_t GetUsedMemorySize() const; | 329 size_t GetUsedMemorySize() const; |
327 | 330 |
328 int FindUntrackedObjects() { return ids_.FindUntrackedObjects(); } | 331 int FindUntrackedObjects() { return ids_.FindUntrackedObjects(); } |
329 | 332 |
330 void UpdateHeapObjectsMap() { ids_.UpdateHeapObjectsMap(); } | 333 void UpdateHeapObjectsMap() { ids_.UpdateHeapObjectsMap(); } |
331 | 334 |
332 private: | 335 private: |
333 bool is_tracking_objects_; // Whether tracking object moves is needed. | 336 bool is_tracking_objects_; // Whether tracking object moves is needed. |
334 List<HeapSnapshot*> snapshots_; | 337 List<HeapSnapshot*> snapshots_; |
335 StringsStorage names_; | 338 StringsStorage names_; |
336 // Mapping from HeapObject addresses to objects' uids. | 339 // Mapping from HeapObject addresses to objects' uids. |
337 HeapObjectsMap ids_; | 340 HeapObjectsMap ids_; |
| 341 AllocationTracker* allocation_tracker_; |
338 | 342 |
339 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection); | 343 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection); |
340 }; | 344 }; |
341 | 345 |
342 | 346 |
343 // A typedef for referencing anything that can be snapshotted living | 347 // A typedef for referencing anything that can be snapshotted living |
344 // in any kind of heap memory. | 348 // in any kind of heap memory. |
345 typedef void* HeapThing; | 349 typedef void* HeapThing; |
346 | 350 |
347 | 351 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 } | 670 } |
667 | 671 |
668 int GetStringId(const char* s); | 672 int GetStringId(const char* s); |
669 int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } | 673 int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } |
670 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); | 674 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); |
671 void SerializeEdges(); | 675 void SerializeEdges(); |
672 void SerializeImpl(); | 676 void SerializeImpl(); |
673 void SerializeNode(HeapEntry* entry); | 677 void SerializeNode(HeapEntry* entry); |
674 void SerializeNodes(); | 678 void SerializeNodes(); |
675 void SerializeSnapshot(); | 679 void SerializeSnapshot(); |
| 680 void SerializeTraceTree(); |
| 681 void SerializeTraceNode(AllocationTraceNode* node); |
| 682 void SerializeTraceNodeInfos(); |
676 void SerializeString(const unsigned char* s); | 683 void SerializeString(const unsigned char* s); |
677 void SerializeStrings(); | 684 void SerializeStrings(); |
678 | 685 |
679 static const int kEdgeFieldsCount; | 686 static const int kEdgeFieldsCount; |
680 static const int kNodeFieldsCount; | 687 static const int kNodeFieldsCount; |
681 | 688 |
682 HeapSnapshot* snapshot_; | 689 HeapSnapshot* snapshot_; |
683 HashMap strings_; | 690 HashMap strings_; |
684 int next_node_id_; | 691 int next_node_id_; |
685 int next_string_id_; | 692 int next_string_id_; |
686 OutputStreamWriter* writer_; | 693 OutputStreamWriter* writer_; |
687 | 694 |
688 friend class HeapSnapshotJSONSerializerEnumerator; | 695 friend class HeapSnapshotJSONSerializerEnumerator; |
689 friend class HeapSnapshotJSONSerializerIterator; | 696 friend class HeapSnapshotJSONSerializerIterator; |
690 | 697 |
691 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 698 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
692 }; | 699 }; |
693 | 700 |
694 | 701 |
695 } } // namespace v8::internal | 702 } } // namespace v8::internal |
696 | 703 |
697 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ | 704 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ |
698 | 705 |
OLD | NEW |