Skip to content

Commit

Permalink
svm: adopt "JDK-8312498 Thread::getState and JVM TI GetThreadState sh…
Browse files Browse the repository at this point in the history
…ould return TIMED_WAITING virtual thread is timed parked" [GR-48899]

(cherry picked from commit 421ff99)
  • Loading branch information
zapster authored and zakkak committed May 22, 2024
1 parent 49b4215 commit 1e48201
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.util.Locale;
import java.util.concurrent.Executor;

import org.graalvm.compiler.serviceprovider.JavaVersionUtil;

import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.annotate.Alias;
Expand Down Expand Up @@ -62,8 +64,12 @@ public final class Target_java_lang_VirtualThread {
@Alias static int PINNED;
@Alias static int YIELDING;
@Alias static int TERMINATED;
@Alias static int RUNNABLE_SUSPENDED;
@Alias static int PARKED_SUSPENDED;
@Alias //
@TargetElement(onlyWith = JDK21OrEarlier.class) //
static int RUNNABLE_SUSPENDED;
@Alias //
@TargetElement(onlyWith = JDK21OrEarlier.class) //
static int PARKED_SUSPENDED;
@Alias static Target_jdk_internal_vm_ContinuationScope VTHREAD_SCOPE;
// Checkstyle: resume

Expand Down Expand Up @@ -164,7 +170,7 @@ Thread.State threadState() {
} else {
return Thread.State.RUNNABLE;
}
} else if (state == RUNNABLE || state == RUNNABLE_SUSPENDED) {
} else if (state == RUNNABLE || (JavaVersionUtil.JAVA_SPEC <= 21 && state == RUNNABLE_SUSPENDED)) {
return Thread.State.RUNNABLE;
} else if (state == RUNNING) {
Object token = VirtualThreadHelper.acquireInterruptLockMaybeSwitch(this);
Expand All @@ -179,7 +185,7 @@ Thread.State threadState() {
return Thread.State.RUNNABLE;
} else if (state == PARKING || state == YIELDING) {
return Thread.State.RUNNABLE;
} else if (state == PARKED || state == PARKED_SUSPENDED || state == PINNED) {
} else if (state == PARKED || (JavaVersionUtil.JAVA_SPEC <= 21 && state == PARKED_SUSPENDED) || state == PINNED) {
int parkedThreadStatus = MonitorSupport.singleton().getParkedThreadStatus(asThread(this), false);
switch (parkedThreadStatus) {
case ThreadStatus.BLOCKED_ON_MONITOR_ENTER:
Expand Down

0 comments on commit 1e48201

Please sign in to comment.