Revision f230a1cf deps/v8/src/heap-snapshot-generator.h
deps/v8/src/heap-snapshot-generator.h | ||
---|---|---|
33 | 33 |
namespace v8 { |
34 | 34 |
namespace internal { |
35 | 35 |
|
36 |
class AllocationTracker; |
|
37 |
class AllocationTraceNode; |
|
36 | 38 |
class HeapEntry; |
37 | 39 |
class HeapSnapshot; |
38 | 40 |
|
... | ... | |
227 | 229 |
|
228 | 230 |
void SnapshotGenerationFinished(); |
229 | 231 |
SnapshotObjectId FindEntry(Address addr); |
230 |
SnapshotObjectId FindOrAddEntry(Address addr, unsigned int size); |
|
231 |
void MoveObject(Address from, Address to); |
|
232 |
SnapshotObjectId FindOrAddEntry(Address addr, |
|
233 |
unsigned int size, |
|
234 |
bool accessed = true); |
|
235 |
void MoveObject(Address from, Address to, int size); |
|
236 |
void NewObject(Address addr, int size); |
|
237 |
void UpdateObjectSize(Address addr, int size); |
|
232 | 238 |
SnapshotObjectId last_assigned_id() const { |
233 | 239 |
return next_id_ - kObjectIdStep; |
234 | 240 |
} |
... | ... | |
247 | 253 |
static const SnapshotObjectId kGcRootsFirstSubrootId; |
248 | 254 |
static const SnapshotObjectId kFirstAvailableObjectId; |
249 | 255 |
|
256 |
int FindUntrackedObjects(); |
|
257 |
|
|
258 |
void UpdateHeapObjectsMap(); |
|
259 |
|
|
250 | 260 |
private: |
251 | 261 |
struct EntryInfo { |
252 | 262 |
EntryInfo(SnapshotObjectId id, Address addr, unsigned int size) |
... | ... | |
265 | 275 |
uint32_t count; |
266 | 276 |
}; |
267 | 277 |
|
268 |
void UpdateHeapObjectsMap(); |
|
269 | 278 |
void RemoveDeadEntries(); |
270 | 279 |
|
271 | 280 |
SnapshotObjectId next_id_; |
... | ... | |
289 | 298 |
SnapshotObjectId PushHeapObjectsStats(OutputStream* stream) { |
290 | 299 |
return ids_.PushHeapObjectsStats(stream); |
291 | 300 |
} |
292 |
void StartHeapObjectsTracking() { is_tracking_objects_ = true; }
|
|
293 |
void StopHeapObjectsTracking() { ids_.StopHeapObjectsTracking(); }
|
|
301 |
void StartHeapObjectsTracking();
|
|
302 |
void StopHeapObjectsTracking();
|
|
294 | 303 |
|
295 | 304 |
HeapSnapshot* NewSnapshot(const char* name, unsigned uid); |
296 | 305 |
void SnapshotGenerationFinished(HeapSnapshot* snapshot); |
... | ... | |
298 | 307 |
void RemoveSnapshot(HeapSnapshot* snapshot); |
299 | 308 |
|
300 | 309 |
StringsStorage* names() { return &names_; } |
310 |
AllocationTracker* allocation_tracker() { return allocation_tracker_; } |
|
301 | 311 |
|
302 | 312 |
SnapshotObjectId FindObjectId(Address object_addr) { |
303 | 313 |
return ids_.FindEntry(object_addr); |
... | ... | |
306 | 316 |
return ids_.FindOrAddEntry(object_addr, object_size); |
307 | 317 |
} |
308 | 318 |
Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id); |
309 |
void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } |
|
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 |
} |
|
310 | 326 |
SnapshotObjectId last_assigned_id() const { |
311 | 327 |
return ids_.last_assigned_id(); |
312 | 328 |
} |
313 | 329 |
size_t GetUsedMemorySize() const; |
314 | 330 |
|
331 |
int FindUntrackedObjects() { return ids_.FindUntrackedObjects(); } |
|
332 |
|
|
333 |
void UpdateHeapObjectsMap() { ids_.UpdateHeapObjectsMap(); } |
|
334 |
|
|
315 | 335 |
private: |
316 | 336 |
bool is_tracking_objects_; // Whether tracking object moves is needed. |
317 | 337 |
List<HeapSnapshot*> snapshots_; |
318 | 338 |
StringsStorage names_; |
319 | 339 |
// Mapping from HeapObject addresses to objects' uids. |
320 | 340 |
HeapObjectsMap ids_; |
341 |
AllocationTracker* allocation_tracker_; |
|
321 | 342 |
|
322 | 343 |
DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection); |
323 | 344 |
}; |
... | ... | |
628 | 649 |
public: |
629 | 650 |
explicit HeapSnapshotJSONSerializer(HeapSnapshot* snapshot) |
630 | 651 |
: snapshot_(snapshot), |
631 |
strings_(ObjectsMatch),
|
|
652 |
strings_(StringsMatch),
|
|
632 | 653 |
next_node_id_(1), |
633 | 654 |
next_string_id_(1), |
634 | 655 |
writer_(NULL) { |
... | ... | |
636 | 657 |
void Serialize(v8::OutputStream* stream); |
637 | 658 |
|
638 | 659 |
private: |
639 |
INLINE(static bool ObjectsMatch(void* key1, void* key2)) { |
|
640 |
return key1 == key2; |
|
660 |
INLINE(static bool StringsMatch(void* key1, void* key2)) { |
|
661 |
return strcmp(reinterpret_cast<char*>(key1), |
|
662 |
reinterpret_cast<char*>(key2)) == 0; |
|
641 | 663 |
} |
642 | 664 |
|
643 |
INLINE(static uint32_t ObjectHash(const void* key)) { |
|
644 |
return ComputeIntegerHash( |
|
645 |
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key)), |
|
646 |
v8::internal::kZeroHashSeed); |
|
665 |
INLINE(static uint32_t StringHash(const void* string)) { |
|
666 |
const char* s = reinterpret_cast<const char*>(string); |
|
667 |
int len = static_cast<int>(strlen(s)); |
|
668 |
return StringHasher::HashSequentialString( |
|
669 |
s, len, v8::internal::kZeroHashSeed); |
|
647 | 670 |
} |
648 | 671 |
|
649 | 672 |
int GetStringId(const char* s); |
... | ... | |
654 | 677 |
void SerializeNode(HeapEntry* entry); |
655 | 678 |
void SerializeNodes(); |
656 | 679 |
void SerializeSnapshot(); |
680 |
void SerializeTraceTree(); |
|
681 |
void SerializeTraceNode(AllocationTraceNode* node); |
|
682 |
void SerializeTraceNodeInfos(); |
|
657 | 683 |
void SerializeString(const unsigned char* s); |
658 | 684 |
void SerializeStrings(); |
659 |
void SortHashMap(HashMap* map, List<HashMap::Entry*>* sorted_entries); |
|
660 | 685 |
|
661 | 686 |
static const int kEdgeFieldsCount; |
662 | 687 |
static const int kNodeFieldsCount; |
Also available in: Unified diff