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

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

Issue 850663002: Oilpan: fix computation of ThreadState::m_collectionRate. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Undo ill-effects of previous patchset Created 5 years, 11 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/ThreadState.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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 if (sweepForbidden()) 850 if (sweepForbidden())
851 return; 851 return;
852 852
853 ThreadState::SweepForbiddenScope scope(this); 853 ThreadState::SweepForbiddenScope scope(this);
854 { 854 {
855 TRACE_EVENT0("blink_gc", "ThreadState::completeSweep"); 855 TRACE_EVENT0("blink_gc", "ThreadState::completeSweep");
856 for (int i = 0; i < NumberOfHeaps; i++) 856 for (int i = 0; i < NumberOfHeaps; i++)
857 m_heaps[i]->completeSweep(); 857 m_heaps[i]->completeSweep();
858 } 858 }
859 859
860 if (isMainThread()) { 860 if (isMainThread() && m_allocatedObjectSizeBeforeGC) {
861 // FIXME: Heap::markedObjectSize() may not be accurate because other 861 // FIXME: Heap::markedObjectSize() may not be accurate because other
862 // threads may not have finished sweeping. 862 // threads may not have finished sweeping.
863 m_collectionRate = 1.0 * Heap::markedObjectSize() / m_allocatedObjectSiz eBeforeSweeping; 863 m_collectionRate = 1.0 * Heap::markedObjectSize() / m_allocatedObjectSiz eBeforeGC;
864 ASSERT(m_collectionRate >= 0);
865
866 // The main thread might be at a safe point, with other
867 // threads leaving theirs and accumulating marked object size
868 // while continuing to sweep. That accumulated size might end up
869 // exceeding what the main thread sampled in preGC() (recorded
870 // in m_allocatedObjectSizeBeforeGC), resulting in a non-sensical
871 // > 1.0 rate.
872 //
873 // This is rare (cf. HeapTest.Threading for a case though);
874 // reset the invalid rate if encountered.
875 //
876 if (m_collectionRate > 1.0)
877 m_collectionRate = 1.0;
864 } else { 878 } else {
865 // FIXME: We should make m_lowCollectionRate available in non-main 879 // FIXME: We should make m_collectionRate available in non-main threads.
866 // threads.
867 m_collectionRate = 1.0; 880 m_collectionRate = 1.0;
868 } 881 }
869 882
870 setGCState(gcState() == Sweeping ? NoGCScheduled : GCScheduled); 883 setGCState(gcState() == Sweeping ? NoGCScheduled : GCScheduled);
871 } 884 }
872 885
873 void ThreadState::prepareRegionTree() 886 void ThreadState::prepareRegionTree()
874 { 887 {
875 // Add the regions allocated by this thread to the region search tree. 888 // Add the regions allocated by this thread to the region search tree.
876 for (PageMemoryRegion* region : m_allocatedRegionsSinceLastGC) 889 for (PageMemoryRegion* region : m_allocatedRegionsSinceLastGC)
877 Heap::addPageMemoryRegion(region); 890 Heap::addPageMemoryRegion(region);
878 m_allocatedRegionsSinceLastGC.clear(); 891 m_allocatedRegionsSinceLastGC.clear();
879 } 892 }
880 893
881 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() 894 void ThreadState::flushHeapDoesNotContainCacheIfNeeded()
882 { 895 {
883 if (m_shouldFlushHeapDoesNotContainCache) { 896 if (m_shouldFlushHeapDoesNotContainCache) {
884 Heap::flushHeapDoesNotContainCache(); 897 Heap::flushHeapDoesNotContainCache();
885 m_shouldFlushHeapDoesNotContainCache = false; 898 m_shouldFlushHeapDoesNotContainCache = false;
886 } 899 }
887 } 900 }
888 901
889 void ThreadState::preGC() 902 void ThreadState::preGC()
890 { 903 {
891 ASSERT(!isInGC()); 904 ASSERT(!isInGC());
892 setGCState(GCRunning); 905 setGCState(GCRunning);
893 makeConsistentForSweeping(); 906 makeConsistentForSweeping();
894 prepareRegionTree(); 907 prepareRegionTree();
895 flushHeapDoesNotContainCacheIfNeeded(); 908 flushHeapDoesNotContainCacheIfNeeded();
909 if (isMainThread())
910 m_allocatedObjectSizeBeforeGC = Heap::allocatedObjectSize() + Heap::mark edObjectSize();
896 } 911 }
897 912
898 void ThreadState::postGC(GCType gcType) 913 void ThreadState::postGC(GCType gcType)
899 { 914 {
900 ASSERT(isInGC()); 915 ASSERT(isInGC());
901 setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled) ; 916 setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled) ;
902 for (int i = 0; i < NumberOfHeaps; i++) 917 for (int i = 0; i < NumberOfHeaps; i++)
903 m_heaps[i]->prepareForSweep(); 918 m_heaps[i]->prepareForSweep();
904 } 919 }
905 920
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 } 1045 }
1031 } 1046 }
1032 1047
1033 void ThreadState::postGCProcessing() 1048 void ThreadState::postGCProcessing()
1034 { 1049 {
1035 checkThread(); 1050 checkThread();
1036 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) 1051 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled)
1037 return; 1052 return;
1038 1053
1039 m_didV8GCAfterLastGC = false; 1054 m_didV8GCAfterLastGC = false;
1040 if (isMainThread())
1041 m_allocatedObjectSizeBeforeSweeping = Heap::allocatedObjectSize();
1042 1055
1043 #if ENABLE(GC_PROFILE_HEAP) 1056 #if ENABLE(GC_PROFILE_HEAP)
1044 // We snapshot the heap prior to sweeping to get numbers for both resources 1057 // We snapshot the heap prior to sweeping to get numbers for both resources
1045 // that have been allocated since the last GC and for resources that are 1058 // that have been allocated since the last GC and for resources that are
1046 // going to be freed. 1059 // going to be freed.
1047 bool gcTracingEnabled; 1060 bool gcTracingEnabled;
1048 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); 1061 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled);
1049 if (gcTracingEnabled) 1062 if (gcTracingEnabled)
1050 snapshot(); 1063 snapshot();
1051 #endif 1064 #endif
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 return gcInfo; 1175 return gcInfo;
1163 } 1176 }
1164 } 1177 }
1165 if (needLockForIteration) 1178 if (needLockForIteration)
1166 threadAttachMutex().unlock(); 1179 threadAttachMutex().unlock();
1167 return nullptr; 1180 return nullptr;
1168 } 1181 }
1169 #endif 1182 #endif
1170 1183
1171 } // namespace blink 1184 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698