OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "platform/heap/SafePoint.h" | 6 #include "platform/heap/SafePoint.h" |
7 | 7 |
8 #include "wtf/Atomics.h" | 8 #include "wtf/Atomics.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 27 matching lines...) Expand all Loading... |
38 ThreadState::AttachedThreadStateSet& threads = ThreadState::attachedThreads(
); | 38 ThreadState::AttachedThreadStateSet& threads = ThreadState::attachedThreads(
); |
39 | 39 |
40 MutexLocker locker(m_mutex); | 40 MutexLocker locker(m_mutex); |
41 atomicAdd(&m_unparkedThreadCount, threads.size()); | 41 atomicAdd(&m_unparkedThreadCount, threads.size()); |
42 releaseStore(&m_canResume, 0); | 42 releaseStore(&m_canResume, 0); |
43 | 43 |
44 for (ThreadState* state : threads) { | 44 for (ThreadState* state : threads) { |
45 if (state == current) | 45 if (state == current) |
46 continue; | 46 continue; |
47 | 47 |
48 for (ThreadState::Interruptor* interruptor : state->interruptors()) | 48 for (auto& interruptor : state->interruptors()) |
49 interruptor->requestInterrupt(); | 49 interruptor->requestInterrupt(); |
50 } | 50 } |
51 | 51 |
52 while (acquireLoad(&m_unparkedThreadCount) > 0) { | 52 while (acquireLoad(&m_unparkedThreadCount) > 0) { |
53 double expirationTime = currentTime() + lockingTimeout(); | 53 double expirationTime = currentTime() + lockingTimeout(); |
54 if (!m_parked.timedWait(m_mutex, expirationTime)) { | 54 if (!m_parked.timedWait(m_mutex, expirationTime)) { |
55 // One of the other threads did not return to a safepoint within the
maximum | 55 // One of the other threads did not return to a safepoint within the
maximum |
56 // time we allow for threads to be parked. Abandon the GC and resume
the | 56 // time we allow for threads to be parked. Abandon the GC and resume
the |
57 // currently parked threads. | 57 // currently parked threads. |
58 resumeOthers(true); | 58 resumeOthers(true); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // If no other thread is waiting for other threads to park then | 131 // If no other thread is waiting for other threads to park then |
132 // this counter can be negative: if N threads are at safe-points | 132 // this counter can be negative: if N threads are at safe-points |
133 // the counter will be -N. | 133 // the counter will be -N. |
134 if (!atomicDecrement(&m_unparkedThreadCount)) { | 134 if (!atomicDecrement(&m_unparkedThreadCount)) { |
135 MutexLocker locker(m_mutex); | 135 MutexLocker locker(m_mutex); |
136 m_parked.signal(); // Safe point reached. | 136 m_parked.signal(); // Safe point reached. |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 } // namespace blink | 140 } // namespace blink |
OLD | NEW |