OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/lockers.h" | 6 #include "vm/lockers.h" |
7 #include "vm/safepoint.h" | 7 #include "vm/safepoint.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 SafepointHandler* handler = thread->isolate()->safepoint_handler(); | 22 SafepointHandler* handler = thread->isolate()->safepoint_handler(); |
23 handler->ExitSafepointUsingLock(thread); | 23 handler->ExitSafepointUsingLock(thread); |
24 } | 24 } |
25 thread->set_execution_state(Thread::kThreadInVM); | 25 thread->set_execution_state(Thread::kThreadInVM); |
26 } | 26 } |
27 | 27 |
28 | 28 |
29 Monitor::WaitResult MonitorLocker::WaitWithSafepointCheck(Thread* thread, | 29 Monitor::WaitResult MonitorLocker::WaitWithSafepointCheck(Thread* thread, |
30 int64_t millis) { | 30 int64_t millis) { |
31 ASSERT(thread == Thread::Current()); | 31 ASSERT(thread == Thread::Current()); |
| 32 ASSERT(thread->execution_state() == Thread::kThreadInVM); |
32 thread->set_execution_state(Thread::kThreadInBlockedState); | 33 thread->set_execution_state(Thread::kThreadInBlockedState); |
33 thread->EnterSafepoint(); | 34 thread->EnterSafepoint(); |
34 Monitor::WaitResult result = monitor_->Wait(millis); | 35 Monitor::WaitResult result = monitor_->Wait(millis); |
35 // First try a fast update of the thread state to indicate it is not at a | 36 // First try a fast update of the thread state to indicate it is not at a |
36 // safepoint anymore. | 37 // safepoint anymore. |
37 uint32_t old_state = Thread::SetAtSafepoint(true, 0); | 38 uint32_t old_state = Thread::SetAtSafepoint(true, 0); |
38 uword addr = | 39 uword addr = |
39 reinterpret_cast<uword>(thread) + Thread::safepoint_state_offset(); | 40 reinterpret_cast<uword>(thread) + Thread::safepoint_state_offset(); |
40 if (AtomicOperations::CompareAndSwapUint32( | 41 if (AtomicOperations::CompareAndSwapUint32( |
41 reinterpret_cast<uint32_t*>(addr), old_state, 0) != old_state) { | 42 reinterpret_cast<uint32_t*>(addr), old_state, 0) != old_state) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 monitor_->Enter(); | 112 monitor_->Enter(); |
112 } | 113 } |
113 thread->set_execution_state(Thread::kThreadInVM); | 114 thread->set_execution_state(Thread::kThreadInVM); |
114 return result; | 115 return result; |
115 } else { | 116 } else { |
116 return monitor_->Wait(millis); | 117 return monitor_->Wait(millis); |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
120 } // namespace dart | 121 } // namespace dart |
OLD | NEW |