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