Skip to content

Commit

Permalink
svm: adopt "JDK-8321270: Virtual Thread.yield consumes parking permit…
Browse files Browse the repository at this point in the history
…" [GR-50851]

openjdk/jdk@29d7a22
  • Loading branch information
zapster committed Dec 11, 2023
1 parent 55d9e08 commit 595ac63
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.annotate.TargetElement;
import com.oracle.svm.core.jdk.JDK21OrEarlier;
import com.oracle.svm.core.jdk.JDK22OrLater;
import com.oracle.svm.core.jfr.HasJfrSupport;
import com.oracle.svm.core.jfr.SubstrateJVM;
Expand All @@ -60,17 +61,20 @@ public final class Target_java_lang_VirtualThread {
// Checkstyle: stop
@Alias static int NEW;
@Alias static int STARTED;
@Alias static int RUNNABLE;
@Alias //
@TargetElement(onlyWith = JDK21OrEarlier.class) static int RUNNABLE;
@Alias static int RUNNING;
@Alias static int PARKING;
@Alias static int PARKED;
@Alias static int PINNED;
@Alias static int YIELDING;
@TargetElement(onlyWith = JDK22OrLater.class) @Alias static int YIELDED;
@Alias static int TERMINATED;
@Alias static int SUSPENDED;
@TargetElement(onlyWith = JDK22OrLater.class) @Alias static int TIMED_PARKING;
@TargetElement(onlyWith = JDK22OrLater.class) @Alias static int TIMED_PARKED;
@TargetElement(onlyWith = JDK22OrLater.class) @Alias static int TIMED_PINNED;
@TargetElement(onlyWith = JDK22OrLater.class) @Alias static int UNPARKED;
@Alias static Target_jdk_internal_vm_ContinuationScope VTHREAD_SCOPE;

/**
Expand Down Expand Up @@ -300,7 +304,9 @@ Thread.State threadState() {
} else {
return Thread.State.RUNNABLE;
}
} else if (state == RUNNABLE) {
} else if (JavaVersionUtil.JAVA_SPEC < 22 && state == RUNNABLE) {
return Thread.State.RUNNABLE;
} else if (JavaVersionUtil.JAVA_SPEC >= 22 && (state == UNPARKED || state == YIELDED)) {
return Thread.State.RUNNABLE;
} else if (state == RUNNING) {
Object token = VirtualThreadHelper.acquireInterruptLockMaybeSwitch(this);
Expand Down

0 comments on commit 595ac63

Please sign in to comment.