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