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

[GR-45143] Remove SubstrateVirtualThreads. #6560

Merged
merged 1 commit into from
May 8, 2023
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
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