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

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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); 201 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
202 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>(); 202 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>();
203 new (s_mainThreadStateStorage) ThreadState(); 203 new (s_mainThreadStateStorage) ThreadState();
204 } 204 }
205 205
206 void ThreadState::attachCurrentThread() { 206 void ThreadState::attachCurrentThread() {
207 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); 207 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
208 new ThreadState(); 208 new ThreadState();
209 } 209 }
210 210
211 void ThreadState::cleanupPages() { 211 void ThreadState::removeAllPages() {
212 ASSERT(checkThread()); 212 ASSERT(checkThread());
213 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) 213 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i)
214 m_arenas[i]->cleanupPages(); 214 m_arenas[i]->removeAllPages();
215 } 215 }
216 216
217 void ThreadState::runTerminationGC() { 217 void ThreadState::runTerminationGC() {
218 if (isMainThread()) { 218 if (isMainThread()) {
219 cleanupPages(); 219 removeAllPages();
220 return; 220 return;
221 } 221 }
222 ASSERT(checkThread()); 222 ASSERT(checkThread());
223 223
224 // Finish sweeping. 224 // Finish sweeping.
225 completeSweep(); 225 completeSweep();
226 226
227 releaseStaticPersistentNodes(); 227 releaseStaticPersistentNodes();
228 228
229 // From here on ignore all conservatively discovered 229 // From here on ignore all conservatively discovered
(...skipping 21 matching lines...) Expand all
251 oldCount = currentCount; 251 oldCount = currentCount;
252 currentCount = getPersistentRegion()->numberOfPersistents(); 252 currentCount = getPersistentRegion()->numberOfPersistents();
253 } 253 }
254 // We should not have any persistents left when getting to this point, 254 // We should not have any persistents left when getting to this point,
255 // if we have it is probably a bug so adding a debug ASSERT to catch this. 255 // if we have it is probably a bug so adding a debug ASSERT to catch this.
256 ASSERT(!currentCount); 256 ASSERT(!currentCount);
257 // All of pre-finalizers should be consumed. 257 // All of pre-finalizers should be consumed.
258 ASSERT(m_orderedPreFinalizers.isEmpty()); 258 ASSERT(m_orderedPreFinalizers.isEmpty());
259 RELEASE_ASSERT(gcState() == NoGCScheduled); 259 RELEASE_ASSERT(gcState() == NoGCScheduled);
260 260
261 // Add pages to the orphaned page pool to ensure any global GCs from this 261 removeAllPages();
262 // point on will not trace objects on this thread's arenas.
263 cleanupPages();
264 } 262 }
265 263
266 void ThreadState::cleanupMainThread() { 264 void ThreadState::cleanupMainThread() {
267 ASSERT(isMainThread()); 265 ASSERT(isMainThread());
268 266
269 releaseStaticPersistentNodes(); 267 releaseStaticPersistentNodes();
270 268
271 // Finish sweeping before shutting down V8. Otherwise, some destructor 269 // Finish sweeping before shutting down V8. Otherwise, some destructor
272 // may access V8 and cause crashes. 270 // may access V8 and cause crashes.
273 completeSweep(); 271 completeSweep();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 deadSize(Vector<size_t>(numObjectTypes)) {} 383 deadSize(Vector<size_t>(numObjectTypes)) {}
386 384
387 void ThreadState::pushThreadLocalWeakCallback(void* object, 385 void ThreadState::pushThreadLocalWeakCallback(void* object,
388 WeakCallback callback) { 386 WeakCallback callback) {
389 CallbackStack::Item* slot = m_threadLocalWeakCallbackStack->allocateEntry(); 387 CallbackStack::Item* slot = m_threadLocalWeakCallbackStack->allocateEntry();
390 *slot = CallbackStack::Item(object, callback); 388 *slot = CallbackStack::Item(object, callback);
391 } 389 }
392 390
393 bool ThreadState::popAndInvokeThreadLocalWeakCallback(Visitor* visitor) { 391 bool ThreadState::popAndInvokeThreadLocalWeakCallback(Visitor* visitor) {
394 ASSERT(checkThread()); 392 ASSERT(checkThread());
395 // For weak processing we should never reach orphaned pages since orphaned
396 // pages are not traced and thus objects on those pages are never be
397 // registered as objects on orphaned pages. We cannot assert this here since
398 // we might have an off-heap collection. We assert it in
399 // ThreadHeap::pushThreadLocalWeakCallback.
400 if (CallbackStack::Item* item = m_threadLocalWeakCallbackStack->pop()) { 393 if (CallbackStack::Item* item = m_threadLocalWeakCallbackStack->pop()) {
401 item->call(visitor); 394 item->call(visitor);
402 return true; 395 return true;
403 } 396 }
404 return false; 397 return false;
405 } 398 }
406 399
407 void ThreadState::threadLocalWeakProcessing() { 400 void ThreadState::threadLocalWeakProcessing() {
408 ASSERT(checkThread()); 401 ASSERT(checkThread());
409 ASSERT(!sweepForbidden()); 402 ASSERT(!sweepForbidden());
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 // state. 1670 // state.
1678 heap().visitStackRoots(visitor.get()); 1671 heap().visitStackRoots(visitor.get());
1679 1672
1680 // 3. Transitive closure to trace objects including ephemerons. 1673 // 3. Transitive closure to trace objects including ephemerons.
1681 heap().processMarkingStack(visitor.get()); 1674 heap().processMarkingStack(visitor.get());
1682 1675
1683 heap().postMarkingProcessing(visitor.get()); 1676 heap().postMarkingProcessing(visitor.get());
1684 heap().globalWeakProcessing(visitor.get()); 1677 heap().globalWeakProcessing(visitor.get());
1685 } 1678 }
1686 1679
1687 // Now we can delete all orphaned pages because there are no dangling
1688 // pointers to the orphaned pages. (If we have such dangling pointers,
1689 // we should have crashed during marking before getting here.)
1690 heap().getOrphanedPagePool()->decommitOrphanedPages();
1691
1692 double markingTimeInMilliseconds = WTF::currentTimeMS() - startTime; 1680 double markingTimeInMilliseconds = WTF::currentTimeMS() - startTime;
1693 heap().heapStats().setEstimatedMarkingTimePerByte( 1681 heap().heapStats().setEstimatedMarkingTimePerByte(
1694 totalObjectSize ? (markingTimeInMilliseconds / 1000 / totalObjectSize) 1682 totalObjectSize ? (markingTimeInMilliseconds / 1000 / totalObjectSize)
1695 : 0); 1683 : 0);
1696 1684
1697 #if PRINT_HEAP_STATS 1685 #if PRINT_HEAP_STATS
1698 dataLogF( 1686 dataLogF(
1699 "ThreadHeap::collectGarbage (gcReason=%s, lazySweeping=%d, " 1687 "ThreadHeap::collectGarbage (gcReason=%s, lazySweeping=%d, "
1700 "time=%.1lfms)\n", 1688 "time=%.1lfms)\n",
1701 gcReasonString(reason), gcType == BlinkGC::GCWithoutSweep, 1689 gcReasonString(reason), gcType == BlinkGC::GCWithoutSweep,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, 1769 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep,
1782 BlinkGC::ForcedGC); 1770 BlinkGC::ForcedGC);
1783 size_t liveObjects = heap().heapStats().markedObjectSize(); 1771 size_t liveObjects = heap().heapStats().markedObjectSize();
1784 if (liveObjects == previousLiveObjects) 1772 if (liveObjects == previousLiveObjects)
1785 break; 1773 break;
1786 previousLiveObjects = liveObjects; 1774 previousLiveObjects = liveObjects;
1787 } 1775 }
1788 } 1776 }
1789 1777
1790 } // namespace blink 1778 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698