summaryrefslogtreecommitdiff
path: root/openjdkjvmti/ti_thread.h
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2017-09-22 15:33:41 -0700
committer Alex Light <allight@google.com> 2017-09-25 11:35:38 -0700
commit7ddc23d9ea95848724754eae270a0a1ce108edb9 (patch)
tree3d68e2745d0be0cdf95c05d45edc94859f1438ac /openjdkjvmti/ti_thread.h
parentba461c3c5b588b0b65d3cc99aa12fe46a673962c (diff)
Consolidate all JVMTI jthread decoding.
We had multiple places where we would decode jthreads. This meant that we did not always check all required constraints before using it. This CL consolidates all jthread decoding into the ThreadUtil::GetNativeThread function and adds a helper ThreadUtil::GetAliveNativeThread function to check the most common requirements on jthreads passed to JVMTI. Bug: 66709480 Test: ./test.py --host -j50 Test: cd openjdkjvmti && git grep -W FromManagedThread Change-Id: Ib6f4bc8510012e0332831bea67e1842a49092917
Diffstat (limited to 'openjdkjvmti/ti_thread.h')
-rw-r--r--openjdkjvmti/ti_thread.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/openjdkjvmti/ti_thread.h b/openjdkjvmti/ti_thread.h
index 57b194362f..ceebff67ec 100644
--- a/openjdkjvmti/ti_thread.h
+++ b/openjdkjvmti/ti_thread.h
@@ -93,8 +93,24 @@ class ThreadUtil {
const jthread* threads,
jvmtiError* results);
- static art::Thread* GetNativeThread(jthread thread,
- const art::ScopedObjectAccessAlreadyRunnable& soa)
+ // Returns true if we decoded the thread and it is alive, false otherwise with an appropriate
+ // error placed into 'err'. A thread is alive if it has had it's 'start' function called and has
+ // (or at least could have) executed managed code and has not yet returned past it's first managed
+ // frame. This means that the thread returned might have IsStillStarting() return true. Code that
+ // does not consider that alive should check manually.
+ static bool GetAliveNativeThread(jthread thread,
+ const art::ScopedObjectAccessAlreadyRunnable& soa,
+ /*out*/ art::Thread** thr,
+ /*out*/ jvmtiError* err)
+ REQUIRES_SHARED(art::Locks::mutator_lock_)
+ REQUIRES(art::Locks::thread_list_lock_);
+
+ // Returns true if we decoded the thread, false otherwise with an appropriate error placed into
+ // 'err'
+ static bool GetNativeThread(jthread thread,
+ const art::ScopedObjectAccessAlreadyRunnable& soa,
+ /*out*/ art::Thread** thr,
+ /*out*/ jvmtiError* err)
REQUIRES_SHARED(art::Locks::mutator_lock_)
REQUIRES(art::Locks::thread_list_lock_);