| 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 17 matching lines...) Expand all Loading... |
| 28 #ifndef V8_PROFILE_GENERATOR_H_ | 28 #ifndef V8_PROFILE_GENERATOR_H_ |
| 29 #define V8_PROFILE_GENERATOR_H_ | 29 #define V8_PROFILE_GENERATOR_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "hashmap.h" | 32 #include "hashmap.h" |
| 33 #include "../include/v8-profiler.h" | 33 #include "../include/v8-profiler.h" |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 typedef uint32_t SnapshotObjectId; | |
| 39 | |
| 40 class TokenEnumerator { | 38 class TokenEnumerator { |
| 41 public: | 39 public: |
| 42 TokenEnumerator(); | 40 TokenEnumerator(); |
| 43 ~TokenEnumerator(); | 41 ~TokenEnumerator(); |
| 44 int GetTokenId(Object* token); | 42 int GetTokenId(Object* token); |
| 45 | 43 |
| 46 static const int kNoSecurityToken = -1; | 44 static const int kNoSecurityToken = -1; |
| 47 static const int kInheritsSecurityToken = -2; | 45 static const int kInheritsSecurityToken = -2; |
| 48 | 46 |
| 49 private: | 47 private: |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 kRegExp = v8::HeapGraphNode::kRegExp, | 526 kRegExp = v8::HeapGraphNode::kRegExp, |
| 529 kHeapNumber = v8::HeapGraphNode::kHeapNumber, | 527 kHeapNumber = v8::HeapGraphNode::kHeapNumber, |
| 530 kNative = v8::HeapGraphNode::kNative, | 528 kNative = v8::HeapGraphNode::kNative, |
| 531 kSynthetic = v8::HeapGraphNode::kSynthetic | 529 kSynthetic = v8::HeapGraphNode::kSynthetic |
| 532 }; | 530 }; |
| 533 | 531 |
| 534 HeapEntry() { } | 532 HeapEntry() { } |
| 535 void Init(HeapSnapshot* snapshot, | 533 void Init(HeapSnapshot* snapshot, |
| 536 Type type, | 534 Type type, |
| 537 const char* name, | 535 const char* name, |
| 538 SnapshotObjectId id, | 536 uint64_t id, |
| 539 int self_size, | 537 int self_size, |
| 540 int children_count, | 538 int children_count, |
| 541 int retainers_count); | 539 int retainers_count); |
| 542 | 540 |
| 543 HeapSnapshot* snapshot() { return snapshot_; } | 541 HeapSnapshot* snapshot() { return snapshot_; } |
| 544 Type type() { return static_cast<Type>(type_); } | 542 Type type() { return static_cast<Type>(type_); } |
| 545 const char* name() { return name_; } | 543 const char* name() { return name_; } |
| 546 void set_name(const char* name) { name_ = name; } | 544 void set_name(const char* name) { name_ = name; } |
| 547 inline SnapshotObjectId id(); | 545 inline uint64_t id(); |
| 548 int self_size() { return self_size_; } | 546 int self_size() { return self_size_; } |
| 549 int retained_size() { return retained_size_; } | 547 int retained_size() { return retained_size_; } |
| 550 void add_retained_size(int size) { retained_size_ += size; } | 548 void add_retained_size(int size) { retained_size_ += size; } |
| 551 void set_retained_size(int value) { retained_size_ = value; } | 549 void set_retained_size(int value) { retained_size_ = value; } |
| 552 int ordered_index() { return ordered_index_; } | 550 int ordered_index() { return ordered_index_; } |
| 553 void set_ordered_index(int value) { ordered_index_ = value; } | 551 void set_ordered_index(int value) { ordered_index_ = value; } |
| 554 | 552 |
| 555 Vector<HeapGraphEdge> children() { | 553 Vector<HeapGraphEdge> children() { |
| 556 return Vector<HeapGraphEdge>(children_arr(), children_count_); } | 554 return Vector<HeapGraphEdge>(children_arr(), children_count_); } |
| 557 Vector<HeapGraphEdge*> retainers() { | 555 Vector<HeapGraphEdge*> retainers() { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 HeapEntry* gc_roots() { return gc_roots_entry_; } | 644 HeapEntry* gc_roots() { return gc_roots_entry_; } |
| 647 HeapEntry* natives_root() { return natives_root_entry_; } | 645 HeapEntry* natives_root() { return natives_root_entry_; } |
| 648 HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; } | 646 HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; } |
| 649 List<HeapEntry*>* entries() { return &entries_; } | 647 List<HeapEntry*>* entries() { return &entries_; } |
| 650 int raw_entries_size() { return raw_entries_size_; } | 648 int raw_entries_size() { return raw_entries_size_; } |
| 651 | 649 |
| 652 void AllocateEntries( | 650 void AllocateEntries( |
| 653 int entries_count, int children_count, int retainers_count); | 651 int entries_count, int children_count, int retainers_count); |
| 654 HeapEntry* AddEntry(HeapEntry::Type type, | 652 HeapEntry* AddEntry(HeapEntry::Type type, |
| 655 const char* name, | 653 const char* name, |
| 656 SnapshotObjectId id, | 654 uint64_t id, |
| 657 int size, | 655 int size, |
| 658 int children_count, | 656 int children_count, |
| 659 int retainers_count); | 657 int retainers_count); |
| 660 HeapEntry* AddRootEntry(int children_count); | 658 HeapEntry* AddRootEntry(int children_count); |
| 661 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); | 659 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); |
| 662 HeapEntry* AddGcSubrootEntry(int tag, | 660 HeapEntry* AddGcSubrootEntry(int tag, |
| 663 int children_count, | 661 int children_count, |
| 664 int retainers_count); | 662 int retainers_count); |
| 665 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); | 663 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); |
| 666 void ClearPaint(); | 664 void ClearPaint(); |
| 667 HeapEntry* GetEntryById(SnapshotObjectId id); | 665 HeapEntry* GetEntryById(uint64_t id); |
| 668 List<HeapEntry*>* GetSortedEntriesList(); | 666 List<HeapEntry*>* GetSortedEntriesList(); |
| 669 template<class Visitor> | 667 template<class Visitor> |
| 670 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } | 668 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } |
| 671 void SetDominatorsToSelf(); | 669 void SetDominatorsToSelf(); |
| 672 | 670 |
| 673 void Print(int max_depth); | 671 void Print(int max_depth); |
| 674 void PrintEntriesSize(); | 672 void PrintEntriesSize(); |
| 675 | 673 |
| 676 private: | 674 private: |
| 677 HeapEntry* GetNextEntryToInit(); | 675 HeapEntry* GetNextEntryToInit(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 694 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); | 692 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); |
| 695 }; | 693 }; |
| 696 | 694 |
| 697 | 695 |
| 698 class HeapObjectsMap { | 696 class HeapObjectsMap { |
| 699 public: | 697 public: |
| 700 HeapObjectsMap(); | 698 HeapObjectsMap(); |
| 701 ~HeapObjectsMap(); | 699 ~HeapObjectsMap(); |
| 702 | 700 |
| 703 void SnapshotGenerationFinished(); | 701 void SnapshotGenerationFinished(); |
| 704 SnapshotObjectId FindObject(Address addr); | 702 uint64_t FindObject(Address addr); |
| 705 void MoveObject(Address from, Address to); | 703 void MoveObject(Address from, Address to); |
| 706 | 704 |
| 707 static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); | 705 static uint64_t GenerateId(v8::RetainedObjectInfo* info); |
| 708 static inline SnapshotObjectId GetNthGcSubrootId(int delta); | 706 static inline uint64_t GetNthGcSubrootId(int delta); |
| 709 | 707 |
| 710 static const int kObjectIdStep = 2; | 708 static const int kObjectIdStep = 2; |
| 711 static const SnapshotObjectId kInternalRootObjectId; | 709 static const uint64_t kInternalRootObjectId; |
| 712 static const SnapshotObjectId kGcRootsObjectId; | 710 static const uint64_t kGcRootsObjectId; |
| 713 static const SnapshotObjectId kNativesRootObjectId; | 711 static const uint64_t kNativesRootObjectId; |
| 714 static const SnapshotObjectId kGcRootsFirstSubrootId; | 712 static const uint64_t kGcRootsFirstSubrootId; |
| 715 static const SnapshotObjectId kFirstAvailableObjectId; | 713 static const uint64_t kFirstAvailableObjectId; |
| 716 | 714 |
| 717 private: | 715 private: |
| 718 struct EntryInfo { | 716 struct EntryInfo { |
| 719 explicit EntryInfo(SnapshotObjectId id) : id(id), accessed(true) { } | 717 explicit EntryInfo(uint64_t id) : id(id), accessed(true) { } |
| 720 EntryInfo(SnapshotObjectId id, bool accessed) : id(id), accessed(accessed) {
} | 718 EntryInfo(uint64_t id, bool accessed) : id(id), accessed(accessed) { } |
| 721 SnapshotObjectId id; | 719 uint64_t id; |
| 722 bool accessed; | 720 bool accessed; |
| 723 }; | 721 }; |
| 724 | 722 |
| 725 void AddEntry(Address addr, SnapshotObjectId id); | 723 void AddEntry(Address addr, uint64_t id); |
| 726 SnapshotObjectId FindEntry(Address addr); | 724 uint64_t FindEntry(Address addr); |
| 727 void RemoveDeadEntries(); | 725 void RemoveDeadEntries(); |
| 728 | 726 |
| 729 static bool AddressesMatch(void* key1, void* key2) { | 727 static bool AddressesMatch(void* key1, void* key2) { |
| 730 return key1 == key2; | 728 return key1 == key2; |
| 731 } | 729 } |
| 732 | 730 |
| 733 static uint32_t AddressHash(Address addr) { | 731 static uint32_t AddressHash(Address addr) { |
| 734 return ComputeIntegerHash( | 732 return ComputeIntegerHash( |
| 735 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)), | 733 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)), |
| 736 v8::internal::kZeroHashSeed); | 734 v8::internal::kZeroHashSeed); |
| 737 } | 735 } |
| 738 | 736 |
| 739 bool initial_fill_mode_; | 737 bool initial_fill_mode_; |
| 740 SnapshotObjectId next_id_; | 738 uint64_t next_id_; |
| 741 HashMap entries_map_; | 739 HashMap entries_map_; |
| 742 List<EntryInfo>* entries_; | 740 List<EntryInfo>* entries_; |
| 743 | 741 |
| 744 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); | 742 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); |
| 745 }; | 743 }; |
| 746 | 744 |
| 747 | 745 |
| 748 class HeapSnapshotsCollection { | 746 class HeapSnapshotsCollection { |
| 749 public: | 747 public: |
| 750 HeapSnapshotsCollection(); | 748 HeapSnapshotsCollection(); |
| 751 ~HeapSnapshotsCollection(); | 749 ~HeapSnapshotsCollection(); |
| 752 | 750 |
| 753 bool is_tracking_objects() { return is_tracking_objects_; } | 751 bool is_tracking_objects() { return is_tracking_objects_; } |
| 754 | 752 |
| 755 HeapSnapshot* NewSnapshot( | 753 HeapSnapshot* NewSnapshot( |
| 756 HeapSnapshot::Type type, const char* name, unsigned uid); | 754 HeapSnapshot::Type type, const char* name, unsigned uid); |
| 757 void SnapshotGenerationFinished(HeapSnapshot* snapshot); | 755 void SnapshotGenerationFinished(HeapSnapshot* snapshot); |
| 758 List<HeapSnapshot*>* snapshots() { return &snapshots_; } | 756 List<HeapSnapshot*>* snapshots() { return &snapshots_; } |
| 759 HeapSnapshot* GetSnapshot(unsigned uid); | 757 HeapSnapshot* GetSnapshot(unsigned uid); |
| 760 void RemoveSnapshot(HeapSnapshot* snapshot); | 758 void RemoveSnapshot(HeapSnapshot* snapshot); |
| 761 | 759 |
| 762 StringsStorage* names() { return &names_; } | 760 StringsStorage* names() { return &names_; } |
| 763 TokenEnumerator* token_enumerator() { return token_enumerator_; } | 761 TokenEnumerator* token_enumerator() { return token_enumerator_; } |
| 764 | 762 |
| 765 SnapshotObjectId GetObjectId(Address addr) { return ids_.FindObject(addr); } | 763 uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); } |
| 766 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); | 764 Handle<HeapObject> FindHeapObjectById(uint64_t id); |
| 767 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } | 765 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } |
| 768 | 766 |
| 769 private: | 767 private: |
| 770 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { | 768 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { |
| 771 return key1 == key2; | 769 return key1 == key2; |
| 772 } | 770 } |
| 773 | 771 |
| 774 bool is_tracking_objects_; // Whether tracking object moves is needed. | 772 bool is_tracking_objects_; // Whether tracking object moves is needed. |
| 775 List<HeapSnapshot*> snapshots_; | 773 List<HeapSnapshot*> snapshots_; |
| 776 // Mapping from snapshots' uids to HeapSnapshot* pointers. | 774 // Mapping from snapshots' uids to HeapSnapshot* pointers. |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 | 1153 |
| 1156 friend class HeapSnapshotJSONSerializerEnumerator; | 1154 friend class HeapSnapshotJSONSerializerEnumerator; |
| 1157 friend class HeapSnapshotJSONSerializerIterator; | 1155 friend class HeapSnapshotJSONSerializerIterator; |
| 1158 | 1156 |
| 1159 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 1157 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 1160 }; | 1158 }; |
| 1161 | 1159 |
| 1162 } } // namespace v8::internal | 1160 } } // namespace v8::internal |
| 1163 | 1161 |
| 1164 #endif // V8_PROFILE_GENERATOR_H_ | 1162 #endif // V8_PROFILE_GENERATOR_H_ |
| OLD | NEW |