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

Side by Side Diff: src/heap-snapshot-generator.h

Issue 136643008: A64: Synchronize with r18256. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | « src/heap-profiler.cc ('k') | src/heap-snapshot-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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 unsigned type_: 4; 147 unsigned type_: 4;
148 int children_count_: 28; 148 int children_count_: 28;
149 int children_index_; 149 int children_index_;
150 int self_size_; 150 int self_size_;
151 SnapshotObjectId id_; 151 SnapshotObjectId id_;
152 HeapSnapshot* snapshot_; 152 HeapSnapshot* snapshot_;
153 const char* name_; 153 const char* name_;
154 }; 154 };
155 155
156 156
157 class HeapSnapshotsCollection;
158
159 // HeapSnapshot represents a single heap snapshot. It is stored in 157 // HeapSnapshot represents a single heap snapshot. It is stored in
160 // HeapSnapshotsCollection, which is also a factory for 158 // HeapProfiler, which is also a factory for
161 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap 159 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap
162 // to be able to return them even if they were collected. 160 // to be able to return them even if they were collected.
163 // HeapSnapshotGenerator fills in a HeapSnapshot. 161 // HeapSnapshotGenerator fills in a HeapSnapshot.
164 class HeapSnapshot { 162 class HeapSnapshot {
165 public: 163 public:
166 HeapSnapshot(HeapSnapshotsCollection* collection, 164 HeapSnapshot(HeapProfiler* profiler,
167 const char* title, 165 const char* title,
168 unsigned uid); 166 unsigned uid);
169 void Delete(); 167 void Delete();
170 168
171 HeapSnapshotsCollection* collection() { return collection_; } 169 HeapProfiler* profiler() { return profiler_; }
172 const char* title() { return title_; } 170 const char* title() { return title_; }
173 unsigned uid() { return uid_; } 171 unsigned uid() { return uid_; }
174 size_t RawSnapshotSize() const; 172 size_t RawSnapshotSize() const;
175 HeapEntry* root() { return &entries_[root_index_]; } 173 HeapEntry* root() { return &entries_[root_index_]; }
176 HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; } 174 HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; }
177 HeapEntry* natives_root() { return &entries_[natives_root_index_]; } 175 HeapEntry* natives_root() { return &entries_[natives_root_index_]; }
178 HeapEntry* gc_subroot(int index) { 176 HeapEntry* gc_subroot(int index) {
179 return &entries_[gc_subroot_indexes_[index]]; 177 return &entries_[gc_subroot_indexes_[index]];
180 } 178 }
181 List<HeapEntry>& entries() { return entries_; } 179 List<HeapEntry>& entries() { return entries_; }
(...skipping 13 matching lines...) Expand all
195 HeapEntry* AddGcSubrootEntry(int tag); 193 HeapEntry* AddGcSubrootEntry(int tag);
196 HeapEntry* AddNativesRootEntry(); 194 HeapEntry* AddNativesRootEntry();
197 HeapEntry* GetEntryById(SnapshotObjectId id); 195 HeapEntry* GetEntryById(SnapshotObjectId id);
198 List<HeapEntry*>* GetSortedEntriesList(); 196 List<HeapEntry*>* GetSortedEntriesList();
199 void FillChildren(); 197 void FillChildren();
200 198
201 void Print(int max_depth); 199 void Print(int max_depth);
202 void PrintEntriesSize(); 200 void PrintEntriesSize();
203 201
204 private: 202 private:
205 HeapSnapshotsCollection* collection_; 203 HeapProfiler* profiler_;
206 const char* title_; 204 const char* title_;
207 unsigned uid_; 205 unsigned uid_;
208 int root_index_; 206 int root_index_;
209 int gc_roots_index_; 207 int gc_roots_index_;
210 int natives_root_index_; 208 int natives_root_index_;
211 int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags]; 209 int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags];
212 List<HeapEntry> entries_; 210 List<HeapEntry> entries_;
213 List<HeapGraphEdge> edges_; 211 List<HeapGraphEdge> edges_;
214 List<HeapGraphEdge*> children_; 212 List<HeapGraphEdge*> children_;
215 List<HeapEntry*> sorted_entries_; 213 List<HeapEntry*> sorted_entries_;
216 SnapshotObjectId max_snapshot_js_object_id_; 214 SnapshotObjectId max_snapshot_js_object_id_;
217 215
218 friend class HeapSnapshotTester; 216 friend class HeapSnapshotTester;
219 217
220 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); 218 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot);
221 }; 219 };
222 220
223 221
224 class HeapObjectsMap { 222 class HeapObjectsMap {
225 public: 223 public:
226 explicit HeapObjectsMap(Heap* heap); 224 explicit HeapObjectsMap(Heap* heap);
227 225
228 Heap* heap() const { return heap_; } 226 Heap* heap() const { return heap_; }
229 227
230 void SnapshotGenerationFinished();
231 SnapshotObjectId FindEntry(Address addr); 228 SnapshotObjectId FindEntry(Address addr);
232 SnapshotObjectId FindOrAddEntry(Address addr, 229 SnapshotObjectId FindOrAddEntry(Address addr,
233 unsigned int size, 230 unsigned int size,
234 bool accessed = true); 231 bool accessed = true);
235 void MoveObject(Address from, Address to, int size); 232 void MoveObject(Address from, Address to, int size);
236 void NewObject(Address addr, int size);
237 void UpdateObjectSize(Address addr, int size); 233 void UpdateObjectSize(Address addr, int size);
238 SnapshotObjectId last_assigned_id() const { 234 SnapshotObjectId last_assigned_id() const {
239 return next_id_ - kObjectIdStep; 235 return next_id_ - kObjectIdStep;
240 } 236 }
241 237
242 void StopHeapObjectsTracking(); 238 void StopHeapObjectsTracking();
243 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); 239 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
244 size_t GetUsedMemorySize() const; 240 size_t GetUsedMemorySize() const;
245 241
246 static SnapshotObjectId GenerateId(Heap* heap, v8::RetainedObjectInfo* info); 242 SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info);
247 static inline SnapshotObjectId GetNthGcSubrootId(int delta); 243 static inline SnapshotObjectId GetNthGcSubrootId(int delta);
248 244
249 static const int kObjectIdStep = 2; 245 static const int kObjectIdStep = 2;
250 static const SnapshotObjectId kInternalRootObjectId; 246 static const SnapshotObjectId kInternalRootObjectId;
251 static const SnapshotObjectId kGcRootsObjectId; 247 static const SnapshotObjectId kGcRootsObjectId;
252 static const SnapshotObjectId kNativesRootObjectId; 248 static const SnapshotObjectId kNativesRootObjectId;
253 static const SnapshotObjectId kGcRootsFirstSubrootId; 249 static const SnapshotObjectId kGcRootsFirstSubrootId;
254 static const SnapshotObjectId kFirstAvailableObjectId; 250 static const SnapshotObjectId kFirstAvailableObjectId;
255 251
256 int FindUntrackedObjects(); 252 int FindUntrackedObjects();
257 253
258 void UpdateHeapObjectsMap(); 254 void UpdateHeapObjectsMap();
255 void RemoveDeadEntries();
259 256
260 private: 257 private:
261 struct EntryInfo { 258 struct EntryInfo {
262 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size) 259 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size)
263 : id(id), addr(addr), size(size), accessed(true) { } 260 : id(id), addr(addr), size(size), accessed(true) { }
264 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed) 261 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed)
265 : id(id), addr(addr), size(size), accessed(accessed) { } 262 : id(id), addr(addr), size(size), accessed(accessed) { }
266 SnapshotObjectId id; 263 SnapshotObjectId id;
267 Address addr; 264 Address addr;
268 unsigned int size; 265 unsigned int size;
269 bool accessed; 266 bool accessed;
270 }; 267 };
271 struct TimeInterval { 268 struct TimeInterval {
272 explicit TimeInterval(SnapshotObjectId id) : id(id), size(0), count(0) { } 269 explicit TimeInterval(SnapshotObjectId id) : id(id), size(0), count(0) { }
273 SnapshotObjectId id; 270 SnapshotObjectId id;
274 uint32_t size; 271 uint32_t size;
275 uint32_t count; 272 uint32_t count;
276 }; 273 };
277 274
278 void RemoveDeadEntries();
279
280 SnapshotObjectId next_id_; 275 SnapshotObjectId next_id_;
281 HashMap entries_map_; 276 HashMap entries_map_;
282 List<EntryInfo> entries_; 277 List<EntryInfo> entries_;
283 List<TimeInterval> time_intervals_; 278 List<TimeInterval> time_intervals_;
284 Heap* heap_; 279 Heap* heap_;
285 280
286 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); 281 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap);
287 }; 282 };
288 283
289 284
290 class HeapSnapshotsCollection {
291 public:
292 explicit HeapSnapshotsCollection(Heap* heap);
293 ~HeapSnapshotsCollection();
294
295 Heap* heap() const { return ids_.heap(); }
296
297 bool is_tracking_objects() { return is_tracking_objects_; }
298 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream) {
299 return ids_.PushHeapObjectsStats(stream);
300 }
301 void StartHeapObjectsTracking();
302 void StopHeapObjectsTracking();
303
304 HeapSnapshot* NewSnapshot(const char* name, unsigned uid);
305 void SnapshotGenerationFinished(HeapSnapshot* snapshot);
306 List<HeapSnapshot*>* snapshots() { return &snapshots_; }
307 void RemoveSnapshot(HeapSnapshot* snapshot);
308
309 StringsStorage* names() { return &names_; }
310 AllocationTracker* allocation_tracker() { return allocation_tracker_; }
311
312 SnapshotObjectId FindObjectId(Address object_addr) {
313 return ids_.FindEntry(object_addr);
314 }
315 SnapshotObjectId GetObjectId(Address object_addr, int object_size) {
316 return ids_.FindOrAddEntry(object_addr, object_size);
317 }
318 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
319 void ObjectMoveEvent(Address from, Address to, int size) {
320 ids_.MoveObject(from, to, size);
321 }
322 void NewObjectEvent(Address addr, int size);
323 void UpdateObjectSizeEvent(Address addr, int size) {
324 ids_.UpdateObjectSize(addr, size);
325 }
326 SnapshotObjectId last_assigned_id() const {
327 return ids_.last_assigned_id();
328 }
329 size_t GetUsedMemorySize() const;
330
331 int FindUntrackedObjects() { return ids_.FindUntrackedObjects(); }
332
333 void UpdateHeapObjectsMap() { ids_.UpdateHeapObjectsMap(); }
334
335 private:
336 bool is_tracking_objects_; // Whether tracking object moves is needed.
337 List<HeapSnapshot*> snapshots_;
338 StringsStorage names_;
339 // Mapping from HeapObject addresses to objects' uids.
340 HeapObjectsMap ids_;
341 AllocationTracker* allocation_tracker_;
342
343 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection);
344 };
345
346
347 // A typedef for referencing anything that can be snapshotted living 285 // A typedef for referencing anything that can be snapshotted living
348 // in any kind of heap memory. 286 // in any kind of heap memory.
349 typedef void* HeapThing; 287 typedef void* HeapThing;
350 288
351 289
352 // An interface that creates HeapEntries by HeapThings. 290 // An interface that creates HeapEntries by HeapThings.
353 class HeapEntriesAllocator { 291 class HeapEntriesAllocator {
354 public: 292 public:
355 virtual ~HeapEntriesAllocator() { } 293 virtual ~HeapEntriesAllocator() { }
356 virtual HeapEntry* AllocateEntry(HeapThing ptr) = 0; 294 virtual HeapEntry* AllocateEntry(HeapThing ptr) = 0;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 const char* GetStrongGcSubrootName(Object* object); 467 const char* GetStrongGcSubrootName(Object* object);
530 void TagObject(Object* obj, const char* tag); 468 void TagObject(Object* obj, const char* tag);
531 469
532 HeapEntry* GetEntry(Object* obj); 470 HeapEntry* GetEntry(Object* obj);
533 471
534 static inline HeapObject* GetNthGcSubrootObject(int delta); 472 static inline HeapObject* GetNthGcSubrootObject(int delta);
535 static inline int GetGcSubrootOrder(HeapObject* subroot); 473 static inline int GetGcSubrootOrder(HeapObject* subroot);
536 474
537 Heap* heap_; 475 Heap* heap_;
538 HeapSnapshot* snapshot_; 476 HeapSnapshot* snapshot_;
539 HeapSnapshotsCollection* collection_; 477 StringsStorage* names_;
478 HeapObjectsMap* heap_object_map_;
540 SnapshottingProgressReportingInterface* progress_; 479 SnapshottingProgressReportingInterface* progress_;
541 SnapshotFillerInterface* filler_; 480 SnapshotFillerInterface* filler_;
542 HeapObjectsSet objects_tags_; 481 HeapObjectsSet objects_tags_;
543 HeapObjectsSet strong_gc_subroot_names_; 482 HeapObjectsSet strong_gc_subroot_names_;
544 HeapObjectsSet user_roots_; 483 HeapObjectsSet user_roots_;
545 v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_; 484 v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_;
546 485
547 static HeapObject* const kGcRootsObject; 486 static HeapObject* const kGcRootsObject;
548 static HeapObject* const kFirstGcSubrootObject; 487 static HeapObject* const kFirstGcSubrootObject;
549 static HeapObject* const kLastGcSubrootObject; 488 static HeapObject* const kLastGcSubrootObject;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 529 }
591 INLINE(static bool StringsMatch(void* key1, void* key2)) { 530 INLINE(static bool StringsMatch(void* key1, void* key2)) {
592 return strcmp(reinterpret_cast<char*>(key1), 531 return strcmp(reinterpret_cast<char*>(key1),
593 reinterpret_cast<char*>(key2)) == 0; 532 reinterpret_cast<char*>(key2)) == 0;
594 } 533 }
595 534
596 NativeGroupRetainedObjectInfo* FindOrAddGroupInfo(const char* label); 535 NativeGroupRetainedObjectInfo* FindOrAddGroupInfo(const char* label);
597 536
598 Isolate* isolate_; 537 Isolate* isolate_;
599 HeapSnapshot* snapshot_; 538 HeapSnapshot* snapshot_;
600 HeapSnapshotsCollection* collection_; 539 StringsStorage* names_;
601 SnapshottingProgressReportingInterface* progress_; 540 SnapshottingProgressReportingInterface* progress_;
602 bool embedder_queried_; 541 bool embedder_queried_;
603 HeapObjectsSet in_groups_; 542 HeapObjectsSet in_groups_;
604 // RetainedObjectInfo* -> List<HeapObject*>* 543 // RetainedObjectInfo* -> List<HeapObject*>*
605 HashMap objects_by_info_; 544 HashMap objects_by_info_;
606 HashMap native_groups_; 545 HashMap native_groups_;
607 HeapEntriesAllocator* synthetic_entries_allocator_; 546 HeapEntriesAllocator* synthetic_entries_allocator_;
608 HeapEntriesAllocator* native_entries_allocator_; 547 HeapEntriesAllocator* native_entries_allocator_;
609 // Used during references extraction. 548 // Used during references extraction.
610 SnapshotFillerInterface* filler_; 549 SnapshotFillerInterface* filler_;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 friend class HeapSnapshotJSONSerializerEnumerator; 636 friend class HeapSnapshotJSONSerializerEnumerator;
698 friend class HeapSnapshotJSONSerializerIterator; 637 friend class HeapSnapshotJSONSerializerIterator;
699 638
700 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 639 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
701 }; 640 };
702 641
703 642
704 } } // namespace v8::internal 643 } } // namespace v8::internal
705 644
706 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ 645 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_
OLDNEW
« no previous file with comments | « src/heap-profiler.cc ('k') | src/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698