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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 HeapObjectsMap(); | 703 HeapObjectsMap(); |
704 ~HeapObjectsMap(); | 704 ~HeapObjectsMap(); |
705 | 705 |
706 void SnapshotGenerationFinished(); | 706 void SnapshotGenerationFinished(); |
707 SnapshotObjectId FindObject(Address addr); | 707 SnapshotObjectId FindObject(Address addr); |
708 void MoveObject(Address from, Address to); | 708 void MoveObject(Address from, Address to); |
709 SnapshotObjectId last_assigned_id() const { | 709 SnapshotObjectId last_assigned_id() const { |
710 return next_id_ - kObjectIdStep; | 710 return next_id_ - kObjectIdStep; |
711 } | 711 } |
712 | 712 |
| 713 void StartHeapObjectsTracking(); |
| 714 void StopHeapObjectsTracking(); |
| 715 void PushHeapObjectsStats(OutputStream* stream); |
| 716 |
713 static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); | 717 static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); |
714 static inline SnapshotObjectId GetNthGcSubrootId(int delta); | 718 static inline SnapshotObjectId GetNthGcSubrootId(int delta); |
715 | 719 |
716 static const int kObjectIdStep = 2; | 720 static const int kObjectIdStep = 2; |
717 static const SnapshotObjectId kInternalRootObjectId; | 721 static const SnapshotObjectId kInternalRootObjectId; |
718 static const SnapshotObjectId kGcRootsObjectId; | 722 static const SnapshotObjectId kGcRootsObjectId; |
719 static const SnapshotObjectId kNativesRootObjectId; | 723 static const SnapshotObjectId kNativesRootObjectId; |
720 static const SnapshotObjectId kGcRootsFirstSubrootId; | 724 static const SnapshotObjectId kGcRootsFirstSubrootId; |
721 static const SnapshotObjectId kFirstAvailableObjectId; | 725 static const SnapshotObjectId kFirstAvailableObjectId; |
722 | 726 |
723 private: | 727 private: |
724 struct EntryInfo { | 728 struct EntryInfo { |
725 EntryInfo(SnapshotObjectId id, Address addr) | 729 EntryInfo(SnapshotObjectId id, Address addr) |
726 : id(id), addr(addr), accessed(true) { } | 730 : id(id), addr(addr), accessed(true) { } |
727 EntryInfo(SnapshotObjectId id, Address addr, bool accessed) | 731 EntryInfo(SnapshotObjectId id, Address addr, bool accessed) |
728 : id(id), addr(addr), accessed(accessed) { } | 732 : id(id), addr(addr), accessed(accessed) { } |
729 SnapshotObjectId id; | 733 SnapshotObjectId id; |
730 Address addr; | 734 Address addr; |
731 bool accessed; | 735 bool accessed; |
732 }; | 736 }; |
733 | 737 |
734 void AddEntry(Address addr, SnapshotObjectId id); | 738 void AddEntry(Address addr, SnapshotObjectId id); |
735 SnapshotObjectId FindEntry(Address addr); | 739 SnapshotObjectId FindEntry(Address addr); |
| 740 SnapshotObjectId FindOrAddEntry(Address addr); |
| 741 void UpdateHeapObjectsMap(); |
736 void RemoveDeadEntries(); | 742 void RemoveDeadEntries(); |
737 | 743 |
738 static bool AddressesMatch(void* key1, void* key2) { | 744 static bool AddressesMatch(void* key1, void* key2) { |
739 return key1 == key2; | 745 return key1 == key2; |
740 } | 746 } |
741 | 747 |
742 static uint32_t AddressHash(Address addr) { | 748 static uint32_t AddressHash(Address addr) { |
743 return ComputeIntegerHash( | 749 return ComputeIntegerHash( |
744 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)), | 750 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)), |
745 v8::internal::kZeroHashSeed); | 751 v8::internal::kZeroHashSeed); |
746 } | 752 } |
747 | 753 |
748 bool initial_fill_mode_; | 754 bool initial_fill_mode_; |
749 SnapshotObjectId next_id_; | 755 SnapshotObjectId next_id_; |
750 HashMap entries_map_; | 756 HashMap entries_map_; |
751 List<EntryInfo>* entries_; | 757 List<EntryInfo>* entries_; |
| 758 struct FragmentInfo { |
| 759 explicit FragmentInfo(SnapshotObjectId id) : id(id), count(0) { } |
| 760 SnapshotObjectId id; |
| 761 uint32_t count; |
| 762 }; |
| 763 List<FragmentInfo> fragment_infos_; |
752 | 764 |
753 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); | 765 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); |
754 }; | 766 }; |
755 | 767 |
756 | 768 |
757 class HeapSnapshotsCollection { | 769 class HeapSnapshotsCollection { |
758 public: | 770 public: |
759 HeapSnapshotsCollection(); | 771 HeapSnapshotsCollection(); |
760 ~HeapSnapshotsCollection(); | 772 ~HeapSnapshotsCollection(); |
761 | 773 |
762 bool is_tracking_objects() { return is_tracking_objects_; } | 774 bool is_tracking_objects() { return is_tracking_objects_; } |
| 775 void PushHeapObjectsStats(OutputStream* stream) { |
| 776 return ids_.PushHeapObjectsStats(stream); |
| 777 } |
| 778 void StartHeapObjectsTracking() { |
| 779 is_tracking_objects_ = true; |
| 780 ids_.StartHeapObjectsTracking(); |
| 781 } |
| 782 void StopHeapObjectsTracking() { ids_.StopHeapObjectsTracking(); } |
763 | 783 |
764 HeapSnapshot* NewSnapshot( | 784 HeapSnapshot* NewSnapshot( |
765 HeapSnapshot::Type type, const char* name, unsigned uid); | 785 HeapSnapshot::Type type, const char* name, unsigned uid); |
766 void SnapshotGenerationFinished(HeapSnapshot* snapshot); | 786 void SnapshotGenerationFinished(HeapSnapshot* snapshot); |
767 List<HeapSnapshot*>* snapshots() { return &snapshots_; } | 787 List<HeapSnapshot*>* snapshots() { return &snapshots_; } |
768 HeapSnapshot* GetSnapshot(unsigned uid); | 788 HeapSnapshot* GetSnapshot(unsigned uid); |
769 void RemoveSnapshot(HeapSnapshot* snapshot); | 789 void RemoveSnapshot(HeapSnapshot* snapshot); |
770 | 790 |
771 StringsStorage* names() { return &names_; } | 791 StringsStorage* names() { return &names_; } |
772 TokenEnumerator* token_enumerator() { return token_enumerator_; } | 792 TokenEnumerator* token_enumerator() { return token_enumerator_; } |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 | 1185 |
1166 friend class HeapSnapshotJSONSerializerEnumerator; | 1186 friend class HeapSnapshotJSONSerializerEnumerator; |
1167 friend class HeapSnapshotJSONSerializerIterator; | 1187 friend class HeapSnapshotJSONSerializerIterator; |
1168 | 1188 |
1169 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 1189 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
1170 }; | 1190 }; |
1171 | 1191 |
1172 } } // namespace v8::internal | 1192 } } // namespace v8::internal |
1173 | 1193 |
1174 #endif // V8_PROFILE_GENERATOR_H_ | 1194 #endif // V8_PROFILE_GENERATOR_H_ |
OLD | NEW |