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

Side by Side Diff: third_party/WebKit/Source/platform/heap/ThreadState.cpp

Issue 1761853002: Shut down all threads before the main thread shuts down (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 RELEASE_ASSERT(m_threadStackSize > 4 * 0x1000); 198 RELEASE_ASSERT(m_threadStackSize > 4 * 0x1000);
199 m_threadStackSize -= 4 * 0x1000; 199 m_threadStackSize -= 4 * 0x1000;
200 return m_threadStackSize; 200 return m_threadStackSize;
201 } 201 }
202 #endif 202 #endif
203 203
204 void ThreadState::attachMainThread() 204 void ThreadState::attachMainThread()
205 { 205 {
206 RELEASE_ASSERT(!Heap::s_shutdownCalled); 206 RELEASE_ASSERT(!Heap::s_shutdownCalled);
207 MutexLocker locker(threadAttachMutex()); 207 MutexLocker locker(threadAttachMutex());
208 ThreadState* state = new(s_mainThreadStateStorage) ThreadState(); 208 ThreadState* state = new (s_mainThreadStateStorage) ThreadState();
209 attachedThreads().add(state); 209 attachedThreads().add(state);
210 } 210 }
211 211
212 void ThreadState::detachMainThread() 212 void ThreadState::detachMainThread()
213 { 213 {
214 // Enter a safe point before trying to acquire threadAttachMutex 214 // Enter a safe point before trying to acquire threadAttachMutex
215 // to avoid dead lock if another thread is preparing for GC, has acquired 215 // to avoid dead lock if another thread is preparing for GC, has acquired
216 // threadAttachMutex and waiting for other threads to pause or reach a 216 // threadAttachMutex and waiting for other threads to pause or reach a
217 // safepoint. 217 // safepoint.
218 ThreadState* state = mainThreadState(); 218 ThreadState* state = mainThreadState();
219 ASSERT(state->checkThread());
219 220
220 // 1. Finish sweeping. 221 // 1. Finish sweeping.
221 state->completeSweep(); 222 state->completeSweep();
222 { 223 {
223 SafePointAwareMutexLocker locker(threadAttachMutex(), BlinkGC::NoHeapPoi ntersOnStack); 224 SafePointAwareMutexLocker locker(threadAttachMutex(), BlinkGC::NoHeapPoi ntersOnStack);
224 225
225 // 2. Add the main thread's heap pages to the orphaned pool. 226 // 2. Add the main thread's heap pages to the orphaned pool.
226 state->cleanupPages(); 227 state->cleanupPages();
227 228
228 // 3. Detach the main thread. 229 // 3. Detach the main thread.
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 threadDump->addScalar("dead_count", "objects", totalDeadCount); 1540 threadDump->addScalar("dead_count", "objects", totalDeadCount);
1540 threadDump->addScalar("live_size", "bytes", totalLiveSize); 1541 threadDump->addScalar("live_size", "bytes", totalLiveSize);
1541 threadDump->addScalar("dead_size", "bytes", totalDeadSize); 1542 threadDump->addScalar("dead_size", "bytes", totalDeadSize);
1542 1543
1543 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); 1544 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName);
1544 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName); 1545 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName);
1545 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid()); 1546 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid());
1546 } 1547 }
1547 1548
1548 } // namespace blink 1549 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698