| 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 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "platform/heap/Heap.h" | 32 #include "platform/heap/Heap.h" |
| 33 | 33 |
| 34 #include "platform/ScriptForbiddenScope.h" | 34 #include "platform/ScriptForbiddenScope.h" |
| 35 #include "platform/Task.h" | 35 #include "platform/Task.h" |
| 36 #include "platform/TraceEvent.h" | 36 #include "platform/TraceEvent.h" |
| 37 #include "platform/heap/BlinkGCMemoryDumpProvider.h" |
| 37 #include "platform/heap/CallbackStack.h" | 38 #include "platform/heap/CallbackStack.h" |
| 38 #include "platform/heap/MarkingVisitor.h" | 39 #include "platform/heap/MarkingVisitor.h" |
| 39 #include "platform/heap/PageMemory.h" | 40 #include "platform/heap/PageMemory.h" |
| 40 #include "platform/heap/PagePool.h" | 41 #include "platform/heap/PagePool.h" |
| 41 #include "platform/heap/SafePoint.h" | 42 #include "platform/heap/SafePoint.h" |
| 42 #include "platform/heap/ThreadState.h" | 43 #include "platform/heap/ThreadState.h" |
| 43 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
| 45 #include "public/platform/WebMemoryAllocatorDump.h" |
| 44 #include "wtf/Assertions.h" | 46 #include "wtf/Assertions.h" |
| 45 #include "wtf/ContainerAnnotations.h" | 47 #include "wtf/ContainerAnnotations.h" |
| 46 #include "wtf/LeakAnnotations.h" | 48 #include "wtf/LeakAnnotations.h" |
| 47 #include "wtf/MainThread.h" | 49 #include "wtf/MainThread.h" |
| 48 #include "wtf/PageAllocator.h" | 50 #include "wtf/PageAllocator.h" |
| 49 #include "wtf/Partitions.h" | 51 #include "wtf/Partitions.h" |
| 50 #include "wtf/PassOwnPtr.h" | 52 #include "wtf/PassOwnPtr.h" |
| 51 #if ENABLE(GC_PROFILING) | 53 #if ENABLE(GC_PROFILING) |
| 52 #include "platform/TracedValue.h" | 54 #include "platform/TracedValue.h" |
| 53 #include "wtf/HashMap.h" | 55 #include "wtf/HashMap.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 208 |
| 207 ASSERT(!m_firstUnsweptPage); | 209 ASSERT(!m_firstUnsweptPage); |
| 208 // Add the BaseHeap's pages to the orphanedPagePool. | 210 // Add the BaseHeap's pages to the orphanedPagePool. |
| 209 for (BasePage* page = m_firstPage; page; page = page->next()) { | 211 for (BasePage* page = m_firstPage; page; page = page->next()) { |
| 210 Heap::decreaseAllocatedSpace(page->size()); | 212 Heap::decreaseAllocatedSpace(page->size()); |
| 211 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); | 213 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); |
| 212 } | 214 } |
| 213 m_firstPage = nullptr; | 215 m_firstPage = nullptr; |
| 214 } | 216 } |
| 215 | 217 |
| 218 void BaseHeap::takeSnapshot(const String& dumpBaseName) |
| 219 { |
| 220 size_t pageCount = 0; |
| 221 for (BasePage* page = m_firstPage; page; page = page->next()) { |
| 222 pageCount++; |
| 223 } |
| 224 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance(
)->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); |
| 225 allocatorDump->AddScalar("blink_page_count", "objects", pageCount); |
| 226 } |
| 227 |
| 216 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) | 228 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
| 217 BasePage* BaseHeap::findPageFromAddress(Address address) | 229 BasePage* BaseHeap::findPageFromAddress(Address address) |
| 218 { | 230 { |
| 219 for (BasePage* page = m_firstPage; page; page = page->next()) { | 231 for (BasePage* page = m_firstPage; page; page = page->next()) { |
| 220 if (page->contains(address)) | 232 if (page->contains(address)) |
| 221 return page; | 233 return page; |
| 222 } | 234 } |
| 223 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { | 235 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { |
| 224 if (page->contains(address)) | 236 if (page->contains(address)) |
| 225 return page; | 237 return page; |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); | 1640 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); |
| 1629 s_markingVisitor = new MarkingVisitor<Visitor::GlobalMarking>(); | 1641 s_markingVisitor = new MarkingVisitor<Visitor::GlobalMarking>(); |
| 1630 s_freePagePool = new FreePagePool(); | 1642 s_freePagePool = new FreePagePool(); |
| 1631 s_orphanedPagePool = new OrphanedPagePool(); | 1643 s_orphanedPagePool = new OrphanedPagePool(); |
| 1632 s_allocatedObjectSize = 0; | 1644 s_allocatedObjectSize = 0; |
| 1633 s_allocatedSpace = 0; | 1645 s_allocatedSpace = 0; |
| 1634 s_markedObjectSize = 0; | 1646 s_markedObjectSize = 0; |
| 1635 s_estimatedMarkingTimePerByte = 0.0; | 1647 s_estimatedMarkingTimePerByte = 0.0; |
| 1636 | 1648 |
| 1637 GCInfoTable::init(); | 1649 GCInfoTable::init(); |
| 1650 |
| 1651 if (Platform::current()->currentThread()) |
| 1652 Platform::current()->registerMemoryDumpProvider(BlinkGCMemoryDumpProvide
r::instance()); |
| 1638 } | 1653 } |
| 1639 | 1654 |
| 1640 void Heap::shutdown() | 1655 void Heap::shutdown() |
| 1641 { | 1656 { |
| 1657 if (Platform::current()->currentThread()) |
| 1658 Platform::current()->unregisterMemoryDumpProvider(BlinkGCMemoryDumpProvi
der::instance()); |
| 1642 s_shutdownCalled = true; | 1659 s_shutdownCalled = true; |
| 1643 ThreadState::shutdownHeapIfNecessary(); | 1660 ThreadState::shutdownHeapIfNecessary(); |
| 1644 } | 1661 } |
| 1645 | 1662 |
| 1646 void Heap::doShutdown() | 1663 void Heap::doShutdown() |
| 1647 { | 1664 { |
| 1648 // We don't want to call doShutdown() twice. | 1665 // We don't want to call doShutdown() twice. |
| 1649 if (!s_markingVisitor) | 1666 if (!s_markingVisitor) |
| 1650 return; | 1667 return; |
| 1651 | 1668 |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2228 size_t Heap::s_allocatedObjectSize = 0; | 2245 size_t Heap::s_allocatedObjectSize = 0; |
| 2229 size_t Heap::s_allocatedSpace = 0; | 2246 size_t Heap::s_allocatedSpace = 0; |
| 2230 size_t Heap::s_markedObjectSize = 0; | 2247 size_t Heap::s_markedObjectSize = 0; |
| 2231 // We don't want to use 0 KB for the initial value because it may end up | 2248 // We don't want to use 0 KB for the initial value because it may end up |
| 2232 // triggering the first GC of some thread too prematurely. | 2249 // triggering the first GC of some thread too prematurely. |
| 2233 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; | 2250 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; |
| 2234 size_t Heap::s_externalObjectSizeAtLastGC = 0; | 2251 size_t Heap::s_externalObjectSizeAtLastGC = 0; |
| 2235 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2252 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
| 2236 | 2253 |
| 2237 } // namespace blink | 2254 } // namespace blink |
| OLD | NEW |