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

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

Issue 10086004: Add size metric into 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
« no previous file with comments | « include/v8-profiler.h ('k') | src/profile-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); 697 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot);
698 }; 698 };
699 699
700 700
701 class HeapObjectsMap { 701 class HeapObjectsMap {
702 public: 702 public:
703 HeapObjectsMap(); 703 HeapObjectsMap();
704 ~HeapObjectsMap(); 704 ~HeapObjectsMap();
705 705
706 void SnapshotGenerationFinished(); 706 void SnapshotGenerationFinished();
707 SnapshotObjectId FindObject(Address addr); 707 SnapshotObjectId FindEntry(Address addr);
708 SnapshotObjectId FindOrAddEntry(Address addr, unsigned int size);
708 void MoveObject(Address from, Address to); 709 void MoveObject(Address from, Address to);
709 SnapshotObjectId last_assigned_id() const { 710 SnapshotObjectId last_assigned_id() const {
710 return next_id_ - kObjectIdStep; 711 return next_id_ - kObjectIdStep;
711 } 712 }
712 713
713 void StopHeapObjectsTracking(); 714 void StopHeapObjectsTracking();
714 void PushHeapObjectsStats(OutputStream* stream); 715 void PushHeapObjectsStats(OutputStream* stream);
715 716
716 static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); 717 static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info);
717 static inline SnapshotObjectId GetNthGcSubrootId(int delta); 718 static inline SnapshotObjectId GetNthGcSubrootId(int delta);
718 719
719 static const int kObjectIdStep = 2; 720 static const int kObjectIdStep = 2;
720 static const SnapshotObjectId kInternalRootObjectId; 721 static const SnapshotObjectId kInternalRootObjectId;
721 static const SnapshotObjectId kGcRootsObjectId; 722 static const SnapshotObjectId kGcRootsObjectId;
722 static const SnapshotObjectId kNativesRootObjectId; 723 static const SnapshotObjectId kNativesRootObjectId;
723 static const SnapshotObjectId kGcRootsFirstSubrootId; 724 static const SnapshotObjectId kGcRootsFirstSubrootId;
724 static const SnapshotObjectId kFirstAvailableObjectId; 725 static const SnapshotObjectId kFirstAvailableObjectId;
725 726
726 private: 727 private:
727 struct EntryInfo { 728 struct EntryInfo {
728 EntryInfo(SnapshotObjectId id, Address addr) 729 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size)
729 : id(id), addr(addr), accessed(true) { } 730 : id(id), addr(addr), size(size), accessed(true) { }
730 EntryInfo(SnapshotObjectId id, Address addr, bool accessed) 731 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed)
731 : id(id), addr(addr), accessed(accessed) { } 732 : id(id), addr(addr), size(size), accessed(accessed) { }
732 SnapshotObjectId id; 733 SnapshotObjectId id;
733 Address addr; 734 Address addr;
735 unsigned int size;
734 bool accessed; 736 bool accessed;
735 }; 737 };
736 struct TimeInterval { 738 struct TimeInterval {
737 explicit TimeInterval(SnapshotObjectId id) : id(id), count(0) { } 739 explicit TimeInterval(SnapshotObjectId id) : id(id), size(0), count(0) { }
738 SnapshotObjectId id; 740 SnapshotObjectId id;
741 unsigned int size;
739 uint32_t count; 742 uint32_t count;
740 }; 743 };
741 744
742 void AddEntry(Address addr, SnapshotObjectId id);
743 SnapshotObjectId FindEntry(Address addr);
744 SnapshotObjectId FindOrAddEntry(Address addr);
745 void UpdateHeapObjectsMap(); 745 void UpdateHeapObjectsMap();
746 void RemoveDeadEntries(); 746 void RemoveDeadEntries();
747 747
748 static bool AddressesMatch(void* key1, void* key2) { 748 static bool AddressesMatch(void* key1, void* key2) {
749 return key1 == key2; 749 return key1 == key2;
750 } 750 }
751 751
752 static uint32_t AddressHash(Address addr) { 752 static uint32_t AddressHash(Address addr) {
753 return ComputeIntegerHash( 753 return ComputeIntegerHash(
754 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)), 754 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)),
755 v8::internal::kZeroHashSeed); 755 v8::internal::kZeroHashSeed);
756 } 756 }
757 757
758 bool initial_fill_mode_;
759 SnapshotObjectId next_id_; 758 SnapshotObjectId next_id_;
760 HashMap entries_map_; 759 HashMap entries_map_;
761 List<EntryInfo>* entries_; 760 List<EntryInfo>* entries_;
762 List<TimeInterval> time_intervals_; 761 List<TimeInterval> time_intervals_;
763 762
764 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); 763 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap);
765 }; 764 };
766 765
767 766
768 class HeapSnapshotsCollection { 767 class HeapSnapshotsCollection {
(...skipping 11 matching lines...) Expand all
780 HeapSnapshot* NewSnapshot( 779 HeapSnapshot* NewSnapshot(
781 HeapSnapshot::Type type, const char* name, unsigned uid); 780 HeapSnapshot::Type type, const char* name, unsigned uid);
782 void SnapshotGenerationFinished(HeapSnapshot* snapshot); 781 void SnapshotGenerationFinished(HeapSnapshot* snapshot);
783 List<HeapSnapshot*>* snapshots() { return &snapshots_; } 782 List<HeapSnapshot*>* snapshots() { return &snapshots_; }
784 HeapSnapshot* GetSnapshot(unsigned uid); 783 HeapSnapshot* GetSnapshot(unsigned uid);
785 void RemoveSnapshot(HeapSnapshot* snapshot); 784 void RemoveSnapshot(HeapSnapshot* snapshot);
786 785
787 StringsStorage* names() { return &names_; } 786 StringsStorage* names() { return &names_; }
788 TokenEnumerator* token_enumerator() { return token_enumerator_; } 787 TokenEnumerator* token_enumerator() { return token_enumerator_; }
789 788
790 SnapshotObjectId GetObjectId(Address addr) { return ids_.FindObject(addr); } 789 SnapshotObjectId GetObjectId(Address object_addr, int object_size) {
790 return ids_.FindOrAddEntry(object_addr, object_size);
791 }
791 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); 792 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
792 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } 793 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); }
793 SnapshotObjectId last_assigned_id() const { 794 SnapshotObjectId last_assigned_id() const {
794 return ids_.last_assigned_id(); 795 return ids_.last_assigned_id();
795 } 796 }
796 797
797 private: 798 private:
798 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { 799 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) {
799 return key1 == key2; 800 return key1 == key2;
800 } 801 }
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 1182
1182 friend class HeapSnapshotJSONSerializerEnumerator; 1183 friend class HeapSnapshotJSONSerializerEnumerator;
1183 friend class HeapSnapshotJSONSerializerIterator; 1184 friend class HeapSnapshotJSONSerializerIterator;
1184 1185
1185 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 1186 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
1186 }; 1187 };
1187 1188
1188 } } // namespace v8::internal 1189 } } // namespace v8::internal
1189 1190
1190 #endif // V8_PROFILE_GENERATOR_H_ 1191 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« no previous file with comments | « include/v8-profiler.h ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698