Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 | 61 |
| 62 // Provides a storage of strings allocated in C++ heap, to hold them | 62 // Provides a storage of strings allocated in C++ heap, to hold them |
| 63 // forever, even if they disappear from JS heap or external storage. | 63 // forever, even if they disappear from JS heap or external storage. |
| 64 class StringsStorage { | 64 class StringsStorage { |
| 65 public: | 65 public: |
| 66 StringsStorage(); | 66 StringsStorage(); |
| 67 ~StringsStorage(); | 67 ~StringsStorage(); |
| 68 | 68 |
| 69 const char* GetCopy(const char* src); | |
| 70 const char* GetFormatted(const char* format, ...); | |
| 71 const char* GetVFormatted(const char* format, va_list args); | |
| 69 const char* GetName(String* name); | 72 const char* GetName(String* name); |
| 70 const char* GetName(int index); | 73 const char* GetName(int index); |
| 71 inline const char* GetFunctionName(String* name); | 74 inline const char* GetFunctionName(String* name); |
| 72 inline const char* GetFunctionName(const char* name); | 75 inline const char* GetFunctionName(const char* name); |
| 73 | 76 |
| 74 private: | 77 private: |
| 75 INLINE(static bool StringsMatch(void* key1, void* key2)) { | 78 INLINE(static bool StringsMatch(void* key1, void* key2)) { |
| 76 return strcmp(reinterpret_cast<char*>(key1), | 79 return strcmp(reinterpret_cast<char*>(key1), |
| 77 reinterpret_cast<char*>(key2)) == 0; | 80 reinterpret_cast<char*>(key2)) == 0; |
| 78 } | 81 } |
| 82 const char* AddOrDisposeString(char* str, uint32_t hash); | |
| 79 | 83 |
| 80 // Mapping of strings by String::Hash to const char* strings. | 84 // Mapping of strings by String::Hash to const char* strings. |
| 81 HashMap names_; | 85 HashMap names_; |
| 82 // Mapping from ints to char* strings. | |
| 83 List<char*> index_names_; | |
| 84 | 86 |
| 85 DISALLOW_COPY_AND_ASSIGN(StringsStorage); | 87 DISALLOW_COPY_AND_ASSIGN(StringsStorage); |
| 86 }; | 88 }; |
| 87 | 89 |
| 88 | 90 |
| 89 class CodeEntry { | 91 class CodeEntry { |
| 90 public: | 92 public: |
| 91 // CodeEntry doesn't own name strings, just references them. | 93 // CodeEntry doesn't own name strings, just references them. |
| 92 INLINE(CodeEntry(Logger::LogEventsAndTags tag, | 94 INLINE(CodeEntry(Logger::LogEventsAndTags tag, |
| 93 const char* name_prefix, | 95 const char* name_prefix, |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 class HeapEntry BASE_EMBEDDED { | 512 class HeapEntry BASE_EMBEDDED { |
| 511 public: | 513 public: |
| 512 enum Type { | 514 enum Type { |
| 513 kHidden = v8::HeapGraphNode::kHidden, | 515 kHidden = v8::HeapGraphNode::kHidden, |
| 514 kArray = v8::HeapGraphNode::kArray, | 516 kArray = v8::HeapGraphNode::kArray, |
| 515 kString = v8::HeapGraphNode::kString, | 517 kString = v8::HeapGraphNode::kString, |
| 516 kObject = v8::HeapGraphNode::kObject, | 518 kObject = v8::HeapGraphNode::kObject, |
| 517 kCode = v8::HeapGraphNode::kCode, | 519 kCode = v8::HeapGraphNode::kCode, |
| 518 kClosure = v8::HeapGraphNode::kClosure, | 520 kClosure = v8::HeapGraphNode::kClosure, |
| 519 kRegExp = v8::HeapGraphNode::kRegExp, | 521 kRegExp = v8::HeapGraphNode::kRegExp, |
| 520 kHeapNumber = v8::HeapGraphNode::kHeapNumber | 522 kHeapNumber = v8::HeapGraphNode::kHeapNumber, |
| 523 kNative = v8::HeapGraphNode::kNative | |
| 521 }; | 524 }; |
| 522 | 525 |
| 523 HeapEntry() { } | 526 HeapEntry() { } |
| 524 void Init(HeapSnapshot* snapshot, | 527 void Init(HeapSnapshot* snapshot, |
| 525 Type type, | 528 Type type, |
| 526 const char* name, | 529 const char* name, |
| 527 uint64_t id, | 530 uint64_t id, |
| 528 int self_size, | 531 int self_size, |
| 529 int children_count, | 532 int children_count, |
| 530 int retainers_count); | 533 int retainers_count); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 } | 600 } |
| 598 HeapGraphEdge** retainers_arr() { | 601 HeapGraphEdge** retainers_arr() { |
| 599 return reinterpret_cast<HeapGraphEdge**>(children_arr() + children_count_); | 602 return reinterpret_cast<HeapGraphEdge**>(children_arr() + children_count_); |
| 600 } | 603 } |
| 601 void CalculateExactRetainedSize(); | 604 void CalculateExactRetainedSize(); |
| 602 void FindRetainingPaths(CachedHeapGraphPath* prev_path, | 605 void FindRetainingPaths(CachedHeapGraphPath* prev_path, |
| 603 List<HeapGraphPath*>* retaining_paths); | 606 List<HeapGraphPath*>* retaining_paths); |
| 604 const char* TypeAsString(); | 607 const char* TypeAsString(); |
| 605 | 608 |
| 606 unsigned painted_: 2; | 609 unsigned painted_: 2; |
| 607 unsigned type_: 3; | 610 unsigned type_: 4; |
| 608 int children_count_: 27; | 611 int children_count_: 26; |
| 609 int retainers_count_; | 612 int retainers_count_; |
| 610 int self_size_; | 613 int self_size_; |
| 611 union { | 614 union { |
| 612 int ordered_index_; // Used during dominator tree building. | 615 int ordered_index_; // Used during dominator tree building. |
| 613 int retained_size_; // At that moment, there is no retained size yet. | 616 int retained_size_; // At that moment, there is no retained size yet. |
| 614 }; | 617 }; |
| 615 HeapEntry* dominator_; | 618 HeapEntry* dominator_; |
| 616 HeapSnapshot* snapshot_; | 619 HeapSnapshot* snapshot_; |
| 617 struct Id { | 620 struct Id { |
| 618 uint32_t id1_; | 621 uint32_t id1_; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 const char* title, | 673 const char* title, |
| 671 unsigned uid); | 674 unsigned uid); |
| 672 ~HeapSnapshot(); | 675 ~HeapSnapshot(); |
| 673 | 676 |
| 674 HeapSnapshotsCollection* collection() { return collection_; } | 677 HeapSnapshotsCollection* collection() { return collection_; } |
| 675 Type type() { return type_; } | 678 Type type() { return type_; } |
| 676 const char* title() { return title_; } | 679 const char* title() { return title_; } |
| 677 unsigned uid() { return uid_; } | 680 unsigned uid() { return uid_; } |
| 678 HeapEntry* root() { return root_entry_; } | 681 HeapEntry* root() { return root_entry_; } |
| 679 HeapEntry* gc_roots() { return gc_roots_entry_; } | 682 HeapEntry* gc_roots() { return gc_roots_entry_; } |
| 683 HeapEntry* dom_subtrees_root() { return dom_subtrees_root_entry_; } | |
|
Vitaly Repeshko
2011/03/09 19:10:08
"dom" -> "native"?
mnaganov (inactive)
2011/03/10 12:23:35
Done.
| |
| 680 List<HeapEntry*>* entries() { return &entries_; } | 684 List<HeapEntry*>* entries() { return &entries_; } |
| 681 | 685 |
| 682 void AllocateEntries( | 686 void AllocateEntries( |
| 683 int entries_count, int children_count, int retainers_count); | 687 int entries_count, int children_count, int retainers_count); |
| 684 HeapEntry* AddEntry(HeapEntry::Type type, | 688 HeapEntry* AddEntry(HeapEntry::Type type, |
| 685 const char* name, | 689 const char* name, |
| 686 uint64_t id, | 690 uint64_t id, |
| 687 int size, | 691 int size, |
| 688 int children_count, | 692 int children_count, |
| 689 int retainers_count); | 693 int retainers_count); |
| 690 HeapEntry* AddRootEntry(int children_count); | 694 HeapEntry* AddRootEntry(int children_count); |
| 691 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); | 695 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); |
| 696 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); | |
| 692 void ClearPaint(); | 697 void ClearPaint(); |
| 693 HeapSnapshotsDiff* CompareWith(HeapSnapshot* snapshot); | 698 HeapSnapshotsDiff* CompareWith(HeapSnapshot* snapshot); |
| 694 HeapEntry* GetEntryById(uint64_t id); | 699 HeapEntry* GetEntryById(uint64_t id); |
| 695 List<HeapGraphPath*>* GetRetainingPaths(HeapEntry* entry); | 700 List<HeapGraphPath*>* GetRetainingPaths(HeapEntry* entry); |
| 696 List<HeapEntry*>* GetSortedEntriesList(); | 701 List<HeapEntry*>* GetSortedEntriesList(); |
| 697 template<class Visitor> | 702 template<class Visitor> |
| 698 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } | 703 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } |
| 699 void SetDominatorsToSelf(); | 704 void SetDominatorsToSelf(); |
| 700 | 705 |
| 701 void Print(int max_depth); | 706 void Print(int max_depth); |
| 702 void PrintEntriesSize(); | 707 void PrintEntriesSize(); |
| 703 | 708 |
| 704 private: | 709 private: |
| 705 HeapEntry* GetNextEntryToInit(); | 710 HeapEntry* GetNextEntryToInit(); |
| 706 | 711 |
| 707 HeapSnapshotsCollection* collection_; | 712 HeapSnapshotsCollection* collection_; |
| 708 Type type_; | 713 Type type_; |
| 709 const char* title_; | 714 const char* title_; |
| 710 unsigned uid_; | 715 unsigned uid_; |
| 711 HeapEntry* root_entry_; | 716 HeapEntry* root_entry_; |
| 712 HeapEntry* gc_roots_entry_; | 717 HeapEntry* gc_roots_entry_; |
| 718 HeapEntry* dom_subtrees_root_entry_; | |
| 713 char* raw_entries_; | 719 char* raw_entries_; |
| 714 List<HeapEntry*> entries_; | 720 List<HeapEntry*> entries_; |
| 715 bool entries_sorted_; | 721 bool entries_sorted_; |
| 716 HashMap retaining_paths_; | 722 HashMap retaining_paths_; |
| 717 #ifdef DEBUG | 723 #ifdef DEBUG |
| 718 int raw_entries_size_; | 724 int raw_entries_size_; |
| 719 #endif | 725 #endif |
| 720 | 726 |
| 721 friend class HeapSnapshotTester; | 727 friend class HeapSnapshotTester; |
| 722 | 728 |
| 723 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); | 729 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); |
| 724 }; | 730 }; |
| 725 | 731 |
| 726 | 732 |
| 727 class HeapObjectsMap { | 733 class HeapObjectsMap { |
| 728 public: | 734 public: |
| 729 HeapObjectsMap(); | 735 HeapObjectsMap(); |
| 730 ~HeapObjectsMap(); | 736 ~HeapObjectsMap(); |
| 731 | 737 |
| 732 void SnapshotGenerationFinished(); | 738 void SnapshotGenerationFinished(); |
| 733 uint64_t FindObject(Address addr); | 739 uint64_t FindObject(Address addr); |
| 734 void MoveObject(Address from, Address to); | 740 void MoveObject(Address from, Address to); |
| 735 | 741 |
| 742 static uint64_t GenerateId(v8::RetainedObjectInfo* info); | |
| 743 | |
| 736 static const uint64_t kInternalRootObjectId; | 744 static const uint64_t kInternalRootObjectId; |
| 737 static const uint64_t kGcRootsObjectId; | 745 static const uint64_t kGcRootsObjectId; |
| 746 static const uint64_t kNativesRootObjectId; | |
| 738 static const uint64_t kFirstAvailableObjectId; | 747 static const uint64_t kFirstAvailableObjectId; |
| 739 | 748 |
| 740 private: | 749 private: |
| 741 struct EntryInfo { | 750 struct EntryInfo { |
| 742 explicit EntryInfo(uint64_t id) : id(id), accessed(true) { } | 751 explicit EntryInfo(uint64_t id) : id(id), accessed(true) { } |
| 743 EntryInfo(uint64_t id, bool accessed) : id(id), accessed(accessed) { } | 752 EntryInfo(uint64_t id, bool accessed) : id(id), accessed(accessed) { } |
| 744 uint64_t id; | 753 uint64_t id; |
| 745 bool accessed; | 754 bool accessed; |
| 746 }; | 755 }; |
| 747 | 756 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 825 ~HeapSnapshotsCollection(); | 834 ~HeapSnapshotsCollection(); |
| 826 | 835 |
| 827 bool is_tracking_objects() { return is_tracking_objects_; } | 836 bool is_tracking_objects() { return is_tracking_objects_; } |
| 828 | 837 |
| 829 HeapSnapshot* NewSnapshot( | 838 HeapSnapshot* NewSnapshot( |
| 830 HeapSnapshot::Type type, const char* name, unsigned uid); | 839 HeapSnapshot::Type type, const char* name, unsigned uid); |
| 831 void SnapshotGenerationFinished(HeapSnapshot* snapshot); | 840 void SnapshotGenerationFinished(HeapSnapshot* snapshot); |
| 832 List<HeapSnapshot*>* snapshots() { return &snapshots_; } | 841 List<HeapSnapshot*>* snapshots() { return &snapshots_; } |
| 833 HeapSnapshot* GetSnapshot(unsigned uid); | 842 HeapSnapshot* GetSnapshot(unsigned uid); |
| 834 | 843 |
| 835 const char* GetName(String* name) { return names_.GetName(name); } | 844 StringsStorage* names() { return &names_; } |
| 836 const char* GetName(int index) { return names_.GetName(index); } | |
| 837 const char* GetFunctionName(String* name) { | |
| 838 return names_.GetFunctionName(name); | |
| 839 } | |
| 840 | |
| 841 TokenEnumerator* token_enumerator() { return token_enumerator_; } | 845 TokenEnumerator* token_enumerator() { return token_enumerator_; } |
| 842 | 846 |
| 843 uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); } | 847 uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); } |
| 844 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } | 848 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } |
| 845 | 849 |
| 846 HeapSnapshotsDiff* CompareSnapshots(HeapSnapshot* snapshot1, | 850 HeapSnapshotsDiff* CompareSnapshots(HeapSnapshot* snapshot1, |
| 847 HeapSnapshot* snapshot2); | 851 HeapSnapshot* snapshot2); |
| 848 | 852 |
| 849 private: | 853 private: |
| 850 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { | 854 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 943 HashMap entries_; | 947 HashMap entries_; |
| 944 | 948 |
| 945 DISALLOW_COPY_AND_ASSIGN(HeapObjectsSet); | 949 DISALLOW_COPY_AND_ASSIGN(HeapObjectsSet); |
| 946 }; | 950 }; |
| 947 | 951 |
| 948 | 952 |
| 949 // An interface used to populate a snapshot with nodes and edges. | 953 // An interface used to populate a snapshot with nodes and edges. |
| 950 class SnapshotFillerInterface { | 954 class SnapshotFillerInterface { |
| 951 public: | 955 public: |
| 952 virtual ~SnapshotFillerInterface() { } | 956 virtual ~SnapshotFillerInterface() { } |
| 953 virtual HeapEntry* AddEntry(HeapThing ptr) = 0; | 957 virtual HeapEntry* AddEntry(HeapThing ptr, |
| 954 virtual HeapEntry* FindOrAddEntry(HeapThing ptr) = 0; | 958 HeapEntriesAllocator* allocator) = 0; |
| 959 virtual HeapEntry* FindEntry(HeapThing ptr) = 0; | |
| 960 virtual HeapEntry* FindOrAddEntry(HeapThing ptr, | |
| 961 HeapEntriesAllocator* allocator) = 0; | |
| 955 virtual void SetIndexedReference(HeapGraphEdge::Type type, | 962 virtual void SetIndexedReference(HeapGraphEdge::Type type, |
| 956 HeapThing parent_ptr, | 963 HeapThing parent_ptr, |
| 957 HeapEntry* parent_entry, | 964 HeapEntry* parent_entry, |
| 958 int index, | 965 int index, |
| 959 HeapThing child_ptr, | 966 HeapThing child_ptr, |
| 960 HeapEntry* child_entry) = 0; | 967 HeapEntry* child_entry) = 0; |
| 961 virtual void SetIndexedAutoIndexReference(HeapGraphEdge::Type type, | 968 virtual void SetIndexedAutoIndexReference(HeapGraphEdge::Type type, |
| 962 HeapThing parent_ptr, | 969 HeapThing parent_ptr, |
| 963 HeapEntry* parent_entry, | 970 HeapEntry* parent_entry, |
| 964 HeapThing child_ptr, | 971 HeapThing child_ptr, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 983 virtual void ProgressStep() = 0; | 990 virtual void ProgressStep() = 0; |
| 984 virtual bool ProgressReport(bool force) = 0; | 991 virtual bool ProgressReport(bool force) = 0; |
| 985 }; | 992 }; |
| 986 | 993 |
| 987 | 994 |
| 988 // An implementation of V8 heap graph extractor. | 995 // An implementation of V8 heap graph extractor. |
| 989 class V8HeapExplorer : public HeapEntriesAllocator { | 996 class V8HeapExplorer : public HeapEntriesAllocator { |
| 990 public: | 997 public: |
| 991 V8HeapExplorer(HeapSnapshot* snapshot, | 998 V8HeapExplorer(HeapSnapshot* snapshot, |
| 992 SnapshottingProgressReportingInterface* progress); | 999 SnapshottingProgressReportingInterface* progress); |
| 993 ~V8HeapExplorer(); | 1000 virtual ~V8HeapExplorer(); |
| 994 virtual HeapEntry* AllocateEntry( | 1001 virtual HeapEntry* AllocateEntry( |
| 995 HeapThing ptr, int children_count, int retainers_count); | 1002 HeapThing ptr, int children_count, int retainers_count); |
| 996 void AddRootEntries(SnapshotFillerInterface* filler); | 1003 void AddRootEntries(SnapshotFillerInterface* filler); |
| 997 int EstimateObjectsCount(); | 1004 int EstimateObjectsCount(); |
| 998 bool IterateAndExtractReferences(SnapshotFillerInterface* filler); | 1005 bool IterateAndExtractReferences(SnapshotFillerInterface* filler); |
| 999 | 1006 |
| 1007 static HeapObject* const kInternalRootObject; | |
| 1008 | |
| 1000 private: | 1009 private: |
| 1001 HeapEntry* AddEntry( | 1010 HeapEntry* AddEntry( |
| 1002 HeapObject* object, int children_count, int retainers_count); | 1011 HeapObject* object, int children_count, int retainers_count); |
| 1003 HeapEntry* AddEntry(HeapObject* object, | 1012 HeapEntry* AddEntry(HeapObject* object, |
| 1004 HeapEntry::Type type, | 1013 HeapEntry::Type type, |
| 1005 const char* name, | 1014 const char* name, |
| 1006 int children_count, | 1015 int children_count, |
| 1007 int retainers_count); | 1016 int retainers_count); |
| 1008 void ExtractReferences(HeapObject* obj); | 1017 void ExtractReferences(HeapObject* obj); |
| 1009 void ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry); | 1018 void ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1045 HeapEntry* GetEntry(Object* obj); | 1054 HeapEntry* GetEntry(Object* obj); |
| 1046 | 1055 |
| 1047 HeapSnapshot* snapshot_; | 1056 HeapSnapshot* snapshot_; |
| 1048 HeapSnapshotsCollection* collection_; | 1057 HeapSnapshotsCollection* collection_; |
| 1049 SnapshottingProgressReportingInterface* progress_; | 1058 SnapshottingProgressReportingInterface* progress_; |
| 1050 // Used during references extraction to mark heap objects that | 1059 // Used during references extraction to mark heap objects that |
| 1051 // are references via non-hidden properties. | 1060 // are references via non-hidden properties. |
| 1052 HeapObjectsSet known_references_; | 1061 HeapObjectsSet known_references_; |
| 1053 SnapshotFillerInterface* filler_; | 1062 SnapshotFillerInterface* filler_; |
| 1054 | 1063 |
| 1055 static HeapObject* const kInternalRootObject; | |
| 1056 static HeapObject* const kGcRootsObject; | 1064 static HeapObject* const kGcRootsObject; |
| 1057 | 1065 |
| 1058 friend class IndexedReferencesExtractor; | 1066 friend class IndexedReferencesExtractor; |
| 1059 friend class RootsReferencesExtractor; | 1067 friend class RootsReferencesExtractor; |
| 1060 | 1068 |
| 1061 DISALLOW_COPY_AND_ASSIGN(V8HeapExplorer); | 1069 DISALLOW_COPY_AND_ASSIGN(V8HeapExplorer); |
| 1062 }; | 1070 }; |
| 1063 | 1071 |
| 1064 | 1072 |
| 1073 // An implementation of retained native objects extractor. | |
| 1074 class NativeObjectsExplorer : public HeapEntriesAllocator { | |
| 1075 public: | |
| 1076 NativeObjectsExplorer(HeapSnapshot* snapshot, | |
| 1077 SnapshottingProgressReportingInterface* progress); | |
| 1078 virtual ~NativeObjectsExplorer(); | |
| 1079 virtual HeapEntry* AllocateEntry( | |
| 1080 HeapThing ptr, int children_count, int retainers_count); | |
| 1081 void AddRootEntries(SnapshotFillerInterface* filler); | |
| 1082 int EstimateObjectsCount(); | |
| 1083 bool IterateAndExtractReferences(SnapshotFillerInterface* filler); | |
| 1084 | |
| 1085 private: | |
| 1086 void FillRetainedObjects(); | |
| 1087 List<HeapObject*>* GetListMaybeDisposeInfo(v8::RetainedObjectInfo* info); | |
| 1088 void SetNativeRootReference(v8::RetainedObjectInfo* info); | |
| 1089 void SetRootNativesRootReference(); | |
| 1090 void SetWrapperNativeReferences(HeapObject* wrapper, | |
| 1091 v8::RetainedObjectInfo* info); | |
| 1092 void VisitSubtreeWrapper(Object** p, uint16_t class_id); | |
| 1093 | |
| 1094 static uint32_t InfoHash(v8::RetainedObjectInfo* info) { | |
| 1095 return ComputeIntegerHash(static_cast<uint32_t>(info->GetHash())); | |
| 1096 } | |
| 1097 static bool RetainedInfosMatch(void* key1, void* key2) { | |
| 1098 return key1 == key2 || | |
| 1099 (reinterpret_cast<v8::RetainedObjectInfo*>(key1))->IsEquivalent( | |
| 1100 reinterpret_cast<v8::RetainedObjectInfo*>(key2)); | |
| 1101 } | |
| 1102 | |
| 1103 HeapSnapshot* snapshot_; | |
| 1104 HeapSnapshotsCollection* collection_; | |
| 1105 SnapshottingProgressReportingInterface* progress_; | |
| 1106 bool embedder_queried_; | |
| 1107 HeapObjectsSet in_groups_; | |
| 1108 // RetainedObjectInfo* -> List<HeapObject*>* | |
| 1109 HashMap objects_by_info_; | |
| 1110 // Used during references extraction. | |
| 1111 SnapshotFillerInterface* filler_; | |
| 1112 | |
| 1113 static HeapThing const kNativesRootObject; | |
| 1114 | |
| 1115 friend class GlobalHandlesExtractor; | |
| 1116 | |
| 1117 DISALLOW_COPY_AND_ASSIGN(NativeObjectsExplorer); | |
| 1118 }; | |
| 1119 | |
| 1120 | |
| 1065 class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { | 1121 class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { |
| 1066 public: | 1122 public: |
| 1067 HeapSnapshotGenerator(HeapSnapshot* snapshot, | 1123 HeapSnapshotGenerator(HeapSnapshot* snapshot, |
| 1068 v8::ActivityControl* control); | 1124 v8::ActivityControl* control); |
| 1069 bool GenerateSnapshot(); | 1125 bool GenerateSnapshot(); |
| 1070 | 1126 |
| 1071 private: | 1127 private: |
| 1072 bool ApproximateRetainedSizes(); | 1128 bool ApproximateRetainedSizes(); |
| 1073 bool BuildDominatorTree(const Vector<HeapEntry*>& entries, | 1129 bool BuildDominatorTree(const Vector<HeapEntry*>& entries, |
| 1074 Vector<HeapEntry*>* dominators); | 1130 Vector<HeapEntry*>* dominators); |
| 1075 bool CountEntriesAndReferences(); | 1131 bool CountEntriesAndReferences(); |
| 1076 bool FillReferences(); | 1132 bool FillReferences(); |
| 1077 void FillReversePostorderIndexes(Vector<HeapEntry*>* entries); | 1133 void FillReversePostorderIndexes(Vector<HeapEntry*>* entries); |
| 1078 void ProgressStep(); | 1134 void ProgressStep(); |
| 1079 bool ProgressReport(bool force = false); | 1135 bool ProgressReport(bool force = false); |
| 1080 bool SetEntriesDominators(); | 1136 bool SetEntriesDominators(); |
| 1081 void SetProgressTotal(int iterations_count); | 1137 void SetProgressTotal(int iterations_count); |
| 1082 | 1138 |
| 1083 HeapSnapshot* snapshot_; | 1139 HeapSnapshot* snapshot_; |
| 1084 v8::ActivityControl* control_; | 1140 v8::ActivityControl* control_; |
| 1085 V8HeapExplorer v8_heap_explorer_; | 1141 V8HeapExplorer v8_heap_explorer_; |
| 1142 NativeObjectsExplorer dom_explorer_; | |
| 1086 // Mapping from HeapThing pointers to HeapEntry* pointers. | 1143 // Mapping from HeapThing pointers to HeapEntry* pointers. |
| 1087 HeapEntriesMap entries_; | 1144 HeapEntriesMap entries_; |
| 1088 // Used during snapshot generation. | 1145 // Used during snapshot generation. |
| 1089 int progress_counter_; | 1146 int progress_counter_; |
| 1090 int progress_total_; | 1147 int progress_total_; |
| 1091 | 1148 |
| 1092 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator); | 1149 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator); |
| 1093 }; | 1150 }; |
| 1094 | 1151 |
| 1095 class OutputStreamWriter; | 1152 class OutputStreamWriter; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1142 }; | 1199 }; |
| 1143 | 1200 |
| 1144 | 1201 |
| 1145 String* GetConstructorNameForHeapProfile(JSObject* object); | 1202 String* GetConstructorNameForHeapProfile(JSObject* object); |
| 1146 | 1203 |
| 1147 } } // namespace v8::internal | 1204 } } // namespace v8::internal |
| 1148 | 1205 |
| 1149 #endif // ENABLE_LOGGING_AND_PROFILING | 1206 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1150 | 1207 |
| 1151 #endif // V8_PROFILE_GENERATOR_H_ | 1208 #endif // V8_PROFILE_GENERATOR_H_ |
| OLD | NEW |