diff options
-rw-r--r-- | runtime/native/dalvik_system_VMStack.cc | 2 | ||||
-rw-r--r-- | runtime/openjdkjvmti/ti_stack.cc | 4 | ||||
-rw-r--r-- | runtime/thread.cc | 3 | ||||
-rw-r--r-- | runtime/thread.h | 1 |
4 files changed, 6 insertions, 4 deletions
diff --git a/runtime/native/dalvik_system_VMStack.cc b/runtime/native/dalvik_system_VMStack.cc index 268d71ac65..be6f7f2204 100644 --- a/runtime/native/dalvik_system_VMStack.cc +++ b/runtime/native/dalvik_system_VMStack.cc @@ -41,7 +41,7 @@ static jobject GetThreadStack(const ScopedFastNativeObjectAccess& soa, jobject p Thread* heap_task_thread = Runtime::Current()->GetHeap()->GetTaskProcessor()->GetRunningThread(); // heap_task_thread could be null if the daemons aren't yet started. - if (heap_task_thread != nullptr && decoded_peer == heap_task_thread->GetPeer()) { + if (heap_task_thread != nullptr && decoded_peer == heap_task_thread->GetPeerFromOtherThread()) { return nullptr; } // Suspend thread to build stack trace. diff --git a/runtime/openjdkjvmti/ti_stack.cc b/runtime/openjdkjvmti/ti_stack.cc index b5a6c6e1ee..067c7c153d 100644 --- a/runtime/openjdkjvmti/ti_stack.cc +++ b/runtime/openjdkjvmti/ti_stack.cc @@ -328,7 +328,7 @@ jvmtiError StackUtil::GetAllStackTraces(jvmtiEnv* env, // For the time being, set the thread to null. We don't have good ScopedLocalRef // infrastructure. - DCHECK(self->GetPeer() != nullptr); + DCHECK(self->GetPeerFromOtherThread() != nullptr); stack_info.thread = nullptr; stack_info.state = JVMTI_THREAD_STATE_SUSPENDED; @@ -495,7 +495,7 @@ jvmtiError StackUtil::GetThreadListStackTraces(jvmtiEnv* env, // For the time being, set the thread to null. We don't have good ScopedLocalRef // infrastructure. - DCHECK(self->GetPeer() != nullptr); + DCHECK(self->GetPeerFromOtherThread() != nullptr); stack_info.thread = nullptr; stack_info.state = JVMTI_THREAD_STATE_SUSPENDED; diff --git a/runtime/thread.cc b/runtime/thread.cc index f33da18e5f..7ee0cd1d3f 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -3485,7 +3485,8 @@ bool Thread::IsAotCompiler() { } mirror::Object* Thread::GetPeerFromOtherThread() const { - mirror::Object* peer = GetPeer(); + DCHECK(tlsPtr_.jpeer == nullptr); + mirror::Object* peer = tlsPtr_.opeer; if (kUseReadBarrier && Current()->GetIsGcMarking()) { // We may call Thread::Dump() in the middle of the CC thread flip and this thread's stack // may have not been flipped yet and peer may be a from-space (stale) ref. So explicitly diff --git a/runtime/thread.h b/runtime/thread.h index a46e799d72..e500e0b9e4 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -359,6 +359,7 @@ class Thread { uint64_t GetCpuMicroTime() const; mirror::Object* GetPeer() const REQUIRES_SHARED(Locks::mutator_lock_) { + DCHECK(Thread::Current() == this) << "Use GetPeerFromOtherThread instead"; CHECK(tlsPtr_.jpeer == nullptr); return tlsPtr_.opeer; } |