| 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 UpdateHeapObjectsMap(); |
| 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; |
| 260 }; | 268 }; |
| 261 struct TimeInterval { | 269 struct TimeInterval { |
| 262 explicit TimeInterval(SnapshotObjectId id) : id(id), size(0), count(0) { } | 270 explicit TimeInterval(SnapshotObjectId id) : id(id), size(0), count(0) { } |
| 263 SnapshotObjectId id; | 271 SnapshotObjectId id; |
| 264 uint32_t size; | 272 uint32_t size; |
| 265 uint32_t count; | 273 uint32_t count; |
| 266 }; | 274 }; |
| 267 | 275 |
| 268 void UpdateHeapObjectsMap(); | |
| 269 void RemoveDeadEntries(); | 276 void RemoveDeadEntries(); |
| 270 | 277 |
| 271 SnapshotObjectId next_id_; | 278 SnapshotObjectId next_id_; |
| 272 HashMap entries_map_; | 279 HashMap entries_map_; |
| 273 List<EntryInfo> entries_; | 280 List<EntryInfo> entries_; |
| 274 List<TimeInterval> time_intervals_; | 281 List<TimeInterval> time_intervals_; |
| 275 Heap* heap_; | 282 Heap* heap_; |
| 276 | 283 |
| 277 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); | 284 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); |
| 278 }; | 285 }; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 299 | 306 |
| 300 StringsStorage* names() { return &names_; } | 307 StringsStorage* names() { return &names_; } |
| 301 | 308 |
| 302 SnapshotObjectId FindObjectId(Address object_addr) { | 309 SnapshotObjectId FindObjectId(Address object_addr) { |
| 303 return ids_.FindEntry(object_addr); | 310 return ids_.FindEntry(object_addr); |
| 304 } | 311 } |
| 305 SnapshotObjectId GetObjectId(Address object_addr, int object_size) { | 312 SnapshotObjectId GetObjectId(Address object_addr, int object_size) { |
| 306 return ids_.FindOrAddEntry(object_addr, object_size); | 313 return ids_.FindOrAddEntry(object_addr, object_size); |
| 307 } | 314 } |
| 308 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); | 315 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); |
| 309 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } | 316 void ObjectMoveEvent(Address from, Address to, int size) { |
| 317 ids_.MoveObject(from, to, size); |
| 318 } |
| 319 void NewObjectEvent(Address addr, int size) { ids_.NewObject(addr, size); } |
| 320 void UpdateObjectSizeEvent(Address addr, int size) { |
| 321 ids_.UpdateObjectSize(addr, size); |
| 322 } |
| 310 SnapshotObjectId last_assigned_id() const { | 323 SnapshotObjectId last_assigned_id() const { |
| 311 return ids_.last_assigned_id(); | 324 return ids_.last_assigned_id(); |
| 312 } | 325 } |
| 313 size_t GetUsedMemorySize() const; | 326 size_t GetUsedMemorySize() const; |
| 314 | 327 |
| 328 int FindUntrackedObjects() { return ids_.FindUntrackedObjects(); } |
| 329 |
| 330 void UpdateHeapObjectsMap() { ids_.UpdateHeapObjectsMap(); } |
| 331 |
| 315 private: | 332 private: |
| 316 bool is_tracking_objects_; // Whether tracking object moves is needed. | 333 bool is_tracking_objects_; // Whether tracking object moves is needed. |
| 317 List<HeapSnapshot*> snapshots_; | 334 List<HeapSnapshot*> snapshots_; |
| 318 StringsStorage names_; | 335 StringsStorage names_; |
| 319 // Mapping from HeapObject addresses to objects' uids. | 336 // Mapping from HeapObject addresses to objects' uids. |
| 320 HeapObjectsMap ids_; | 337 HeapObjectsMap ids_; |
| 321 | 338 |
| 322 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection); | 339 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection); |
| 323 }; | 340 }; |
| 324 | 341 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 friend class HeapSnapshotJSONSerializerIterator; | 689 friend class HeapSnapshotJSONSerializerIterator; |
| 673 | 690 |
| 674 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 691 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
| 675 }; | 692 }; |
| 676 | 693 |
| 677 | 694 |
| 678 } } // namespace v8::internal | 695 } } // namespace v8::internal |
| 679 | 696 |
| 680 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ | 697 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ |
| 681 | 698 |
| OLD | NEW |