diff options
author | 2023-11-27 19:11:46 +0000 | |
---|---|---|
committer | 2023-11-27 21:16:13 +0000 | |
commit | 4f815246b0cc18410baeb74ceeb8b4696e3ea174 (patch) | |
tree | d7632514d6a655d63651b01e223673507b1c7701 | |
parent | 7f515181fdbe88a139d973d3481964d9cb7ed118 (diff) |
Revert "Don't call GetPeerFromOtherThread with thread_list_lock_ held"
This reverts commit 2c4bfa20cfd4ea556a5a94f942ced5d2ccfe1c06.
Reason for revert: b/313347640
Change-Id: I055f1a868c9fe6a74278670e075c2e2aa3e82d2b
-rw-r--r-- | openjdkjvmti/ti_object.cc | 12 | ||||
-rw-r--r-- | openjdkjvmti/ti_thread.cc | 18 | ||||
-rw-r--r-- | openjdkjvmti/ti_threadgroup.cc | 9 | ||||
-rw-r--r-- | runtime/thread.h | 3 |
4 files changed, 17 insertions, 25 deletions
diff --git a/openjdkjvmti/ti_object.cc b/openjdkjvmti/ti_object.cc index 24ccbaf417..f37df86048 100644 --- a/openjdkjvmti/ti_object.cc +++ b/openjdkjvmti/ti_object.cc @@ -105,15 +105,13 @@ jvmtiError ObjectUtil::GetObjectMonitorUsage( notify_wait.push_back(jni->AddLocalReference<jthread>(thd->GetPeerFromOtherThread())); wait.push_back(jni->AddLocalReference<jthread>(thd->GetPeerFromOtherThread())); } - // Scan all threads to see which are waiting on this particular monitor. - std::list<art::Thread*> thread_list; { + // Scan all threads to see which are waiting on this particular monitor. art::MutexLock tll(self, *art::Locks::thread_list_lock_); - thread_list = art::Runtime::Current()->GetThreadList()->GetList(); - } - for (art::Thread* thd : thread_list) { - if (thd != info.owner_ && target.Ptr() == thd->GetMonitorEnterObject()) { - wait.push_back(jni->AddLocalReference<jthread>(thd->GetPeerFromOtherThread())); + for (art::Thread* thd : art::Runtime::Current()->GetThreadList()->GetList()) { + if (thd != info.owner_ && target.Ptr() == thd->GetMonitorEnterObject()) { + wait.push_back(jni->AddLocalReference<jthread>(thd->GetPeerFromOtherThread())); + } } } } diff --git a/openjdkjvmti/ti_thread.cc b/openjdkjvmti/ti_thread.cc index 33cc754bf6..13eebbff04 100644 --- a/openjdkjvmti/ti_thread.cc +++ b/openjdkjvmti/ti_thread.cc @@ -265,13 +265,12 @@ jvmtiError ThreadUtil::GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadI art::Thread* self = art::Thread::Current(); art::ScopedObjectAccess soa(self); + art::MutexLock mu(self, *art::Locks::thread_list_lock_); + art::Thread* target; jvmtiError err = ERR(INTERNAL); - { - art::MutexLock mu(self, *art::Locks::thread_list_lock_); - if (!GetNativeThread(thread, soa, &target, &err)) { - return err; - } + if (!GetNativeThread(thread, soa, &target, &err)) { + return err; } JvmtiUniquePtr<char[]> name_uptr; @@ -638,11 +637,10 @@ jvmtiError ThreadUtil::GetAllThreads(jvmtiEnv* env, art::Thread* current = art::Thread::Current(); art::ScopedObjectAccess soa(current); - std::list<art::Thread*> thread_list; - { - art::MutexLock mu(current, *art::Locks::thread_list_lock_); - thread_list = art::Runtime::Current()->GetThreadList()->GetList(); - } + + art::MutexLock mu(current, *art::Locks::thread_list_lock_); + std::list<art::Thread*> thread_list = art::Runtime::Current()->GetThreadList()->GetList(); + std::vector<art::ObjPtr<art::mirror::Object>> peers; for (art::Thread* thread : thread_list) { diff --git a/openjdkjvmti/ti_threadgroup.cc b/openjdkjvmti/ti_threadgroup.cc index f6f0e21846..120024e8b2 100644 --- a/openjdkjvmti/ti_threadgroup.cc +++ b/openjdkjvmti/ti_threadgroup.cc @@ -169,12 +169,9 @@ static void GetThreads(art::Handle<art::mirror::Object> thread_group, std::vector<art::ObjPtr<art::mirror::Object>>* thread_peers) REQUIRES_SHARED(art::Locks::mutator_lock_) REQUIRES(!art::Locks::thread_list_lock_) { CHECK(thread_group != nullptr); - std::list<art::Thread*> thread_list; - { - art::MutexLock mu(art::Thread::Current(), *art::Locks::thread_list_lock_); - thread_list = art::Runtime::Current()->GetThreadList()->GetList(); - } - for (art::Thread* t : thread_list) { + + art::MutexLock mu(art::Thread::Current(), *art::Locks::thread_list_lock_); + for (art::Thread* t : art::Runtime::Current()->GetThreadList()->GetList()) { if (t->IsStillStarting()) { continue; } diff --git a/runtime/thread.h b/runtime/thread.h index 88e3d453fb..e1503ae72f 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -521,8 +521,7 @@ class Thread { // This function will force a flip for the other thread if necessary. // Since we hold a shared mutator lock, a new flip function cannot be concurrently // installed - mirror::Object* GetPeerFromOtherThread() REQUIRES_SHARED(Locks::mutator_lock_) - REQUIRES(!Locks::thread_list_lock_); + mirror::Object* GetPeerFromOtherThread() REQUIRES_SHARED(Locks::mutator_lock_); bool HasPeer() const { return tlsPtr_.jpeer != nullptr || tlsPtr_.opeer != nullptr; |