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 630 matching lines...) Loading... |
641 HeapSnapshotsCollection* collection() { return collection_; } | 641 HeapSnapshotsCollection* collection() { return collection_; } |
642 Type type() { return type_; } | 642 Type type() { return type_; } |
643 const char* title() { return title_; } | 643 const char* title() { return title_; } |
644 unsigned uid() { return uid_; } | 644 unsigned uid() { return uid_; } |
645 HeapEntry* root() { return root_entry_; } | 645 HeapEntry* root() { return root_entry_; } |
646 HeapEntry* gc_roots() { return gc_roots_entry_; } | 646 HeapEntry* gc_roots() { return gc_roots_entry_; } |
647 HeapEntry* natives_root() { return natives_root_entry_; } | 647 HeapEntry* natives_root() { return natives_root_entry_; } |
648 HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; } | 648 HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; } |
649 List<HeapEntry*>* entries() { return &entries_; } | 649 List<HeapEntry*>* entries() { return &entries_; } |
650 size_t raw_entries_size() { return raw_entries_size_; } | 650 size_t raw_entries_size() { return raw_entries_size_; } |
| 651 int number_of_edges() { return number_of_edges_; } |
651 void RememberLastJSObjectId(); | 652 void RememberLastJSObjectId(); |
652 SnapshotObjectId max_snapshot_js_object_id() const { | 653 SnapshotObjectId max_snapshot_js_object_id() const { |
653 return max_snapshot_js_object_id_; | 654 return max_snapshot_js_object_id_; |
654 } | 655 } |
655 | 656 |
656 void AllocateEntries( | 657 void AllocateEntries( |
657 int entries_count, int children_count, int retainers_count); | 658 int entries_count, int children_count, int retainers_count); |
658 HeapEntry* AddEntry(HeapEntry::Type type, | 659 HeapEntry* AddEntry(HeapEntry::Type type, |
659 const char* name, | 660 const char* name, |
660 SnapshotObjectId id, | 661 SnapshotObjectId id, |
(...skipping 22 matching lines...) Loading... |
683 const char* title_; | 684 const char* title_; |
684 unsigned uid_; | 685 unsigned uid_; |
685 HeapEntry* root_entry_; | 686 HeapEntry* root_entry_; |
686 HeapEntry* gc_roots_entry_; | 687 HeapEntry* gc_roots_entry_; |
687 HeapEntry* natives_root_entry_; | 688 HeapEntry* natives_root_entry_; |
688 HeapEntry* gc_subroot_entries_[VisitorSynchronization::kNumberOfSyncTags]; | 689 HeapEntry* gc_subroot_entries_[VisitorSynchronization::kNumberOfSyncTags]; |
689 char* raw_entries_; | 690 char* raw_entries_; |
690 List<HeapEntry*> entries_; | 691 List<HeapEntry*> entries_; |
691 List<HeapEntry*> sorted_entries_; | 692 List<HeapEntry*> sorted_entries_; |
692 size_t raw_entries_size_; | 693 size_t raw_entries_size_; |
| 694 int number_of_edges_; |
693 SnapshotObjectId max_snapshot_js_object_id_; | 695 SnapshotObjectId max_snapshot_js_object_id_; |
694 | 696 |
695 friend class HeapSnapshotTester; | 697 friend class HeapSnapshotTester; |
696 | 698 |
697 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); | 699 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); |
698 }; | 700 }; |
699 | 701 |
700 | 702 |
701 class HeapObjectsMap { | 703 class HeapObjectsMap { |
702 public: | 704 public: |
(...skipping 433 matching lines...) Loading... |
1136 INLINE(static bool ObjectsMatch(void* key1, void* key2)) { | 1138 INLINE(static bool ObjectsMatch(void* key1, void* key2)) { |
1137 return key1 == key2; | 1139 return key1 == key2; |
1138 } | 1140 } |
1139 | 1141 |
1140 INLINE(static uint32_t ObjectHash(const void* key)) { | 1142 INLINE(static uint32_t ObjectHash(const void* key)) { |
1141 return ComputeIntegerHash( | 1143 return ComputeIntegerHash( |
1142 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key)), | 1144 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key)), |
1143 v8::internal::kZeroHashSeed); | 1145 v8::internal::kZeroHashSeed); |
1144 } | 1146 } |
1145 | 1147 |
| 1148 void CalculateNodeIndexes(const List<HeapEntry*>& nodes); |
1146 HeapSnapshot* CreateFakeSnapshot(); | 1149 HeapSnapshot* CreateFakeSnapshot(); |
1147 int GetStringId(const char* s); | 1150 int GetStringId(const char* s); |
1148 void SerializeEdge(HeapGraphEdge* edge); | 1151 void SerializeEdge(HeapGraphEdge* edge, bool first_edge); |
| 1152 void SerializeEdges(const List<HeapEntry*>& nodes); |
1149 void SerializeImpl(); | 1153 void SerializeImpl(); |
1150 void SerializeNode(HeapEntry* entry); | 1154 void SerializeNode(HeapEntry* entry, int edges_index); |
1151 void SerializeNodes(); | 1155 void SerializeNodes(const List<HeapEntry*>& nodes); |
1152 void SerializeSnapshot(); | 1156 void SerializeSnapshot(); |
1153 void SerializeString(const unsigned char* s); | 1157 void SerializeString(const unsigned char* s); |
1154 void SerializeStrings(); | 1158 void SerializeStrings(); |
1155 void SortHashMap(HashMap* map, List<HashMap::Entry*>* sorted_entries); | 1159 void SortHashMap(HashMap* map, List<HashMap::Entry*>* sorted_entries); |
1156 | 1160 |
1157 static const int kMaxSerializableSnapshotRawSize; | 1161 static const int kMaxSerializableSnapshotRawSize; |
1158 | 1162 |
1159 HeapSnapshot* snapshot_; | 1163 HeapSnapshot* snapshot_; |
1160 HashMap strings_; | 1164 HashMap strings_; |
1161 int next_node_id_; | 1165 int next_node_id_; |
1162 int next_string_id_; | 1166 int next_string_id_; |
1163 OutputStreamWriter* writer_; | 1167 OutputStreamWriter* writer_; |
1164 | 1168 |
1165 friend class HeapSnapshotJSONSerializerEnumerator; | 1169 friend class HeapSnapshotJSONSerializerEnumerator; |
1166 friend class HeapSnapshotJSONSerializerIterator; | 1170 friend class HeapSnapshotJSONSerializerIterator; |
1167 | 1171 |
1168 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 1172 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
1169 }; | 1173 }; |
1170 | 1174 |
1171 } } // namespace v8::internal | 1175 } } // namespace v8::internal |
1172 | 1176 |
1173 #endif // V8_PROFILE_GENERATOR_H_ | 1177 #endif // V8_PROFILE_GENERATOR_H_ |
OLD | NEW |