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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapPage.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 Heap::decreaseAllocatedSpace(page->size()); 129 Heap::decreaseAllocatedSpace(page->size());
130 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); 130 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page);
131 } 131 }
132 m_firstPage = nullptr; 132 m_firstPage = nullptr;
133 } 133 }
134 134
135 void BaseHeap::takeSnapshot(const String& dumpBaseName, ThreadState::GCSnapshotI nfo& info) 135 void BaseHeap::takeSnapshot(const String& dumpBaseName, ThreadState::GCSnapshotI nfo& info)
136 { 136 {
137 // |dumpBaseName| at this point is "blink_gc/thread_X/heaps/HeapName" 137 // |dumpBaseName| at this point is "blink_gc/thread_X/heaps/HeapName"
138 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); 138 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(dumpBaseName);
139 size_t pageIndex = 0; 139 size_t pageCount = 0;
140 size_t heapTotalFreeSize = 0; 140 BasePage::HeapSnapshotInfo heapInfo;
141 size_t heapTotalFreeCount = 0;
142 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { 141 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
143 size_t heapPageFreeSize = 0; 142 String dumpName = dumpBaseName + String::format("/pages/page_%lu", stati c_cast<unsigned long>(pageCount++));
144 size_t heapPageFreeCount = 0; 143 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance() ->createMemoryAllocatorDumpForCurrentGC(dumpName);
145 page->takeSnapshot(dumpBaseName, pageIndex, info, &heapPageFreeSize, &he apPageFreeCount); 144
146 heapTotalFreeSize += heapPageFreeSize; 145 page->takeSnapshot(pageDump, info, heapInfo);
147 heapTotalFreeCount += heapPageFreeCount;
148 pageIndex++;
149 } 146 }
150 allocatorDump->addScalar("blink_page_count", "objects", pageIndex); 147 allocatorDump->addScalar("blink_page_count", "objects", pageCount);
151 148
152 // When taking a full dump (w/ freelist), both the /buckets and /pages 149 // When taking a full dump (w/ freelist), both the /buckets and /pages
153 // report their free size but they are not meant to be added together. 150 // report their free size but they are not meant to be added together.
154 // Therefore, here we override the free_size of the parent heap to be 151 // Therefore, here we override the free_size of the parent heap to be
155 // equal to the free_size of the sum of its heap pages. 152 // equal to the free_size of the sum of its heap pages.
156 allocatorDump->addScalar("free_size", "bytes", heapTotalFreeSize); 153 allocatorDump->addScalar("free_size", "bytes", heapInfo.freeSize);
157 allocatorDump->addScalar("free_count", "objects", heapTotalFreeCount); 154 allocatorDump->addScalar("free_count", "objects", heapInfo.freeCount);
158 } 155 }
159 156
160 #if ENABLE(ASSERT) 157 #if ENABLE(ASSERT)
161 BasePage* BaseHeap::findPageFromAddress(Address address) 158 BasePage* BaseHeap::findPageFromAddress(Address address)
162 { 159 {
163 for (BasePage* page = m_firstPage; page; page = page->next()) { 160 for (BasePage* page = m_firstPage; page; page = page->next()) {
164 if (page->contains(address)) 161 if (page->contains(address))
165 return page; 162 return page;
166 } 163 }
167 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { 164 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 // cross thread pointer usage. 1381 // cross thread pointer usage.
1385 #if defined(ADDRESS_SANITIZER) 1382 #if defined(ADDRESS_SANITIZER)
1386 // This needs to zap poisoned memory as well. 1383 // This needs to zap poisoned memory as well.
1387 // Force unpoison memory before memset. 1384 // Force unpoison memory before memset.
1388 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); 1385 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize());
1389 #endif 1386 #endif
1390 OrphanedPagePool::asanDisabledMemset(payload(), OrphanedPagePool::orphanedZa pValue, payloadSize()); 1387 OrphanedPagePool::asanDisabledMemset(payload(), OrphanedPagePool::orphanedZa pValue, payloadSize());
1391 BasePage::markOrphaned(); 1388 BasePage::markOrphaned();
1392 } 1389 }
1393 1390
1394 void NormalPage::takeSnapshot(String dumpName, size_t pageIndex, ThreadState::GC SnapshotInfo& info, size_t* outFreeSize, size_t* outFreeCount) 1391 void NormalPage::takeSnapshot(WebMemoryAllocatorDump* pageDump, ThreadState::GCS napshotInfo& info, HeapSnapshotInfo& heapInfo)
1395 { 1392 {
1396 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long> (pageIndex)));
1397 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName);
1398
1399 HeapObjectHeader* header = nullptr; 1393 HeapObjectHeader* header = nullptr;
1400 size_t liveCount = 0; 1394 size_t liveCount = 0;
1401 size_t deadCount = 0; 1395 size_t deadCount = 0;
1402 size_t freeCount = 0; 1396 size_t freeCount = 0;
1403 size_t liveSize = 0; 1397 size_t liveSize = 0;
1404 size_t deadSize = 0; 1398 size_t deadSize = 0;
1405 size_t freeSize = 0; 1399 size_t freeSize = 0;
1406 for (Address headerAddress = payload(); headerAddress < payloadEnd(); header Address += header->size()) { 1400 for (Address headerAddress = payload(); headerAddress < payloadEnd(); header Address += header->size()) {
1407 header = reinterpret_cast<HeapObjectHeader*>(headerAddress); 1401 header = reinterpret_cast<HeapObjectHeader*>(headerAddress);
1408 if (header->isFree()) { 1402 if (header->isFree()) {
(...skipping 15 matching lines...) Expand all
1424 info.deadSize[gcInfoIndex] += header->size(); 1418 info.deadSize[gcInfoIndex] += header->size();
1425 } 1419 }
1426 } 1420 }
1427 1421
1428 pageDump->addScalar("live_count", "objects", liveCount); 1422 pageDump->addScalar("live_count", "objects", liveCount);
1429 pageDump->addScalar("dead_count", "objects", deadCount); 1423 pageDump->addScalar("dead_count", "objects", deadCount);
1430 pageDump->addScalar("free_count", "objects", freeCount); 1424 pageDump->addScalar("free_count", "objects", freeCount);
1431 pageDump->addScalar("live_size", "bytes", liveSize); 1425 pageDump->addScalar("live_size", "bytes", liveSize);
1432 pageDump->addScalar("dead_size", "bytes", deadSize); 1426 pageDump->addScalar("dead_size", "bytes", deadSize);
1433 pageDump->addScalar("free_size", "bytes", freeSize); 1427 pageDump->addScalar("free_size", "bytes", freeSize);
1434 *outFreeSize = freeSize; 1428 heapInfo.freeSize += freeSize;
1435 *outFreeCount = freeCount; 1429 heapInfo.freeCount += freeCount;
1436 } 1430 }
1437 1431
1438 #if ENABLE(ASSERT) 1432 #if ENABLE(ASSERT)
1439 bool NormalPage::contains(Address addr) 1433 bool NormalPage::contains(Address addr)
1440 { 1434 {
1441 Address blinkPageStart = roundToBlinkPageStart(address()); 1435 Address blinkPageStart = roundToBlinkPageStart(address());
1442 ASSERT(blinkPageStart == address() - blinkGuardPageSize); // Page is at alig ned address plus guard page size. 1436 ASSERT(blinkPageStart == address() - blinkGuardPageSize); // Page is at alig ned address plus guard page size.
1443 return blinkPageStart <= addr && addr < blinkPageStart + blinkPageSize; 1437 return blinkPageStart <= addr && addr < blinkPageStart + blinkPageSize;
1444 } 1438 }
1445 #endif 1439 #endif
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 } 1514 }
1521 1515
1522 void LargeObjectPage::markOrphaned() 1516 void LargeObjectPage::markOrphaned()
1523 { 1517 {
1524 // Zap the payload with a recognizable value to detect any incorrect 1518 // Zap the payload with a recognizable value to detect any incorrect
1525 // cross thread pointer usage. 1519 // cross thread pointer usage.
1526 OrphanedPagePool::asanDisabledMemset(payload(), OrphanedPagePool::orphanedZa pValue, payloadSize()); 1520 OrphanedPagePool::asanDisabledMemset(payload(), OrphanedPagePool::orphanedZa pValue, payloadSize());
1527 BasePage::markOrphaned(); 1521 BasePage::markOrphaned();
1528 } 1522 }
1529 1523
1530 void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex, ThreadStat e::GCSnapshotInfo& info, size_t* outFreeSize, size_t* outFreeCount) 1524 void LargeObjectPage::takeSnapshot(WebMemoryAllocatorDump* pageDump, ThreadState ::GCSnapshotInfo& info, HeapSnapshotInfo&)
1531 { 1525 {
1532 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long> (pageIndex)));
1533 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName);
1534
1535 size_t liveSize = 0; 1526 size_t liveSize = 0;
1536 size_t deadSize = 0; 1527 size_t deadSize = 0;
1537 size_t liveCount = 0; 1528 size_t liveCount = 0;
1538 size_t deadCount = 0; 1529 size_t deadCount = 0;
1539 HeapObjectHeader* header = heapObjectHeader(); 1530 HeapObjectHeader* header = heapObjectHeader();
1540 size_t gcInfoIndex = header->gcInfoIndex(); 1531 size_t gcInfoIndex = header->gcInfoIndex();
1541 size_t payloadSize = header->payloadSize(); 1532 size_t payloadSize = header->payloadSize();
1542 if (header->isMarked()) { 1533 if (header->isMarked()) {
1543 liveCount = 1; 1534 liveCount = 1;
1544 liveSize += payloadSize; 1535 liveSize += payloadSize;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1593
1603 m_hasEntries = true; 1594 m_hasEntries = true;
1604 size_t index = hash(address); 1595 size_t index = hash(address);
1605 ASSERT(!(index & 1)); 1596 ASSERT(!(index & 1));
1606 Address cachePage = roundToBlinkPageStart(address); 1597 Address cachePage = roundToBlinkPageStart(address);
1607 m_entries[index + 1] = m_entries[index]; 1598 m_entries[index + 1] = m_entries[index];
1608 m_entries[index] = cachePage; 1599 m_entries[index] = cachePage;
1609 } 1600 }
1610 1601
1611 } // namespace blink 1602 } // namespace blink
OLDNEW
« 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