Skip to content

Commit bf3b1ae

Browse files
committed
[GR-34749] [GR-36413] [GR-36109] [GR-34435] Cleanups.
PullRequest: graal/11032
2 parents 0f8d9bf + 7c02782 commit bf3b1ae

File tree

8 files changed

+10
-139
lines changed

8 files changed

+10
-139
lines changed

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixJavaThreads.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*
3030
* @see PosixPlatformThreads
3131
*/
32-
public class PosixJavaThreads {
33-
protected PosixJavaThreads() {
32+
public final class PosixJavaThreads {
33+
private PosixJavaThreads() {
3434
}
3535
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public static boolean printFatalError(Log log, Pointer sp, CodePointer ip, Regis
191191
* further errors occur while printing diagnostics.
192192
*/
193193
if (!fatalErrorState().trySet(log, sp, ip, registerContext, frameHasCalleeSavedRegisters) && !isFatalErrorHandlingThread()) {
194-
log.string("Error: printDiagnostics already in progress by another thread.").newline();
194+
log.string("Error: printFatalError already in progress by another thread.").newline();
195195
log.newline();
196196
return false;
197197
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateUtil.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
4343
import org.graalvm.nativeimage.Platform;
4444
import org.graalvm.nativeimage.Platforms;
45-
import org.graalvm.nativeimage.c.function.CodePointer;
4645
import org.graalvm.nativeimage.c.type.CCharPointer;
4746
import org.graalvm.nativeimage.c.type.CCharPointerPointer;
4847
import org.graalvm.nativeimage.c.type.CTypeConversion;
@@ -55,7 +54,6 @@
5554
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
5655
import com.oracle.svm.core.annotate.TargetClass;
5756
import com.oracle.svm.core.annotate.Uninterruptible;
58-
import com.oracle.svm.core.log.Log;
5957
import com.oracle.svm.core.util.VMError;
6058
import com.oracle.svm.util.ReflectionUtil;
6159
import com.oracle.svm.util.StringUtil;
@@ -250,11 +248,6 @@ public interface Thunk {
250248
void invoke();
251249
}
252250

253-
/** Prints extensive diagnostic information for a fatal error to the given log. */
254-
public static boolean printDiagnostics(Log log, Pointer sp, CodePointer ip) {
255-
return SubstrateDiagnostics.printFatalError(log, sp, ip, WordFactory.nullPointer(), false);
256-
}
257-
258251
/**
259252
* Similar to {@link String#split(String)} but with a fixed separator string instead of a
260253
* regular expression. This avoids making regular expression code reachable.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/cpufeature/RuntimeCPUFeatureCheckImpl.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
import java.util.EnumSet;
3232
import java.util.Set;
3333

34-
import com.oracle.svm.core.CPUFeatureAccess;
35-
import com.oracle.svm.core.SubstrateTargetDescription;
36-
import com.oracle.svm.core.SubstrateUtil;
3734
import org.graalvm.compiler.api.replacements.Fold;
3835
import org.graalvm.compiler.api.replacements.SnippetReflectionProvider;
3936
import org.graalvm.compiler.core.common.NumUtil;
@@ -54,6 +51,9 @@
5451
import org.graalvm.nativeimage.Platforms;
5552
import org.graalvm.nativeimage.hosted.Feature;
5653

54+
import com.oracle.svm.core.CPUFeatureAccess;
55+
import com.oracle.svm.core.SubstrateTargetDescription;
56+
import com.oracle.svm.core.SubstrateUtil;
5757
import com.oracle.svm.core.annotate.AutomaticFeature;
5858
import com.oracle.svm.core.config.ConfigurationValues;
5959
import com.oracle.svm.core.jdk.RuntimeSupport;
@@ -92,10 +92,9 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
9292
* This needs to be a separate class, making this a lambda call or an anonymous class would pull the
9393
* {@link Feature} hierarchy into the image.
9494
*/
95-
final class RuntimeCPUFeatureCheckInitializer implements Runnable {
96-
95+
final class RuntimeCPUFeatureCheckInitializer implements RuntimeSupport.Hook {
9796
@Override
98-
public void run() {
97+
public void execute(boolean isFirstIsolate) {
9998
RuntimeCPUFeatureCheckImpl.instance().reinitialize();
10099
}
101100
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RuntimeSupport.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -163,27 +163,4 @@ private enum InitializationState {
163163
InProgress,
164164
Done
165165
}
166-
167-
/*
168-
* GR-36109: the following methods are for compatibility with legacy code and to be removed.
169-
*/
170-
171-
@Platforms(Platform.HOSTED_ONLY.class)
172-
public void addStartupHook(Runnable hook) {
173-
addHook(startupHooks, firstIsolate -> hook.run());
174-
}
175-
176-
@Platforms(Platform.HOSTED_ONLY.class)
177-
public void addShutdownHook(Runnable hook) {
178-
addHook(shutdownHooks, firstIsolate -> hook.run());
179-
}
180-
181-
public void addInitializationHook(Runnable hook) {
182-
addHook(initializationHooks, firstIsolate -> hook.run());
183-
}
184-
185-
public void addTearDownHook(Runnable hook) {
186-
addHook(tearDownHooks, firstIsolate -> hook.run());
187-
}
188-
189166
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreads.java

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,13 @@
3434
import org.graalvm.compiler.core.common.SuppressFBWarnings;
3535
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
3636
import org.graalvm.nativeimage.IsolateThread;
37-
import org.graalvm.nativeimage.ObjectHandle;
38-
import org.graalvm.nativeimage.Platform;
39-
import org.graalvm.nativeimage.Platforms;
40-
import org.graalvm.nativeimage.c.struct.RawStructure;
4137

4238
import com.oracle.svm.core.annotate.AlwaysInline;
4339
import com.oracle.svm.core.annotate.NeverInline;
4440
import com.oracle.svm.core.annotate.Uninterruptible;
4541
import com.oracle.svm.core.jdk.StackTraceUtils;
4642
import com.oracle.svm.core.jdk.Target_jdk_internal_misc_VM;
4743
import com.oracle.svm.core.snippets.KnownIntrinsics;
48-
import com.oracle.svm.core.util.VMError;
4944

5045
/**
5146
* Implements operations on {@linkplain Target_java_lang_Thread Java threads}, which are on a higher
@@ -69,14 +64,13 @@
6964
* @see <a href="https://openjdk.java.net/projects/loom/">Wiki and source code of Project Loom on
7065
* which concepts of virtual threads, carrier threads, etc. are modeled</a>
7166
*/
72-
public class JavaThreads {
67+
public final class JavaThreads {
7368
/** For Thread.nextThreadID(). */
7469
static final AtomicLong threadSeqNumber = new AtomicLong();
7570
/** For Thread.nextThreadNum(). */
7671
static final AtomicInteger threadInitNumber = new AtomicInteger();
7772

78-
@Platforms(Platform.HOSTED_ONLY.class)
79-
protected JavaThreads() {
73+
private JavaThreads() {
8074
}
8175

8276
@SuppressFBWarnings(value = "BC", justification = "Cast for @TargetClass")
@@ -325,50 +319,4 @@ public static Object getCurrentThreadLockHelper() {
325319
}
326320
return PlatformThreads.lockHelper.get();
327321
}
328-
329-
/**
330-
*
331-
* GR-34749: class {@link PlatformThreads} has been split off from JavaThreads for code specific
332-
* to OS threads, but legacy code still subclasses JavaThreads to provide OS-specific
333-
* implementations. We install {@link LegacyPlatformThreads} that calls the methods below. These
334-
* methods and {@link LegacyPlatformThreads} should be removed once they are no longer needed.
335-
*
336-
*/
337-
338-
@RawStructure
339-
protected interface ThreadStartData extends PlatformThreads.ThreadStartData {
340-
}
341-
342-
@SuppressWarnings("unused")
343-
protected void prepareStartData(Thread thread, ThreadStartData startData) {
344-
/*
345-
* GR-36413: Call PlatformThreads.prepareStart instead. Delete this method and
346-
* PlatformThreads.prepareStartData once they are no longer needed.
347-
*/
348-
PlatformThreads.prepareStartData(thread, startData);
349-
}
350-
351-
protected static void exit(Thread thread) {
352-
PlatformThreads.exit(thread);
353-
}
354-
355-
@SuppressWarnings("unused")
356-
protected static void threadStartRoutine(ObjectHandle threadHandle) {
357-
PlatformThreads.threadStartRoutine(threadHandle);
358-
}
359-
360-
@SuppressWarnings("unused")
361-
protected void doStartThread(Thread thread, long stackSize) {
362-
throw VMError.shouldNotReachHere("Subclass PlatformThreads instead.");
363-
}
364-
365-
@SuppressWarnings("unused")
366-
protected void setNativeName(Thread thread, String name) {
367-
throw VMError.shouldNotReachHere("Subclass PlatformThreads instead.");
368-
}
369-
370-
@SuppressWarnings("unused")
371-
protected void yield() {
372-
throw VMError.shouldNotReachHere("Subclass PlatformThreads instead.");
373-
}
374322
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@
5353
import org.graalvm.nativeimage.c.function.CEntryPoint;
5454
import org.graalvm.nativeimage.c.struct.RawField;
5555
import org.graalvm.nativeimage.c.struct.RawStructure;
56-
import org.graalvm.nativeimage.hosted.Feature;
5756
import org.graalvm.word.PointerBase;
5857
import org.graalvm.word.WordFactory;
5958

6059
import com.oracle.svm.core.SubstrateDiagnostics;
6160
import com.oracle.svm.core.SubstrateOptions;
6261
import com.oracle.svm.core.SubstrateUtil;
63-
import com.oracle.svm.core.annotate.AutomaticFeature;
6462
import com.oracle.svm.core.annotate.NeverInline;
6563
import com.oracle.svm.core.annotate.Uninterruptible;
6664
import com.oracle.svm.core.heap.Heap;
@@ -603,16 +601,6 @@ protected <T extends ThreadStartData> T prepareStart(Thread thread, int startDat
603601
return startData;
604602
}
605603

606-
/** GR-36413: for compatibility with legacy code, to be removed. Call prepareStart instead. */
607-
protected static void prepareStartData(Thread thread, ThreadStartData startData) {
608-
startData.setIsolate(CurrentIsolate.getIsolate());
609-
startData.setThreadHandle(ObjectHandles.getGlobal().create(thread));
610-
611-
if (!thread.isDaemon()) {
612-
nonDaemonThreads.incrementAndGet();
613-
}
614-
}
615-
616604
protected void undoPrepareStartOnError(Thread thread, ThreadStartData startData) {
617605
if (!thread.isDaemon()) {
618606
undoPrepareNonDaemonStartOnError();
@@ -974,31 +962,3 @@ public void operate() {
974962
}
975963
}
976964
}
977-
978-
final class LegacyPlatformThreads extends PlatformThreads {
979-
@Override
980-
protected boolean doStartThread(Thread thread, long stackSize) {
981-
ImageSingletons.lookup(JavaThreads.class).doStartThread(thread, stackSize);
982-
return true;
983-
}
984-
985-
@Override
986-
protected void setNativeName(Thread thread, String name) {
987-
ImageSingletons.lookup(JavaThreads.class).setNativeName(thread, name);
988-
}
989-
990-
@Override
991-
protected void yieldCurrent() {
992-
ImageSingletons.lookup(JavaThreads.class).yield();
993-
}
994-
}
995-
996-
@AutomaticFeature
997-
final class LegacyPlatformThreadsFeature implements Feature {
998-
@Override
999-
public void duringSetup(DuringSetupAccess access) {
1000-
if (!ImageSingletons.contains(PlatformThreads.class)) {
1001-
ImageSingletons.add(PlatformThreads.class, new LegacyPlatformThreads());
1002-
}
1003-
}
1004-
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMThreads.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -774,12 +774,6 @@ public static void assertStatusVM() {
774774
}
775775
}
776776

777-
// This method will be removed in GR-34435.
778-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
779-
public static void setStatusIgnoreSafepoints() {
780-
SafepointBehavior.markThreadAsCrashed();
781-
}
782-
783777
public static boolean isValidStatus(int status) {
784778
return status > STATUS_ILLEGAL && status <= MAX_STATUS;
785779
}

0 commit comments

Comments
 (0)