Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8309612: [REDO] JDK-8307153 JVMTI GetThreadState on carrier should return STATE_WAITING #14366

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/hotspot/share/prims/jvmtiEnvBase.cpp
Original file line number Diff line number Diff line change
@@ -761,6 +761,10 @@ JvmtiEnvBase::get_thread_state(oop thread_oop, JavaThread* jt) {
jint state = get_thread_state_base(thread_oop, jt);

if (is_thread_carrying_vthread(jt, thread_oop)) {
// It's okay for the JVMTI state to be reported as WAITING when waiting
// for something other than an Object.wait. So, we treat a thread carrying
// a virtual thread as waiting indefinitely which is not runnable.
// It is why the RUNNABLE bit is cleared and the WAITING bits are added.
state &= ~JVMTI_THREAD_STATE_RUNNABLE;
state |= JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY;
}
@@ -1736,7 +1740,7 @@ JvmtiEnvBase::suspend_thread(oop thread_oop, JavaThread* java_thread, bool singl
(is_virtual && JvmtiVTSuspender::is_vthread_suspended(thread_h())),
"sanity check");

// An attempt to handshake-suspend a thread carrying virtual thread will result in
// An attempt to handshake-suspend a thread carrying a virtual thread will result in
// suspension of mounted virtual thread. So, we just mark it as suspended
// and it will be actually suspended at virtual thread unmount transition.
if (!is_thread_carrying) {
4 changes: 2 additions & 2 deletions src/hotspot/share/prims/jvmtiEnvBase.hpp
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ class JvmtiEnvBase : public CHeapObj<mtInternal> {
static jvmtiError check_thread_list(jint count, const jthread* list);
static bool is_in_thread_list(jint count, const jthread* list, oop jt_oop);

// check if thread_oop represents a thread carrying virtual thread
// check if thread_oop represents a thread carrying a virtual thread
static bool is_thread_carrying_vthread(JavaThread* java_thread, oop thread_oop) {
return java_thread != nullptr && java_thread->jvmti_vthread() != nullptr
&& java_thread->jvmti_vthread() != thread_oop
@@ -180,7 +180,7 @@ class JvmtiEnvBase : public CHeapObj<mtInternal> {
static oop current_thread_obj_or_resolve_external_guard(jthread thread);

// Return true if the thread identified with a pair <jt,thr_obj> is current.
// A thread carrying virtual thread is not treated as current.
// A thread carrying a virtual thread is not treated as current.
static bool is_JavaThread_current(JavaThread* jt, oop thr_obj) {
JavaThread* current = JavaThread::current();
// jt can be null in case of a virtual thread