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