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
diff --git a/openjdkjvmti/ti_thread.h b/openjdkjvmti/ti_thread.h
index 57b1943..ceebff6 100644
--- a/openjdkjvmti/ti_thread.h
+++ b/openjdkjvmti/ti_thread.h
@@ -93,8 +93,24 @@
                                      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_);