Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: src/profile-generator.h

Issue 10049002: Introduce a way to grab heap stats. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments addressed Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 };
736 struct TimeInterval {
737 explicit TimeInterval(SnapshotObjectId id) : id(id), count(0) { }
738 SnapshotObjectId id;
739 uint32_t count;
740 };
733 741
734 void AddEntry(Address addr, SnapshotObjectId id); 742 void AddEntry(Address addr, SnapshotObjectId id);
735 SnapshotObjectId FindEntry(Address addr); 743 SnapshotObjectId FindEntry(Address addr);
744 SnapshotObjectId FindOrAddEntry(Address addr);
745 void UpdateHeapObjectsMap();
736 void RemoveDeadEntries(); 746 void RemoveDeadEntries();
737 747
738 static bool AddressesMatch(void* key1, void* key2) { 748 static bool AddressesMatch(void* key1, void* key2) {
739 return key1 == key2; 749 return key1 == key2;
740 } 750 }
741 751
742 static uint32_t AddressHash(Address addr) { 752 static uint32_t AddressHash(Address addr) {
743 return ComputeIntegerHash( 753 return ComputeIntegerHash(
744 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)), 754 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)),
745 v8::internal::kZeroHashSeed); 755 v8::internal::kZeroHashSeed);
746 } 756 }
747 757
748 bool initial_fill_mode_; 758 bool initial_fill_mode_;
749 SnapshotObjectId next_id_; 759 SnapshotObjectId next_id_;
750 HashMap entries_map_; 760 HashMap entries_map_;
751 List<EntryInfo>* entries_; 761 List<EntryInfo>* entries_;
762 List<TimeInterval> time_intervals_;
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() { is_tracking_objects_ = true; }
778 void StopHeapObjectsTracking() { ids_.StopHeapObjectsTracking(); }
763 779
764 HeapSnapshot* NewSnapshot( 780 HeapSnapshot* NewSnapshot(
765 HeapSnapshot::Type type, const char* name, unsigned uid); 781 HeapSnapshot::Type type, const char* name, unsigned uid);
766 void SnapshotGenerationFinished(HeapSnapshot* snapshot); 782 void SnapshotGenerationFinished(HeapSnapshot* snapshot);
767 List<HeapSnapshot*>* snapshots() { return &snapshots_; } 783 List<HeapSnapshot*>* snapshots() { return &snapshots_; }
768 HeapSnapshot* GetSnapshot(unsigned uid); 784 HeapSnapshot* GetSnapshot(unsigned uid);
769 void RemoveSnapshot(HeapSnapshot* snapshot); 785 void RemoveSnapshot(HeapSnapshot* snapshot);
770 786
771 StringsStorage* names() { return &names_; } 787 StringsStorage* names() { return &names_; }
772 TokenEnumerator* token_enumerator() { return token_enumerator_; } 788 TokenEnumerator* token_enumerator() { return token_enumerator_; }
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 1181
1166 friend class HeapSnapshotJSONSerializerEnumerator; 1182 friend class HeapSnapshotJSONSerializerEnumerator;
1167 friend class HeapSnapshotJSONSerializerIterator; 1183 friend class HeapSnapshotJSONSerializerIterator;
1168 1184
1169 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 1185 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
1170 }; 1186 };
1171 1187
1172 } } // namespace v8::internal 1188 } } // namespace v8::internal
1173 1189
1174 #endif // V8_PROFILE_GENERATOR_H_ 1190 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698