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

Unified Diff: Source/heap/ThreadState.cpp

Issue 187483002: Oilpan: We need to collect all garbage before shutting down the worker thread (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« Source/heap/ThreadState.h ('K') | « Source/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/heap/ThreadState.cpp
diff --git a/Source/heap/ThreadState.cpp b/Source/heap/ThreadState.cpp
index 233a979afe7ea6e39a9d325529717307e42d90a9..763d22cf16f5af91a1a6713920456ddb2dc5710b 100644
--- a/Source/heap/ThreadState.cpp
+++ b/Source/heap/ThreadState.cpp
@@ -296,13 +296,7 @@ void ThreadState::cleanup()
// After this GC we expect heap to be empty because
// preCleanup tasks should have cleared all persistent
// handles that were externally owned.
- // FIXME: oilpan: we should perform a single GC and everything
- // should die. Unfortunately it is not the case for all objects
- // because the hierarchy was not completely moved to the heap and
- // some heap allocated objects own objects that contain persistents
- // pointing to other heap allocated objects.
- Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
- Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
+ Heap::collectAllGarbage(ThreadState::NoHeapPointersOnStack);
// Verify that all heaps are empty now.
for (int i = 0; i < NumberOfHeaps; i++)
@@ -317,6 +311,16 @@ void ThreadState::cleanup()
void ThreadState::detach()
{
ThreadState* state = current();
+
+ // When ThreadState is detaching from non-main thread its
Mads Ager (chromium) 2014/03/05 07:40:34 Ah, you moved it here. Have the comment on what cl
haraken 2014/03/05 08:50:26 Done.
+ // heap is expected to be empty (because it is going away).
+ // Perform registered cleanup tasks and garbage collection
+ // to sweep away any objects that are left on this heap.
+ // We assert that nothing must remain after this cleanup.
+ // If assertion does not hold we crash as we are potentially
+ // in the dangling pointer situation.
+ state->cleanup();
+
// Enter safe point before trying to acquire threadAttachMutex
// to avoid dead lock if another thread is preparing for GC, has acquired
// threadAttachMutex and waiting for other threads to pause or reach a
« Source/heap/ThreadState.h ('K') | « Source/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698