8308609: java/lang/ScopedValue/StressStackOverflow.java fails with "-XX:-VMContinuations"

Reviewed-by: alanb
This commit is contained in:
Andrew Haley 2023-06-16 12:21:11 +00:00
parent b412fc79c3
commit 44a8aa0691
7 changed files with 82 additions and 70 deletions

View file

@ -1578,7 +1578,7 @@ public class Thread implements Runnable {
*/
@Hidden
@ForceInline
private void runWith(Object bindings, Runnable op) {
final void runWith(Object bindings, Runnable op) {
ensureMaterializedForStackWalk(bindings);
op.run();
Reference.reachabilityFence(bindings);

View file

@ -433,7 +433,8 @@ class ThreadBuilders {
// run is specified to do nothing when Thread is a virtual thread
if (Thread.currentThread() == this && !runInvoked) {
runInvoked = true;
task.run();
Object bindings = Thread.scopedValueBindings();
runWith(bindings, task);
}
}

View file

@ -24,7 +24,6 @@
*/
package java.lang;
import java.lang.ref.Reference;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Locale;
@ -54,7 +53,6 @@ import jdk.internal.vm.StackableScope;
import jdk.internal.vm.ThreadContainer;
import jdk.internal.vm.ThreadContainers;
import jdk.internal.vm.annotation.ChangesCurrentThread;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.annotation.Hidden;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.vm.annotation.JvmtiMountTransition;
@ -306,7 +304,7 @@ final class VirtualThread extends BaseVirtualThread {
event.commit();
}
Object bindings = scopedValueBindings();
Object bindings = Thread.scopedValueBindings();
try {
runWith(bindings, task);
} catch (Throwable exc) {
@ -334,14 +332,6 @@ final class VirtualThread extends BaseVirtualThread {
}
}
@Hidden
@ForceInline
private void runWith(Object bindings, Runnable op) {
ensureMaterializedForStackWalk(bindings);
op.run();
Reference.reachabilityFence(bindings);
}
/**
* Mounts this virtual thread onto the current platform thread. On
* return, the current thread is the virtual thread.