Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 int index, | 568 int index, |
| 569 HeapEntry* entry, | 569 HeapEntry* entry, |
| 570 int retainer_index); | 570 int retainer_index); |
| 571 void SetNamedReference(HeapGraphEdge::Type type, | 571 void SetNamedReference(HeapGraphEdge::Type type, |
| 572 int child_index, | 572 int child_index, |
| 573 const char* name, | 573 const char* name, |
| 574 HeapEntry* entry, | 574 HeapEntry* entry, |
| 575 int retainer_index); | 575 int retainer_index); |
| 576 void SetUnidirElementReference(int child_index, int index, HeapEntry* entry); | 576 void SetUnidirElementReference(int child_index, int index, HeapEntry* entry); |
| 577 | 577 |
| 578 int EntrySize() { return EntriesSize(1, children_count_, retainers_count_); } | 578 uint64_t EntrySize() { |
| 579 return EntriesSize(1, children_count_, retainers_count_); | |
| 580 } | |
| 579 | 581 |
| 580 void Print( | 582 void Print( |
| 581 const char* prefix, const char* edge_name, int max_depth, int indent); | 583 const char* prefix, const char* edge_name, int max_depth, int indent); |
| 582 | 584 |
| 583 Handle<HeapObject> GetHeapObject(); | 585 Handle<HeapObject> GetHeapObject(); |
| 584 | 586 |
| 585 static int EntriesSize(int entries_count, | 587 static uint64_t EntriesSize(int entries_count, |
| 586 int children_count, | 588 int children_count, |
| 587 int retainers_count); | 589 int retainers_count); |
| 588 | 590 |
| 589 private: | 591 private: |
| 590 HeapGraphEdge* children_arr() { | 592 HeapGraphEdge* children_arr() { |
| 591 return reinterpret_cast<HeapGraphEdge*>(this + 1); | 593 return reinterpret_cast<HeapGraphEdge*>(this + 1); |
| 592 } | 594 } |
| 593 HeapGraphEdge** retainers_arr() { | 595 HeapGraphEdge** retainers_arr() { |
| 594 return reinterpret_cast<HeapGraphEdge**>(children_arr() + children_count_); | 596 return reinterpret_cast<HeapGraphEdge**>(children_arr() + children_count_); |
| 595 } | 597 } |
| 596 const char* TypeAsString(); | 598 const char* TypeAsString(); |
| 597 | 599 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 610 uint32_t id1_; | 612 uint32_t id1_; |
| 611 uint32_t id2_; | 613 uint32_t id2_; |
| 612 } id_; // This is to avoid extra padding of 64-bit value. | 614 } id_; // This is to avoid extra padding of 64-bit value. |
| 613 const char* name_; | 615 const char* name_; |
| 614 | 616 |
| 615 DISALLOW_COPY_AND_ASSIGN(HeapEntry); | 617 DISALLOW_COPY_AND_ASSIGN(HeapEntry); |
| 616 }; | 618 }; |
| 617 | 619 |
| 618 | 620 |
| 619 class HeapSnapshotsCollection; | 621 class HeapSnapshotsCollection; |
| 622 class RawEntriesStorage; | |
| 620 | 623 |
| 621 // HeapSnapshot represents a single heap snapshot. It is stored in | 624 // HeapSnapshot represents a single heap snapshot. It is stored in |
| 622 // HeapSnapshotsCollection, which is also a factory for | 625 // HeapSnapshotsCollection, which is also a factory for |
| 623 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap | 626 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap |
| 624 // to be able to return them even if they were collected. | 627 // to be able to return them even if they were collected. |
| 625 // HeapSnapshotGenerator fills in a HeapSnapshot. | 628 // HeapSnapshotGenerator fills in a HeapSnapshot. |
| 626 class HeapSnapshot { | 629 class HeapSnapshot { |
| 627 public: | 630 public: |
| 628 enum Type { | 631 enum Type { |
| 629 kFull = v8::HeapSnapshot::kFull | 632 kFull = v8::HeapSnapshot::kFull |
| 630 }; | 633 }; |
| 631 | 634 |
| 632 HeapSnapshot(HeapSnapshotsCollection* collection, | 635 HeapSnapshot(HeapSnapshotsCollection* collection, |
| 633 Type type, | 636 Type type, |
| 634 const char* title, | 637 const char* title, |
| 635 unsigned uid); | 638 unsigned uid); |
| 636 ~HeapSnapshot(); | 639 ~HeapSnapshot(); |
| 637 void Delete(); | 640 void Delete(); |
| 638 | 641 |
| 639 HeapSnapshotsCollection* collection() { return collection_; } | 642 HeapSnapshotsCollection* collection() { return collection_; } |
| 640 Type type() { return type_; } | 643 Type type() { return type_; } |
| 641 const char* title() { return title_; } | 644 const char* title() { return title_; } |
| 642 unsigned uid() { return uid_; } | 645 unsigned uid() { return uid_; } |
| 643 HeapEntry* root() { return root_entry_; } | 646 HeapEntry* root() { return root_entry_; } |
| 644 HeapEntry* gc_roots() { return gc_roots_entry_; } | 647 HeapEntry* gc_roots() { return gc_roots_entry_; } |
| 645 HeapEntry* natives_root() { return natives_root_entry_; } | 648 HeapEntry* natives_root() { return natives_root_entry_; } |
| 646 HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; } | 649 HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; } |
| 647 List<HeapEntry*>* entries() { return &entries_; } | 650 List<HeapEntry*>* entries() { return &entries_; } |
| 648 int raw_entries_size() { return raw_entries_size_; } | 651 uint64_t raw_entries_size() { return raw_entries_size_; } |
|
mnaganov (inactive)
2012/03/08 15:25:10
Why not size_t?
| |
| 649 | 652 |
| 650 void AllocateEntries( | 653 void AllocateEntries( |
| 651 int entries_count, int children_count, int retainers_count); | 654 int entries_count, int children_count, int retainers_count); |
| 652 HeapEntry* AddEntry(HeapEntry::Type type, | 655 HeapEntry* AddEntry(HeapEntry::Type type, |
| 653 const char* name, | 656 const char* name, |
| 654 uint64_t id, | 657 uint64_t id, |
| 655 int size, | 658 int size, |
| 656 int children_count, | 659 int children_count, |
| 657 int retainers_count); | 660 int retainers_count); |
| 658 HeapEntry* AddRootEntry(int children_count); | 661 HeapEntry* AddRootEntry(int children_count); |
| 659 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); | 662 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); |
| 660 HeapEntry* AddGcSubrootEntry(int tag, | 663 HeapEntry* AddGcSubrootEntry(int tag, |
| 661 int children_count, | 664 int children_count, |
| 662 int retainers_count); | 665 int retainers_count); |
| 663 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); | 666 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); |
| 664 void ClearPaint(); | 667 void ClearPaint(); |
| 665 HeapEntry* GetEntryById(uint64_t id); | 668 HeapEntry* GetEntryById(uint64_t id); |
| 666 List<HeapEntry*>* GetSortedEntriesList(); | 669 List<HeapEntry*>* GetSortedEntriesList(); |
| 667 template<class Visitor> | 670 template<class Visitor> |
| 668 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } | 671 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } |
| 669 void SetDominatorsToSelf(); | 672 void SetDominatorsToSelf(); |
| 670 | 673 |
| 671 void Print(int max_depth); | 674 void Print(int max_depth); |
| 672 void PrintEntriesSize(); | 675 void PrintEntriesSize(); |
| 673 | 676 |
| 674 private: | 677 private: |
| 675 HeapEntry* GetNextEntryToInit(); | 678 HeapEntry* GetNextEntryToInit(size_t size); |
| 676 | 679 |
| 677 HeapSnapshotsCollection* collection_; | 680 HeapSnapshotsCollection* collection_; |
| 678 Type type_; | 681 Type type_; |
| 679 const char* title_; | 682 const char* title_; |
| 680 unsigned uid_; | 683 unsigned uid_; |
| 681 HeapEntry* root_entry_; | 684 HeapEntry* root_entry_; |
| 682 HeapEntry* gc_roots_entry_; | 685 HeapEntry* gc_roots_entry_; |
| 683 HeapEntry* natives_root_entry_; | 686 HeapEntry* natives_root_entry_; |
| 684 HeapEntry* gc_subroot_entries_[VisitorSynchronization::kNumberOfSyncTags]; | 687 HeapEntry* gc_subroot_entries_[VisitorSynchronization::kNumberOfSyncTags]; |
| 685 char* raw_entries_; | 688 RawEntriesStorage* raw_entries_; |
| 686 List<HeapEntry*> entries_; | 689 List<HeapEntry*> entries_; |
| 687 bool entries_sorted_; | 690 bool entries_sorted_; |
| 688 int raw_entries_size_; | 691 uint64_t raw_entries_size_; |
| 689 | 692 |
| 690 friend class HeapSnapshotTester; | 693 friend class HeapSnapshotTester; |
| 691 | 694 |
| 692 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); | 695 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); |
| 693 }; | 696 }; |
| 694 | 697 |
| 695 | 698 |
| 696 class HeapObjectsMap { | 699 class HeapObjectsMap { |
| 697 public: | 700 public: |
| 698 HeapObjectsMap(); | 701 HeapObjectsMap(); |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1135 int GetStringId(const char* s); | 1138 int GetStringId(const char* s); |
| 1136 void SerializeEdge(HeapGraphEdge* edge); | 1139 void SerializeEdge(HeapGraphEdge* edge); |
| 1137 void SerializeImpl(); | 1140 void SerializeImpl(); |
| 1138 void SerializeNode(HeapEntry* entry); | 1141 void SerializeNode(HeapEntry* entry); |
| 1139 void SerializeNodes(); | 1142 void SerializeNodes(); |
| 1140 void SerializeSnapshot(); | 1143 void SerializeSnapshot(); |
| 1141 void SerializeString(const unsigned char* s); | 1144 void SerializeString(const unsigned char* s); |
| 1142 void SerializeStrings(); | 1145 void SerializeStrings(); |
| 1143 void SortHashMap(HashMap* map, List<HashMap::Entry*>* sorted_entries); | 1146 void SortHashMap(HashMap* map, List<HashMap::Entry*>* sorted_entries); |
| 1144 | 1147 |
| 1145 static const int kMaxSerializableSnapshotRawSize; | |
| 1146 | |
| 1147 HeapSnapshot* snapshot_; | 1148 HeapSnapshot* snapshot_; |
| 1148 HashMap nodes_; | 1149 HashMap nodes_; |
| 1149 HashMap strings_; | 1150 HashMap strings_; |
| 1150 int next_node_id_; | 1151 int next_node_id_; |
| 1151 int next_string_id_; | 1152 int next_string_id_; |
| 1152 OutputStreamWriter* writer_; | 1153 OutputStreamWriter* writer_; |
| 1153 | 1154 |
| 1154 friend class HeapSnapshotJSONSerializerEnumerator; | 1155 friend class HeapSnapshotJSONSerializerEnumerator; |
| 1155 friend class HeapSnapshotJSONSerializerIterator; | 1156 friend class HeapSnapshotJSONSerializerIterator; |
| 1156 | 1157 |
| 1157 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 1158 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 1158 }; | 1159 }; |
| 1159 | 1160 |
| 1160 } } // namespace v8::internal | 1161 } } // namespace v8::internal |
| 1161 | 1162 |
| 1162 #endif // V8_PROFILE_GENERATOR_H_ | 1163 #endif // V8_PROFILE_GENERATOR_H_ |
| OLD | NEW |