Chromium Code Reviews| Index: third_party/WebKit/Source/platform/heap/ThreadState.cpp |
| diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.cpp b/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
| index 8446223a5880b38e074f72b38ad995b6393ba25a..ba16cfa8dd16132f2c475d397aaf4f52a59208fb 100644 |
| --- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
| +++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
| @@ -209,6 +209,16 @@ void ThreadState::attachMainThread() |
| attachedThreads().add(state); |
| } |
| + |
| +void ThreadState::stopMainThread() |
| +{ |
| + ASSERT(isMainThread()); |
| + |
| + // Finish sweeping before shutting down V8. Otherwise, some destructor |
| + // may access V8 and cause crashes. |
| + completeSweep(); |
|
haraken
2016/03/10 05:42:23
Maybe we should add enterGCForbidenScope() before
haraken
2016/03/10 05:42:23
Another option is just to remove completeSweep().
|
| +} |
| + |
| void ThreadState::detachMainThread() |
| { |
| // Enter a safe point before trying to acquire threadAttachMutex |
| @@ -221,20 +231,17 @@ void ThreadState::detachMainThread() |
| // You must call unregisterTraceDOMWrappers before detaching |
| // the main thread. |
| ASSERT(!state->m_isolate); |
| + ASSERT(!state->isSweepingInProgress()); |
| - // 1. Finish sweeping. |
| - state->completeSweep(); |
| - { |
| - SafePointAwareMutexLocker locker(threadAttachMutex(), BlinkGC::NoHeapPointersOnStack); |
| + SafePointAwareMutexLocker locker(threadAttachMutex(), BlinkGC::NoHeapPointersOnStack); |
| - // 2. Add the main thread's heap pages to the orphaned pool. |
| - state->cleanupPages(); |
| + // Add the main thread's heap pages to the orphaned pool. |
| + state->cleanupPages(); |
| - // 3. Detach the main thread. |
| - ASSERT(attachedThreads().contains(state)); |
| - attachedThreads().remove(state); |
| - state->~ThreadState(); |
| - } |
| + // Detach the main thread. |
| + ASSERT(attachedThreads().contains(state)); |
| + attachedThreads().remove(state); |
| + state->~ThreadState(); |
| } |
| void ThreadState::attach() |