Chromium Code Reviews| Index: Source/platform/heap/Heap.cpp |
| diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp |
| index 78e44c0415c2c5b0801cb09b3dfba62428e4b581..ac38009a060ef6080591eed7ecea9daa99ba9aac 100644 |
| --- a/Source/platform/heap/Heap.cpp |
| +++ b/Source/platform/heap/Heap.cpp |
| @@ -217,11 +217,12 @@ void BaseHeap::cleanupPages() |
| void BaseHeap::takeSnapshot(const String& dumpBaseName) |
| { |
| + WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); |
| size_t pageCount = 0; |
| for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { |
| + page->takeSnapshot(dumpBaseName, pageCount); |
| pageCount++; |
| } |
| - WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); |
| allocatorDump->AddScalar("blink_page_count", "objects", pageCount); |
| } |
| @@ -1346,6 +1347,47 @@ void NormalPage::markOrphaned() |
| BasePage::markOrphaned(); |
| } |
| +void NormalPage::takeSnapshot(const String& dumpBaseName, size_t pageIndex) |
| +{ |
| + String pageName = dumpBaseName.isolatedCopy(); |
| + pageName.append(String::format("/page_%zu", pageIndex)); |
|
Primiano Tucci (use gerrit)
2015/05/28 12:47:00
maybe this is a bit more clear and efficient if yo
ssid
2015/05/28 13:06:10
With offline discussion, this seems better.
|
| + WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(pageName); |
| + |
| + HeapObjectHeader* header = nullptr; |
| + size_t objectCount = 0; |
| + size_t liveCount = 0; |
| + size_t deadCount = 0; |
| + size_t freeCount = 0; |
| + size_t liveSize = 0; |
| + size_t deadSize = 0; |
| + size_t freeSize = 0; |
| + size_t encodedSize = 0; |
| + for (Address addr = payload(); addr < payloadEnd(); addr += header->size()) { |
| + header = reinterpret_cast<HeapObjectHeader*>(addr); |
| + objectCount++; |
| + encodedSize += header->encodedSize(); |
|
Primiano Tucci (use gerrit)
2015/05/28 12:47:00
as above, let's remove this.
ssid
2015/05/28 13:06:10
Done.
|
| + if (header->isFree()) { |
| + freeCount++; |
| + freeSize += header->size(); |
| + } else if (header->isMarked()) { |
| + liveCount++; |
| + liveSize += header->size(); |
| + } else { |
| + deadCount++; |
| + deadSize += header->size(); |
| + } |
| + } |
| + |
| + pageDump->AddScalar("object_count", "objects", objectCount); |
| + pageDump->AddScalar("encoded_size", "bytes", encodedSize); |
| + pageDump->AddScalar("live_count", "objects", liveCount); |
| + pageDump->AddScalar("dead_count", "objects", deadCount); |
| + pageDump->AddScalar("free_count", "objects", freeCount); |
| + pageDump->AddScalar("live_size", "bytes", liveSize); |
| + pageDump->AddScalar("dead_size", "bytes", deadSize); |
| + pageDump->AddScalar("free_size", "bytes", freeSize); |
| +} |
| + |
| #if ENABLE(GC_PROFILING) |
| const GCInfo* NormalPage::findGCInfo(Address address) |
| { |
| @@ -1513,6 +1555,34 @@ void LargeObjectPage::markOrphaned() |
| BasePage::markOrphaned(); |
| } |
| +void LargeObjectPage::takeSnapshot(const String& dumpBaseName, size_t pageIndex) |
| +{ |
| + String pageName = dumpBaseName.isolatedCopy(); |
| + pageName.append(String::format("/page_%zu", pageIndex)); |
|
Primiano Tucci (use gerrit)
2015/05/28 12:47:00
ditto here
ssid
2015/05/28 13:06:10
ditto.
|
| + WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(pageName); |
| + |
| + size_t liveSize = 0; |
| + size_t deadSize = 0; |
| + size_t liveCount = 0; |
| + size_t deadCount = 0; |
| + HeapObjectHeader* header = heapObjectHeader(); |
| + if (header->isMarked()) { |
| + liveCount = 1; |
| + liveSize += header->size(); |
| + } else { |
| + deadCount = 1; |
| + deadSize += header->size(); |
| + } |
| + |
| + pageDump->AddScalar("object_count", "objects", 1u); |
| + pageDump->AddScalar("live_count", "objects", liveCount); |
| + pageDump->AddScalar("dead_count", "objects", deadCount); |
| + pageDump->AddScalar("live_size", "bytes", liveSize); |
| + pageDump->AddScalar("dead_size", "bytes", deadSize); |
| + pageDump->AddScalar("free_size", "bytes", 0u); |
|
Primiano Tucci (use gerrit)
2015/05/28 12:47:00
Don't dump these if you know that they don't apply
ssid
2015/05/28 13:06:09
Done.
|
| + pageDump->AddScalar("free_count", "objects", 0u); |
| +} |
| + |
| #if ENABLE(GC_PROFILING) |
| const GCInfo* LargeObjectPage::findGCInfo(Address address) |
| { |