From b957ee40f302d54edf704b36120ef21fe977453a Mon Sep 17 00:00:00 2001 From: Peter Hofer Date: Thu, 5 Oct 2023 14:09:26 +0200 Subject: [PATCH] Remove virtual thread and continuation abstractions and code paths that have become unnecessary. --- .../genscavenge/ThreadLocalAllocation.java | 4 +- .../graal/GenScavengeAllocationSnippets.java | 5 +- .../graal/GenScavengeAllocationSupport.java | 13 +- .../ClassInitializationInfo.java | 11 +- .../snippets/SubstrateAllocationSnippets.java | 5 +- .../core/graal/stackvalue/StackValueNode.java | 3 +- .../core/heap/StoredContinuationAccess.java | 10 +- .../svm/core/hub/InteriorObjRefWalker.java | 4 +- .../image/DisallowedImageHeapObjects.java | 28 +-- .../core/jdk/ContinuationsNotSupported.java | 36 --- .../svm/core/jdk/ContinuationsSupported.java | 36 --- .../src/com/oracle/svm/core/jdk/LoomJDK.java | 36 --- .../com/oracle/svm/core/jdk/NotLoomJDK.java | 36 --- .../oracle/svm/core/jdk/StackTraceUtils.java | 10 +- .../jdk/Target_java_lang_StackWalker.java | 15 +- .../svm/core/jni/functions/JNIFunctions.java | 13 +- .../monitor/MultiThreadedMonitorSupport.java | 5 +- .../oracle/svm/core/thread/Continuation.java | 15 +- .../svm/core/thread/ContinuationSupport.java | 25 +- .../svm/core/thread/ContinuationsFeature.java | 64 ++--- .../oracle/svm/core/thread/JavaThreads.java | 155 +++++++----- .../oracle/svm/core/thread/LoomSupport.java | 52 ---- .../svm/core/thread/LoomVirtualThreads.java | 230 ------------------ .../svm/core/thread/PlatformThreads.java | 75 +++--- .../com/oracle/svm/core/thread/Safepoint.java | 2 +- .../core/thread/Target_java_lang_Thread.java | 101 ++------ .../Target_java_lang_VirtualThread.java | 9 +- ..._jdk_internal_misc_Unsafe_JavaThreads.java | 5 +- .../Target_jdk_internal_vm_Continuation.java | 37 +-- ..._jdk_internal_vm_ContinuationSupport.java} | 25 +- .../svm/core/thread/VirtualThreads.java | 76 ------ .../src/com/oracle/svm/hosted/SVMHost.java | 4 +- .../thread/HostedContinuationsFeature.java | 3 +- .../jfr/TestJavaLevelVirtualThreadEvents.java | 4 +- 34 files changed, 269 insertions(+), 883 deletions(-) delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ContinuationsNotSupported.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ContinuationsSupported.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/LoomJDK.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NotLoomJDK.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/LoomSupport.java delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/LoomVirtualThreads.java rename substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/{Continuations.java => Target_jdk_internal_vm_ContinuationSupport.java} (57%) delete mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VirtualThreads.java diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ThreadLocalAllocation.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ThreadLocalAllocation.java index 1c27f3931935..2c123a36acd3 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ThreadLocalAllocation.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ThreadLocalAllocation.java @@ -67,7 +67,7 @@ import com.oracle.svm.core.snippets.KnownIntrinsics; import com.oracle.svm.core.snippets.SubstrateForeignCallTarget; import com.oracle.svm.core.stack.StackOverflowCheck; -import com.oracle.svm.core.thread.Continuation; +import com.oracle.svm.core.thread.ContinuationSupport; import com.oracle.svm.core.thread.VMOperation; import com.oracle.svm.core.thread.VMThreads; import com.oracle.svm.core.threadlocal.FastThreadLocal; @@ -375,7 +375,7 @@ private static Object allocateLargeArrayLikeObjectInNewTlab(DynamicHub hub, int @Uninterruptible(reason = "Holds uninitialized memory") private static Object formatArrayLikeObject(Pointer memory, DynamicHub hub, int length, boolean unaligned, FillContent fillContent, byte[] podReferenceMap) { Class clazz = DynamicHub.toClass(hub); - if (Continuation.isSupported() && clazz == StoredContinuation.class) { + if (ContinuationSupport.isSupported() && clazz == StoredContinuation.class) { return FormatStoredContinuationNode.formatStoredContinuation(memory, clazz, length, false, unaligned, true); } else if (Pod.RuntimeSupport.isPresent() && podReferenceMap != null) { return FormatPodNode.formatPod(memory, clazz, length, podReferenceMap, false, unaligned, fillContent, true); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeAllocationSnippets.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeAllocationSnippets.java index 247f6d6f6d3c..000c85080d58 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeAllocationSnippets.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeAllocationSnippets.java @@ -58,7 +58,6 @@ import com.oracle.svm.core.heap.Pod; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.LayoutEncoding; -import com.oracle.svm.core.thread.Continuation; import com.oracle.svm.core.thread.ContinuationSupport; import jdk.vm.ci.meta.JavaKind; @@ -130,7 +129,7 @@ public Templates(OptionValues options, Providers providers, SubstrateAllocationS this.baseTemplates = baseTemplates; formatObject = snippet(providers, GenScavengeAllocationSnippets.class, "formatObjectSnippet"); formatArray = snippet(providers, GenScavengeAllocationSnippets.class, "formatArraySnippet"); - formatStoredContinuation = Continuation.isSupported() ? snippet(providers, GenScavengeAllocationSnippets.class, "formatStoredContinuation") : null; + formatStoredContinuation = ContinuationSupport.isSupported() ? snippet(providers, GenScavengeAllocationSnippets.class, "formatStoredContinuation") : null; formatPod = Pod.RuntimeSupport.isPresent() ? snippet(providers, GenScavengeAllocationSnippets.class, "formatPodSnippet", @@ -141,7 +140,7 @@ public Templates(OptionValues options, Providers providers, SubstrateAllocationS public void registerLowering(Map, NodeLoweringProvider> lowerings) { lowerings.put(FormatObjectNode.class, new FormatObjectLowering()); lowerings.put(FormatArrayNode.class, new FormatArrayLowering()); - if (Continuation.isSupported()) { + if (ContinuationSupport.isSupported()) { lowerings.put(FormatStoredContinuationNode.class, new FormatStoredContinuationLowering()); } if (Pod.RuntimeSupport.isPresent()) { diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeAllocationSupport.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeAllocationSupport.java index 5af97cbc22e5..f99a080c56a8 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeAllocationSupport.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeAllocationSupport.java @@ -24,18 +24,19 @@ */ package com.oracle.svm.core.genscavenge.graal; -import com.oracle.svm.core.heap.Pod; -import com.oracle.svm.core.snippets.SnippetRuntime.SubstrateForeignCallDescriptor; -import com.oracle.svm.core.thread.Continuation; -import jdk.compiler.graal.core.common.spi.ForeignCallDescriptor; -import jdk.compiler.graal.word.Word; import org.graalvm.word.UnsignedWord; import com.oracle.svm.core.genscavenge.HeapParameters; import com.oracle.svm.core.genscavenge.ThreadLocalAllocation; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.graal.snippets.GCAllocationSupport; +import com.oracle.svm.core.heap.Pod; import com.oracle.svm.core.snippets.SnippetRuntime; +import com.oracle.svm.core.snippets.SnippetRuntime.SubstrateForeignCallDescriptor; +import com.oracle.svm.core.thread.ContinuationSupport; + +import jdk.compiler.graal.core.common.spi.ForeignCallDescriptor; +import jdk.compiler.graal.word.Word; public class GenScavengeAllocationSupport implements GCAllocationSupport { private static final SubstrateForeignCallDescriptor SLOW_NEW_INSTANCE = SnippetRuntime.findForeignCall(ThreadLocalAllocation.class, "slowPathNewInstance", true); @@ -46,7 +47,7 @@ public class GenScavengeAllocationSupport implements GCAllocationSupport { public static void registerForeignCalls(SubstrateForeignCallsProvider foreignCalls) { foreignCalls.register(UNCONDITIONAL_FOREIGN_CALLS); - if (Continuation.isSupported()) { + if (ContinuationSupport.isSupported()) { foreignCalls.register(SLOW_NEW_STORED_CONTINUATION); } if (Pod.RuntimeSupport.isPresent()) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java index c723a428a5cf..f13625d036df 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java @@ -29,7 +29,6 @@ import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.IsolateThread; -import com.oracle.svm.core.hub.PredefinedClassesSupport; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CFunctionPointer; @@ -38,10 +37,12 @@ import com.oracle.svm.core.FunctionPointerHolder; import com.oracle.svm.core.c.InvokeJavaFunctionPointer; import com.oracle.svm.core.hub.DynamicHub; +import com.oracle.svm.core.hub.PredefinedClassesSupport; import com.oracle.svm.core.jdk.InternalVMMethod; import com.oracle.svm.core.snippets.SubstrateForeignCallTarget; +import com.oracle.svm.core.thread.ContinuationSupport; import com.oracle.svm.core.thread.JavaThreads; -import com.oracle.svm.core.thread.VirtualThreads; +import com.oracle.svm.core.thread.Target_jdk_internal_vm_Continuation; import com.oracle.svm.core.util.VMError; import jdk.internal.misc.Unsafe; @@ -263,16 +264,16 @@ private static void initialize(ClassInitializationInfo info, DynamicHub hub) { } boolean pinned = false; - if (VirtualThreads.isSupported() && JavaThreads.isCurrentThreadVirtual()) { + if (ContinuationSupport.isSupported() && JavaThreads.isCurrentThreadVirtual()) { // See comment on field `initThread` - VirtualThreads.singleton().pinCurrent(); + Target_jdk_internal_vm_Continuation.pin(); pinned = true; } try { doInitialize(info, hub); } finally { if (pinned) { - VirtualThreads.singleton().unpinCurrent(); + Target_jdk_internal_vm_Continuation.unpin(); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SubstrateAllocationSnippets.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SubstrateAllocationSnippets.java index f3fa72e27dc1..1755d04ffd69 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SubstrateAllocationSnippets.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SubstrateAllocationSnippets.java @@ -102,7 +102,6 @@ import com.oracle.svm.core.snippets.SnippetRuntime; import com.oracle.svm.core.snippets.SnippetRuntime.SubstrateForeignCallDescriptor; import com.oracle.svm.core.snippets.SubstrateForeignCallTarget; -import com.oracle.svm.core.thread.Continuation; import com.oracle.svm.core.thread.ContinuationSupport; import com.oracle.svm.core.util.VMError; @@ -600,7 +599,7 @@ public Templates(OptionValues options, Providers providers, SubstrateAllocationS ALLOCATION_LOCATIONS); SnippetInfo allocateStoredContinuationSnippet = null; - if (Continuation.isSupported()) { + if (ContinuationSupport.isSupported()) { allocateStoredContinuationSnippet = snippet(providers, SubstrateAllocationSnippets.class, "allocateStoredContinuation", @@ -634,7 +633,7 @@ public void registerLowering(Map, NodeLoweringProvider> lowerings.put(NewMultiArrayNode.class, new NewMultiArrayLowering()); lowerings.put(ValidateNewInstanceClassNode.class, new ValidateNewInstanceClassLowering()); - if (Continuation.isSupported()) { + if (ContinuationSupport.isSupported()) { lowerings.put(NewStoredContinuationNode.class, new NewStoredContinuationLowering()); } if (Pod.RuntimeSupport.isPresent()) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/stackvalue/StackValueNode.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/stackvalue/StackValueNode.java index f7d9c8454a4c..8c2785c164ed 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/stackvalue/StackValueNode.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/stackvalue/StackValueNode.java @@ -46,7 +46,6 @@ import com.oracle.svm.core.FrameAccess; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.config.ConfigurationValues; -import com.oracle.svm.core.thread.VirtualThreads; import jdk.vm.ci.meta.ResolvedJavaMethod; @@ -153,7 +152,7 @@ public static StackValueNode create(int sizeInBytes, ResolvedJavaMethod method, * around in a caller, but these are difficult to ensure across multiple callers and * callees. */ - boolean checkVirtualThread = disallowVirtualThread && VirtualThreads.isSupported() && !Uninterruptible.Utils.isUninterruptible(method); + boolean checkVirtualThread = disallowVirtualThread && !Uninterruptible.Utils.isUninterruptible(method); return create(sizeInBytes, slotIdentity, checkVirtualThread); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/StoredContinuationAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/StoredContinuationAccess.java index e8da66702ef1..ca165013e1f1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/StoredContinuationAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/StoredContinuationAccess.java @@ -39,9 +39,9 @@ import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.UnmanagedMemoryUtil; import com.oracle.svm.core.AlwaysInline; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.UnmanagedMemoryUtil; import com.oracle.svm.core.c.NonmovableArray; import com.oracle.svm.core.code.CodeInfo; import com.oracle.svm.core.code.CodeInfoAccess; @@ -126,7 +126,7 @@ private static int allocateFromStack(Continuation cont, Pointer baseSp, Pointer if (!yield) { PreemptVisitor visitor = new PreemptVisitor(baseSp); JavaStackWalker.walkThread(targetThread, visitor); - if (visitor.preemptStatus != Continuation.FREEZE_OK) { + if (visitor.preemptStatus != ContinuationSupport.FREEZE_OK) { return visitor.preemptStatus; } startSp = visitor.leafSP; @@ -139,7 +139,7 @@ private static int allocateFromStack(Continuation cont, Pointer baseSp, Pointer StoredContinuation instance = allocate(framesSize); fillUninterruptibly(instance, startIp, startSp, framesSize); cont.stored = instance; - return Continuation.FREEZE_OK; + return ContinuationSupport.FREEZE_OK; } @Uninterruptible(reason = "Prevent modifications to the stack while initializing instance and copying frames.") @@ -300,7 +300,7 @@ private static final class PreemptVisitor extends StackFrameVisitor { Pointer leafSP; CodePointer leafIP; - int preemptStatus = Continuation.FREEZE_OK; + int preemptStatus = ContinuationSupport.FREEZE_OK; PreemptVisitor(Pointer endSP) { this.endSP = endSP; @@ -315,7 +315,7 @@ protected boolean visitFrame(Pointer sp, CodePointer ip, CodeInfo codeInfo, Deop FrameInfoQueryResult frameInfo = CodeInfoTable.lookupCodeInfoQueryResult(codeInfo, ip).getFrameInfo(); if (frameInfo.getSourceClass().equals(StoredContinuationAccess.class) && frameInfo.getSourceMethodName().equals("allocateToYield")) { // Continuation is already in the process of yielding, cancel preemption. - preemptStatus = Continuation.YIELDING; + preemptStatus = ContinuationSupport.FREEZE_YIELDING; return false; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/InteriorObjRefWalker.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/InteriorObjRefWalker.java index cc7a03916128..25c128eaf93a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/InteriorObjRefWalker.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/InteriorObjRefWalker.java @@ -43,7 +43,7 @@ import com.oracle.svm.core.heap.PodReferenceMapDecoder; import com.oracle.svm.core.heap.ReferenceAccess; import com.oracle.svm.core.heap.StoredContinuationAccess; -import com.oracle.svm.core.thread.Continuation; +import com.oracle.svm.core.thread.ContinuationSupport; import com.oracle.svm.core.util.VMError; /** @@ -130,7 +130,7 @@ private static boolean walkPod(Object obj, ObjectReferenceVisitor visitor, Dynam @AlwaysInline("Performance critical version") @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static boolean walkStoredContinuation(Object obj, ObjectReferenceVisitor visitor) { - if (!Continuation.isSupported()) { + if (!ContinuationSupport.isSupported()) { throw VMError.shouldNotReachHere("Stored continuation objects cannot be in the heap if the continuation support is disabled."); } return StoredContinuationAccess.walkReferences(obj, visitor); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java index 125efc0dba22..b6ccc67d8976 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java @@ -37,7 +37,6 @@ import java.util.concurrent.ThreadLocalRandom; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.thread.VirtualThreads; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; @@ -52,20 +51,12 @@ public interface DisallowedObjectReporter { RuntimeException raise(String msg, Object obj, String initializerAction); } - private static final Class CANCELLABLE_CLASS; - private static final Class JDK_VIRTUAL_THREAD_CLASS; - private static final Class CONTINUATION_CLASS; - private static final Method CONTINUATION_IS_STARTED_METHOD; - private static final Class CLEANER_CLEANABLE_CLASS; - private static final Class LEGACY_CLEANER_CLASS; - static { - CANCELLABLE_CLASS = ReflectionUtil.lookupClass(false, "sun.nio.fs.Cancellable"); - JDK_VIRTUAL_THREAD_CLASS = ReflectionUtil.lookupClass(true, "java.lang.VirtualThread"); - CONTINUATION_CLASS = ReflectionUtil.lookupClass(true, "jdk.internal.vm.Continuation"); - CONTINUATION_IS_STARTED_METHOD = (CONTINUATION_CLASS == null) ? null : ReflectionUtil.lookupMethod(CONTINUATION_CLASS, "isStarted"); - CLEANER_CLEANABLE_CLASS = ReflectionUtil.lookupClass(false, "jdk.internal.ref.CleanerImpl$CleanerCleanable"); - LEGACY_CLEANER_CLASS = ReflectionUtil.lookupClass(false, "jdk.internal.ref.Cleaner"); - } + private static final Class CANCELLABLE_CLASS = ReflectionUtil.lookupClass(false, "sun.nio.fs.Cancellable"); + private static final Class VIRTUAL_THREAD_CLASS = ReflectionUtil.lookupClass(false, "java.lang.VirtualThread"); + private static final Class CONTINUATION_CLASS = ReflectionUtil.lookupClass(false, "jdk.internal.vm.Continuation"); + private static final Method CONTINUATION_IS_STARTED_METHOD = ReflectionUtil.lookupMethod(CONTINUATION_CLASS, "isStarted"); + private static final Class CLEANER_CLEANABLE_CLASS = ReflectionUtil.lookupClass(false, "jdk.internal.ref.CleanerImpl$CleanerCleanable"); + private static final Class LEGACY_CLEANER_CLASS = ReflectionUtil.lookupClass(false, "jdk.internal.ref.Cleaner"); public static void check(Object obj, DisallowedObjectReporter reporter) { if (((obj instanceof Random) && !(obj instanceof ThreadLocalRandom)) || obj instanceof SplittableRandom) { @@ -75,9 +66,8 @@ public static void check(Object obj, DisallowedObjectReporter reporter) { } /* Started platform threads */ - if (obj instanceof Thread) { - final Thread asThread = (Thread) obj; - if (VirtualThreads.isSupported() && (VirtualThreads.singleton().isVirtual(asThread) || (JDK_VIRTUAL_THREAD_CLASS != null && JDK_VIRTUAL_THREAD_CLASS.isInstance(asThread)))) { + if (obj instanceof Thread asThread) { + if (VIRTUAL_THREAD_CLASS.isInstance(asThread)) { // allowed unless the thread is mounted, in which case it references its carrier // thread and fails } else if (asThread.getState() != Thread.State.NEW && asThread.getState() != Thread.State.TERMINATED) { @@ -86,7 +76,7 @@ public static void check(Object obj, DisallowedObjectReporter reporter) { asThread, "Prevent threads from starting during image generation, or a started thread from being included in the image."); } } - if (SubstrateUtil.HOSTED && CONTINUATION_CLASS != null && CONTINUATION_CLASS.isInstance(obj)) { + if (SubstrateUtil.HOSTED && CONTINUATION_CLASS.isInstance(obj)) { boolean isStarted; try { isStarted = (Boolean) CONTINUATION_IS_STARTED_METHOD.invoke(obj); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ContinuationsNotSupported.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ContinuationsNotSupported.java deleted file mode 100644 index 070f91430ff9..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ContinuationsNotSupported.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.jdk; - -import java.util.function.BooleanSupplier; - -import com.oracle.svm.core.thread.Continuation; - -public class ContinuationsNotSupported implements BooleanSupplier { - @Override - public boolean getAsBoolean() { - return !Continuation.isSupported(); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ContinuationsSupported.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ContinuationsSupported.java deleted file mode 100644 index 58e6fbf190ce..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ContinuationsSupported.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.jdk; - -import java.util.function.BooleanSupplier; - -import com.oracle.svm.core.thread.Continuation; - -public class ContinuationsSupported implements BooleanSupplier { - @Override - public boolean getAsBoolean() { - return Continuation.isSupported(); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/LoomJDK.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/LoomJDK.java deleted file mode 100644 index 308577de3d72..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/LoomJDK.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.jdk; - -import java.util.function.BooleanSupplier; - -import com.oracle.svm.core.thread.LoomSupport; - -public class LoomJDK implements BooleanSupplier { - @Override - public boolean getAsBoolean() { - return LoomSupport.isEnabled(); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NotLoomJDK.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NotLoomJDK.java deleted file mode 100644 index 3107a626cad7..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NotLoomJDK.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.jdk; - -import java.util.function.BooleanSupplier; - -import com.oracle.svm.core.thread.LoomSupport; - -public class NotLoomJDK implements BooleanSupplier { - @Override - public boolean getAsBoolean() { - return !LoomSupport.isEnabled(); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/StackTraceUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/StackTraceUtils.java index 308f01da0ec7..38cc6bf04a62 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/StackTraceUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/StackTraceUtils.java @@ -61,11 +61,8 @@ import com.oracle.svm.core.stack.StackFrameVisitor; import com.oracle.svm.core.thread.JavaThreads; import com.oracle.svm.core.thread.JavaVMOperation; -import com.oracle.svm.core.thread.LoomSupport; -import com.oracle.svm.core.thread.PlatformThreads; import com.oracle.svm.core.thread.Target_jdk_internal_vm_Continuation; import com.oracle.svm.core.thread.VMOperation; -import com.oracle.svm.core.thread.VirtualThreads; import com.oracle.svm.core.util.VMError; import jdk.vm.ci.meta.MetaAccessProvider; @@ -104,10 +101,7 @@ public static void visitCurrentThreadStackFrames(Pointer startSP, Pointer endSP, @NeverInline("Potentially starting a stack walk in the caller frame") public static StackTraceElement[] getStackTraceAtSafepoint(Thread thread) { assert VMOperation.isInProgressAtSafepoint(); - if (VirtualThreads.isSupported()) { // NOTE: also for platform threads! - return VirtualThreads.singleton().getVirtualOrPlatformThreadStackTraceAtSafepoint(thread, readCallerStackPointer()); - } - return PlatformThreads.getStackTraceAtSafepoint(thread, readCallerStackPointer()); + return JavaThreads.getStackTraceAtSafepoint(thread, readCallerStackPointer()); } public static StackTraceElement[] getThreadStackTraceAtSafepoint(IsolateThread isolateThread, Pointer endSP) { @@ -186,7 +180,7 @@ public static boolean shouldShowFrame(FrameInfoQueryResult frameInfo, boolean sh return false; } - if (LoomSupport.isEnabled() && clazz == Target_jdk_internal_vm_Continuation.class) { + if (clazz == Target_jdk_internal_vm_Continuation.class) { String name = frameInfo.getSourceMethodName(); if (name.startsWith("enter") || name.startsWith("yield")) { return false; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_StackWalker.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_StackWalker.java index e6aed227bf14..4ab3bd5db3cc 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_StackWalker.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_StackWalker.java @@ -48,7 +48,6 @@ import com.oracle.svm.core.annotate.Delete; 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.code.CodeInfo; import com.oracle.svm.core.code.CodeInfoAccess; import com.oracle.svm.core.code.CodeInfoTable; @@ -65,8 +64,8 @@ import com.oracle.svm.core.stack.JavaStackWalk; import com.oracle.svm.core.stack.JavaStackWalker; import com.oracle.svm.core.thread.Continuation; +import com.oracle.svm.core.thread.ContinuationSupport; import com.oracle.svm.core.thread.JavaThreads; -import com.oracle.svm.core.thread.LoomSupport; import com.oracle.svm.core.thread.Target_java_lang_VirtualThread; import com.oracle.svm.core.thread.Target_jdk_internal_vm_Continuation; import com.oracle.svm.core.thread.Target_jdk_internal_vm_ContinuationScope; @@ -79,13 +78,13 @@ final class Target_java_lang_StackWalker { /** * Current continuation that the stack walker is on. */ - @Alias @TargetElement(onlyWith = LoomJDK.class)// + @Alias // Target_jdk_internal_vm_Continuation continuation; /** * Target continuation scope if we're iterating a {@link Target_jdk_internal_vm_Continuation}. */ - @Alias @TargetElement(onlyWith = LoomJDK.class)// + @Alias // Target_jdk_internal_vm_ContinuationScope contScope; @Alias Set