| OLD | NEW |
| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 ASSERT(!m_firstUnsweptPage); | 236 ASSERT(!m_firstUnsweptPage); |
| 237 // Add the BaseHeap's pages to the orphanedPagePool. | 237 // Add the BaseHeap's pages to the orphanedPagePool. |
| 238 for (BasePage* page = m_firstPage; page; page = page->next()) { | 238 for (BasePage* page = m_firstPage; page; page = page->next()) { |
| 239 Heap::decreaseAllocatedSpace(page->size()); | 239 Heap::decreaseAllocatedSpace(page->size()); |
| 240 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); | 240 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); |
| 241 } | 241 } |
| 242 m_firstPage = nullptr; | 242 m_firstPage = nullptr; |
| 243 } | 243 } |
| 244 | 244 |
| 245 void BaseHeap::takeSnapshot(const String& dumpBaseName) | 245 void BaseHeap::takeSnapshot(const String& dumpBaseName, ThreadState::GCSnapshotI
nfo& info) |
| 246 { | 246 { |
| 247 // |dumpBaseName| at this point is "blink_gc/thread_X/heaps/HeapName" | 247 // |dumpBaseName| at this point is "blink_gc/thread_X/heaps/HeapName" |
| 248 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance(
)->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); | 248 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance(
)->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); |
| 249 size_t pageIndex = 0; | 249 size_t pageIndex = 0; |
| 250 size_t heapTotalFreeSize = 0; | 250 size_t heapTotalFreeSize = 0; |
| 251 size_t heapTotalFreeCount = 0; | 251 size_t heapTotalFreeCount = 0; |
| 252 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { | 252 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { |
| 253 size_t heapPageFreeSize = 0; | 253 size_t heapPageFreeSize = 0; |
| 254 size_t heapPageFreeCount = 0; | 254 size_t heapPageFreeCount = 0; |
| 255 page->takeSnapshot(dumpBaseName, pageIndex, &heapPageFreeSize, &heapPage
FreeCount); | 255 page->takeSnapshot(dumpBaseName, pageIndex, info, &heapPageFreeSize, &he
apPageFreeCount); |
| 256 heapTotalFreeSize += heapPageFreeSize; | 256 heapTotalFreeSize += heapPageFreeSize; |
| 257 heapTotalFreeCount += heapPageFreeCount; | 257 heapTotalFreeCount += heapPageFreeCount; |
| 258 pageIndex++; | 258 pageIndex++; |
| 259 } | 259 } |
| 260 allocatorDump->AddScalar("blink_page_count", "objects", pageIndex); | 260 allocatorDump->AddScalar("blink_page_count", "objects", pageIndex); |
| 261 | 261 |
| 262 // When taking a full dump (w/ freelist), both the /buckets and /pages | 262 // When taking a full dump (w/ freelist), both the /buckets and /pages |
| 263 // report their free size but they are not meant to be added together. | 263 // report their free size but they are not meant to be added together. |
| 264 // Therefore, here we override the free_size of the parent heap to be | 264 // Therefore, here we override the free_size of the parent heap to be |
| 265 // equal to the free_size of the sum of its heap pages. | 265 // equal to the free_size of the sum of its heap pages. |
| (...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 // cross thread pointer usage. | 1548 // cross thread pointer usage. |
| 1549 #if defined(ADDRESS_SANITIZER) | 1549 #if defined(ADDRESS_SANITIZER) |
| 1550 // This needs to zap poisoned memory as well. | 1550 // This needs to zap poisoned memory as well. |
| 1551 // Force unpoison memory before memset. | 1551 // Force unpoison memory before memset. |
| 1552 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); | 1552 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); |
| 1553 #endif | 1553 #endif |
| 1554 OrphanedPagePool::asanDisabledMemset(payload(), OrphanedPagePool::orphanedZa
pValue, payloadSize()); | 1554 OrphanedPagePool::asanDisabledMemset(payload(), OrphanedPagePool::orphanedZa
pValue, payloadSize()); |
| 1555 BasePage::markOrphaned(); | 1555 BasePage::markOrphaned(); |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 void NormalPage::takeSnapshot(String dumpName, size_t pageIndex, size_t* outFree
Size, size_t* outFreeCount) | 1558 void NormalPage::takeSnapshot(String dumpName, size_t pageIndex, ThreadState::GC
SnapshotInfo& info, size_t* outFreeSize, size_t* outFreeCount) |
| 1559 { | 1559 { |
| 1560 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long>
(pageIndex))); | 1560 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long>
(pageIndex))); |
| 1561 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr
eateMemoryAllocatorDumpForCurrentGC(dumpName); | 1561 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr
eateMemoryAllocatorDumpForCurrentGC(dumpName); |
| 1562 | 1562 |
| 1563 HeapObjectHeader* header = nullptr; | 1563 HeapObjectHeader* header = nullptr; |
| 1564 size_t liveCount = 0; | 1564 size_t liveCount = 0; |
| 1565 size_t deadCount = 0; | 1565 size_t deadCount = 0; |
| 1566 size_t freeCount = 0; | 1566 size_t freeCount = 0; |
| 1567 size_t liveSize = 0; | 1567 size_t liveSize = 0; |
| 1568 size_t deadSize = 0; | 1568 size_t deadSize = 0; |
| 1569 size_t freeSize = 0; | 1569 size_t freeSize = 0; |
| 1570 for (Address headerAddress = payload(); headerAddress < payloadEnd(); header
Address += header->size()) { | 1570 for (Address headerAddress = payload(); headerAddress < payloadEnd(); header
Address += header->size()) { |
| 1571 header = reinterpret_cast<HeapObjectHeader*>(headerAddress); | 1571 header = reinterpret_cast<HeapObjectHeader*>(headerAddress); |
| 1572 if (header->isFree()) { | 1572 if (header->isFree()) { |
| 1573 freeCount++; | 1573 freeCount++; |
| 1574 freeSize += header->size(); | 1574 freeSize += header->size(); |
| 1575 } else if (header->isMarked()) { | 1575 } else if (header->isMarked()) { |
| 1576 liveCount++; | 1576 liveCount++; |
| 1577 liveSize += header->size(); | 1577 liveSize += header->size(); |
| 1578 |
| 1579 size_t gcInfoIndex = header->gcInfoIndex(); |
| 1580 info.liveCount[gcInfoIndex]++; |
| 1581 info.liveSize[gcInfoIndex] += header->size(); |
| 1578 } else { | 1582 } else { |
| 1579 deadCount++; | 1583 deadCount++; |
| 1580 deadSize += header->size(); | 1584 deadSize += header->size(); |
| 1585 |
| 1586 size_t gcInfoIndex = header->gcInfoIndex(); |
| 1587 info.deadCount[gcInfoIndex]++; |
| 1588 info.deadSize[gcInfoIndex] += header->size(); |
| 1581 } | 1589 } |
| 1582 } | 1590 } |
| 1583 | 1591 |
| 1584 pageDump->AddScalar("live_count", "objects", liveCount); | 1592 pageDump->AddScalar("live_count", "objects", liveCount); |
| 1585 pageDump->AddScalar("dead_count", "objects", deadCount); | 1593 pageDump->AddScalar("dead_count", "objects", deadCount); |
| 1586 pageDump->AddScalar("free_count", "objects", freeCount); | 1594 pageDump->AddScalar("free_count", "objects", freeCount); |
| 1587 pageDump->AddScalar("live_size", "bytes", liveSize); | 1595 pageDump->AddScalar("live_size", "bytes", liveSize); |
| 1588 pageDump->AddScalar("dead_size", "bytes", deadSize); | 1596 pageDump->AddScalar("dead_size", "bytes", deadSize); |
| 1589 pageDump->AddScalar("free_size", "bytes", freeSize); | 1597 pageDump->AddScalar("free_size", "bytes", freeSize); |
| 1590 *outFreeSize = freeSize; | 1598 *outFreeSize = freeSize; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 } | 1767 } |
| 1760 | 1768 |
| 1761 void LargeObjectPage::markOrphaned() | 1769 void LargeObjectPage::markOrphaned() |
| 1762 { | 1770 { |
| 1763 // Zap the payload with a recognizable value to detect any incorrect | 1771 // Zap the payload with a recognizable value to detect any incorrect |
| 1764 // cross thread pointer usage. | 1772 // cross thread pointer usage. |
| 1765 OrphanedPagePool::asanDisabledMemset(payload(), OrphanedPagePool::orphanedZa
pValue, payloadSize()); | 1773 OrphanedPagePool::asanDisabledMemset(payload(), OrphanedPagePool::orphanedZa
pValue, payloadSize()); |
| 1766 BasePage::markOrphaned(); | 1774 BasePage::markOrphaned(); |
| 1767 } | 1775 } |
| 1768 | 1776 |
| 1769 void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex, size_t* ou
tFreeSize, size_t* outFreeCount) | 1777 void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex, ThreadStat
e::GCSnapshotInfo& info, size_t* outFreeSize, size_t* outFreeCount) |
| 1770 { | 1778 { |
| 1771 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long>
(pageIndex))); | 1779 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long>
(pageIndex))); |
| 1772 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr
eateMemoryAllocatorDumpForCurrentGC(dumpName); | 1780 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr
eateMemoryAllocatorDumpForCurrentGC(dumpName); |
| 1773 | 1781 |
| 1774 size_t liveSize = 0; | 1782 size_t liveSize = 0; |
| 1775 size_t deadSize = 0; | 1783 size_t deadSize = 0; |
| 1776 size_t liveCount = 0; | 1784 size_t liveCount = 0; |
| 1777 size_t deadCount = 0; | 1785 size_t deadCount = 0; |
| 1778 HeapObjectHeader* header = heapObjectHeader(); | 1786 HeapObjectHeader* header = heapObjectHeader(); |
| 1787 size_t gcInfoIndex = header->gcInfoIndex(); |
| 1779 if (header->isMarked()) { | 1788 if (header->isMarked()) { |
| 1780 liveCount = 1; | 1789 liveCount = 1; |
| 1781 liveSize += header->payloadSize(); | 1790 liveSize += header->payloadSize(); |
| 1791 info.liveCount[gcInfoIndex]++; |
| 1792 info.liveSize[gcInfoIndex] += header->size(); |
| 1782 } else { | 1793 } else { |
| 1783 deadCount = 1; | 1794 deadCount = 1; |
| 1784 deadSize += header->payloadSize(); | 1795 deadSize += header->payloadSize(); |
| 1796 info.deadCount[gcInfoIndex]++; |
| 1797 info.deadSize[gcInfoIndex] += header->size(); |
| 1785 } | 1798 } |
| 1786 | 1799 |
| 1787 pageDump->AddScalar("live_count", "objects", liveCount); | 1800 pageDump->AddScalar("live_count", "objects", liveCount); |
| 1788 pageDump->AddScalar("dead_count", "objects", deadCount); | 1801 pageDump->AddScalar("dead_count", "objects", deadCount); |
| 1789 pageDump->AddScalar("live_size", "bytes", liveSize); | 1802 pageDump->AddScalar("live_size", "bytes", liveSize); |
| 1790 pageDump->AddScalar("dead_size", "bytes", deadSize); | 1803 pageDump->AddScalar("dead_size", "bytes", deadSize); |
| 1791 } | 1804 } |
| 1792 | 1805 |
| 1793 #if ENABLE(GC_PROFILING) | 1806 #if ENABLE(GC_PROFILING) |
| 1794 const GCInfo* LargeObjectPage::findGCInfo(Address address) | 1807 const GCInfo* LargeObjectPage::findGCInfo(Address address) |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 size_t Heap::s_objectSizeAtLastGC = 0; | 2548 size_t Heap::s_objectSizeAtLastGC = 0; |
| 2536 size_t Heap::s_markedObjectSize = 0; | 2549 size_t Heap::s_markedObjectSize = 0; |
| 2537 size_t Heap::s_persistentCount = 0; | 2550 size_t Heap::s_persistentCount = 0; |
| 2538 size_t Heap::s_persistentCountAtLastGC = 0; | 2551 size_t Heap::s_persistentCountAtLastGC = 0; |
| 2539 size_t Heap::s_collectedPersistentCount = 0; | 2552 size_t Heap::s_collectedPersistentCount = 0; |
| 2540 size_t Heap::s_partitionAllocSizeAtLastGC = 0; | 2553 size_t Heap::s_partitionAllocSizeAtLastGC = 0; |
| 2541 size_t Heap::s_heapSizePerPersistent = 0; | 2554 size_t Heap::s_heapSizePerPersistent = 0; |
| 2542 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2555 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
| 2543 | 2556 |
| 2544 } // namespace blink | 2557 } // namespace blink |
| OLD | NEW |