diff options
| -rw-r--r-- | runtime/monitor.cc | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 822e0fb293..64edba8a1f 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -642,21 +642,22 @@ void Monitor::InflateThinLocked(Thread* self, Handle<mirror::Object>& obj, LockW } else { ThreadList* thread_list = Runtime::Current()->GetThreadList(); // Suspend the owner, inflate. First change to blocked and give up mutator_lock_. - ScopedThreadStateChange tsc(self, kBlocked); self->SetMonitorEnterObject(obj.Get()); - if (lock_word == obj->GetLockWord(true)) { // If lock word hasn't changed. - bool timed_out; - Thread* owner = thread_list->SuspendThreadByThreadId(owner_thread_id, false, &timed_out); - if (owner != nullptr) { - // We succeeded in suspending the thread, check the lock's status didn't change. - lock_word = obj->GetLockWord(true); - if (lock_word.GetState() == LockWord::kThinLocked && - lock_word.ThinLockOwner() == owner_thread_id) { - // Go ahead and inflate the lock. - Inflate(self, owner, obj.Get(), hash_code); - } - thread_list->Resume(owner, false); + bool timed_out; + Thread* owner; + { + ScopedThreadStateChange tsc(self, kBlocked); + owner = thread_list->SuspendThreadByThreadId(owner_thread_id, false, &timed_out); + } + if (owner != nullptr) { + // We succeeded in suspending the thread, check the lock's status didn't change. + lock_word = obj->GetLockWord(true); + if (lock_word.GetState() == LockWord::kThinLocked && + lock_word.ThinLockOwner() == owner_thread_id) { + // Go ahead and inflate the lock. + Inflate(self, owner, obj.Get(), hash_code); } + thread_list->Resume(owner, false); } self->SetMonitorEnterObject(nullptr); } |