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

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

Issue 2684633004: Remove orphaned pages from Oilpan (Closed)
Patch Set: temp Created 3 years, 10 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
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 void ThreadState::attachMainThread() { 200 void ThreadState::attachMainThread() {
201 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>(); 201 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>();
202 new (s_mainThreadStateStorage) ThreadState(); 202 new (s_mainThreadStateStorage) ThreadState();
203 } 203 }
204 204
205 void ThreadState::attachCurrentThread() { 205 void ThreadState::attachCurrentThread() {
206 new ThreadState(); 206 new ThreadState();
207 } 207 }
208 208
209 void ThreadState::cleanupPages() { 209 void ThreadState::removeAllPages() {
210 ASSERT(checkThread()); 210 ASSERT(checkThread());
211 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) 211 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i)
212 m_arenas[i]->cleanupPages(); 212 m_arenas[i]->removeAllPages();
213 } 213 }
214 214
215 void ThreadState::runTerminationGC() { 215 void ThreadState::runTerminationGC() {
216 if (isMainThread()) { 216 if (isMainThread()) {
217 cleanupPages(); 217 removeAllPages();
218 return; 218 return;
219 } 219 }
220 ASSERT(checkThread()); 220 ASSERT(checkThread());
221 221
222 // Finish sweeping. 222 // Finish sweeping.
223 completeSweep(); 223 completeSweep();
224 224
225 releaseStaticPersistentNodes(); 225 releaseStaticPersistentNodes();
226 226
227 // From here on ignore all conservatively discovered 227 // From here on ignore all conservatively discovered
(...skipping 24 matching lines...) Expand all
252 oldCount = currentCount; 252 oldCount = currentCount;
253 currentCount = getPersistentRegion()->numberOfPersistents(); 253 currentCount = getPersistentRegion()->numberOfPersistents();
254 } 254 }
255 // We should not have any persistents left when getting to this point, 255 // We should not have any persistents left when getting to this point,
256 // if we have it is probably a bug so adding a debug ASSERT to catch this. 256 // if we have it is probably a bug so adding a debug ASSERT to catch this.
257 ASSERT(!currentCount); 257 ASSERT(!currentCount);
258 // All of pre-finalizers should be consumed. 258 // All of pre-finalizers should be consumed.
259 ASSERT(m_orderedPreFinalizers.isEmpty()); 259 ASSERT(m_orderedPreFinalizers.isEmpty());
260 RELEASE_ASSERT(gcState() == NoGCScheduled); 260 RELEASE_ASSERT(gcState() == NoGCScheduled);
261 261
262 // Add pages to the orphaned page pool to ensure any global GCs from this 262 removeAllPages();
263 // point on will not trace objects on this thread's arenas.
264 cleanupPages();
265 } 263 }
266 264
267 void ThreadState::detachCurrentThread() { 265 void ThreadState::detachCurrentThread() {
268 ThreadState* state = current(); 266 ThreadState* state = current();
269 state->heap().detach(state); 267 state->heap().detach(state);
270 RELEASE_ASSERT(state->gcState() == ThreadState::NoGCScheduled); 268 RELEASE_ASSERT(state->gcState() == ThreadState::NoGCScheduled);
271 delete state; 269 delete state;
272 } 270 }
273 271
274 NO_SANITIZE_ADDRESS 272 NO_SANITIZE_ADDRESS
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 deadSize(Vector<size_t>(numObjectTypes)) {} 357 deadSize(Vector<size_t>(numObjectTypes)) {}
360 358
361 void ThreadState::pushThreadLocalWeakCallback(void* object, 359 void ThreadState::pushThreadLocalWeakCallback(void* object,
362 WeakCallback callback) { 360 WeakCallback callback) {
363 CallbackStack::Item* slot = m_threadLocalWeakCallbackStack->allocateEntry(); 361 CallbackStack::Item* slot = m_threadLocalWeakCallbackStack->allocateEntry();
364 *slot = CallbackStack::Item(object, callback); 362 *slot = CallbackStack::Item(object, callback);
365 } 363 }
366 364
367 bool ThreadState::popAndInvokeThreadLocalWeakCallback(Visitor* visitor) { 365 bool ThreadState::popAndInvokeThreadLocalWeakCallback(Visitor* visitor) {
368 ASSERT(checkThread()); 366 ASSERT(checkThread());
369 // For weak processing we should never reach orphaned pages since orphaned
370 // pages are not traced and thus objects on those pages are never be
371 // registered as objects on orphaned pages. We cannot assert this here since
372 // we might have an off-heap collection. We assert it in
373 // ThreadHeap::pushThreadLocalWeakCallback.
374 if (CallbackStack::Item* item = m_threadLocalWeakCallbackStack->pop()) { 367 if (CallbackStack::Item* item = m_threadLocalWeakCallbackStack->pop()) {
375 item->call(visitor); 368 item->call(visitor);
376 return true; 369 return true;
377 } 370 }
378 return false; 371 return false;
379 } 372 }
380 373
381 void ThreadState::threadLocalWeakProcessing() { 374 void ThreadState::threadLocalWeakProcessing() {
382 ASSERT(checkThread()); 375 ASSERT(checkThread());
383 ASSERT(!sweepForbidden()); 376 ASSERT(!sweepForbidden());
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 // state. 1644 // state.
1652 heap().visitStackRoots(visitor.get()); 1645 heap().visitStackRoots(visitor.get());
1653 1646
1654 // 3. Transitive closure to trace objects including ephemerons. 1647 // 3. Transitive closure to trace objects including ephemerons.
1655 heap().processMarkingStack(visitor.get()); 1648 heap().processMarkingStack(visitor.get());
1656 1649
1657 heap().postMarkingProcessing(visitor.get()); 1650 heap().postMarkingProcessing(visitor.get());
1658 heap().globalWeakProcessing(visitor.get()); 1651 heap().globalWeakProcessing(visitor.get());
1659 } 1652 }
1660 1653
1661 // Now we can delete all orphaned pages because there are no dangling
1662 // pointers to the orphaned pages. (If we have such dangling pointers,
1663 // we should have crashed during marking before getting here.)
1664 heap().getOrphanedPagePool()->decommitOrphanedPages();
1665
1666 double markingTimeInMilliseconds = WTF::currentTimeMS() - startTime; 1654 double markingTimeInMilliseconds = WTF::currentTimeMS() - startTime;
1667 heap().heapStats().setEstimatedMarkingTimePerByte( 1655 heap().heapStats().setEstimatedMarkingTimePerByte(
1668 totalObjectSize ? (markingTimeInMilliseconds / 1000 / totalObjectSize) 1656 totalObjectSize ? (markingTimeInMilliseconds / 1000 / totalObjectSize)
1669 : 0); 1657 : 0);
1670 1658
1671 #if PRINT_HEAP_STATS 1659 #if PRINT_HEAP_STATS
1672 dataLogF( 1660 dataLogF(
1673 "ThreadHeap::collectGarbage (gcReason=%s, lazySweeping=%d, " 1661 "ThreadHeap::collectGarbage (gcReason=%s, lazySweeping=%d, "
1674 "time=%.1lfms)\n", 1662 "time=%.1lfms)\n",
1675 gcReasonString(reason), gcType == BlinkGC::GCWithoutSweep, 1663 gcReasonString(reason), gcType == BlinkGC::GCWithoutSweep,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, 1743 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep,
1756 BlinkGC::ForcedGC); 1744 BlinkGC::ForcedGC);
1757 size_t liveObjects = heap().heapStats().markedObjectSize(); 1745 size_t liveObjects = heap().heapStats().markedObjectSize();
1758 if (liveObjects == previousLiveObjects) 1746 if (liveObjects == previousLiveObjects)
1759 break; 1747 break;
1760 previousLiveObjects = liveObjects; 1748 previousLiveObjects = liveObjects;
1761 } 1749 }
1762 } 1750 }
1763 1751
1764 } // namespace blink 1752 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | third_party/WebKit/Source/platform/heap/TraceTraits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698