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

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

Issue 10012013: Get rid of HeapEntry to ID map in heap profile serializer (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: 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 | « no previous file | 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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 Type type() { return static_cast<Type>(type_); } 542 Type type() { return static_cast<Type>(type_); }
543 const char* name() { return name_; } 543 const char* name() { return name_; }
544 void set_name(const char* name) { name_ = name; } 544 void set_name(const char* name) { name_ = name; }
545 inline SnapshotObjectId id() { return id_; } 545 inline SnapshotObjectId id() { return id_; }
546 int self_size() { return self_size_; } 546 int self_size() { return self_size_; }
547 int retained_size() { return retained_size_; } 547 int retained_size() { return retained_size_; }
548 void add_retained_size(int size) { retained_size_ += size; } 548 void add_retained_size(int size) { retained_size_ += size; }
549 void set_retained_size(int value) { retained_size_ = value; } 549 void set_retained_size(int value) { retained_size_ = value; }
550 int ordered_index() { return ordered_index_; } 550 int ordered_index() { return ordered_index_; }
551 void set_ordered_index(int value) { ordered_index_ = value; } 551 void set_ordered_index(int value) { ordered_index_ = value; }
552 int entry_index() { return entry_index_; }
553 void set_entry_index(int value) { entry_index_ = value; }
552 554
553 Vector<HeapGraphEdge> children() { 555 Vector<HeapGraphEdge> children() {
554 return Vector<HeapGraphEdge>(children_arr(), children_count_); } 556 return Vector<HeapGraphEdge>(children_arr(), children_count_); }
555 Vector<HeapGraphEdge*> retainers() { 557 Vector<HeapGraphEdge*> retainers() {
556 return Vector<HeapGraphEdge*>(retainers_arr(), retainers_count_); } 558 return Vector<HeapGraphEdge*>(retainers_arr(), retainers_count_); }
557 HeapEntry* dominator() { return dominator_; } 559 HeapEntry* dominator() { return dominator_; }
558 void set_dominator(HeapEntry* entry) { 560 void set_dominator(HeapEntry* entry) {
559 ASSERT(entry != NULL); 561 ASSERT(entry != NULL);
560 dominator_ = entry; 562 dominator_ = entry;
561 } 563 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 601
600 unsigned painted_: 1; 602 unsigned painted_: 1;
601 unsigned type_: 4; 603 unsigned type_: 4;
602 int children_count_: 27; 604 int children_count_: 27;
603 int retainers_count_; 605 int retainers_count_;
604 int self_size_; 606 int self_size_;
605 union { 607 union {
606 int ordered_index_; // Used during dominator tree building. 608 int ordered_index_; // Used during dominator tree building.
607 int retained_size_; // At that moment, there is no retained size yet. 609 int retained_size_; // At that moment, there is no retained size yet.
608 }; 610 };
611 int entry_index_;
609 SnapshotObjectId id_; 612 SnapshotObjectId id_;
610 HeapEntry* dominator_; 613 HeapEntry* dominator_;
611 HeapSnapshot* snapshot_; 614 HeapSnapshot* snapshot_;
612 const char* name_; 615 const char* name_;
613 616
614 DISALLOW_COPY_AND_ASSIGN(HeapEntry); 617 DISALLOW_COPY_AND_ASSIGN(HeapEntry);
615 }; 618 };
616 619
617 620
618 class HeapSnapshotsCollection; 621 class HeapSnapshotsCollection;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 int retainers_count); 663 int retainers_count);
661 HeapEntry* AddRootEntry(int children_count); 664 HeapEntry* AddRootEntry(int children_count);
662 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); 665 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count);
663 HeapEntry* AddGcSubrootEntry(int tag, 666 HeapEntry* AddGcSubrootEntry(int tag,
664 int children_count, 667 int children_count,
665 int retainers_count); 668 int retainers_count);
666 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); 669 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count);
667 void ClearPaint(); 670 void ClearPaint();
668 HeapEntry* GetEntryById(SnapshotObjectId id); 671 HeapEntry* GetEntryById(SnapshotObjectId id);
669 List<HeapEntry*>* GetSortedEntriesList(); 672 List<HeapEntry*>* GetSortedEntriesList();
670 template<class Visitor>
671 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); }
672 void SetDominatorsToSelf(); 673 void SetDominatorsToSelf();
673 674
674 void Print(int max_depth); 675 void Print(int max_depth);
675 void PrintEntriesSize(); 676 void PrintEntriesSize();
676 677
677 private: 678 private:
678 HeapEntry* GetNextEntryToInit(); 679 HeapEntry* GetNextEntryToInit();
679 680
680 HeapSnapshotsCollection* collection_; 681 HeapSnapshotsCollection* collection_;
681 Type type_; 682 Type type_;
682 const char* title_; 683 const char* title_;
683 unsigned uid_; 684 unsigned uid_;
684 HeapEntry* root_entry_; 685 HeapEntry* root_entry_;
685 HeapEntry* gc_roots_entry_; 686 HeapEntry* gc_roots_entry_;
686 HeapEntry* natives_root_entry_; 687 HeapEntry* natives_root_entry_;
687 HeapEntry* gc_subroot_entries_[VisitorSynchronization::kNumberOfSyncTags]; 688 HeapEntry* gc_subroot_entries_[VisitorSynchronization::kNumberOfSyncTags];
688 char* raw_entries_; 689 char* raw_entries_;
689 List<HeapEntry*> entries_; 690 List<HeapEntry*> entries_;
690 bool entries_sorted_; 691 List<HeapEntry*> sorted_entries_;
691 size_t raw_entries_size_; 692 size_t raw_entries_size_;
692 SnapshotObjectId max_snapshot_js_object_id_; 693 SnapshotObjectId max_snapshot_js_object_id_;
693 694
694 friend class HeapSnapshotTester; 695 friend class HeapSnapshotTester;
695 696
696 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); 697 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot);
697 }; 698 };
698 699
699 700
700 class HeapObjectsMap { 701 class HeapObjectsMap {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 }; 809 };
809 810
810 811
811 // The HeapEntriesMap instance is used to track a mapping between 812 // The HeapEntriesMap instance is used to track a mapping between
812 // real heap objects and their representations in heap snapshots. 813 // real heap objects and their representations in heap snapshots.
813 class HeapEntriesMap { 814 class HeapEntriesMap {
814 public: 815 public:
815 HeapEntriesMap(); 816 HeapEntriesMap();
816 ~HeapEntriesMap(); 817 ~HeapEntriesMap();
817 818
818 void AllocateEntries(); 819 void AllocateEntries(HeapThing root_object);
819 HeapEntry* Map(HeapThing thing); 820 HeapEntry* Map(HeapThing thing);
820 void Pair(HeapThing thing, HeapEntriesAllocator* allocator, HeapEntry* entry); 821 void Pair(HeapThing thing, HeapEntriesAllocator* allocator, HeapEntry* entry);
821 void CountReference(HeapThing from, HeapThing to, 822 void CountReference(HeapThing from, HeapThing to,
822 int* prev_children_count = NULL, 823 int* prev_children_count = NULL,
823 int* prev_retainers_count = NULL); 824 int* prev_retainers_count = NULL);
824 825
825 int entries_count() { return entries_count_; } 826 int entries_count() { return entries_count_; }
826 int total_children_count() { return total_children_count_; } 827 int total_children_count() { return total_children_count_; }
827 int total_retainers_count() { return total_retainers_count_; } 828 int total_retainers_count() { return total_retainers_count_; }
828 829
829 static HeapEntry* const kHeapEntryPlaceholder; 830 static HeapEntry* const kHeapEntryPlaceholder;
830 831
831 private: 832 private:
832 struct EntryInfo { 833 struct EntryInfo {
833 EntryInfo(HeapEntry* entry, HeapEntriesAllocator* allocator) 834 EntryInfo(HeapEntry* entry, HeapEntriesAllocator* allocator)
834 : entry(entry), 835 : entry(entry),
835 allocator(allocator), 836 allocator(allocator),
836 children_count(0), 837 children_count(0),
837 retainers_count(0) { 838 retainers_count(0) {
838 } 839 }
839 HeapEntry* entry; 840 HeapEntry* entry;
840 HeapEntriesAllocator* allocator; 841 HeapEntriesAllocator* allocator;
841 int children_count; 842 int children_count;
842 int retainers_count; 843 int retainers_count;
843 }; 844 };
844 845
846 static inline void AllocateHeapEntryForMapEntry(HashMap::Entry* map_entry);
847
845 static uint32_t Hash(HeapThing thing) { 848 static uint32_t Hash(HeapThing thing) {
846 return ComputeIntegerHash( 849 return ComputeIntegerHash(
847 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(thing)), 850 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(thing)),
848 v8::internal::kZeroHashSeed); 851 v8::internal::kZeroHashSeed);
849 } 852 }
850 static bool HeapThingsMatch(HeapThing key1, HeapThing key2) { 853 static bool HeapThingsMatch(HeapThing key1, HeapThing key2) {
851 return key1 == key2; 854 return key1 == key2;
852 } 855 }
853 856
854 HashMap entries_; 857 HashMap entries_;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 1118
1116 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator); 1119 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator);
1117 }; 1120 };
1118 1121
1119 class OutputStreamWriter; 1122 class OutputStreamWriter;
1120 1123
1121 class HeapSnapshotJSONSerializer { 1124 class HeapSnapshotJSONSerializer {
1122 public: 1125 public:
1123 explicit HeapSnapshotJSONSerializer(HeapSnapshot* snapshot) 1126 explicit HeapSnapshotJSONSerializer(HeapSnapshot* snapshot)
1124 : snapshot_(snapshot), 1127 : snapshot_(snapshot),
1125 nodes_(ObjectsMatch),
1126 strings_(ObjectsMatch), 1128 strings_(ObjectsMatch),
1127 next_node_id_(1), 1129 next_node_id_(1),
1128 next_string_id_(1), 1130 next_string_id_(1),
1129 writer_(NULL) { 1131 writer_(NULL) {
1130 } 1132 }
1131 void Serialize(v8::OutputStream* stream); 1133 void Serialize(v8::OutputStream* stream);
1132 1134
1133 private: 1135 private:
1134 INLINE(static bool ObjectsMatch(void* key1, void* key2)) { 1136 INLINE(static bool ObjectsMatch(void* key1, void* key2)) {
1135 return key1 == key2; 1137 return key1 == key2;
1136 } 1138 }
1137 1139
1138 INLINE(static uint32_t ObjectHash(const void* key)) { 1140 INLINE(static uint32_t ObjectHash(const void* key)) {
1139 return ComputeIntegerHash( 1141 return ComputeIntegerHash(
1140 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key)), 1142 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key)),
1141 v8::internal::kZeroHashSeed); 1143 v8::internal::kZeroHashSeed);
1142 } 1144 }
1143 1145
1144 void EnumerateNodes();
1145 HeapSnapshot* CreateFakeSnapshot(); 1146 HeapSnapshot* CreateFakeSnapshot();
1146 int GetNodeId(HeapEntry* entry);
1147 int GetStringId(const char* s); 1147 int GetStringId(const char* s);
1148 void SerializeEdge(HeapGraphEdge* edge); 1148 void SerializeEdge(HeapGraphEdge* edge);
1149 void SerializeImpl(); 1149 void SerializeImpl();
1150 void SerializeNode(HeapEntry* entry); 1150 void SerializeNode(HeapEntry* entry);
1151 void SerializeNodes(); 1151 void SerializeNodes();
1152 void SerializeSnapshot(); 1152 void SerializeSnapshot();
1153 void SerializeString(const unsigned char* s); 1153 void SerializeString(const unsigned char* s);
1154 void SerializeStrings(); 1154 void SerializeStrings();
1155 void SortHashMap(HashMap* map, List<HashMap::Entry*>* sorted_entries); 1155 void SortHashMap(HashMap* map, List<HashMap::Entry*>* sorted_entries);
1156 1156
1157 static const int kMaxSerializableSnapshotRawSize; 1157 static const int kMaxSerializableSnapshotRawSize;
1158 1158
1159 HeapSnapshot* snapshot_; 1159 HeapSnapshot* snapshot_;
1160 HashMap nodes_;
1161 HashMap strings_; 1160 HashMap strings_;
1162 int next_node_id_; 1161 int next_node_id_;
1163 int next_string_id_; 1162 int next_string_id_;
1164 OutputStreamWriter* writer_; 1163 OutputStreamWriter* writer_;
1165 1164
1166 friend class HeapSnapshotJSONSerializerEnumerator; 1165 friend class HeapSnapshotJSONSerializerEnumerator;
1167 friend class HeapSnapshotJSONSerializerIterator; 1166 friend class HeapSnapshotJSONSerializerIterator;
1168 1167
1169 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 1168 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
1170 }; 1169 };
1171 1170
1172 } } // namespace v8::internal 1171 } } // namespace v8::internal
1173 1172
1174 #endif // V8_PROFILE_GENERATOR_H_ 1173 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« no previous file with comments | « no previous file | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698