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

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

Issue 1159143006: Oilpan: Remove Heap::s_lastGCWasConservative (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | no next file » | 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 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 #if !ENABLE(ASSERT) 1687 #if !ENABLE(ASSERT)
1688 if (s_heapDoesNotContainCache->lookup(address)) 1688 if (s_heapDoesNotContainCache->lookup(address))
1689 return nullptr; 1689 return nullptr;
1690 #endif 1690 #endif
1691 1691
1692 if (BasePage* page = lookup(address)) { 1692 if (BasePage* page = lookup(address)) {
1693 ASSERT(page->contains(address)); 1693 ASSERT(page->contains(address));
1694 ASSERT(!page->orphaned()); 1694 ASSERT(!page->orphaned());
1695 ASSERT(!s_heapDoesNotContainCache->lookup(address)); 1695 ASSERT(!s_heapDoesNotContainCache->lookup(address));
1696 page->checkAndMarkPointer(visitor, address); 1696 page->checkAndMarkPointer(visitor, address);
1697 // FIXME: We only need to set the conservative flag if
1698 // checkAndMarkPointer actually marked the pointer.
1699 s_lastGCWasConservative = true;
1700 return address; 1697 return address;
1701 } 1698 }
1702 1699
1703 #if !ENABLE(ASSERT) 1700 #if !ENABLE(ASSERT)
1704 s_heapDoesNotContainCache->addEntry(address); 1701 s_heapDoesNotContainCache->addEntry(address);
1705 #else 1702 #else
1706 if (!s_heapDoesNotContainCache->lookup(address)) 1703 if (!s_heapDoesNotContainCache->lookup(address))
1707 s_heapDoesNotContainCache->addEntry(address); 1704 s_heapDoesNotContainCache->addEntry(address);
1708 #endif 1705 #endif
1709 return nullptr; 1706 return nullptr;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 if (!gcScope.allThreadsParked()) { 1890 if (!gcScope.allThreadsParked()) {
1894 // Restore the original GCState. 1891 // Restore the original GCState.
1895 if (LIKELY(state->gcState() == ThreadState::StoppingOtherThreads)) 1892 if (LIKELY(state->gcState() == ThreadState::StoppingOtherThreads))
1896 state->setGCState(originalGCState); 1893 state->setGCState(originalGCState);
1897 return; 1894 return;
1898 } 1895 }
1899 1896
1900 if (state->isMainThread()) 1897 if (state->isMainThread())
1901 ScriptForbiddenScope::enter(); 1898 ScriptForbiddenScope::enter();
1902 1899
1903 s_lastGCWasConservative = false;
1904
1905 TRACE_EVENT2("blink_gc", "Heap::collectGarbage", 1900 TRACE_EVENT2("blink_gc", "Heap::collectGarbage",
1906 "lazySweeping", gcType == ThreadState::GCWithoutSweep, 1901 "lazySweeping", gcType == ThreadState::GCWithoutSweep,
1907 "gcReason", gcReasonString(reason)); 1902 "gcReason", gcReasonString(reason));
1908 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC"); 1903 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC");
1909 double timeStamp = WTF::currentTimeMS(); 1904 double timeStamp = WTF::currentTimeMS();
1910 #if ENABLE(GC_PROFILING) 1905 #if ENABLE(GC_PROFILING)
1911 static_cast<MarkingVisitor<Visitor::GlobalMarking>*>(s_markingVisitor)->obje ctGraph().clear(); 1906 static_cast<MarkingVisitor<Visitor::GlobalMarking>*>(s_markingVisitor)->obje ctGraph().clear();
1912 #endif 1907 #endif
1913 1908
1914 // Disallow allocation during garbage collection (but not during the 1909 // Disallow allocation during garbage collection (but not during the
1915 // finalization that happens when the gcScope is torn down). 1910 // finalization that happens when the gcScope is torn down).
1916 ThreadState::NoAllocationScope noAllocationScope(state); 1911 ThreadState::NoAllocationScope noAllocationScope(state);
1917 1912
1918 preGC(); 1913 preGC();
1919 1914
1920 StackFrameDepthScope stackDepthScope; 1915 StackFrameDepthScope stackDepthScope;
1921 1916
1922 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz e(); 1917 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz e();
1923 Heap::resetHeapCounters(); 1918 Heap::resetHeapCounters();
1924 1919
1925 // 1. Trace persistent roots. 1920 // 1. Trace persistent roots.
1926 ThreadState::visitPersistentRoots(s_markingVisitor); 1921 ThreadState::visitPersistentRoots(s_markingVisitor);
1927 1922
1928 // 2. Trace objects reachable from the persistent roots including 1923 // 2. Trace objects reachable from the persistent roots.
Erik Corry Chromium.org 2015/05/30 22:21:50 Either you don't need this step, or it should incl
haraken 2015/06/01 01:29:37 Good point. Done.
1929 // ephemerons.
1930 processMarkingStack(s_markingVisitor); 1924 processMarkingStack(s_markingVisitor);
Erik Corry Chromium.org 2015/05/30 22:21:50 The effect of this was to first find all the preci
haraken 2015/06/01 01:29:37 I don't fully understand this part. How does the o
Erik Corry Chromium.org 2015/06/08 13:26:38 It doesn't change the amount kept alive, it just m
1931 1925
1932 // 3. Trace objects reachable from the stack. We do this independent of the 1926 // 3. Trace objects reachable from the stack. We do this independent of the
1933 // given stackState since other threads might have a different stack state. 1927 // given stackState since other threads might have a different stack state.
1934 ThreadState::visitStackRoots(s_markingVisitor); 1928 ThreadState::visitStackRoots(s_markingVisitor);
1935 1929
1936 // 4. Trace objects reachable from the stack "roots" including ephemerons. 1930 // 4. Trace objects reachable from the stack "roots".
1937 // Only do the processing if we found a pointer to an object on one of the 1931 processMarkingStack(s_markingVisitor);
sof 2015/05/29 12:54:47 Hmm, I think I prefer it the way it is on trunk, b
haraken 2015/05/29 14:38:24 If I'm not missing something, this change reduces
1938 // thread stacks. 1932
1939 if (lastGCWasConservative()) 1933 // 5. Trace ephemerons.
1940 processMarkingStack(s_markingVisitor); 1934 processEphemerons(s_markingVisitor);
Erik Corry Chromium.org 2015/05/30 22:21:50 This starts off by doing step 4, so step 4 is not
1941 1935
1942 postMarkingProcessing(s_markingVisitor); 1936 postMarkingProcessing(s_markingVisitor);
1943 globalWeakProcessing(s_markingVisitor); 1937 globalWeakProcessing(s_markingVisitor);
1944 1938
1945 // Now we can delete all orphaned pages because there are no dangling 1939 // Now we can delete all orphaned pages because there are no dangling
1946 // pointers to the orphaned pages. (If we have such dangling pointers, 1940 // pointers to the orphaned pages. (If we have such dangling pointers,
1947 // we should have crashed during marking before getting here.) 1941 // we should have crashed during marking before getting here.)
1948 orphanedPagePool()->decommitOrphanedPages(); 1942 orphanedPagePool()->decommitOrphanedPages();
1949 1943
1950 postGC(gcType); 1944 postGC(gcType);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 // only cases where this could happen is if a subsequent conservative 1982 // only cases where this could happen is if a subsequent conservative
1989 // global GC finds a "pointer" on the stack or due to a programming 1983 // global GC finds a "pointer" on the stack or due to a programming
1990 // error where an object has a dangling cross-thread pointer to an 1984 // error where an object has a dangling cross-thread pointer to an
1991 // object on this heap. 1985 // object on this heap.
1992 state->visitPersistents(&markingVisitor); 1986 state->visitPersistents(&markingVisitor);
1993 1987
1994 // 2. Trace objects reachable from the thread's persistent roots 1988 // 2. Trace objects reachable from the thread's persistent roots
1995 // including ephemerons. 1989 // including ephemerons.
1996 processMarkingStack(&markingVisitor); 1990 processMarkingStack(&markingVisitor);
1997 1991
1992 // 3. Trace ephemerons.
1993 processEphemerons(&markingVisitor);
Erik Corry Chromium.org 2015/05/30 22:21:50 This starts by doing step 2.
1994
1998 postMarkingProcessing(&markingVisitor); 1995 postMarkingProcessing(&markingVisitor);
1999 globalWeakProcessing(&markingVisitor); 1996 globalWeakProcessing(&markingVisitor);
2000 1997
2001 state->postGC(ThreadState::GCWithSweep); 1998 state->postGC(ThreadState::GCWithSweep);
2002 } 1999 }
2003 state->preSweep(); 2000 state->preSweep();
2004 } 2001 }
2005 2002
2006 void Heap::processMarkingStack(Visitor* markingVisitor) 2003 void Heap::processMarkingStack(Visitor* markingVisitor)
2007 { 2004 {
2005 // Iteratively mark all objects that are reachable from the objects
2006 // currently pushed onto the marking stack.
2007 TRACE_EVENT0("blink_gc", "Heap::processMarkingStackSingleThreaded");
2008 while (popAndInvokeTraceCallback(markingVisitor)) { }
2009 }
2010
2011 void Heap::processEphemerons(Visitor* markingVisitor)
2012 {
2008 // Ephemeron fixed point loop. 2013 // Ephemeron fixed point loop.
2009 do { 2014 do {
2010 { 2015 {
2011 // Iteratively mark all objects that are reachable from the objects 2016 // Iteratively mark all objects that are reachable from the objects
2012 // currently pushed onto the marking stack. 2017 // currently pushed onto the marking stack.
2013 TRACE_EVENT0("blink_gc", "Heap::processMarkingStackSingleThreaded"); 2018 TRACE_EVENT0("blink_gc", "Heap::processMarkingStackSingleThreaded");
2014 while (popAndInvokeTraceCallback(markingVisitor)) { } 2019 while (popAndInvokeTraceCallback(markingVisitor)) { }
2015 } 2020 }
2016 2021
2017 { 2022 {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 s_externalObjectSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages(); 2225 s_externalObjectSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages();
2221 } 2226 }
2222 2227
2223 Visitor* Heap::s_markingVisitor; 2228 Visitor* Heap::s_markingVisitor;
2224 CallbackStack* Heap::s_markingStack; 2229 CallbackStack* Heap::s_markingStack;
2225 CallbackStack* Heap::s_postMarkingCallbackStack; 2230 CallbackStack* Heap::s_postMarkingCallbackStack;
2226 CallbackStack* Heap::s_globalWeakCallbackStack; 2231 CallbackStack* Heap::s_globalWeakCallbackStack;
2227 CallbackStack* Heap::s_ephemeronStack; 2232 CallbackStack* Heap::s_ephemeronStack;
2228 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; 2233 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache;
2229 bool Heap::s_shutdownCalled = false; 2234 bool Heap::s_shutdownCalled = false;
2230 bool Heap::s_lastGCWasConservative = false;
2231 FreePagePool* Heap::s_freePagePool; 2235 FreePagePool* Heap::s_freePagePool;
2232 OrphanedPagePool* Heap::s_orphanedPagePool; 2236 OrphanedPagePool* Heap::s_orphanedPagePool;
2233 Heap::RegionTree* Heap::s_regionTree = nullptr; 2237 Heap::RegionTree* Heap::s_regionTree = nullptr;
2234 size_t Heap::s_allocatedObjectSize = 0; 2238 size_t Heap::s_allocatedObjectSize = 0;
2235 size_t Heap::s_allocatedSpace = 0; 2239 size_t Heap::s_allocatedSpace = 0;
2236 size_t Heap::s_markedObjectSize = 0; 2240 size_t Heap::s_markedObjectSize = 0;
2237 // We don't want to use 0 KB for the initial value because it may end up 2241 // We don't want to use 0 KB for the initial value because it may end up
2238 // triggering the first GC of some thread too prematurely. 2242 // triggering the first GC of some thread too prematurely.
2239 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; 2243 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024;
2240 size_t Heap::s_externalObjectSizeAtLastGC = 0; 2244 size_t Heap::s_externalObjectSizeAtLastGC = 0;
2241 double Heap::s_estimatedMarkingTimePerByte = 0.0; 2245 double Heap::s_estimatedMarkingTimePerByte = 0.0;
2242 2246
2243 } // namespace blink 2247 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698