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::dumpMemory(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( )->createMemoryAllocatorDumpForLastGC(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 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1618 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); | 1630 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); |
1619 s_markingVisitor = new MarkingVisitor<Visitor::GlobalMarking>(); | 1631 s_markingVisitor = new MarkingVisitor<Visitor::GlobalMarking>(); |
1620 s_freePagePool = new FreePagePool(); | 1632 s_freePagePool = new FreePagePool(); |
1621 s_orphanedPagePool = new OrphanedPagePool(); | 1633 s_orphanedPagePool = new OrphanedPagePool(); |
1622 s_allocatedObjectSize = 0; | 1634 s_allocatedObjectSize = 0; |
1623 s_allocatedSpace = 0; | 1635 s_allocatedSpace = 0; |
1624 s_markedObjectSize = 0; | 1636 s_markedObjectSize = 0; |
1625 s_estimatedMarkingTimePerByte = 0.0; | 1637 s_estimatedMarkingTimePerByte = 0.0; |
1626 | 1638 |
1627 GCInfoTable::init(); | 1639 GCInfoTable::init(); |
1640 | |
1641 if (Platform::current()->currentThread()) | |
1642 Platform::current()->registerMemoryDumpProvider(BlinkGCMemoryDumpProvide r::instance()); | |
1628 } | 1643 } |
1629 | 1644 |
1630 void Heap::shutdown() | 1645 void Heap::shutdown() |
1631 { | 1646 { |
1647 if (Platform::current()->currentThread()) | |
1648 Platform::current()->unregisterMemoryDumpProvider(BlinkGCMemoryDumpProvi der::instance()); | |
1649 | |
1632 s_shutdownCalled = true; | 1650 s_shutdownCalled = true; |
1633 ThreadState::shutdownHeapIfNecessary(); | 1651 ThreadState::shutdownHeapIfNecessary(); |
1634 } | 1652 } |
1635 | 1653 |
1636 void Heap::doShutdown() | 1654 void Heap::doShutdown() |
1637 { | 1655 { |
1638 // We don't want to call doShutdown() twice. | 1656 // We don't want to call doShutdown() twice. |
1639 if (!s_markingVisitor) | 1657 if (!s_markingVisitor) |
1640 return; | 1658 return; |
1641 | 1659 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1856 | 1874 |
1857 void Heap::preGC() | 1875 void Heap::preGC() |
1858 { | 1876 { |
1859 ASSERT(!ThreadState::current()->isInGC()); | 1877 ASSERT(!ThreadState::current()->isInGC()); |
1860 for (ThreadState* state : ThreadState::attachedThreads()) | 1878 for (ThreadState* state : ThreadState::attachedThreads()) |
1861 state->preGC(); | 1879 state->preGC(); |
1862 } | 1880 } |
1863 | 1881 |
1864 void Heap::postGC(ThreadState::GCType gcType) | 1882 void Heap::postGC(ThreadState::GCType gcType) |
1865 { | 1883 { |
1884 bool enabled = BlinkGCMemoryDumpProvider::isMemoryTracingEnabled(); | |
Primiano Tucci (use gerrit)
2015/05/26 11:24:06
nit: const bool isMemoryTracingEnabled = BlinkGCMe
ssid
2015/05/27 13:15:06
Done.
| |
1885 if (enabled) | |
1886 BlinkGCMemoryDumpProvider::instance()->clearLastGCProcessMemoryDump(); | |
1887 | |
1866 ASSERT(ThreadState::current()->isInGC()); | 1888 ASSERT(ThreadState::current()->isInGC()); |
1867 for (ThreadState* state : ThreadState::attachedThreads()) | 1889 for (ThreadState* state : ThreadState::attachedThreads()) { |
1890 if (enabled) | |
1891 state->dumpMemory(); | |
haraken
2015/05/26 12:21:59
postGC wouldn't be a good timing to take memory du
Primiano Tucci (use gerrit)
2015/05/26 14:18:03
Oh, I think did it in PostGC because the existing
| |
1892 | |
1868 state->postGC(gcType); | 1893 state->postGC(gcType); |
1894 } | |
1895 | |
1896 // TODO(ssid): Request global dump from blink when support is available | |
1897 // (crbug.com/490087). For the moment the dump is periodically invoked by | |
1898 // the MemoryDumpManager every X secs. | |
1869 } | 1899 } |
1870 | 1900 |
1871 const char* Heap::gcReasonString(GCReason reason) | 1901 const char* Heap::gcReasonString(GCReason reason) |
1872 { | 1902 { |
1873 switch (reason) { | 1903 switch (reason) { |
1874 #define STRINGIFY_REASON(reason) case reason: return #reason; | 1904 #define STRINGIFY_REASON(reason) case reason: return #reason; |
1875 STRINGIFY_REASON(IdleGC); | 1905 STRINGIFY_REASON(IdleGC); |
1876 STRINGIFY_REASON(PreciseGC); | 1906 STRINGIFY_REASON(PreciseGC); |
1877 STRINGIFY_REASON(ConservativeGC); | 1907 STRINGIFY_REASON(ConservativeGC); |
1878 STRINGIFY_REASON(ForcedGC); | 1908 STRINGIFY_REASON(ForcedGC); |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2235 size_t Heap::s_allocatedObjectSize = 0; | 2265 size_t Heap::s_allocatedObjectSize = 0; |
2236 size_t Heap::s_allocatedSpace = 0; | 2266 size_t Heap::s_allocatedSpace = 0; |
2237 size_t Heap::s_markedObjectSize = 0; | 2267 size_t Heap::s_markedObjectSize = 0; |
2238 // We don't want to use 0 KB for the initial value because it may end up | 2268 // We don't want to use 0 KB for the initial value because it may end up |
2239 // triggering the first GC of some thread too prematurely. | 2269 // triggering the first GC of some thread too prematurely. |
2240 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; | 2270 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; |
2241 size_t Heap::s_externalObjectSizeAtLastGC = 0; | 2271 size_t Heap::s_externalObjectSizeAtLastGC = 0; |
2242 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2272 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
2243 | 2273 |
2244 } // namespace blink | 2274 } // namespace blink |
OLD | NEW |