Skip to content

Commit e8dcc2e

Browse files
committed
Update JVMTI GetThreadState for an unmounted carrier thread
New behaviour was noticed in JTREG GetThreadStateMountedTest. An unmounted carrier thread is considered implicitly parked, and all other bits except ALIVE and SUSPENDED are removed from the bitmask. Related: #18810 Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
1 parent e014e2e commit e8dcc2e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

runtime/jvmti/jvmtiHelpers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,14 +805,15 @@ getThreadState(J9VMThread *currentThread, j9object_t threadObject)
805805
jint state = getThreadStateHelper(currentThread, threadObject, vmThread);
806806

807807
#if JAVA_SPEC_VERSION >= 19
808-
if (J9_ARE_ANY_BITS_SET(state, JVMTI_THREAD_STATE_RUNNABLE)) {
808+
if (J9_ARE_ANY_BITS_SET(state, JVMTI_THREAD_STATE_ALIVE)) {
809809
if ((NULL != vmThread->currentContinuation)
810810
&& (vmThread->threadObject != vmThread->carrierThreadObject)
811811
) {
812812
/* If a virtual thread is mounted on a carrier thread, then the carrier thread
813-
* is considered implicitly parked.
813+
* is considered implicitly parked, and all other bits except ALIVE and SUSPENDED
814+
* are removed from the bitmask.
814815
*/
815-
state &= ~JVMTI_THREAD_STATE_RUNNABLE;
816+
state &= (JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_SUSPENDED);
816817
state |= JVMTI_THREAD_STATE_WAITING_INDEFINITELY;
817818
state |= JVMTI_THREAD_STATE_WAITING;
818819
}

0 commit comments

Comments
 (0)