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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) |
|
alexeif
2012/04/13 15:01:27
padding?
| |
| 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) |
|
alexeif
2012/04/13 15:01:27
why not a default value for 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)), |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 780 HeapSnapshot* NewSnapshot( | 780 HeapSnapshot* NewSnapshot( |
| 781 HeapSnapshot::Type type, const char* name, unsigned uid); | 781 HeapSnapshot::Type type, const char* name, unsigned uid); |
| 782 void SnapshotGenerationFinished(HeapSnapshot* snapshot); | 782 void SnapshotGenerationFinished(HeapSnapshot* snapshot); |
| 783 List<HeapSnapshot*>* snapshots() { return &snapshots_; } | 783 List<HeapSnapshot*>* snapshots() { return &snapshots_; } |
| 784 HeapSnapshot* GetSnapshot(unsigned uid); | 784 HeapSnapshot* GetSnapshot(unsigned uid); |
| 785 void RemoveSnapshot(HeapSnapshot* snapshot); | 785 void RemoveSnapshot(HeapSnapshot* snapshot); |
| 786 | 786 |
| 787 StringsStorage* names() { return &names_; } | 787 StringsStorage* names() { return &names_; } |
| 788 TokenEnumerator* token_enumerator() { return token_enumerator_; } | 788 TokenEnumerator* token_enumerator() { return token_enumerator_; } |
| 789 | 789 |
| 790 SnapshotObjectId GetObjectId(Address addr) { return ids_.FindObject(addr); } | 790 SnapshotObjectId GetObjectId(Address object_addr, int object_size) { |
| 791 return ids_.FindOrAddEntry(object_addr, object_size); | |
| 792 } | |
| 791 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); | 793 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); |
| 792 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } | 794 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } |
| 793 SnapshotObjectId last_assigned_id() const { | 795 SnapshotObjectId last_assigned_id() const { |
| 794 return ids_.last_assigned_id(); | 796 return ids_.last_assigned_id(); |
| 795 } | 797 } |
| 796 | 798 |
| 797 private: | 799 private: |
| 798 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { | 800 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { |
| 799 return key1 == key2; | 801 return key1 == key2; |
| 800 } | 802 } |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 | 1183 |
| 1182 friend class HeapSnapshotJSONSerializerEnumerator; | 1184 friend class HeapSnapshotJSONSerializerEnumerator; |
| 1183 friend class HeapSnapshotJSONSerializerIterator; | 1185 friend class HeapSnapshotJSONSerializerIterator; |
| 1184 | 1186 |
| 1185 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 1187 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 1186 }; | 1188 }; |
| 1187 | 1189 |
| 1188 } } // namespace v8::internal | 1190 } } // namespace v8::internal |
| 1189 | 1191 |
| 1190 #endif // V8_PROFILE_GENERATOR_H_ | 1192 #endif // V8_PROFILE_GENERATOR_H_ |
| OLD | NEW |