| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 SafePointAwareMutexLocker locker(threadAttachMutex(), BlinkGC::NoHeapPoi
ntersOnStack); | 228 SafePointAwareMutexLocker locker(threadAttachMutex(), BlinkGC::NoHeapPoi
ntersOnStack); |
| 229 | 229 |
| 230 // 2. Add the main thread's heap pages to the orphaned pool. | 230 // 2. Add the main thread's heap pages to the orphaned pool. |
| 231 state->cleanupPages(); | 231 state->cleanupPages(); |
| 232 | 232 |
| 233 // 3. Detach the main thread. | 233 // 3. Detach the main thread. |
| 234 ASSERT(attachedThreads().contains(state)); | 234 ASSERT(attachedThreads().contains(state)); |
| 235 attachedThreads().remove(state); | 235 attachedThreads().remove(state); |
| 236 state->~ThreadState(); | 236 state->~ThreadState(); |
| 237 } | 237 } |
| 238 shutdownHeapIfNecessary(); | |
| 239 } | |
| 240 | |
| 241 void ThreadState::shutdownHeapIfNecessary() | |
| 242 { | |
| 243 // We don't need to enter a safe point before acquiring threadAttachMutex | |
| 244 // because this thread is already detached. | |
| 245 | |
| 246 MutexLocker locker(threadAttachMutex()); | |
| 247 // We start shutting down the heap if there is no running thread | |
| 248 // and Heap::shutdown() is already called. | |
| 249 if (!attachedThreads().size() && Heap::s_shutdownCalled) | |
| 250 Heap::doShutdown(); | |
| 251 } | 238 } |
| 252 | 239 |
| 253 void ThreadState::attach() | 240 void ThreadState::attach() |
| 254 { | 241 { |
| 255 RELEASE_ASSERT(!Heap::s_shutdownCalled); | 242 RELEASE_ASSERT(!Heap::s_shutdownCalled); |
| 256 MutexLocker locker(threadAttachMutex()); | 243 MutexLocker locker(threadAttachMutex()); |
| 257 ThreadState* state = new ThreadState(); | 244 ThreadState* state = new ThreadState(); |
| 258 attachedThreads().add(state); | 245 attachedThreads().add(state); |
| 259 } | 246 } |
| 260 | 247 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 attachedThreads().remove(this); | 303 attachedThreads().remove(this); |
| 317 } | 304 } |
| 318 } | 305 } |
| 319 | 306 |
| 320 void ThreadState::detach() | 307 void ThreadState::detach() |
| 321 { | 308 { |
| 322 ThreadState* state = current(); | 309 ThreadState* state = current(); |
| 323 state->cleanup(); | 310 state->cleanup(); |
| 324 RELEASE_ASSERT(state->gcState() == ThreadState::NoGCScheduled); | 311 RELEASE_ASSERT(state->gcState() == ThreadState::NoGCScheduled); |
| 325 delete state; | 312 delete state; |
| 326 shutdownHeapIfNecessary(); | |
| 327 } | 313 } |
| 328 | 314 |
| 329 void ThreadState::visitPersistentRoots(Visitor* visitor) | 315 void ThreadState::visitPersistentRoots(Visitor* visitor) |
| 330 { | 316 { |
| 331 TRACE_EVENT0("blink_gc", "ThreadState::visitPersistentRoots"); | 317 TRACE_EVENT0("blink_gc", "ThreadState::visitPersistentRoots"); |
| 332 Heap::crossThreadPersistentRegion().tracePersistentNodes(visitor); | 318 Heap::crossThreadPersistentRegion().tracePersistentNodes(visitor); |
| 333 | 319 |
| 334 for (ThreadState* state : attachedThreads()) | 320 for (ThreadState* state : attachedThreads()) |
| 335 state->visitPersistents(visitor); | 321 state->visitPersistents(visitor); |
| 336 } | 322 } |
| (...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 threadDump->addScalar("dead_count", "objects", totalDeadCount); | 1530 threadDump->addScalar("dead_count", "objects", totalDeadCount); |
| 1545 threadDump->addScalar("live_size", "bytes", totalLiveSize); | 1531 threadDump->addScalar("live_size", "bytes", totalLiveSize); |
| 1546 threadDump->addScalar("dead_size", "bytes", totalDeadSize); | 1532 threadDump->addScalar("dead_size", "bytes", totalDeadSize); |
| 1547 | 1533 |
| 1548 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); | 1534 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); |
| 1549 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); | 1535 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); |
| 1550 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); | 1536 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); |
| 1551 } | 1537 } |
| 1552 | 1538 |
| 1553 } // namespace blink | 1539 } // namespace blink |
| OLD | NEW |