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 #ifndef SafePoint_h | 5 #ifndef SafePoint_h |
6 #define SafePoint_h | 6 #define SafePoint_h |
7 | 7 |
8 #include "platform/heap/ThreadState.h" | 8 #include "platform/heap/ThreadState.h" |
9 #include "wtf/ThreadingPrimitives.h" | 9 #include "wtf/ThreadingPrimitives.h" |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 static void parkAfterPushRegisters(SafePointBarrier* barrier, ThreadState* s
tate, intptr_t* stackEnd) | 116 static void parkAfterPushRegisters(SafePointBarrier* barrier, ThreadState* s
tate, intptr_t* stackEnd) |
117 { | 117 { |
118 barrier->doPark(state, stackEnd); | 118 barrier->doPark(state, stackEnd); |
119 } | 119 } |
120 void doEnterSafePoint(ThreadState*, intptr_t* stackEnd); | 120 void doEnterSafePoint(ThreadState*, intptr_t* stackEnd); |
121 static void enterSafePointAfterPushRegisters(SafePointBarrier* barrier, Thre
adState* state, intptr_t* stackEnd) | 121 static void enterSafePointAfterPushRegisters(SafePointBarrier* barrier, Thre
adState* state, intptr_t* stackEnd) |
122 { | 122 { |
123 barrier->doEnterSafePoint(state, stackEnd); | 123 barrier->doEnterSafePoint(state, stackEnd); |
124 } | 124 } |
125 | 125 |
126 volatile int m_canResume; | 126 // |m_unparkedThreadCount| tracks amount of unparked threads. It is |
| 127 // positive if and only if a thread has requested the other threads |
| 128 // to park themselves at safe-points in preparation for a GC. |
| 129 // |
| 130 // The last thread to park itself will make the counter hit zero |
| 131 // and should notify GC-requesting thread that it is safe to proceed. |
| 132 // |
| 133 // If no other thread is waiting for other threads to park then |
| 134 // this counter can be negative: if N threads are at safe-points |
| 135 // the counter will be -N. |
127 volatile int m_unparkedThreadCount; | 136 volatile int m_unparkedThreadCount; |
| 137 |
| 138 // |m_parkingRequested| is used to control the transition of threads parked |
| 139 // at a safepoint back to running state. In the event a thread requests |
| 140 // another GC, threads that have yet to leave their safepoint (due to lock |
| 141 // contention, scheduling etc), shouldn't be allowed to leave, but continue |
| 142 // being parked when they do end up getting to run. |
| 143 // |
| 144 // |m_parkingRequested| is set when parkOthers() runs, and cleared by |
| 145 // resumeOthers(), when the global GC steps have completed. |
| 146 // |
| 147 // Threads that were parked after they were requested to and then signalled, |
| 148 // check that no other thread has made another parking request when attempti
ng |
| 149 // to resume in doPark(). |
| 150 volatile int m_parkingRequested; |
| 151 |
128 Mutex m_mutex; | 152 Mutex m_mutex; |
| 153 |
129 ThreadCondition m_parked; | 154 ThreadCondition m_parked; |
130 ThreadCondition m_resume; | 155 ThreadCondition m_resume; |
131 }; | 156 }; |
132 | 157 |
133 } // namespace blink | 158 } // namespace blink |
134 | 159 |
135 #endif | 160 #endif |
OLD | NEW |