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

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

Issue 1159003003: Revert of Oilpan: Implement a GC to take a heap snapshot (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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/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 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 } 831 }
832 832
833 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() 833 void ThreadState::flushHeapDoesNotContainCacheIfNeeded()
834 { 834 {
835 if (m_shouldFlushHeapDoesNotContainCache) { 835 if (m_shouldFlushHeapDoesNotContainCache) {
836 Heap::flushHeapDoesNotContainCache(); 836 Heap::flushHeapDoesNotContainCache();
837 m_shouldFlushHeapDoesNotContainCache = false; 837 m_shouldFlushHeapDoesNotContainCache = false;
838 } 838 }
839 } 839 }
840 840
841 void ThreadState::makeConsistentForSweeping(GCType gcType) 841 void ThreadState::makeConsistentForSweeping()
842 { 842 {
843 ASSERT(isInGC()); 843 ASSERT(isInGC());
844 TRACE_EVENT0("blink_gc", "ThreadState::makeConsistentForSweeping"); 844 TRACE_EVENT0("blink_gc", "ThreadState::makeConsistentForSweeping");
845 for (int i = 0; i < NumberOfHeaps; ++i) 845 for (int i = 0; i < NumberOfHeaps; ++i)
846 m_heaps[i]->makeConsistentForSweeping(gcType); 846 m_heaps[i]->makeConsistentForSweeping();
847 } 847 }
848 848
849 void ThreadState::preGC(GCType gcType) 849 void ThreadState::preGC()
850 { 850 {
851 ASSERT(!isInGC()); 851 ASSERT(!isInGC());
852 setGCState(GCRunning); 852 setGCState(GCRunning);
853 makeConsistentForSweeping(gcType); 853 makeConsistentForSweeping();
854 prepareRegionTree(); 854 prepareRegionTree();
855 flushHeapDoesNotContainCacheIfNeeded(); 855 flushHeapDoesNotContainCacheIfNeeded();
856 clearHeapAges(); 856 clearHeapAges();
857 } 857 }
858 858
859 void ThreadState::postGC(GCType gcType) 859 void ThreadState::postGC(GCType gcType)
860 { 860 {
861 ASSERT(isInGC()); 861 ASSERT(isInGC());
862 862
863 #if ENABLE(GC_PROFILING) 863 #if ENABLE(GC_PROFILING)
864 // We snapshot the heap prior to sweeping to get numbers for both resources 864 // We snapshot the heap prior to sweeping to get numbers for both resources
865 // that have been allocated since the last GC and for resources that are 865 // that have been allocated since the last GC and for resources that are
866 // going to be freed. 866 // going to be freed.
867 bool gcTracingEnabled; 867 bool gcTracingEnabled;
868 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); 868 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled);
869 869
870 if (gcTracingEnabled) { 870 if (gcTracingEnabled) {
871 bool disabledByDefaultGCTracingEnabled; 871 bool disabledByDefaultGCTracingEnabled;
872 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc") , &disabledByDefaultGCTracingEnabled); 872 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc") , &disabledByDefaultGCTracingEnabled);
873 873
874 snapshot(); 874 snapshot();
875 if (disabledByDefaultGCTracingEnabled) 875 if (disabledByDefaultGCTracingEnabled)
876 collectAndReportMarkSweepStats(); 876 collectAndReportMarkSweepStats();
877 incrementMarkedObjectsAge(); 877 incrementMarkedObjectsAge();
878 } 878 }
879 #endif 879 #endif
880 880
881 setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled) ;
881 for (int i = 0; i < NumberOfHeaps; i++) 882 for (int i = 0; i < NumberOfHeaps; i++)
882 m_heaps[i]->prepareForSweep(); 883 m_heaps[i]->prepareForSweep();
883
884 if (gcType == GCWithSweep) {
885 setGCState(EagerSweepScheduled);
886 } else if (gcType == GCWithoutSweep) {
887 setGCState(LazySweepScheduled);
888 } else {
889 takeSnapshot();
890 // This unmarks all marked objects and marks all unmarked objects dead.
891 makeConsistentForSweeping(gcType);
892 // Force setting NoGCScheduled to circumvent checkThread()
893 // in setGCState().
894 m_gcState = NoGCScheduled;
895 }
896 } 884 }
897 885
898 void ThreadState::preSweep() 886 void ThreadState::preSweep()
899 { 887 {
900 checkThread(); 888 checkThread();
901 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) 889 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled)
902 return; 890 return;
903 891
904 { 892 {
905 if (isMainThread()) 893 if (isMainThread())
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 m_vectorBackingHeapIndex = heapIndexOfVectorHeapLeastRecentlyExpanded(Ve ctor1HeapIndex, Vector4HeapIndex); 1258 m_vectorBackingHeapIndex = heapIndexOfVectorHeapLeastRecentlyExpanded(Ve ctor1HeapIndex, Vector4HeapIndex);
1271 } 1259 }
1272 1260
1273 void ThreadState::promptlyFreed(size_t gcInfoIndex) 1261 void ThreadState::promptlyFreed(size_t gcInfoIndex)
1274 { 1262 {
1275 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask; 1263 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask;
1276 // See the comment in vectorBackingHeap() for why this is +3. 1264 // See the comment in vectorBackingHeap() for why this is +3.
1277 m_likelyToBePromptlyFreed[entryIndex] += 3; 1265 m_likelyToBePromptlyFreed[entryIndex] += 3;
1278 } 1266 }
1279 1267
1280 void ThreadState::takeSnapshot()
1281 {
1282 ASSERT(isInGC());
1283 // TODO(ssid): Implement this.
1284 }
1285
1286 #if ENABLE(GC_PROFILING) 1268 #if ENABLE(GC_PROFILING)
1287 const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address) 1269 const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address)
1288 { 1270 {
1289 bool needLockForIteration = !ThreadState::current()->isInGC(); 1271 bool needLockForIteration = !ThreadState::current()->isInGC();
1290 if (needLockForIteration) 1272 if (needLockForIteration)
1291 threadAttachMutex().lock(); 1273 threadAttachMutex().lock();
1292 1274
1293 for (ThreadState* state : attachedThreads()) { 1275 for (ThreadState* state : attachedThreads()) {
1294 if (const GCInfo* gcInfo = state->findGCInfo(address)) { 1276 if (const GCInfo* gcInfo = state->findGCInfo(address)) {
1295 if (needLockForIteration) 1277 if (needLockForIteration)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 json->beginArray(it->key.ascii().data()); 1348 json->beginArray(it->key.ascii().data());
1367 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1349 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1368 json->pushInteger(it->value.ages[age]); 1350 json->pushInteger(it->value.ages[age]);
1369 json->endArray(); 1351 json->endArray();
1370 } 1352 }
1371 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1353 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1372 } 1354 }
1373 #endif 1355 #endif
1374 1356
1375 } // namespace blink 1357 } // 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