Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 843 } | 843 } |
| 844 | 844 |
| 845 void ThreadState::makeConsistentForGC() | 845 void ThreadState::makeConsistentForGC() |
| 846 { | 846 { |
| 847 ASSERT(isInGC()); | 847 ASSERT(isInGC()); |
| 848 TRACE_EVENT0("blink_gc", "ThreadState::makeConsistentForGC"); | 848 TRACE_EVENT0("blink_gc", "ThreadState::makeConsistentForGC"); |
| 849 for (int i = 0; i < NumberOfHeaps; ++i) | 849 for (int i = 0; i < NumberOfHeaps; ++i) |
| 850 m_heaps[i]->makeConsistentForGC(); | 850 m_heaps[i]->makeConsistentForGC(); |
| 851 } | 851 } |
| 852 | 852 |
| 853 void ThreadState::makeConsistentForMutator() | |
| 854 { | |
| 855 ASSERT(isInGC()); | |
| 856 for (int i = 0; i < NumberOfHeaps; ++i) | |
| 857 m_heaps[i]->makeConsistentForMutator(); | |
| 858 } | |
| 859 | |
| 853 void ThreadState::preGC() | 860 void ThreadState::preGC() |
| 854 { | 861 { |
| 855 ASSERT(!isInGC()); | 862 ASSERT(!isInGC()); |
| 856 setGCState(GCRunning); | 863 setGCState(GCRunning); |
| 857 makeConsistentForGC(); | 864 makeConsistentForGC(); |
| 858 prepareRegionTree(); | 865 prepareRegionTree(); |
| 859 flushHeapDoesNotContainCacheIfNeeded(); | 866 flushHeapDoesNotContainCacheIfNeeded(); |
| 860 clearHeapAges(); | 867 clearHeapAges(); |
| 861 } | 868 } |
| 862 | 869 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 875 bool disabledByDefaultGCTracingEnabled; | 882 bool disabledByDefaultGCTracingEnabled; |
| 876 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc") , &disabledByDefaultGCTracingEnabled); | 883 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc") , &disabledByDefaultGCTracingEnabled); |
| 877 | 884 |
| 878 snapshot(); | 885 snapshot(); |
| 879 if (disabledByDefaultGCTracingEnabled) | 886 if (disabledByDefaultGCTracingEnabled) |
| 880 collectAndReportMarkSweepStats(); | 887 collectAndReportMarkSweepStats(); |
| 881 incrementMarkedObjectsAge(); | 888 incrementMarkedObjectsAge(); |
| 882 } | 889 } |
| 883 #endif | 890 #endif |
| 884 | 891 |
| 885 setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled) ; | |
| 886 for (int i = 0; i < NumberOfHeaps; i++) | 892 for (int i = 0; i < NumberOfHeaps; i++) |
| 887 m_heaps[i]->prepareForSweep(); | 893 m_heaps[i]->prepareForSweep(); |
| 894 | |
| 895 if (gcType == GCWithSweep) { | |
| 896 setGCState(EagerSweepScheduled); | |
| 897 } else if (gcType == GCWithoutSweep) { | |
| 898 setGCState(LazySweepScheduled); | |
| 899 } else { | |
| 900 takeSnapshot(); | |
| 901 | |
| 902 // This unmarks all marked objects and marks all unmarked objects dead. | |
| 903 makeConsistentForMutator(); | |
| 904 | |
| 905 // Force setting NoGCScheduled to circumvent checkThread() | |
| 906 // in setGCState(). | |
| 907 m_gcState = NoGCScheduled; | |
|
sof
2015/05/28 12:15:13
Why are you doing this (way)?
haraken
2015/05/28 12:33:36
As commented above, if we call setGCState(NoGCSche
| |
| 908 } | |
| 888 } | 909 } |
| 889 | 910 |
| 890 void ThreadState::preSweep() | 911 void ThreadState::preSweep() |
| 891 { | 912 { |
| 892 checkThread(); | 913 checkThread(); |
| 893 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) | 914 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) |
| 894 return; | 915 return; |
| 895 | 916 |
| 896 { | 917 { |
| 897 if (isMainThread()) | 918 if (isMainThread()) |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1262 m_vectorBackingHeapIndex = heapIndexOfVectorHeapLeastRecentlyExpanded(Ve ctor1HeapIndex, Vector4HeapIndex); | 1283 m_vectorBackingHeapIndex = heapIndexOfVectorHeapLeastRecentlyExpanded(Ve ctor1HeapIndex, Vector4HeapIndex); |
| 1263 } | 1284 } |
| 1264 | 1285 |
| 1265 void ThreadState::promptlyFreed(size_t gcInfoIndex) | 1286 void ThreadState::promptlyFreed(size_t gcInfoIndex) |
| 1266 { | 1287 { |
| 1267 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask; | 1288 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask; |
| 1268 // See the comment in vectorBackingHeap() for why this is +3. | 1289 // See the comment in vectorBackingHeap() for why this is +3. |
| 1269 m_likelyToBePromptlyFreed[entryIndex] += 3; | 1290 m_likelyToBePromptlyFreed[entryIndex] += 3; |
| 1270 } | 1291 } |
| 1271 | 1292 |
| 1293 void ThreadState::takeSnapshot() | |
| 1294 { | |
| 1295 ASSERT(isInGC()); | |
| 1296 // TODO(ssid): Implement this. | |
| 1297 } | |
| 1298 | |
| 1272 #if ENABLE(GC_PROFILING) | 1299 #if ENABLE(GC_PROFILING) |
| 1273 const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address) | 1300 const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address) |
| 1274 { | 1301 { |
| 1275 bool needLockForIteration = !ThreadState::current()->isInGC(); | 1302 bool needLockForIteration = !ThreadState::current()->isInGC(); |
| 1276 if (needLockForIteration) | 1303 if (needLockForIteration) |
| 1277 threadAttachMutex().lock(); | 1304 threadAttachMutex().lock(); |
| 1278 | 1305 |
| 1279 for (ThreadState* state : attachedThreads()) { | 1306 for (ThreadState* state : attachedThreads()) { |
| 1280 if (const GCInfo* gcInfo = state->findGCInfo(address)) { | 1307 if (const GCInfo* gcInfo = state->findGCInfo(address)) { |
| 1281 if (needLockForIteration) | 1308 if (needLockForIteration) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1352 json->beginArray(it->key.ascii().data()); | 1379 json->beginArray(it->key.ascii().data()); |
| 1353 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1380 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
| 1354 json->pushInteger(it->value.ages[age]); | 1381 json->pushInteger(it->value.ages[age]); |
| 1355 json->endArray(); | 1382 json->endArray(); |
| 1356 } | 1383 } |
| 1357 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); | 1384 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); |
| 1358 } | 1385 } |
| 1359 #endif | 1386 #endif |
| 1360 | 1387 |
| 1361 } // namespace blink | 1388 } // namespace blink |
| OLD | NEW |