17 if (no_safepoint_scope_) {
30 thread->ExitSafepointUsingLock();
35 if (no_safepoint_scope_) {
45 if (!mutex_->TryLock()) {
58void SafepointMonitorLocker::AcquireLock() {
59 ASSERT(monitor_ !=
nullptr);
60 if (!monitor_->TryEnter()) {
64 if (thread !=
nullptr) {
73void SafepointMonitorLocker::ReleaseLock() {
79 if (thread !=
nullptr) {
83 result = monitor_->Wait(millis);
87 return monitor_->Wait(millis);
92bool SafepointRwLock::IsCurrentThreadReader() {
97 MonitorLocker ml(&monitor_);
98 for (intptr_t
i = readers_ids_.length() - 1;
i >= 0;
i--) {
99 if (readers_ids_.At(
i) ==
id) {
107bool SafepointRwLock::EnterRead() {
116 IsCurrentThreadReader());
118 const bool can_block_without_safepoint = thread ==
nullptr;
120 bool acquired_read_lock =
false;
121 if (!TryEnterRead(can_block_without_safepoint, &acquired_read_lock)) {
123 TransitionVMToBlocked transition(thread);
124 const bool ok = TryEnterRead(
true, &acquired_read_lock);
128 return acquired_read_lock;
131bool SafepointRwLock::TryEnterRead(
bool can_block,
bool* acquired_read_lock) {
132 MonitorLocker ml(&monitor_);
134 *acquired_read_lock =
false;
145 *acquired_read_lock =
true;
151void SafepointRwLock::LeaveRead() {
152 MonitorLocker ml(&monitor_);
156 intptr_t
i = readers_ids_.length() - 1;
159 if (readers_ids_.At(
i) ==
id) {
160 readers_ids_.RemoveAt(
i);
173void SafepointRwLock::EnterWrite() {
184 const bool can_block_without_safepoint = thread ==
nullptr;
186 if (!TryEnterWrite(can_block_without_safepoint)) {
188 TransitionVMToBlocked transition(thread);
189 const bool ok = TryEnterWrite(
true);
194bool SafepointRwLock::TryEnterWrite(
bool can_block) {
195 MonitorLocker ml(&monitor_);
201 while (state_ != 0) {
213void SafepointRwLock::LeaveWrite() {
214 MonitorLocker ml(&monitor_);
static bool ok(int result)
#define DEBUG_ASSERT(cond)
#define RELEASE_ASSERT(cond)
Monitor::WaitResult WaitWithSafepointCheck(Thread *thread, int64_t millis=Monitor::kNoTimeout)
static ThreadId GetCurrentThreadId()
static const ThreadId kInvalidThreadId
Monitor::WaitResult Wait(int64_t millis=Monitor::kNoTimeout)
SafepointMutexLocker(Mutex *mutex)
DEBUG_ONLY(bool IsCurrentThreadReader())
bool IsCurrentThreadWriter()
ThreadState * thread() const
void set_execution_state(ExecutionState state)
bool CanAcquireSafepointLocks() const
void DecrementNoSafepointScopeDepth()
static Thread * Current()
ExecutionState execution_state() const
void IncrementNoSafepointScopeDepth()