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

Support the new changes to the VirtualThread states #18673

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion runtime/jvmti/jvmtiHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,11 +859,12 @@ getVirtualThreadState(J9VMThread *currentThread, jthread thread)
}
break;
}
case JVMTI_VTHREAD_STATE_RUNNABLE:
case JVMTI_VTHREAD_STATE_RUNNING:
case JVMTI_VTHREAD_STATE_PARKING:
case JVMTI_VTHREAD_STATE_TIMED_PARKING:
case JVMTI_VTHREAD_STATE_UNPARKED:
case JVMTI_VTHREAD_STATE_YIELDING:
case JVMTI_VTHREAD_STATE_YIELDED:
rc = JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE;
break;
case JVMTI_VTHREAD_STATE_PINNED:
Expand Down
17 changes: 9 additions & 8 deletions runtime/oti/jvmtiInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,15 +574,16 @@ typedef struct jvmtiGcp_translation {
/* These macros corresponds to the states in j.l.VirtualThread. */
#define JVMTI_VTHREAD_STATE_NEW 0
#define JVMTI_VTHREAD_STATE_STARTED 1
#define JVMTI_VTHREAD_STATE_RUNNABLE 2
#define JVMTI_VTHREAD_STATE_RUNNING 3
#define JVMTI_VTHREAD_STATE_PARKING 4
#define JVMTI_VTHREAD_STATE_PARKED 5
#define JVMTI_VTHREAD_STATE_PINNED 6
#define JVMTI_VTHREAD_STATE_TIMED_PARKING 7
#define JVMTI_VTHREAD_STATE_TIMED_PARKED 8
#define JVMTI_VTHREAD_STATE_TIMED_PINNED 9
#define JVMTI_VTHREAD_STATE_RUNNING 2
#define JVMTI_VTHREAD_STATE_PARKING 3
#define JVMTI_VTHREAD_STATE_PARKED 4
#define JVMTI_VTHREAD_STATE_PINNED 5
#define JVMTI_VTHREAD_STATE_TIMED_PARKING 6
#define JVMTI_VTHREAD_STATE_TIMED_PARKED 7
#define JVMTI_VTHREAD_STATE_TIMED_PINNED 8
#define JVMTI_VTHREAD_STATE_UNPARKED 9
#define JVMTI_VTHREAD_STATE_YIELDING 10
#define JVMTI_VTHREAD_STATE_YIELDED 11
#define JVMTI_VTHREAD_STATE_TERMINATED 99
#define JVMTI_VTHREAD_STATE_SUSPENDED (1 << 8)
#endif /* JAVA_SPEC_VERSION >= 19 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,16 @@ private static int readVirtualThreadStates(Class vthreadCls, String fieldName) t
public void test_verifyJVMTIMacros() {
final int JVMTI_VTHREAD_STATE_NEW = 0;
final int JVMTI_VTHREAD_STATE_STARTED = 1;
final int JVMTI_VTHREAD_STATE_RUNNABLE= 2;
final int JVMTI_VTHREAD_STATE_RUNNING = 3;
final int JVMTI_VTHREAD_STATE_PARKING = 4;
final int JVMTI_VTHREAD_STATE_PARKED = 5;
final int JVMTI_VTHREAD_STATE_PINNED = 6;
final int JVMTI_VTHREAD_STATE_TIMED_PARKING = 7;
final int JVMTI_VTHREAD_STATE_TIMED_PARKED = 8;
final int JVMTI_VTHREAD_STATE_TIMED_PINNED = 9;
final int JVMTI_VTHREAD_STATE_RUNNING = 2;
final int JVMTI_VTHREAD_STATE_PARKING = 3;
final int JVMTI_VTHREAD_STATE_PARKED = 4;
final int JVMTI_VTHREAD_STATE_PINNED = 5;
final int JVMTI_VTHREAD_STATE_TIMED_PARKING = 6;
final int JVMTI_VTHREAD_STATE_TIMED_PARKED = 7;
final int JVMTI_VTHREAD_STATE_TIMED_PINNED = 8;
final int JVMTI_VTHREAD_STATE_UNPARKED = 9;
final int JVMTI_VTHREAD_STATE_YIELDING = 10;
final int JVMTI_VTHREAD_STATE_YIELDED = 11;
final int JVMTI_VTHREAD_STATE_TERMINATED = 99;
final int JVMTI_VTHREAD_STATE_SUSPENDED = (1 << 8);

Expand All @@ -292,11 +293,6 @@ public void test_verifyJVMTIMacros() {
Assert.fail("JVMTI_VTHREAD_STATE_STARTED (" + JVMTI_VTHREAD_STATE_STARTED + ") does not match VirtualThread.STARTED (" + value + ")");
}

value = readVirtualThreadStates(vthreadCls, "RUNNABLE");
if (JVMTI_VTHREAD_STATE_RUNNABLE != value) {
Assert.fail("JVMTI_VTHREAD_STATE_RUNNABLE (" + JVMTI_VTHREAD_STATE_RUNNABLE + ") does not match VirtualThread.RUNNABLE (" + value + ")");
}

value = readVirtualThreadStates(vthreadCls, "RUNNING");
if (JVMTI_VTHREAD_STATE_RUNNING != value) {
Assert.fail("JVMTI_VTHREAD_STATE_RUNNING (" + JVMTI_VTHREAD_STATE_RUNNING + ") does not match VirtualThread.RUNNING (" + value + ")");
Expand Down Expand Up @@ -332,11 +328,21 @@ public void test_verifyJVMTIMacros() {
Assert.fail("JVMTI_VTHREAD_STATE_TIMED_PINNED (" + JVMTI_VTHREAD_STATE_TIMED_PINNED + ") does not match VirtualThread.TIMED_PINNED (" + value + ")");
}

value = readVirtualThreadStates(vthreadCls, "UNPARKED");
if (JVMTI_VTHREAD_STATE_UNPARKED != value) {
Assert.fail("JVMTI_VTHREAD_STATE_UNPARKED (" + JVMTI_VTHREAD_STATE_UNPARKED + ") does not match VirtualThread.UNPARKED (" + value + ")");
}

value = readVirtualThreadStates(vthreadCls, "YIELDING");
if (JVMTI_VTHREAD_STATE_YIELDING != value) {
Assert.fail("JVMTI_VTHREAD_STATE_YIELDING (" + JVMTI_VTHREAD_STATE_YIELDING + ") does not match VirtualThread.YIELDING (" + value + ")");
}

value = readVirtualThreadStates(vthreadCls, "YIELDED");
if (JVMTI_VTHREAD_STATE_YIELDED != value) {
Assert.fail("JVMTI_VTHREAD_STATE_YIELDED (" + JVMTI_VTHREAD_STATE_YIELDED + ") does not match VirtualThread.YIELDED (" + value + ")");
}

value = readVirtualThreadStates(vthreadCls, "TERMINATED");
if (JVMTI_VTHREAD_STATE_TERMINATED != value) {
Assert.fail("JVMTI_VTHREAD_STATE_TERMINATED (" + JVMTI_VTHREAD_STATE_TERMINATED + ") does not match VirtualThread.TERMINATED (" + value + ")");
Expand Down