| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 class HeapEntry; | 448 class HeapEntry; |
| 449 | 449 |
| 450 class HeapGraphEdge BASE_EMBEDDED { | 450 class HeapGraphEdge BASE_EMBEDDED { |
| 451 public: | 451 public: |
| 452 enum Type { | 452 enum Type { |
| 453 kContextVariable = v8::HeapGraphEdge::kContextVariable, | 453 kContextVariable = v8::HeapGraphEdge::kContextVariable, |
| 454 kElement = v8::HeapGraphEdge::kElement, | 454 kElement = v8::HeapGraphEdge::kElement, |
| 455 kProperty = v8::HeapGraphEdge::kProperty, | 455 kProperty = v8::HeapGraphEdge::kProperty, |
| 456 kInternal = v8::HeapGraphEdge::kInternal, | 456 kInternal = v8::HeapGraphEdge::kInternal, |
| 457 kHidden = v8::HeapGraphEdge::kHidden, | 457 kHidden = v8::HeapGraphEdge::kHidden, |
| 458 kShortcut = v8::HeapGraphEdge::kShortcut | 458 kShortcut = v8::HeapGraphEdge::kShortcut, |
| 459 kWeak = v8::HeapGraphEdge::kWeak |
| 459 }; | 460 }; |
| 460 | 461 |
| 461 HeapGraphEdge() { } | 462 HeapGraphEdge() { } |
| 462 void Init(int child_index, Type type, const char* name, HeapEntry* to); | 463 void Init(int child_index, Type type, const char* name, HeapEntry* to); |
| 463 void Init(int child_index, Type type, int index, HeapEntry* to); | 464 void Init(int child_index, Type type, int index, HeapEntry* to); |
| 464 void Init(int child_index, int index, HeapEntry* to); | 465 void Init(int child_index, int index, HeapEntry* to); |
| 465 | 466 |
| 466 Type type() { return static_cast<Type>(type_); } | 467 Type type() { return static_cast<Type>(type_); } |
| 467 int index() { | 468 int index() { |
| 468 ASSERT(type_ == kElement || type_ == kHidden); | 469 ASSERT(type_ == kElement || type_ == kHidden || type_ == kWeak); |
| 469 return index_; | 470 return index_; |
| 470 } | 471 } |
| 471 const char* name() { | 472 const char* name() { |
| 472 ASSERT(type_ == kContextVariable | 473 ASSERT(type_ == kContextVariable |
| 473 || type_ == kProperty | 474 || type_ == kProperty |
| 474 || type_ == kInternal | 475 || type_ == kInternal |
| 475 || type_ == kShortcut); | 476 || type_ == kShortcut); |
| 476 return name_; | 477 return name_; |
| 477 } | 478 } |
| 478 HeapEntry* to() { return to_; } | 479 HeapEntry* to() { return to_; } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 void SetNamedReference(HeapGraphEdge::Type type, | 582 void SetNamedReference(HeapGraphEdge::Type type, |
| 582 int child_index, | 583 int child_index, |
| 583 const char* name, | 584 const char* name, |
| 584 HeapEntry* entry, | 585 HeapEntry* entry, |
| 585 int retainer_index); | 586 int retainer_index); |
| 586 void SetUnidirElementReference(int child_index, int index, HeapEntry* entry); | 587 void SetUnidirElementReference(int child_index, int index, HeapEntry* entry); |
| 587 | 588 |
| 588 int EntrySize() { return EntriesSize(1, children_count_, retainers_count_); } | 589 int EntrySize() { return EntriesSize(1, children_count_, retainers_count_); } |
| 589 int RetainedSize(bool exact); | 590 int RetainedSize(bool exact); |
| 590 | 591 |
| 591 void Print(int max_depth, int indent); | 592 void Print( |
| 593 const char* prefix, const char* edge_name, int max_depth, int indent); |
| 592 | 594 |
| 593 Handle<HeapObject> GetHeapObject(); | 595 Handle<HeapObject> GetHeapObject(); |
| 594 | 596 |
| 595 static int EntriesSize(int entries_count, | 597 static int EntriesSize(int entries_count, |
| 596 int children_count, | 598 int children_count, |
| 597 int retainers_count); | 599 int retainers_count); |
| 598 | 600 |
| 599 private: | 601 private: |
| 600 HeapGraphEdge* children_arr() { | 602 HeapGraphEdge* children_arr() { |
| 601 return reinterpret_cast<HeapGraphEdge*>(this + 1); | 603 return reinterpret_cast<HeapGraphEdge*>(this + 1); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 ~HeapSnapshot(); | 656 ~HeapSnapshot(); |
| 655 void Delete(); | 657 void Delete(); |
| 656 | 658 |
| 657 HeapSnapshotsCollection* collection() { return collection_; } | 659 HeapSnapshotsCollection* collection() { return collection_; } |
| 658 Type type() { return type_; } | 660 Type type() { return type_; } |
| 659 const char* title() { return title_; } | 661 const char* title() { return title_; } |
| 660 unsigned uid() { return uid_; } | 662 unsigned uid() { return uid_; } |
| 661 HeapEntry* root() { return root_entry_; } | 663 HeapEntry* root() { return root_entry_; } |
| 662 HeapEntry* gc_roots() { return gc_roots_entry_; } | 664 HeapEntry* gc_roots() { return gc_roots_entry_; } |
| 663 HeapEntry* natives_root() { return natives_root_entry_; } | 665 HeapEntry* natives_root() { return natives_root_entry_; } |
| 666 HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; } |
| 664 List<HeapEntry*>* entries() { return &entries_; } | 667 List<HeapEntry*>* entries() { return &entries_; } |
| 665 int raw_entries_size() { return raw_entries_size_; } | 668 int raw_entries_size() { return raw_entries_size_; } |
| 666 | 669 |
| 667 void AllocateEntries( | 670 void AllocateEntries( |
| 668 int entries_count, int children_count, int retainers_count); | 671 int entries_count, int children_count, int retainers_count); |
| 669 HeapEntry* AddEntry(HeapEntry::Type type, | 672 HeapEntry* AddEntry(HeapEntry::Type type, |
| 670 const char* name, | 673 const char* name, |
| 671 uint64_t id, | 674 uint64_t id, |
| 672 int size, | 675 int size, |
| 673 int children_count, | 676 int children_count, |
| 674 int retainers_count); | 677 int retainers_count); |
| 675 HeapEntry* AddRootEntry(int children_count); | 678 HeapEntry* AddRootEntry(int children_count); |
| 676 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); | 679 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); |
| 680 HeapEntry* AddGcSubrootEntry(int tag, |
| 681 int children_count, |
| 682 int retainers_count); |
| 677 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); | 683 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); |
| 678 void ClearPaint(); | 684 void ClearPaint(); |
| 679 HeapEntry* GetEntryById(uint64_t id); | 685 HeapEntry* GetEntryById(uint64_t id); |
| 680 List<HeapEntry*>* GetSortedEntriesList(); | 686 List<HeapEntry*>* GetSortedEntriesList(); |
| 681 template<class Visitor> | 687 template<class Visitor> |
| 682 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } | 688 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } |
| 683 void SetDominatorsToSelf(); | 689 void SetDominatorsToSelf(); |
| 684 | 690 |
| 685 void Print(int max_depth); | 691 void Print(int max_depth); |
| 686 void PrintEntriesSize(); | 692 void PrintEntriesSize(); |
| 687 | 693 |
| 688 private: | 694 private: |
| 689 HeapEntry* GetNextEntryToInit(); | 695 HeapEntry* GetNextEntryToInit(); |
| 690 | 696 |
| 691 HeapSnapshotsCollection* collection_; | 697 HeapSnapshotsCollection* collection_; |
| 692 Type type_; | 698 Type type_; |
| 693 const char* title_; | 699 const char* title_; |
| 694 unsigned uid_; | 700 unsigned uid_; |
| 695 HeapEntry* root_entry_; | 701 HeapEntry* root_entry_; |
| 696 HeapEntry* gc_roots_entry_; | 702 HeapEntry* gc_roots_entry_; |
| 697 HeapEntry* natives_root_entry_; | 703 HeapEntry* natives_root_entry_; |
| 704 HeapEntry* gc_subroot_entries_[VisitorSynchronization::kNumberOfSyncTags]; |
| 698 char* raw_entries_; | 705 char* raw_entries_; |
| 699 List<HeapEntry*> entries_; | 706 List<HeapEntry*> entries_; |
| 700 bool entries_sorted_; | 707 bool entries_sorted_; |
| 701 int raw_entries_size_; | 708 int raw_entries_size_; |
| 702 | 709 |
| 703 friend class HeapSnapshotTester; | 710 friend class HeapSnapshotTester; |
| 704 | 711 |
| 705 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); | 712 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); |
| 706 }; | 713 }; |
| 707 | 714 |
| 708 | 715 |
| 709 class HeapObjectsMap { | 716 class HeapObjectsMap { |
| 710 public: | 717 public: |
| 711 HeapObjectsMap(); | 718 HeapObjectsMap(); |
| 712 ~HeapObjectsMap(); | 719 ~HeapObjectsMap(); |
| 713 | 720 |
| 714 void SnapshotGenerationFinished(); | 721 void SnapshotGenerationFinished(); |
| 715 uint64_t FindObject(Address addr); | 722 uint64_t FindObject(Address addr); |
| 716 void MoveObject(Address from, Address to); | 723 void MoveObject(Address from, Address to); |
| 717 | 724 |
| 718 static uint64_t GenerateId(v8::RetainedObjectInfo* info); | 725 static uint64_t GenerateId(v8::RetainedObjectInfo* info); |
| 726 static inline uint64_t GetNthGcSubrootId(int delta); |
| 719 | 727 |
| 728 static const int kObjectIdStep = 2; |
| 720 static const uint64_t kInternalRootObjectId; | 729 static const uint64_t kInternalRootObjectId; |
| 721 static const uint64_t kGcRootsObjectId; | 730 static const uint64_t kGcRootsObjectId; |
| 722 static const uint64_t kNativesRootObjectId; | 731 static const uint64_t kNativesRootObjectId; |
| 732 static const uint64_t kGcRootsFirstSubrootId; |
| 723 static const uint64_t kFirstAvailableObjectId; | 733 static const uint64_t kFirstAvailableObjectId; |
| 724 | 734 |
| 725 private: | 735 private: |
| 726 struct EntryInfo { | 736 struct EntryInfo { |
| 727 explicit EntryInfo(uint64_t id) : id(id), accessed(true) { } | 737 explicit EntryInfo(uint64_t id) : id(id), accessed(true) { } |
| 728 EntryInfo(uint64_t id, bool accessed) : id(id), accessed(accessed) { } | 738 EntryInfo(uint64_t id, bool accessed) : id(id), accessed(accessed) { } |
| 729 uint64_t id; | 739 uint64_t id; |
| 730 bool accessed; | 740 bool accessed; |
| 731 }; | 741 }; |
| 732 | 742 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 int field_offset = -1); | 972 int field_offset = -1); |
| 963 void SetInternalReference(HeapObject* parent_obj, | 973 void SetInternalReference(HeapObject* parent_obj, |
| 964 HeapEntry* parent, | 974 HeapEntry* parent, |
| 965 int index, | 975 int index, |
| 966 Object* child, | 976 Object* child, |
| 967 int field_offset = -1); | 977 int field_offset = -1); |
| 968 void SetHiddenReference(HeapObject* parent_obj, | 978 void SetHiddenReference(HeapObject* parent_obj, |
| 969 HeapEntry* parent, | 979 HeapEntry* parent, |
| 970 int index, | 980 int index, |
| 971 Object* child); | 981 Object* child); |
| 982 void SetWeakReference(HeapObject* parent_obj, |
| 983 HeapEntry* parent_entry, |
| 984 int index, |
| 985 Object* child_obj, |
| 986 int field_offset); |
| 972 void SetPropertyReference(HeapObject* parent_obj, | 987 void SetPropertyReference(HeapObject* parent_obj, |
| 973 HeapEntry* parent, | 988 HeapEntry* parent, |
| 974 String* reference_name, | 989 String* reference_name, |
| 975 Object* child, | 990 Object* child, |
| 976 const char* name_format_string = NULL, | 991 const char* name_format_string = NULL, |
| 977 int field_offset = -1); | 992 int field_offset = -1); |
| 978 void SetPropertyShortcutReference(HeapObject* parent_obj, | 993 void SetPropertyShortcutReference(HeapObject* parent_obj, |
| 979 HeapEntry* parent, | 994 HeapEntry* parent, |
| 980 String* reference_name, | 995 String* reference_name, |
| 981 Object* child); | 996 Object* child); |
| 982 void SetRootShortcutReference(Object* child); | 997 void SetRootShortcutReference(Object* child); |
| 983 void SetRootGcRootsReference(); | 998 void SetRootGcRootsReference(); |
| 984 void SetGcRootsReference(Object* child); | 999 void SetGcRootsReference(VisitorSynchronization::SyncTag tag); |
| 1000 void SetGcSubrootReference( |
| 1001 VisitorSynchronization::SyncTag tag, bool is_weak, Object* child); |
| 985 void TagObject(Object* obj, const char* tag); | 1002 void TagObject(Object* obj, const char* tag); |
| 986 | 1003 |
| 987 HeapEntry* GetEntry(Object* obj); | 1004 HeapEntry* GetEntry(Object* obj); |
| 988 | 1005 |
| 1006 static inline HeapObject* GetNthGcSubrootObject(int delta); |
| 1007 static inline int GetGcSubrootOrder(HeapObject* subroot); |
| 1008 |
| 989 Heap* heap_; | 1009 Heap* heap_; |
| 990 HeapSnapshot* snapshot_; | 1010 HeapSnapshot* snapshot_; |
| 991 HeapSnapshotsCollection* collection_; | 1011 HeapSnapshotsCollection* collection_; |
| 992 SnapshottingProgressReportingInterface* progress_; | 1012 SnapshottingProgressReportingInterface* progress_; |
| 993 SnapshotFillerInterface* filler_; | 1013 SnapshotFillerInterface* filler_; |
| 994 HeapObjectsSet objects_tags_; | 1014 HeapObjectsSet objects_tags_; |
| 995 | 1015 |
| 996 static HeapObject* const kGcRootsObject; | 1016 static HeapObject* const kGcRootsObject; |
| 1017 static HeapObject* const kFirstGcSubrootObject; |
| 1018 static HeapObject* const kLastGcSubrootObject; |
| 997 | 1019 |
| 998 friend class IndexedReferencesExtractor; | 1020 friend class IndexedReferencesExtractor; |
| 1021 friend class GcSubrootsEnumerator; |
| 999 friend class RootsReferencesExtractor; | 1022 friend class RootsReferencesExtractor; |
| 1000 | 1023 |
| 1001 DISALLOW_COPY_AND_ASSIGN(V8HeapExplorer); | 1024 DISALLOW_COPY_AND_ASSIGN(V8HeapExplorer); |
| 1002 }; | 1025 }; |
| 1003 | 1026 |
| 1004 | 1027 |
| 1005 // An implementation of retained native objects extractor. | 1028 // An implementation of retained native objects extractor. |
| 1006 class NativeObjectsExplorer : public HeapEntriesAllocator { | 1029 class NativeObjectsExplorer : public HeapEntriesAllocator { |
| 1007 public: | 1030 public: |
| 1008 NativeObjectsExplorer(HeapSnapshot* snapshot, | 1031 NativeObjectsExplorer(HeapSnapshot* snapshot, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 | 1152 |
| 1130 friend class HeapSnapshotJSONSerializerEnumerator; | 1153 friend class HeapSnapshotJSONSerializerEnumerator; |
| 1131 friend class HeapSnapshotJSONSerializerIterator; | 1154 friend class HeapSnapshotJSONSerializerIterator; |
| 1132 | 1155 |
| 1133 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 1156 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 1134 }; | 1157 }; |
| 1135 | 1158 |
| 1136 } } // namespace v8::internal | 1159 } } // namespace v8::internal |
| 1137 | 1160 |
| 1138 #endif // V8_PROFILE_GENERATOR_H_ | 1161 #endif // V8_PROFILE_GENERATOR_H_ |
| OLD | NEW |