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 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 heap().compaction()->finishThreadCompaction(); | 979 heap().compaction()->finishThreadCompaction(); |
980 } | 980 } |
981 | 981 |
982 void ThreadState::makeConsistentForMutator() { | 982 void ThreadState::makeConsistentForMutator() { |
983 ASSERT(isInGC()); | 983 ASSERT(isInGC()); |
984 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) | 984 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) |
985 m_arenas[i]->makeConsistentForMutator(); | 985 m_arenas[i]->makeConsistentForMutator(); |
986 } | 986 } |
987 | 987 |
988 void ThreadState::preGC() { | 988 void ThreadState::preGC() { |
989 if (RuntimeEnabledFeatures::traceWrappablesEnabled() && m_isolate && | 989 if (m_isolate && m_performCleanup) |
990 m_performCleanup) | |
991 m_performCleanup(m_isolate); | 990 m_performCleanup(m_isolate); |
992 | 991 |
993 ASSERT(!isInGC()); | 992 ASSERT(!isInGC()); |
994 setGCState(GCRunning); | 993 setGCState(GCRunning); |
995 makeConsistentForGC(); | 994 makeConsistentForGC(); |
996 flushHeapDoesNotContainCacheIfNeeded(); | 995 flushHeapDoesNotContainCacheIfNeeded(); |
997 clearArenaAges(); | 996 clearArenaAges(); |
998 | 997 |
999 // It is possible, albeit rare, for a thread to be kept | 998 // It is possible, albeit rare, for a thread to be kept |
1000 // at a safepoint across multiple GCs, as resuming all attached | 999 // at a safepoint across multiple GCs, as resuming all attached |
1001 // threads after the "global" GC phases will contend for the shared | 1000 // threads after the "global" GC phases will contend for the shared |
1002 // safepoint barrier mutexes etc, which can additionally delay | 1001 // safepoint barrier mutexes etc, which can additionally delay |
1003 // a thread. Enough so that another thread may initiate | 1002 // a thread. Enough so that another thread may initiate |
1004 // a new GC before this has happened. | 1003 // a new GC before this has happened. |
1005 // | 1004 // |
1006 // In which case the parked thread's ThreadState will have unprocessed | 1005 // In which case the parked thread's ThreadState will have unprocessed |
1007 // entries on its local weak callback stack when that later GC goes | 1006 // entries on its local weak callback stack when that later GC goes |
1008 // ahead. Clear out and invalidate the stack now, as the thread | 1007 // ahead. Clear out and invalidate the stack now, as the thread |
1009 // should only process callbacks that's found to be reachable by | 1008 // should only process callbacks that's found to be reachable by |
1010 // the latest GC, when it eventually gets to next perform | 1009 // the latest GC, when it eventually gets to next perform |
1011 // thread-local weak processing. | 1010 // thread-local weak processing. |
1012 m_threadLocalWeakCallbackStack->decommit(); | 1011 m_threadLocalWeakCallbackStack->decommit(); |
1013 m_threadLocalWeakCallbackStack->commit(); | 1012 m_threadLocalWeakCallbackStack->commit(); |
1014 } | 1013 } |
1015 | 1014 |
1016 void ThreadState::postGC(BlinkGC::GCType gcType) { | 1015 void ThreadState::postGC(BlinkGC::GCType gcType) { |
1017 if (RuntimeEnabledFeatures::traceWrappablesEnabled() && | 1016 if (m_invalidateDeadObjectsInWrappersMarkingDeque) |
1018 m_invalidateDeadObjectsInWrappersMarkingDeque) { | |
1019 m_invalidateDeadObjectsInWrappersMarkingDeque(m_isolate); | 1017 m_invalidateDeadObjectsInWrappersMarkingDeque(m_isolate); |
1020 } | |
1021 | 1018 |
1022 ASSERT(isInGC()); | 1019 ASSERT(isInGC()); |
1023 for (int i = 0; i < BlinkGC::NumberOfArenas; i++) | 1020 for (int i = 0; i < BlinkGC::NumberOfArenas; i++) |
1024 m_arenas[i]->prepareForSweep(); | 1021 m_arenas[i]->prepareForSweep(); |
1025 | 1022 |
1026 if (gcType == BlinkGC::TakeSnapshot) { | 1023 if (gcType == BlinkGC::TakeSnapshot) { |
1027 takeSnapshot(SnapshotType::HeapSnapshot); | 1024 takeSnapshot(SnapshotType::HeapSnapshot); |
1028 | 1025 |
1029 // This unmarks all marked objects and marks all unmarked objects dead. | 1026 // This unmarks all marked objects and marks all unmarked objects dead. |
1030 makeConsistentForMutator(); | 1027 makeConsistentForMutator(); |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, | 1781 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, |
1785 BlinkGC::ForcedGC); | 1782 BlinkGC::ForcedGC); |
1786 size_t liveObjects = heap().heapStats().markedObjectSize(); | 1783 size_t liveObjects = heap().heapStats().markedObjectSize(); |
1787 if (liveObjects == previousLiveObjects) | 1784 if (liveObjects == previousLiveObjects) |
1788 break; | 1785 break; |
1789 previousLiveObjects = liveObjects; | 1786 previousLiveObjects = liveObjects; |
1790 } | 1787 } |
1791 } | 1788 } |
1792 | 1789 |
1793 } // namespace blink | 1790 } // namespace blink |
OLD | NEW |