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 |