Skip to content

Commit

Permalink
Remove SubstrateVirtualThreads.
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-hofer committed May 5, 2023
1 parent 08e385a commit 3c63bf5
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 1,349 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
}
};

@Option(help = "Support continuations (without requiring a Project Loom JDK)") //
public static final HostedOptionKey<Boolean> SupportContinuations = new HostedOptionKey<>(false);

public static final int ForceFallback = 10;
public static final int Automatic = 5;
public static final int NoFallback = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@

import com.oracle.svm.core.NeverInline;
import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.AnnotateOriginal;
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.InjectAccessors;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
Expand All @@ -52,10 +50,6 @@ public static String getSavedProperty(String name) {
return SystemPropertiesSupport.singleton().getSavedProperties().get(name);
}

@AnnotateOriginal
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static native Thread.State toThreadState(int threadStatus);

@Substitute
@NeverInline("Starting a stack walk in the caller frame")
public static ClassLoader latestUserDefinedLoader0() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.NeverInline;
import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.heap.StoredContinuation;
import com.oracle.svm.core.heap.StoredContinuationAccess;
import com.oracle.svm.core.heap.VMOperationInfos;
Expand All @@ -42,15 +41,12 @@
import com.oracle.svm.core.stack.StackOverflowCheck;
import com.oracle.svm.core.util.VMError;

/**
* Foundation for continuation support via {@link SubstrateVirtualThread} or
* {@linkplain Target_jdk_internal_vm_Continuation Project Loom}.
*/
/** Foundation for {@linkplain Target_jdk_internal_vm_Continuation Project Loom} support. */
@InternalVMMethod
public final class Continuation {
@Fold
public static boolean isSupported() {
return SubstrateOptions.SupportContinuations.getValue() || LoomSupport.isEnabled();
return LoomSupport.isEnabled();
}

public static final int YIELDING = -2;
Expand All @@ -69,7 +65,6 @@ public static boolean isSupported() {
/** While executing, frame pointer of initial frame of continuation, {@code null} otherwise. */
private Pointer baseSP;

private boolean done;
private int overflowCheckState;

Continuation(Runnable target) {
Expand Down Expand Up @@ -167,7 +162,6 @@ private void enter2() {
Pointer returnSP = sp;
CodePointer returnIP = ip;

done = true;
ip = WordFactory.nullPointer();
sp = WordFactory.nullPointer();
baseSP = WordFactory.nullPointer();
Expand Down Expand Up @@ -215,18 +209,14 @@ private Integer yield0() {
throw VMError.shouldNotReachHereAtRuntime();
}

public boolean isStarted() {
boolean isStarted() {
return stored != null || ip.isNonNull();
}

public boolean isEmpty() {
boolean isEmpty() {
return stored == null;
}

public boolean isDone() {
return done;
}

private static final class TryPreemptOperation extends JavaVMOperation {
int preemptStatus = FREEZE_OK;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import com.oracle.svm.core.feature.InternalFeature;
import com.oracle.svm.core.heap.StoredContinuation;
import com.oracle.svm.core.heap.StoredContinuationAccess;
import com.oracle.svm.core.option.SubstrateOptionsParser;
import com.oracle.svm.core.util.UserError;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.util.ReflectionUtil;

Expand Down Expand Up @@ -78,22 +76,6 @@ public void afterRegistration(AfterRegistrationAccess access) {
LoomVirtualThreads vt = new LoomVirtualThreads();
ImageSingletons.add(VirtualThreads.class, vt);
ImageSingletons.add(LoomVirtualThreads.class, vt); // for simpler check in LoomSupport
} else if (SubstrateOptions.SupportContinuations.getValue()) {
if (DeoptimizationSupport.enabled()) {
throw UserError.abort("Option %s is in use, but is not supported together with Truffle JIT compilation.",
SubstrateOptionsParser.commandArgument(SubstrateOptions.SupportContinuations, "+"));
} else if (SubstrateOptions.useLLVMBackend()) {
throw UserError.abort("Option %s is in use, but is not supported together with the LLVM backend.",
SubstrateOptionsParser.commandArgument(SubstrateOptions.SupportContinuations, "+"));
} else if (JavaVersionUtil.JAVA_SPEC == 17) {
ImageSingletons.add(VirtualThreads.class, new SubstrateVirtualThreads());
} else if (JavaVersionUtil.JAVA_SPEC >= firstLoomPreviewVersion && JavaVersionUtil.JAVA_SPEC <= lastLoomPreviewVersion) {
throw UserError.abort("Virtual threads on JDK %d are supported only with preview features enabled (--enable-preview). Using option %s is unnecessary.",
JavaVersionUtil.JAVA_SPEC, SubstrateOptionsParser.commandArgument(SubstrateOptions.SupportContinuations, "+"));
} else {
throw UserError.abort("Option %s is in use, but is not supported on JDK %d.",
SubstrateOptionsParser.commandArgument(SubstrateOptions.SupportContinuations, "+"), JavaVersionUtil.JAVA_SPEC);
}
}
finishedRegistration = true;
}
Expand Down Expand Up @@ -129,6 +111,6 @@ public void beforeCompilation(BeforeCompilationAccess access) {
}

static void abortIfUnsupported() {
VMError.guarantee(Continuation.isSupported(), "Virtual thread internals are reachable but support is not available or active.");
VMError.guarantee(Continuation.isSupported(), "Virtual threads internals are reachable but support is not available or active.");
}
}
Loading

0 comments on commit 3c63bf5

Please sign in to comment.