| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // Add the BaseHeap's pages to the orphanedPagePool. | 254 // Add the BaseHeap's pages to the orphanedPagePool. |
| 255 for (BasePage* page = m_firstPage; page; page = page->next()) { | 255 for (BasePage* page = m_firstPage; page; page = page->next()) { |
| 256 Heap::decreaseAllocatedSpace(page->size()); | 256 Heap::decreaseAllocatedSpace(page->size()); |
| 257 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); | 257 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); |
| 258 } | 258 } |
| 259 m_firstPage = nullptr; | 259 m_firstPage = nullptr; |
| 260 } | 260 } |
| 261 | 261 |
| 262 void BaseHeap::takeSnapshot(const String& dumpBaseName) | 262 void BaseHeap::takeSnapshot(const String& dumpBaseName) |
| 263 { | 263 { |
| 264 size_t pageCount = 0; | 264 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance(
)->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); |
| 265 size_t pageIndex = 0; |
| 265 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { | 266 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { |
| 266 pageCount++; | 267 page->takeSnapshot(dumpBaseName, pageIndex); |
| 268 pageIndex++; |
| 267 } | 269 } |
| 268 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance(
)->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); | 270 allocatorDump->AddScalar("blink_page_count", "objects", pageIndex); |
| 269 allocatorDump->AddScalar("blink_page_count", "objects", pageCount); | |
| 270 } | 271 } |
| 271 | 272 |
| 272 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) | 273 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
| 273 BasePage* BaseHeap::findPageFromAddress(Address address) | 274 BasePage* BaseHeap::findPageFromAddress(Address address) |
| 274 { | 275 { |
| 275 for (BasePage* page = m_firstPage; page; page = page->next()) { | 276 for (BasePage* page = m_firstPage; page; page = page->next()) { |
| 276 if (page->contains(address)) | 277 if (page->contains(address)) |
| 277 return page; | 278 return page; |
| 278 } | 279 } |
| 279 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { | 280 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 // cross thread pointer usage. | 1444 // cross thread pointer usage. |
| 1444 #if defined(ADDRESS_SANITIZER) | 1445 #if defined(ADDRESS_SANITIZER) |
| 1445 // This needs to zap poisoned memory as well. | 1446 // This needs to zap poisoned memory as well. |
| 1446 // Force unpoison memory before memset. | 1447 // Force unpoison memory before memset. |
| 1447 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); | 1448 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); |
| 1448 #endif | 1449 #endif |
| 1449 memset(payload(), orphanedZapValue, payloadSize()); | 1450 memset(payload(), orphanedZapValue, payloadSize()); |
| 1450 BasePage::markOrphaned(); | 1451 BasePage::markOrphaned(); |
| 1451 } | 1452 } |
| 1452 | 1453 |
| 1454 void NormalPage::takeSnapshot(String dumpName, size_t pageIndex) |
| 1455 { |
| 1456 dumpName.append(String::format("/page_%lu", static_cast<unsigned long>(pageI
ndex))); |
| 1457 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr
eateMemoryAllocatorDumpForCurrentGC(dumpName); |
| 1458 |
| 1459 HeapObjectHeader* header = nullptr; |
| 1460 size_t liveCount = 0; |
| 1461 size_t deadCount = 0; |
| 1462 size_t freeCount = 0; |
| 1463 size_t liveSize = 0; |
| 1464 size_t deadSize = 0; |
| 1465 size_t freeSize = 0; |
| 1466 for (Address headerAddress = payload(); headerAddress < payloadEnd(); header
Address += header->size()) { |
| 1467 header = reinterpret_cast<HeapObjectHeader*>(headerAddress); |
| 1468 if (header->isFree()) { |
| 1469 freeCount++; |
| 1470 freeSize += header->size(); |
| 1471 } else if (header->isMarked()) { |
| 1472 liveCount++; |
| 1473 liveSize += header->size(); |
| 1474 } else { |
| 1475 deadCount++; |
| 1476 deadSize += header->size(); |
| 1477 } |
| 1478 } |
| 1479 |
| 1480 pageDump->AddScalar("live_count", "objects", liveCount); |
| 1481 pageDump->AddScalar("dead_count", "objects", deadCount); |
| 1482 pageDump->AddScalar("free_count", "objects", freeCount); |
| 1483 pageDump->AddScalar("live_size", "bytes", liveSize); |
| 1484 pageDump->AddScalar("dead_size", "bytes", deadSize); |
| 1485 pageDump->AddScalar("free_size", "bytes", freeSize); |
| 1486 } |
| 1487 |
| 1453 #if ENABLE(GC_PROFILING) | 1488 #if ENABLE(GC_PROFILING) |
| 1454 const GCInfo* NormalPage::findGCInfo(Address address) | 1489 const GCInfo* NormalPage::findGCInfo(Address address) |
| 1455 { | 1490 { |
| 1456 if (address < payload()) | 1491 if (address < payload()) |
| 1457 return nullptr; | 1492 return nullptr; |
| 1458 | 1493 |
| 1459 HeapObjectHeader* header = findHeaderFromAddress(address); | 1494 HeapObjectHeader* header = findHeaderFromAddress(address); |
| 1460 if (!header) | 1495 if (!header) |
| 1461 return nullptr; | 1496 return nullptr; |
| 1462 | 1497 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1618 } | 1653 } |
| 1619 | 1654 |
| 1620 void LargeObjectPage::markOrphaned() | 1655 void LargeObjectPage::markOrphaned() |
| 1621 { | 1656 { |
| 1622 // Zap the payload with a recognizable value to detect any incorrect | 1657 // Zap the payload with a recognizable value to detect any incorrect |
| 1623 // cross thread pointer usage. | 1658 // cross thread pointer usage. |
| 1624 memset(payload(), orphanedZapValue, payloadSize()); | 1659 memset(payload(), orphanedZapValue, payloadSize()); |
| 1625 BasePage::markOrphaned(); | 1660 BasePage::markOrphaned(); |
| 1626 } | 1661 } |
| 1627 | 1662 |
| 1663 void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex) |
| 1664 { |
| 1665 dumpName.append(String::format("/page_%lu", static_cast<unsigned long>(pageI
ndex))); |
| 1666 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr
eateMemoryAllocatorDumpForCurrentGC(dumpName); |
| 1667 |
| 1668 size_t liveSize = 0; |
| 1669 size_t deadSize = 0; |
| 1670 size_t liveCount = 0; |
| 1671 size_t deadCount = 0; |
| 1672 HeapObjectHeader* header = heapObjectHeader(); |
| 1673 if (header->isMarked()) { |
| 1674 liveCount = 1; |
| 1675 liveSize += header->size(); |
| 1676 } else { |
| 1677 deadCount = 1; |
| 1678 deadSize += header->size(); |
| 1679 } |
| 1680 |
| 1681 pageDump->AddScalar("live_count", "objects", liveCount); |
| 1682 pageDump->AddScalar("dead_count", "objects", deadCount); |
| 1683 pageDump->AddScalar("live_size", "bytes", liveSize); |
| 1684 pageDump->AddScalar("dead_size", "bytes", deadSize); |
| 1685 } |
| 1686 |
| 1628 #if ENABLE(GC_PROFILING) | 1687 #if ENABLE(GC_PROFILING) |
| 1629 const GCInfo* LargeObjectPage::findGCInfo(Address address) | 1688 const GCInfo* LargeObjectPage::findGCInfo(Address address) |
| 1630 { | 1689 { |
| 1631 if (!containedInObjectPayload(address)) | 1690 if (!containedInObjectPayload(address)) |
| 1632 return nullptr; | 1691 return nullptr; |
| 1633 HeapObjectHeader* header = heapObjectHeader(); | 1692 HeapObjectHeader* header = heapObjectHeader(); |
| 1634 return Heap::gcInfo(header->gcInfoIndex()); | 1693 return Heap::gcInfo(header->gcInfoIndex()); |
| 1635 } | 1694 } |
| 1636 | 1695 |
| 1637 void LargeObjectPage::snapshot(TracedValue* json, ThreadState::SnapshotInfo* inf
o) | 1696 void LargeObjectPage::snapshot(TracedValue* json, ThreadState::SnapshotInfo* inf
o) |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2336 size_t Heap::s_allocatedObjectSize = 0; | 2395 size_t Heap::s_allocatedObjectSize = 0; |
| 2337 size_t Heap::s_allocatedSpace = 0; | 2396 size_t Heap::s_allocatedSpace = 0; |
| 2338 size_t Heap::s_markedObjectSize = 0; | 2397 size_t Heap::s_markedObjectSize = 0; |
| 2339 // We don't want to use 0 KB for the initial value because it may end up | 2398 // We don't want to use 0 KB for the initial value because it may end up |
| 2340 // triggering the first GC of some thread too prematurely. | 2399 // triggering the first GC of some thread too prematurely. |
| 2341 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; | 2400 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; |
| 2342 size_t Heap::s_externalObjectSizeAtLastGC = 0; | 2401 size_t Heap::s_externalObjectSizeAtLastGC = 0; |
| 2343 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2402 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
| 2344 | 2403 |
| 2345 } // namespace blink | 2404 } // namespace blink |
| OLD | NEW |