OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_ | 5 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_ |
6 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ | 6 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ |
7 | 7 |
8 #include "src/strings-storage.h" | 8 #include "src/strings-storage.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 }; | 134 }; |
135 | 135 |
136 | 136 |
137 // HeapSnapshot represents a single heap snapshot. It is stored in | 137 // HeapSnapshot represents a single heap snapshot. It is stored in |
138 // HeapProfiler, which is also a factory for | 138 // HeapProfiler, which is also a factory for |
139 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap | 139 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap |
140 // to be able to return them even if they were collected. | 140 // to be able to return them even if they were collected. |
141 // HeapSnapshotGenerator fills in a HeapSnapshot. | 141 // HeapSnapshotGenerator fills in a HeapSnapshot. |
142 class HeapSnapshot { | 142 class HeapSnapshot { |
143 public: | 143 public: |
144 HeapSnapshot(HeapProfiler* profiler, | 144 explicit HeapSnapshot(HeapProfiler* profiler); |
145 const char* title, | |
146 unsigned uid); | |
147 void Delete(); | 145 void Delete(); |
148 | 146 |
149 HeapProfiler* profiler() { return profiler_; } | 147 HeapProfiler* profiler() { return profiler_; } |
150 const char* title() { return title_; } | |
151 unsigned uid() { return uid_; } | |
152 size_t RawSnapshotSize() const; | 148 size_t RawSnapshotSize() const; |
153 HeapEntry* root() { return &entries_[root_index_]; } | 149 HeapEntry* root() { return &entries_[root_index_]; } |
154 HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; } | 150 HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; } |
155 HeapEntry* gc_subroot(int index) { | 151 HeapEntry* gc_subroot(int index) { |
156 return &entries_[gc_subroot_indexes_[index]]; | 152 return &entries_[gc_subroot_indexes_[index]]; |
157 } | 153 } |
158 List<HeapEntry>& entries() { return entries_; } | 154 List<HeapEntry>& entries() { return entries_; } |
159 List<HeapGraphEdge>& edges() { return edges_; } | 155 List<HeapGraphEdge>& edges() { return edges_; } |
160 List<HeapGraphEdge*>& children() { return children_; } | 156 List<HeapGraphEdge*>& children() { return children_; } |
161 void RememberLastJSObjectId(); | 157 void RememberLastJSObjectId(); |
(...skipping 12 matching lines...) Expand all Loading... |
174 void FillChildren(); | 170 void FillChildren(); |
175 | 171 |
176 void Print(int max_depth); | 172 void Print(int max_depth); |
177 | 173 |
178 private: | 174 private: |
179 HeapEntry* AddRootEntry(); | 175 HeapEntry* AddRootEntry(); |
180 HeapEntry* AddGcRootsEntry(); | 176 HeapEntry* AddGcRootsEntry(); |
181 HeapEntry* AddGcSubrootEntry(int tag, SnapshotObjectId id); | 177 HeapEntry* AddGcSubrootEntry(int tag, SnapshotObjectId id); |
182 | 178 |
183 HeapProfiler* profiler_; | 179 HeapProfiler* profiler_; |
184 const char* title_; | |
185 unsigned uid_; | |
186 int root_index_; | 180 int root_index_; |
187 int gc_roots_index_; | 181 int gc_roots_index_; |
188 int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags]; | 182 int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags]; |
189 List<HeapEntry> entries_; | 183 List<HeapEntry> entries_; |
190 List<HeapGraphEdge> edges_; | 184 List<HeapGraphEdge> edges_; |
191 List<HeapGraphEdge*> children_; | 185 List<HeapGraphEdge*> children_; |
192 List<HeapEntry*> sorted_entries_; | 186 List<HeapEntry*> sorted_entries_; |
193 SnapshotObjectId max_snapshot_js_object_id_; | 187 SnapshotObjectId max_snapshot_js_object_id_; |
194 | 188 |
195 friend class HeapSnapshotTester; | 189 friend class HeapSnapshotTester; |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 friend class HeapSnapshotJSONSerializerEnumerator; | 599 friend class HeapSnapshotJSONSerializerEnumerator; |
606 friend class HeapSnapshotJSONSerializerIterator; | 600 friend class HeapSnapshotJSONSerializerIterator; |
607 | 601 |
608 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 602 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
609 }; | 603 }; |
610 | 604 |
611 | 605 |
612 } } // namespace v8::internal | 606 } } // namespace v8::internal |
613 | 607 |
614 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ | 608 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ |
OLD | NEW |