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