| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 } | 672 } |
| 669 | 673 |
| 670 int GetStringId(const char* s); | 674 int GetStringId(const char* s); |
| 671 int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } | 675 int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; } |
| 672 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); | 676 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); |
| 673 void SerializeEdges(); | 677 void SerializeEdges(); |
| 674 void SerializeImpl(); | 678 void SerializeImpl(); |
| 675 void SerializeNode(HeapEntry* entry); | 679 void SerializeNode(HeapEntry* entry); |
| 676 void SerializeNodes(); | 680 void SerializeNodes(); |
| 677 void SerializeSnapshot(); | 681 void SerializeSnapshot(); |
| 682 void SerializeTraceTree(); |
| 683 void SerializeTraceNode(AllocationTraceNode* node); |
| 684 void SerializeTraceNodeInfos(); |
| 678 void SerializeString(const unsigned char* s); | 685 void SerializeString(const unsigned char* s); |
| 679 void SerializeStrings(); | 686 void SerializeStrings(); |
| 680 | 687 |
| 681 static const int kEdgeFieldsCount; | 688 static const int kEdgeFieldsCount; |
| 682 static const int kNodeFieldsCount; | 689 static const int kNodeFieldsCount; |
| 683 | 690 |
| 684 HeapSnapshot* snapshot_; | 691 HeapSnapshot* snapshot_; |
| 685 HashMap strings_; | 692 HashMap strings_; |
| 686 int next_node_id_; | 693 int next_node_id_; |
| 687 int next_string_id_; | 694 int next_string_id_; |
| 688 OutputStreamWriter* writer_; | 695 OutputStreamWriter* writer_; |
| 689 | 696 |
| 690 friend class HeapSnapshotJSONSerializerEnumerator; | 697 friend class HeapSnapshotJSONSerializerEnumerator; |
| 691 friend class HeapSnapshotJSONSerializerIterator; | 698 friend class HeapSnapshotJSONSerializerIterator; |
| 692 | 699 |
| 693 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 700 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 694 }; | 701 }; |
| 695 | 702 |
| 696 | 703 |
| 697 } } // namespace v8::internal | 704 } } // namespace v8::internal |
| 698 | 705 |
| 699 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ | 706 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ |
| 700 | 707 |
| OLD | NEW |