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 23 matching lines...) Expand all Loading... | |
| 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/CallbackStack.h" | 37 #include "platform/heap/CallbackStack.h" |
| 38 #include "platform/heap/MarkingVisitor.h" | 38 #include "platform/heap/MarkingVisitor.h" |
| 39 #include "platform/heap/PageMemory.h" | 39 #include "platform/heap/PageMemory.h" |
| 40 #include "platform/heap/PagePool.h" | 40 #include "platform/heap/PagePool.h" |
| 41 #include "platform/heap/SafePoint.h" | 41 #include "platform/heap/SafePoint.h" |
| 42 #include "platform/heap/ThreadState.h" | 42 #include "platform/heap/ThreadState.h" |
| 43 #include "public/platform/Platform.h" | 43 #include "public/platform/Platform.h" |
| 44 #include "public/platform/WebMemoryAllocatorDump.h" | |
| 45 #include "public/platform/WebProcessMemoryDump.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 = Heap::getLastProcessMemoryDump()->cr eateMemoryAllocatorDump(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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1651 delete s_weakCallbackStack; | 1663 delete s_weakCallbackStack; |
| 1652 s_weakCallbackStack = nullptr; | 1664 s_weakCallbackStack = nullptr; |
| 1653 delete s_postMarkingCallbackStack; | 1665 delete s_postMarkingCallbackStack; |
| 1654 s_postMarkingCallbackStack = nullptr; | 1666 s_postMarkingCallbackStack = nullptr; |
| 1655 delete s_markingStack; | 1667 delete s_markingStack; |
| 1656 s_markingStack = nullptr; | 1668 s_markingStack = nullptr; |
| 1657 delete s_ephemeronStack; | 1669 delete s_ephemeronStack; |
| 1658 s_ephemeronStack = nullptr; | 1670 s_ephemeronStack = nullptr; |
| 1659 delete s_regionTree; | 1671 delete s_regionTree; |
| 1660 s_regionTree = nullptr; | 1672 s_regionTree = nullptr; |
| 1673 if (s_lastProcessMemoryDump) { | |
|
Primiano Tucci (use gerrit)
2015/05/22 15:50:21
See my other consideration. If you move this to Bl
ssid
2015/05/22 17:17:10
Done.
| |
| 1674 delete s_lastProcessMemoryDump; | |
| 1675 s_lastProcessMemoryDump = nullptr; | |
| 1676 } | |
| 1677 | |
| 1661 GCInfoTable::shutdown(); | 1678 GCInfoTable::shutdown(); |
| 1662 ThreadState::shutdown(); | 1679 ThreadState::shutdown(); |
| 1663 ASSERT(Heap::allocatedSpace() == 0); | 1680 ASSERT(Heap::allocatedSpace() == 0); |
| 1664 } | 1681 } |
| 1665 | 1682 |
| 1666 #if ENABLE(ASSERT) | 1683 #if ENABLE(ASSERT) |
| 1667 BasePage* Heap::findPageFromAddress(Address address) | 1684 BasePage* Heap::findPageFromAddress(Address address) |
| 1668 { | 1685 { |
| 1669 BasePage* result = nullptr; | 1686 BasePage* result = nullptr; |
| 1670 if (!ThreadState::current()->isInGC()) | 1687 if (!ThreadState::current()->isInGC()) |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1856 | 1873 |
| 1857 void Heap::preGC() | 1874 void Heap::preGC() |
| 1858 { | 1875 { |
| 1859 ASSERT(!ThreadState::current()->isInGC()); | 1876 ASSERT(!ThreadState::current()->isInGC()); |
| 1860 for (ThreadState* state : ThreadState::attachedThreads()) | 1877 for (ThreadState* state : ThreadState::attachedThreads()) |
| 1861 state->preGC(); | 1878 state->preGC(); |
| 1862 } | 1879 } |
| 1863 | 1880 |
| 1864 void Heap::postGC(ThreadState::GCType gcType) | 1881 void Heap::postGC(ThreadState::GCType gcType) |
| 1865 { | 1882 { |
| 1883 // TODO(ssid): Change this to use api from memory-infra to check tracing | |
| 1884 // enabled (crbug.com/490087). | |
| 1885 bool enabled; | |
|
Primiano Tucci (use gerrit)
2015/05/22 15:50:21
s /enabled/memory_tracing_enabled/
ssid
2015/05/22 17:17:10
Done.
| |
| 1886 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("memory-infra") , &enabled); | |
| 1887 if (enabled) | |
| 1888 Heap::clearLastProcessMemoryDump(); | |
| 1889 | |
| 1866 ASSERT(ThreadState::current()->isInGC()); | 1890 ASSERT(ThreadState::current()->isInGC()); |
| 1867 for (ThreadState* state : ThreadState::attachedThreads()) | 1891 for (ThreadState* state : ThreadState::attachedThreads()) { |
| 1892 if (enabled) | |
| 1893 state->dumpMemory(); | |
| 1894 | |
| 1868 state->postGC(gcType); | 1895 state->postGC(gcType); |
| 1896 } | |
| 1897 | |
| 1898 // TODO(ssid): Request global dump from blink when support is available | |
| 1899 // (crbug.com/490087). For the moment the dump is periodically invoked by | |
| 1900 // the MemoryDumpManager every X secs. | |
| 1869 } | 1901 } |
| 1870 | 1902 |
| 1871 const char* Heap::gcReasonString(GCReason reason) | 1903 const char* Heap::gcReasonString(GCReason reason) |
| 1872 { | 1904 { |
| 1873 switch (reason) { | 1905 switch (reason) { |
| 1874 #define STRINGIFY_REASON(reason) case reason: return #reason; | 1906 #define STRINGIFY_REASON(reason) case reason: return #reason; |
| 1875 STRINGIFY_REASON(IdleGC); | 1907 STRINGIFY_REASON(IdleGC); |
| 1876 STRINGIFY_REASON(PreciseGC); | 1908 STRINGIFY_REASON(PreciseGC); |
| 1877 STRINGIFY_REASON(ConservativeGC); | 1909 STRINGIFY_REASON(ConservativeGC); |
| 1878 STRINGIFY_REASON(ForcedGC); | 1910 STRINGIFY_REASON(ForcedGC); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2114 state->setGCState(ThreadState::GCRunning); | 2146 state->setGCState(ThreadState::GCRunning); |
| 2115 state->makeConsistentForSweeping(); | 2147 state->makeConsistentForSweeping(); |
| 2116 objectPayloadSize += state->objectPayloadSizeForTesting(); | 2148 objectPayloadSize += state->objectPayloadSizeForTesting(); |
| 2117 state->setGCState(ThreadState::EagerSweepScheduled); | 2149 state->setGCState(ThreadState::EagerSweepScheduled); |
| 2118 state->setGCState(ThreadState::Sweeping); | 2150 state->setGCState(ThreadState::Sweeping); |
| 2119 state->setGCState(ThreadState::NoGCScheduled); | 2151 state->setGCState(ThreadState::NoGCScheduled); |
| 2120 } | 2152 } |
| 2121 return objectPayloadSize; | 2153 return objectPayloadSize; |
| 2122 } | 2154 } |
| 2123 | 2155 |
| 2156 WebProcessMemoryDump* Heap::getLastProcessMemoryDump() { return s_lastProcessMem oryDump; } | |
| 2157 | |
| 2158 void Heap::clearLastProcessMemoryDump() | |
|
Primiano Tucci (use gerrit)
2015/05/22 15:50:21
Ouch, this is really my fault, I forgot that WPMD
ssid
2015/05/22 17:17:10
Yes i know. Looked like this file had lots of new(
| |
| 2159 { | |
| 2160 if (s_lastProcessMemoryDump) | |
| 2161 delete s_lastProcessMemoryDump; | |
| 2162 s_lastProcessMemoryDump = Platform::current()->createProcessMemoryDump(); | |
| 2163 } | |
| 2164 | |
| 2124 BasePage* Heap::lookup(Address address) | 2165 BasePage* Heap::lookup(Address address) |
| 2125 { | 2166 { |
| 2126 ASSERT(ThreadState::current()->isInGC()); | 2167 ASSERT(ThreadState::current()->isInGC()); |
| 2127 if (!s_regionTree) | 2168 if (!s_regionTree) |
| 2128 return nullptr; | 2169 return nullptr; |
| 2129 if (PageMemoryRegion* region = s_regionTree->lookup(address)) { | 2170 if (PageMemoryRegion* region = s_regionTree->lookup(address)) { |
| 2130 BasePage* page = region->pageFromAddress(address); | 2171 BasePage* page = region->pageFromAddress(address); |
| 2131 return page && !page->orphaned() ? page : nullptr; | 2172 return page && !page->orphaned() ? page : nullptr; |
| 2132 } | 2173 } |
| 2133 return nullptr; | 2174 return nullptr; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2233 OrphanedPagePool* Heap::s_orphanedPagePool; | 2274 OrphanedPagePool* Heap::s_orphanedPagePool; |
| 2234 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2275 Heap::RegionTree* Heap::s_regionTree = nullptr; |
| 2235 size_t Heap::s_allocatedObjectSize = 0; | 2276 size_t Heap::s_allocatedObjectSize = 0; |
| 2236 size_t Heap::s_allocatedSpace = 0; | 2277 size_t Heap::s_allocatedSpace = 0; |
| 2237 size_t Heap::s_markedObjectSize = 0; | 2278 size_t Heap::s_markedObjectSize = 0; |
| 2238 // We don't want to use 0 KB for the initial value because it may end up | 2279 // 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. | 2280 // triggering the first GC of some thread too prematurely. |
| 2240 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; | 2281 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; |
| 2241 size_t Heap::s_externalObjectSizeAtLastGC = 0; | 2282 size_t Heap::s_externalObjectSizeAtLastGC = 0; |
| 2242 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2283 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
| 2284 WebProcessMemoryDump* Heap::s_lastProcessMemoryDump; | |
|
Primiano Tucci (use gerrit)
2015/05/22 15:50:21
This also goes away :)
ssid
2015/05/22 17:17:10
Done.
| |
| 2243 | 2285 |
| 2244 } // namespace blink | 2286 } // namespace blink |
| OLD | NEW |