Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: Source/platform/heap/Heap.cpp

Issue 1149673002: Adding blink gc memory dump infrastructure for thread specific dumps. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase and replacing main thread with thread id. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 252
251 ASSERT(!m_firstUnsweptPage); 253 ASSERT(!m_firstUnsweptPage);
252 // Add the BaseHeap's pages to the orphanedPagePool. 254 // Add the BaseHeap's pages to the orphanedPagePool.
253 for (BasePage* page = m_firstPage; page; page = page->next()) { 255 for (BasePage* page = m_firstPage; page; page = page->next()) {
254 Heap::decreaseAllocatedSpace(page->size()); 256 Heap::decreaseAllocatedSpace(page->size());
255 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); 257 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page);
256 } 258 }
257 m_firstPage = nullptr; 259 m_firstPage = nullptr;
258 } 260 }
259 261
262 void BaseHeap::takeSnapshot(const String& dumpBaseName)
263 {
264 size_t pageCount = 0;
265 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
266 pageCount++;
267 }
268 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(dumpBaseName);
269 allocatorDump->AddScalar("blink_page_count", "objects", pageCount);
270 }
271
260 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) 272 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING)
261 BasePage* BaseHeap::findPageFromAddress(Address address) 273 BasePage* BaseHeap::findPageFromAddress(Address address)
262 { 274 {
263 for (BasePage* page = m_firstPage; page; page = page->next()) { 275 for (BasePage* page = m_firstPage; page; page = page->next()) {
264 if (page->contains(address)) 276 if (page->contains(address))
265 return page; 277 return page;
266 } 278 }
267 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { 279 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
268 if (page->contains(address)) 280 if (page->contains(address))
269 return page; 281 return page;
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 s_ephemeronStack = new CallbackStack(); 1751 s_ephemeronStack = new CallbackStack();
1740 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); 1752 s_heapDoesNotContainCache = new HeapDoesNotContainCache();
1741 s_freePagePool = new FreePagePool(); 1753 s_freePagePool = new FreePagePool();
1742 s_orphanedPagePool = new OrphanedPagePool(); 1754 s_orphanedPagePool = new OrphanedPagePool();
1743 s_allocatedObjectSize = 0; 1755 s_allocatedObjectSize = 0;
1744 s_allocatedSpace = 0; 1756 s_allocatedSpace = 0;
1745 s_markedObjectSize = 0; 1757 s_markedObjectSize = 0;
1746 s_estimatedMarkingTimePerByte = 0.0; 1758 s_estimatedMarkingTimePerByte = 0.0;
1747 1759
1748 GCInfoTable::init(); 1760 GCInfoTable::init();
1761
1762 if (Platform::current() && Platform::current()->currentThread())
1763 Platform::current()->registerMemoryDumpProvider(BlinkGCMemoryDumpProvide r::instance());
1749 } 1764 }
1750 1765
1751 void Heap::shutdown() 1766 void Heap::shutdown()
1752 { 1767 {
1768 if (Platform::current() && Platform::current()->currentThread())
1769 Platform::current()->unregisterMemoryDumpProvider(BlinkGCMemoryDumpProvi der::instance());
1753 s_shutdownCalled = true; 1770 s_shutdownCalled = true;
1754 ThreadState::shutdownHeapIfNecessary(); 1771 ThreadState::shutdownHeapIfNecessary();
1755 } 1772 }
1756 1773
1757 void Heap::doShutdown() 1774 void Heap::doShutdown()
1758 { 1775 {
1759 // We don't want to call doShutdown() twice. 1776 // We don't want to call doShutdown() twice.
1760 if (!s_markingStack) 1777 if (!s_markingStack)
1761 return; 1778 return;
1762 1779
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 2013
1997 if (state->isMainThread()) 2014 if (state->isMainThread())
1998 ScriptForbiddenScope::enter(); 2015 ScriptForbiddenScope::enter();
1999 2016
2000 TRACE_EVENT2("blink_gc", "Heap::collectGarbage", 2017 TRACE_EVENT2("blink_gc", "Heap::collectGarbage",
2001 "lazySweeping", gcType == ThreadState::GCWithoutSweep, 2018 "lazySweeping", gcType == ThreadState::GCWithoutSweep,
2002 "gcReason", gcReasonString(reason)); 2019 "gcReason", gcReasonString(reason));
2003 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC"); 2020 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC");
2004 double timeStamp = WTF::currentTimeMS(); 2021 double timeStamp = WTF::currentTimeMS();
2005 2022
2023 if (gcType == ThreadState::TakeSnapshot)
2024 BlinkGCMemoryDumpProvider::instance()->clearProcessDumpForCurrentGC();
2025
2006 // Disallow allocation during garbage collection (but not during the 2026 // Disallow allocation during garbage collection (but not during the
2007 // finalization that happens when the gcScope is torn down). 2027 // finalization that happens when the gcScope is torn down).
2008 ThreadState::NoAllocationScope noAllocationScope(state); 2028 ThreadState::NoAllocationScope noAllocationScope(state);
2009 2029
2010 preGC(); 2030 preGC();
2011 2031
2012 StackFrameDepthScope stackDepthScope; 2032 StackFrameDepthScope stackDepthScope;
2013 2033
2014 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz e(); 2034 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz e();
2015 if (gcType != ThreadState::TakeSnapshot) 2035 if (gcType != ThreadState::TakeSnapshot)
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2316 size_t Heap::s_allocatedObjectSize = 0; 2336 size_t Heap::s_allocatedObjectSize = 0;
2317 size_t Heap::s_allocatedSpace = 0; 2337 size_t Heap::s_allocatedSpace = 0;
2318 size_t Heap::s_markedObjectSize = 0; 2338 size_t Heap::s_markedObjectSize = 0;
2319 // We don't want to use 0 KB for the initial value because it may end up 2339 // We don't want to use 0 KB for the initial value because it may end up
2320 // triggering the first GC of some thread too prematurely. 2340 // triggering the first GC of some thread too prematurely.
2321 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; 2341 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024;
2322 size_t Heap::s_externalObjectSizeAtLastGC = 0; 2342 size_t Heap::s_externalObjectSizeAtLastGC = 0;
2323 double Heap::s_estimatedMarkingTimePerByte = 0.0; 2343 double Heap::s_estimatedMarkingTimePerByte = 0.0;
2324 2344
2325 } // namespace blink 2345 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698