Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 #include "platform/TraceEvent.h" | 36 #include "platform/TraceEvent.h" |
| 37 #include "platform/heap/BlinkGCMemoryDumpProvider.h" | 37 #include "platform/heap/BlinkGCMemoryDumpProvider.h" |
| 38 #include "platform/heap/CallbackStack.h" | 38 #include "platform/heap/CallbackStack.h" |
| 39 #include "platform/heap/MarkingVisitor.h" | 39 #include "platform/heap/MarkingVisitor.h" |
| 40 #include "platform/heap/PageMemory.h" | 40 #include "platform/heap/PageMemory.h" |
| 41 #include "platform/heap/PagePool.h" | 41 #include "platform/heap/PagePool.h" |
| 42 #include "platform/heap/SafePoint.h" | 42 #include "platform/heap/SafePoint.h" |
| 43 #include "platform/heap/ThreadState.h" | 43 #include "platform/heap/ThreadState.h" |
| 44 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
| 45 #include "public/platform/WebMemoryAllocatorDump.h" | 45 #include "public/platform/WebMemoryAllocatorDump.h" |
| 46 #include "public/platform/WebProcessMemoryDump.h" | |
| 46 #include "wtf/Assertions.h" | 47 #include "wtf/Assertions.h" |
| 47 #include "wtf/ContainerAnnotations.h" | 48 #include "wtf/ContainerAnnotations.h" |
| 48 #include "wtf/LeakAnnotations.h" | 49 #include "wtf/LeakAnnotations.h" |
| 49 #include "wtf/MainThread.h" | 50 #include "wtf/MainThread.h" |
| 50 #include "wtf/PageAllocator.h" | 51 #include "wtf/PageAllocator.h" |
| 51 #include "wtf/Partitions.h" | 52 #include "wtf/Partitions.h" |
| 52 #include "wtf/PassOwnPtr.h" | 53 #include "wtf/PassOwnPtr.h" |
| 53 #if ENABLE(GC_PROFILING) | 54 #if ENABLE(GC_PROFILING) |
| 54 #include "platform/TracedValue.h" | 55 #include "platform/TracedValue.h" |
| 55 #include "wtf/HashMap.h" | 56 #include "wtf/HashMap.h" |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 bool NormalPageHeap::pagesToBeSweptContains(Address address) | 556 bool NormalPageHeap::pagesToBeSweptContains(Address address) |
| 556 { | 557 { |
| 557 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { | 558 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { |
| 558 if (page->contains(address)) | 559 if (page->contains(address)) |
| 559 return true; | 560 return true; |
| 560 } | 561 } |
| 561 return false; | 562 return false; |
| 562 } | 563 } |
| 563 #endif | 564 #endif |
| 564 | 565 |
| 566 void NormalPageHeap::takeFreelistSnapshot(const String& dumpName) | |
| 567 { | |
| 568 if (m_freeList.takeSnapshot(dumpName) && m_firstUnsweptPage) { | |
|
haraken
2015/06/25 00:50:21
What is the '&& m_firstUnsweptPage' check for?
ssid
2015/06/25 03:08:07
the m_firstUnsweptPage checks for if there is any
| |
| 569 WebMemoryAllocatorDump* bucketsDump = BlinkGCMemoryDumpProvider::instanc e()->createMemoryAllocatorDumpForCurrentGC(dumpName + "/buckets"); | |
| 570 WebMemoryAllocatorDump* pagesDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(dumpName + "/pages"); | |
| 571 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->AddOw nershipEdge(pagesDump->guid(), bucketsDump->guid()); | |
| 572 } | |
| 573 } | |
| 574 | |
| 565 #if ENABLE(GC_PROFILING) | 575 #if ENABLE(GC_PROFILING) |
| 566 void NormalPageHeap::snapshotFreeList(TracedValue& json) | 576 void NormalPageHeap::snapshotFreeList(TracedValue& json) |
| 567 { | 577 { |
| 568 json.setInteger("cumulativeAllocationSize", m_cumulativeAllocationSize); | 578 json.setInteger("cumulativeAllocationSize", m_cumulativeAllocationSize); |
| 569 json.setDouble("inlineAllocationRate", static_cast<double>(m_inlineAllocatio nCount) / m_allocationCount); | 579 json.setDouble("inlineAllocationRate", static_cast<double>(m_inlineAllocatio nCount) / m_allocationCount); |
| 570 json.setInteger("inlineAllocationCount", m_inlineAllocationCount); | 580 json.setInteger("inlineAllocationCount", m_inlineAllocationCount); |
| 571 json.setInteger("allocationCount", m_allocationCount); | 581 json.setInteger("allocationCount", m_allocationCount); |
| 572 size_t pageCount = 0; | 582 size_t pageCount = 0; |
| 573 size_t totalPageSize = 0; | 583 size_t totalPageSize = 0; |
| 574 for (NormalPage* page = static_cast<NormalPage*>(m_firstPage); page; page = static_cast<NormalPage*>(page->next())) { | 584 for (NormalPage* page = static_cast<NormalPage*>(m_firstPage); page; page = static_cast<NormalPage*>(page->next())) { |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1113 { | 1123 { |
| 1114 ASSERT(size > 0); | 1124 ASSERT(size > 0); |
| 1115 int index = -1; | 1125 int index = -1; |
| 1116 while (size) { | 1126 while (size) { |
| 1117 size >>= 1; | 1127 size >>= 1; |
| 1118 index++; | 1128 index++; |
| 1119 } | 1129 } |
| 1120 return index; | 1130 return index; |
| 1121 } | 1131 } |
| 1122 | 1132 |
| 1133 bool FreeList::takeSnapshot(const String& dumpBaseName) | |
| 1134 { | |
| 1135 bool didDumpBucketStats = false; | |
| 1136 for (size_t i = 0; i < blinkPageSizeLog2; ++i) { | |
| 1137 size_t entryCount = 0; | |
| 1138 size_t freeSize = 0; | |
| 1139 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next() ) { | |
| 1140 ++entryCount; | |
| 1141 freeSize += entry->size(); | |
| 1142 } | |
| 1143 | |
| 1144 String dumpName = dumpBaseName + String::format("/buckets/bucket_%lu", s tatic_cast<unsigned long>(1 << i)); | |
| 1145 WebMemoryAllocatorDump* bucketDump = BlinkGCMemoryDumpProvider::instance ()->createMemoryAllocatorDumpForCurrentGC(dumpName); | |
| 1146 bucketDump->AddScalar("freelist_entry_count", "objects", entryCount); | |
| 1147 bucketDump->AddScalar("free_size", "bytes", freeSize); | |
| 1148 didDumpBucketStats = true; | |
| 1149 } | |
| 1150 return didDumpBucketStats; | |
| 1151 } | |
| 1152 | |
| 1123 #if ENABLE(GC_PROFILING) | 1153 #if ENABLE(GC_PROFILING) |
| 1124 void FreeList::getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& to talFreeSize) const | 1154 void FreeList::getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& to talFreeSize) const |
| 1125 { | 1155 { |
| 1126 totalFreeSize = 0; | 1156 totalFreeSize = 0; |
| 1127 for (size_t i = 0; i < blinkPageSizeLog2; i++) { | 1157 for (size_t i = 0; i < blinkPageSizeLog2; i++) { |
| 1128 size_t& entryCount = bucketStats[i].entryCount; | 1158 size_t& entryCount = bucketStats[i].entryCount; |
| 1129 size_t& freeSize = bucketStats[i].freeSize; | 1159 size_t& freeSize = bucketStats[i].freeSize; |
| 1130 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next() ) { | 1160 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next() ) { |
| 1131 ++entryCount; | 1161 ++entryCount; |
| 1132 freeSize += entry->size(); | 1162 freeSize += entry->size(); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1446 // This needs to zap poisoned memory as well. | 1476 // This needs to zap poisoned memory as well. |
| 1447 // Force unpoison memory before memset. | 1477 // Force unpoison memory before memset. |
| 1448 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); | 1478 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); |
| 1449 #endif | 1479 #endif |
| 1450 memset(payload(), orphanedZapValue, payloadSize()); | 1480 memset(payload(), orphanedZapValue, payloadSize()); |
| 1451 BasePage::markOrphaned(); | 1481 BasePage::markOrphaned(); |
| 1452 } | 1482 } |
| 1453 | 1483 |
| 1454 void NormalPage::takeSnapshot(String dumpName, size_t pageIndex) | 1484 void NormalPage::takeSnapshot(String dumpName, size_t pageIndex) |
| 1455 { | 1485 { |
| 1456 dumpName.append(String::format("/page_%lu", static_cast<unsigned long>(pageI ndex))); | 1486 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long> (pageIndex))); |
| 1457 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName); | 1487 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName); |
| 1458 | 1488 |
| 1459 HeapObjectHeader* header = nullptr; | 1489 HeapObjectHeader* header = nullptr; |
| 1460 size_t liveCount = 0; | 1490 size_t liveCount = 0; |
| 1461 size_t deadCount = 0; | 1491 size_t deadCount = 0; |
| 1462 size_t freeCount = 0; | 1492 size_t freeCount = 0; |
| 1463 size_t liveSize = 0; | 1493 size_t liveSize = 0; |
| 1464 size_t deadSize = 0; | 1494 size_t deadSize = 0; |
| 1465 size_t freeSize = 0; | 1495 size_t freeSize = 0; |
| 1466 for (Address headerAddress = payload(); headerAddress < payloadEnd(); header Address += header->size()) { | 1496 for (Address headerAddress = payload(); headerAddress < payloadEnd(); header Address += header->size()) { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1655 void LargeObjectPage::markOrphaned() | 1685 void LargeObjectPage::markOrphaned() |
| 1656 { | 1686 { |
| 1657 // Zap the payload with a recognizable value to detect any incorrect | 1687 // Zap the payload with a recognizable value to detect any incorrect |
| 1658 // cross thread pointer usage. | 1688 // cross thread pointer usage. |
| 1659 memset(payload(), orphanedZapValue, payloadSize()); | 1689 memset(payload(), orphanedZapValue, payloadSize()); |
| 1660 BasePage::markOrphaned(); | 1690 BasePage::markOrphaned(); |
| 1661 } | 1691 } |
| 1662 | 1692 |
| 1663 void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex) | 1693 void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex) |
| 1664 { | 1694 { |
| 1665 dumpName.append(String::format("/page_%lu", static_cast<unsigned long>(pageI ndex))); | 1695 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long> (pageIndex))); |
| 1666 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName); | 1696 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName); |
| 1667 | 1697 |
| 1668 size_t liveSize = 0; | 1698 size_t liveSize = 0; |
| 1669 size_t deadSize = 0; | 1699 size_t deadSize = 0; |
| 1670 size_t liveCount = 0; | 1700 size_t liveCount = 0; |
| 1671 size_t deadCount = 0; | 1701 size_t deadCount = 0; |
| 1672 HeapObjectHeader* header = heapObjectHeader(); | 1702 HeapObjectHeader* header = heapObjectHeader(); |
| 1673 if (header->isMarked()) { | 1703 if (header->isMarked()) { |
| 1674 liveCount = 1; | 1704 liveCount = 1; |
| 1675 liveSize += header->size(); | 1705 liveSize += header->size(); |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2395 size_t Heap::s_allocatedObjectSize = 0; | 2425 size_t Heap::s_allocatedObjectSize = 0; |
| 2396 size_t Heap::s_allocatedSpace = 0; | 2426 size_t Heap::s_allocatedSpace = 0; |
| 2397 size_t Heap::s_markedObjectSize = 0; | 2427 size_t Heap::s_markedObjectSize = 0; |
| 2398 // We don't want to use 0 KB for the initial value because it may end up | 2428 // We don't want to use 0 KB for the initial value because it may end up |
| 2399 // triggering the first GC of some thread too prematurely. | 2429 // triggering the first GC of some thread too prematurely. |
| 2400 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; | 2430 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; |
| 2401 size_t Heap::s_externalObjectSizeAtLastGC = 0; | 2431 size_t Heap::s_externalObjectSizeAtLastGC = 0; |
| 2402 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2432 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
| 2403 | 2433 |
| 2404 } // namespace blink | 2434 } // namespace blink |
| OLD | NEW |