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

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

Issue 1159773004: Oilpan: Implement a GC to take a heap snapshot (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/ThreadState.h ('k') | Source/platform/heap/Visitor.h » ('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 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 } 846 }
847 847
848 void ThreadState::makeConsistentForGC() 848 void ThreadState::makeConsistentForGC()
849 { 849 {
850 ASSERT(isInGC()); 850 ASSERT(isInGC());
851 TRACE_EVENT0("blink_gc", "ThreadState::makeConsistentForGC"); 851 TRACE_EVENT0("blink_gc", "ThreadState::makeConsistentForGC");
852 for (int i = 0; i < NumberOfHeaps; ++i) 852 for (int i = 0; i < NumberOfHeaps; ++i)
853 m_heaps[i]->makeConsistentForGC(); 853 m_heaps[i]->makeConsistentForGC();
854 } 854 }
855 855
856 void ThreadState::makeConsistentForMutator()
857 {
858 ASSERT(isInGC());
859 for (int i = 0; i < NumberOfHeaps; ++i)
860 m_heaps[i]->makeConsistentForMutator();
861 }
862
856 void ThreadState::preGC() 863 void ThreadState::preGC()
857 { 864 {
858 ASSERT(!isInGC()); 865 ASSERT(!isInGC());
859 setGCState(GCRunning); 866 setGCState(GCRunning);
860 makeConsistentForGC(); 867 makeConsistentForGC();
861 prepareRegionTree(); 868 prepareRegionTree();
862 flushHeapDoesNotContainCacheIfNeeded(); 869 flushHeapDoesNotContainCacheIfNeeded();
863 clearHeapAges(); 870 clearHeapAges();
864 } 871 }
865 872
(...skipping 12 matching lines...) Expand all
878 bool disabledByDefaultGCTracingEnabled; 885 bool disabledByDefaultGCTracingEnabled;
879 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc") , &disabledByDefaultGCTracingEnabled); 886 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc") , &disabledByDefaultGCTracingEnabled);
880 887
881 snapshot(); 888 snapshot();
882 if (disabledByDefaultGCTracingEnabled) 889 if (disabledByDefaultGCTracingEnabled)
883 collectAndReportMarkSweepStats(); 890 collectAndReportMarkSweepStats();
884 incrementMarkedObjectsAge(); 891 incrementMarkedObjectsAge();
885 } 892 }
886 #endif 893 #endif
887 894
888 setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled) ;
889 for (int i = 0; i < NumberOfHeaps; i++) 895 for (int i = 0; i < NumberOfHeaps; i++)
890 m_heaps[i]->prepareForSweep(); 896 m_heaps[i]->prepareForSweep();
897
898 if (gcType == GCWithSweep) {
899 setGCState(EagerSweepScheduled);
900 } else if (gcType == GCWithoutSweep) {
901 setGCState(LazySweepScheduled);
902 } else {
903 takeSnapshot();
904
905 // This unmarks all marked objects and marks all unmarked objects dead.
906 makeConsistentForMutator();
907
908 // Force setting NoGCScheduled to circumvent checkThread()
909 // in setGCState().
910 m_gcState = NoGCScheduled;
911 }
891 } 912 }
892 913
893 void ThreadState::preSweep() 914 void ThreadState::preSweep()
894 { 915 {
895 checkThread(); 916 checkThread();
896 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) 917 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled)
897 return; 918 return;
898 919
899 { 920 {
900 if (isMainThread()) 921 if (isMainThread())
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 m_vectorBackingHeapIndex = heapIndexOfVectorHeapLeastRecentlyExpanded(Ve ctor1HeapIndex, Vector4HeapIndex); 1311 m_vectorBackingHeapIndex = heapIndexOfVectorHeapLeastRecentlyExpanded(Ve ctor1HeapIndex, Vector4HeapIndex);
1291 } 1312 }
1292 1313
1293 void ThreadState::promptlyFreed(size_t gcInfoIndex) 1314 void ThreadState::promptlyFreed(size_t gcInfoIndex)
1294 { 1315 {
1295 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask; 1316 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask;
1296 // See the comment in vectorBackingHeap() for why this is +3. 1317 // See the comment in vectorBackingHeap() for why this is +3.
1297 m_likelyToBePromptlyFreed[entryIndex] += 3; 1318 m_likelyToBePromptlyFreed[entryIndex] += 3;
1298 } 1319 }
1299 1320
1321 void ThreadState::takeSnapshot()
1322 {
1323 ASSERT(isInGC());
1324 // TODO(ssid): Implement this.
1325 }
1326
1300 #if ENABLE(GC_PROFILING) 1327 #if ENABLE(GC_PROFILING)
1301 const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address) 1328 const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address)
1302 { 1329 {
1303 bool needLockForIteration = !ThreadState::current()->isInGC(); 1330 bool needLockForIteration = !ThreadState::current()->isInGC();
1304 if (needLockForIteration) 1331 if (needLockForIteration)
1305 threadAttachMutex().lock(); 1332 threadAttachMutex().lock();
1306 1333
1307 for (ThreadState* state : attachedThreads()) { 1334 for (ThreadState* state : attachedThreads()) {
1308 if (const GCInfo* gcInfo = state->findGCInfo(address)) { 1335 if (const GCInfo* gcInfo = state->findGCInfo(address)) {
1309 if (needLockForIteration) 1336 if (needLockForIteration)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 json->beginArray(it->key.ascii().data()); 1407 json->beginArray(it->key.ascii().data());
1381 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1408 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1382 json->pushInteger(it->value.ages[age]); 1409 json->pushInteger(it->value.ages[age]);
1383 json->endArray(); 1410 json->endArray();
1384 } 1411 }
1385 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1412 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1386 } 1413 }
1387 #endif 1414 #endif
1388 1415
1389 } // namespace blink 1416 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | Source/platform/heap/Visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698