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