Chromium Code Reviews| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 // Grab the threadAttachMutex to ensure only one thread can shutdown at | 265 // Grab the threadAttachMutex to ensure only one thread can shutdown at |
| 266 // a time and that no other thread can do a global GC. It also allows | 266 // a time and that no other thread can do a global GC. It also allows |
| 267 // safe iteration of the m_threads set which happens as part of | 267 // safe iteration of the m_threads set which happens as part of |
| 268 // thread local GC asserts. We enter a safepoint while waiting for the | 268 // thread local GC asserts. We enter a safepoint while waiting for the |
| 269 // lock to avoid a dead-lock where another thread has already requested | 269 // lock to avoid a dead-lock where another thread has already requested |
| 270 // GC. | 270 // GC. |
| 271 SafePointAwareMutexLocker locker(m_threadAttachMutex, BlinkGC::NoHeapPoi ntersOnStack); | 271 SafePointAwareMutexLocker locker(m_threadAttachMutex, BlinkGC::NoHeapPoi ntersOnStack); |
| 272 thread->runTerminationGC(); | 272 thread->runTerminationGC(); |
| 273 ASSERT(m_threads.contains(thread)); | 273 ASSERT(m_threads.contains(thread)); |
| 274 m_threads.remove(thread); | 274 m_threads.remove(thread); |
| 275 | |
| 276 // The main thread must be the last thread that gets detached. | |
| 277 DCHECK(!thread->isMainThread() || m_threads.isEmpty()); | |
|
sof
2016/06/09 09:55:09
This assert isn't accurate,
DCHECK(thread->isMai
keishi
2016/06/09 10:37:25
The main thread must be the last thread that gets
sof
2016/06/09 10:44:57
Yes, the assert as-is doesn't verify that last con
keishi
2016/06/09 11:47:34
For a per-thread-heap enabled thread:
thread->isMa
sof
2016/06/09 12:00:25
Yes, that condition captures the "owner" of the Th
| |
| 278 if (thread->isMainThread()) | |
| 279 DCHECK_EQ(heapStats().allocatedSpace(), 0u); | |
| 280 if (m_threads.isEmpty()) | |
| 281 delete this; | |
|
sof
2016/06/09 10:00:46
Won't this UAF when the mutex locker stack object
keishi
2016/06/09 10:37:25
I guess you're right. Changed to destruct out of
| |
| 275 } | 282 } |
| 276 // The main thread must be the last thread that gets detached. | |
| 277 ASSERT(!thread->isMainThread() || m_threads.isEmpty()); | |
| 278 if (thread->isMainThread()) | |
| 279 DCHECK_EQ(heapStats().allocatedSpace(), 0u); | |
| 280 if (m_threads.isEmpty()) | |
| 281 delete this; | |
| 282 } | 283 } |
| 283 | 284 |
| 284 bool ThreadHeap::park() | 285 bool ThreadHeap::park() |
| 285 { | 286 { |
| 286 return m_safePointBarrier->parkOthers(); | 287 return m_safePointBarrier->parkOthers(); |
| 287 } | 288 } |
| 288 | 289 |
| 289 void ThreadHeap::resume() | 290 void ThreadHeap::resume() |
| 290 { | 291 { |
| 291 m_safePointBarrier->resumeOthers(); | 292 m_safePointBarrier->resumeOthers(); |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); | 790 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); |
| 790 | 791 |
| 791 m_stats.reset(); | 792 m_stats.reset(); |
| 792 for (ThreadState* state : m_threads) | 793 for (ThreadState* state : m_threads) |
| 793 state->resetHeapCounters(); | 794 state->resetHeapCounters(); |
| 794 } | 795 } |
| 795 | 796 |
| 796 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; | 797 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; |
| 797 | 798 |
| 798 } // namespace blink | 799 } // namespace blink |
| OLD | NEW |