| Index: third_party/WebKit/Source/platform/heap/Heap.cpp
|
| diff --git a/third_party/WebKit/Source/platform/heap/Heap.cpp b/third_party/WebKit/Source/platform/heap/Heap.cpp
|
| index c2b0bb3e801c559c2a502c06c84bede3e602c5ac..527b04a16494c04b763afd0016f77c7b9c69dbbe 100644
|
| --- a/third_party/WebKit/Source/platform/heap/Heap.cpp
|
| +++ b/third_party/WebKit/Source/platform/heap/Heap.cpp
|
| @@ -261,6 +261,7 @@ void ThreadHeap::attach(ThreadState* thread)
|
| void ThreadHeap::detach(ThreadState* thread)
|
| {
|
| ASSERT(ThreadState::current() == thread);
|
| + bool isLastThread = false;
|
| {
|
| // Grab the threadAttachMutex to ensure only one thread can shutdown at
|
| // a time and that no other thread can do a global GC. It also allows
|
| @@ -272,12 +273,16 @@ void ThreadHeap::detach(ThreadState* thread)
|
| thread->runTerminationGC();
|
| ASSERT(m_threads.contains(thread));
|
| m_threads.remove(thread);
|
| + isLastThread = m_threads.isEmpty();
|
| }
|
| - // The main thread must be the last thread that gets detached.
|
| - ASSERT(!thread->isMainThread() || m_threads.isEmpty());
|
| + // The last thread begin detached should be the owning thread, which would
|
| + // be the main thread for the mainThreadHeap and a per thread heap enabled
|
| + // thread otherwise.
|
| + if (isLastThread)
|
| + DCHECK(thread->perThreadHeapEnabled() || thread->isMainThread());
|
| if (thread->isMainThread())
|
| DCHECK_EQ(heapStats().allocatedSpace(), 0u);
|
| - if (m_threads.isEmpty())
|
| + if (isLastThread)
|
| delete this;
|
| }
|
|
|
|
|