Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Unified Diff: third_party/WebKit/Source/platform/heap/HeapPage.cpp

Issue 1700723002: Tidy heap snapshotting implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: zero initialize Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapPage.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/HeapPage.cpp
diff --git a/third_party/WebKit/Source/platform/heap/HeapPage.cpp b/third_party/WebKit/Source/platform/heap/HeapPage.cpp
index e9dcbe158cc2575f8f7b60b7ee480973c5e0c325..d3be9f309502846982e4c39ecf5ccc6481fe31f2 100644
--- a/third_party/WebKit/Source/platform/heap/HeapPage.cpp
+++ b/third_party/WebKit/Source/platform/heap/HeapPage.cpp
@@ -136,25 +136,22 @@ void BaseHeap::takeSnapshot(const String& dumpBaseName, ThreadState::GCSnapshotI
{
// |dumpBaseName| at this point is "blink_gc/thread_X/heaps/HeapName"
WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpBaseName);
- size_t pageIndex = 0;
- size_t heapTotalFreeSize = 0;
- size_t heapTotalFreeCount = 0;
+ size_t pageCount = 0;
+ BasePage::HeapSnapshotInfo heapInfo;
for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
- size_t heapPageFreeSize = 0;
- size_t heapPageFreeCount = 0;
- page->takeSnapshot(dumpBaseName, pageIndex, info, &heapPageFreeSize, &heapPageFreeCount);
- heapTotalFreeSize += heapPageFreeSize;
- heapTotalFreeCount += heapPageFreeCount;
- pageIndex++;
+ String dumpName = dumpBaseName + String::format("/pages/page_%lu", static_cast<unsigned long>(pageCount++));
+ WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpName);
+
+ page->takeSnapshot(pageDump, info, heapInfo);
}
- allocatorDump->addScalar("blink_page_count", "objects", pageIndex);
+ allocatorDump->addScalar("blink_page_count", "objects", pageCount);
// When taking a full dump (w/ freelist), both the /buckets and /pages
// report their free size but they are not meant to be added together.
// Therefore, here we override the free_size of the parent heap to be
// equal to the free_size of the sum of its heap pages.
- allocatorDump->addScalar("free_size", "bytes", heapTotalFreeSize);
- allocatorDump->addScalar("free_count", "objects", heapTotalFreeCount);
+ allocatorDump->addScalar("free_size", "bytes", heapInfo.freeSize);
+ allocatorDump->addScalar("free_count", "objects", heapInfo.freeCount);
}
#if ENABLE(ASSERT)
@@ -1391,11 +1388,8 @@ void NormalPage::markOrphaned()
BasePage::markOrphaned();
}
-void NormalPage::takeSnapshot(String dumpName, size_t pageIndex, ThreadState::GCSnapshotInfo& info, size_t* outFreeSize, size_t* outFreeCount)
+void NormalPage::takeSnapshot(WebMemoryAllocatorDump* pageDump, ThreadState::GCSnapshotInfo& info, HeapSnapshotInfo& heapInfo)
{
- dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long>(pageIndex)));
- WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpName);
-
HeapObjectHeader* header = nullptr;
size_t liveCount = 0;
size_t deadCount = 0;
@@ -1431,8 +1425,8 @@ void NormalPage::takeSnapshot(String dumpName, size_t pageIndex, ThreadState::GC
pageDump->addScalar("live_size", "bytes", liveSize);
pageDump->addScalar("dead_size", "bytes", deadSize);
pageDump->addScalar("free_size", "bytes", freeSize);
- *outFreeSize = freeSize;
- *outFreeCount = freeCount;
+ heapInfo.freeSize += freeSize;
+ heapInfo.freeCount += freeCount;
}
#if ENABLE(ASSERT)
@@ -1527,11 +1521,8 @@ void LargeObjectPage::markOrphaned()
BasePage::markOrphaned();
}
-void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex, ThreadState::GCSnapshotInfo& info, size_t* outFreeSize, size_t* outFreeCount)
+void LargeObjectPage::takeSnapshot(WebMemoryAllocatorDump* pageDump, ThreadState::GCSnapshotInfo& info, HeapSnapshotInfo&)
{
- dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long>(pageIndex)));
- WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpName);
-
size_t liveSize = 0;
size_t deadSize = 0;
size_t liveCount = 0;
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapPage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698