OLD | NEW |
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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 | 219 |
220 class HeapObjectsMap { | 220 class HeapObjectsMap { |
221 public: | 221 public: |
222 explicit HeapObjectsMap(Heap* heap); | 222 explicit HeapObjectsMap(Heap* heap); |
223 | 223 |
224 Heap* heap() const { return heap_; } | 224 Heap* heap() const { return heap_; } |
225 | 225 |
226 void SnapshotGenerationFinished(); | 226 void SnapshotGenerationFinished(); |
227 SnapshotObjectId FindEntry(Address addr); | 227 SnapshotObjectId FindEntry(Address addr); |
228 SnapshotObjectId FindOrAddEntry(Address addr, unsigned int size); | 228 SnapshotObjectId FindOrAddEntry(Address addr, |
229 void MoveObject(Address from, Address to); | 229 unsigned int size, |
| 230 bool accessed = true); |
| 231 void MoveObject(Address from, Address to, int size); |
| 232 void NewObject(Address addr, int size); |
230 SnapshotObjectId last_assigned_id() const { | 233 SnapshotObjectId last_assigned_id() const { |
231 return next_id_ - kObjectIdStep; | 234 return next_id_ - kObjectIdStep; |
232 } | 235 } |
233 | 236 |
234 void StopHeapObjectsTracking(); | 237 void StopHeapObjectsTracking(); |
235 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); | 238 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); |
236 size_t GetUsedMemorySize() const; | 239 size_t GetUsedMemorySize() const; |
237 | 240 |
238 static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); | 241 static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); |
239 static inline SnapshotObjectId GetNthGcSubrootId(int delta); | 242 static inline SnapshotObjectId GetNthGcSubrootId(int delta); |
240 | 243 |
241 static const int kObjectIdStep = 2; | 244 static const int kObjectIdStep = 2; |
242 static const SnapshotObjectId kInternalRootObjectId; | 245 static const SnapshotObjectId kInternalRootObjectId; |
243 static const SnapshotObjectId kGcRootsObjectId; | 246 static const SnapshotObjectId kGcRootsObjectId; |
244 static const SnapshotObjectId kNativesRootObjectId; | 247 static const SnapshotObjectId kNativesRootObjectId; |
245 static const SnapshotObjectId kGcRootsFirstSubrootId; | 248 static const SnapshotObjectId kGcRootsFirstSubrootId; |
246 static const SnapshotObjectId kFirstAvailableObjectId; | 249 static const SnapshotObjectId kFirstAvailableObjectId; |
247 | 250 |
| 251 int FindUntrackedObjects(); |
| 252 |
248 private: | 253 private: |
249 struct EntryInfo { | 254 struct EntryInfo { |
250 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size) | 255 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size) |
251 : id(id), addr(addr), size(size), accessed(true) { } | 256 : id(id), addr(addr), size(size), accessed(true) { } |
252 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed) | 257 EntryInfo(SnapshotObjectId id, Address addr, unsigned int size, bool accessed) |
253 : id(id), addr(addr), size(size), accessed(accessed) { } | 258 : id(id), addr(addr), size(size), accessed(accessed) { } |
254 SnapshotObjectId id; | 259 SnapshotObjectId id; |
255 Address addr; | 260 Address addr; |
256 unsigned int size; | 261 unsigned int size; |
257 bool accessed; | 262 bool accessed; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 302 |
298 StringsStorage* names() { return &names_; } | 303 StringsStorage* names() { return &names_; } |
299 | 304 |
300 SnapshotObjectId FindObjectId(Address object_addr) { | 305 SnapshotObjectId FindObjectId(Address object_addr) { |
301 return ids_.FindEntry(object_addr); | 306 return ids_.FindEntry(object_addr); |
302 } | 307 } |
303 SnapshotObjectId GetObjectId(Address object_addr, int object_size) { | 308 SnapshotObjectId GetObjectId(Address object_addr, int object_size) { |
304 return ids_.FindOrAddEntry(object_addr, object_size); | 309 return ids_.FindOrAddEntry(object_addr, object_size); |
305 } | 310 } |
306 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); | 311 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); |
307 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } | 312 void ObjectMoveEvent(Address from, Address to, int size) { |
| 313 ids_.MoveObject(from, to, size); |
| 314 } |
| 315 void NewObjectEvent(Address addr, int size) { ids_.NewObject(addr, size); } |
308 SnapshotObjectId last_assigned_id() const { | 316 SnapshotObjectId last_assigned_id() const { |
309 return ids_.last_assigned_id(); | 317 return ids_.last_assigned_id(); |
310 } | 318 } |
311 size_t GetUsedMemorySize() const; | 319 size_t GetUsedMemorySize() const; |
312 | 320 |
| 321 int FindUntrackedObjects() { return ids_.FindUntrackedObjects(); } |
| 322 |
313 private: | 323 private: |
314 bool is_tracking_objects_; // Whether tracking object moves is needed. | 324 bool is_tracking_objects_; // Whether tracking object moves is needed. |
315 List<HeapSnapshot*> snapshots_; | 325 List<HeapSnapshot*> snapshots_; |
316 StringsStorage names_; | 326 StringsStorage names_; |
317 // Mapping from HeapObject addresses to objects' uids. | 327 // Mapping from HeapObject addresses to objects' uids. |
318 HeapObjectsMap ids_; | 328 HeapObjectsMap ids_; |
319 | 329 |
320 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection); | 330 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection); |
321 }; | 331 }; |
322 | 332 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 friend class HeapSnapshotJSONSerializerIterator; | 678 friend class HeapSnapshotJSONSerializerIterator; |
669 | 679 |
670 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 680 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
671 }; | 681 }; |
672 | 682 |
673 | 683 |
674 } } // namespace v8::internal | 684 } } // namespace v8::internal |
675 | 685 |
676 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ | 686 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ |
677 | 687 |
OLD | NEW |