| OLD | NEW |
| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 attachedThreads().add(state); | 266 attachedThreads().add(state); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void ThreadState::cleanupPages() | 269 void ThreadState::cleanupPages() |
| 270 { | 270 { |
| 271 ASSERT(checkThread()); | 271 ASSERT(checkThread()); |
| 272 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) | 272 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) |
| 273 m_arenas[i]->cleanupPages(); | 273 m_arenas[i]->cleanupPages(); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void ThreadState::callThreadShutdownHooks() |
| 277 { |
| 278 // Invoke the cleanup hooks. This gives an opportunity to release any |
| 279 // persistent handles that may exist, e.g. in thread-specific static |
| 280 // locals. |
| 281 for (const OwnPtr<SameThreadClosure>& hook : m_threadShutdownHooks) |
| 282 (*hook)(); |
| 283 } |
| 284 |
| 276 void ThreadState::cleanup() | 285 void ThreadState::cleanup() |
| 277 { | 286 { |
| 278 ASSERT(checkThread()); | 287 ASSERT(checkThread()); |
| 279 { | 288 { |
| 280 // Grab the threadAttachMutex to ensure only one thread can shutdown at | 289 // Grab the threadAttachMutex to ensure only one thread can shutdown at |
| 281 // a time and that no other thread can do a global GC. It also allows | 290 // a time and that no other thread can do a global GC. It also allows |
| 282 // safe iteration of the attachedThreads set which happens as part of | 291 // safe iteration of the attachedThreads set which happens as part of |
| 283 // thread local GC asserts. We enter a safepoint while waiting for the | 292 // thread local GC asserts. We enter a safepoint while waiting for the |
| 284 // lock to avoid a dead-lock where another thread has already requested | 293 // lock to avoid a dead-lock where another thread has already requested |
| 285 // GC. | 294 // GC. |
| 286 SafePointAwareMutexLocker locker(threadAttachMutex(), BlinkGC::NoHeapPoi
ntersOnStack); | 295 SafePointAwareMutexLocker locker(threadAttachMutex(), BlinkGC::NoHeapPoi
ntersOnStack); |
| 287 | 296 |
| 288 // Finish sweeping. | 297 // Finish sweeping. |
| 289 completeSweep(); | 298 completeSweep(); |
| 290 | 299 |
| 291 // From here on ignore all conservatively discovered | 300 // From here on ignore all conservatively discovered |
| 292 // pointers into the heap owned by this thread. | 301 // pointers into the heap owned by this thread. |
| 293 m_isTerminating = true; | 302 m_isTerminating = true; |
| 294 | 303 |
| 295 // Invoke the cleanup hooks. This gives an opportunity to release any | 304 ThreadState::callThreadShutdownHooks(); |
| 296 // persistent handles that may exist, e.g. in thread-specific static | |
| 297 // locals. | |
| 298 for (const OwnPtr<SameThreadClosure>& hook : m_threadShutdownHooks) | |
| 299 (*hook)(); | |
| 300 | 305 |
| 301 // Set the terminate flag on all heap pages of this thread. This is used
to | 306 // Set the terminate flag on all heap pages of this thread. This is used
to |
| 302 // ensure we don't trace pages on other threads that are not part of the | 307 // ensure we don't trace pages on other threads that are not part of the |
| 303 // thread local GC. | 308 // thread local GC. |
| 304 prepareForThreadStateTermination(); | 309 prepareForThreadStateTermination(); |
| 305 | 310 |
| 306 ProcessHeap::crossThreadPersistentRegion().prepareForThreadStateTerminat
ion(this); | 311 ProcessHeap::crossThreadPersistentRegion().prepareForThreadStateTerminat
ion(this); |
| 307 | 312 |
| 308 // Do thread local GC's as long as the count of thread local Persistents | 313 // Do thread local GC's as long as the count of thread local Persistents |
| 309 // changes and is above zero. | 314 // changes and is above zero. |
| (...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 threadDump->addScalar("dead_count", "objects", totalDeadCount); | 1569 threadDump->addScalar("dead_count", "objects", totalDeadCount); |
| 1565 threadDump->addScalar("live_size", "bytes", totalLiveSize); | 1570 threadDump->addScalar("live_size", "bytes", totalLiveSize); |
| 1566 threadDump->addScalar("dead_size", "bytes", totalDeadSize); | 1571 threadDump->addScalar("dead_size", "bytes", totalDeadSize); |
| 1567 | 1572 |
| 1568 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); | 1573 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); |
| 1569 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); | 1574 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); |
| 1570 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); | 1575 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); |
| 1571 } | 1576 } |
| 1572 | 1577 |
| 1573 } // namespace blink | 1578 } // namespace blink |
| OLD | NEW |