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 "platform/heap/SafePoint.h" | 5 #include "platform/heap/SafePoint.h" |
6 | 6 |
7 #include "platform/heap/Heap.h" | 7 #include "platform/heap/Heap.h" |
8 #include "wtf/Atomics.h" | 8 #include "wtf/Atomics.h" |
9 #include "wtf/CurrentTime.h" | 9 #include "wtf/CurrentTime.h" |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 if (state == current) | 43 if (state == current) |
44 continue; | 44 continue; |
45 | 45 |
46 for (auto& interruptor : state->interruptors()) | 46 for (auto& interruptor : state->interruptors()) |
47 interruptor->requestInterrupt(); | 47 interruptor->requestInterrupt(); |
48 } | 48 } |
49 | 49 |
50 while (acquireLoad(&m_unparkedThreadCount) > 0) { | 50 while (acquireLoad(&m_unparkedThreadCount) > 0) { |
51 double expirationTime = currentTime() + lockingTimeout(); | 51 double expirationTime = currentTime() + lockingTimeout(); |
52 if (!m_parked.timedWait(m_mutex, expirationTime)) { | 52 if (!m_parked.timedWait(m_mutex, expirationTime)) { |
53 // One of the other threads did not return to a safepoint within the maxim
um | 53 // One of the other threads did not return to a safepoint within the |
54 // time we allow for threads to be parked. Abandon the GC and resume the | 54 // maximum time we allow for threads to be parked. Abandon the GC and |
55 // currently parked threads. | 55 // resume the currently parked threads. |
56 resumeOthers(true); | 56 resumeOthers(true); |
57 return false; | 57 return false; |
58 } | 58 } |
59 } | 59 } |
60 return true; | 60 return true; |
61 } | 61 } |
62 | 62 |
63 void SafePointBarrier::resumeOthers(bool barrierLocked) { | 63 void SafePointBarrier::resumeOthers(bool barrierLocked) { |
64 ThreadState* current = ThreadState::current(); | 64 ThreadState* current = ThreadState::current(); |
65 const ThreadStateSet& threads = current->heap().threads(); | 65 const ThreadStateSet& threads = current->heap().threads(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 intptr_t* stackEnd) { | 119 intptr_t* stackEnd) { |
120 state->recordStackEnd(stackEnd); | 120 state->recordStackEnd(stackEnd); |
121 state->copyStackUntilSafePointScope(); | 121 state->copyStackUntilSafePointScope(); |
122 if (!atomicDecrement(&m_unparkedThreadCount)) { | 122 if (!atomicDecrement(&m_unparkedThreadCount)) { |
123 MutexLocker locker(m_mutex); | 123 MutexLocker locker(m_mutex); |
124 m_parked.signal(); // Safe point reached. | 124 m_parked.signal(); // Safe point reached. |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 } // namespace blink | 128 } // namespace blink |
OLD | NEW |