Skip to content

Commit fb2a2c8

Browse files
Cleanup @NeverInline.
1 parent 098eaa3 commit fb2a2c8

File tree

7 files changed

+27
-13
lines changed

7 files changed

+27
-13
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
@Retention(RetentionPolicy.RUNTIME)
4040
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
4141
public @interface NeverInline {
42+
/**
43+
* In some cases, we don't have proper exception edges on the compiler level at the moment (see
44+
* GR-24649).
45+
*/
46+
String CALLER_CATCHES_IMPLICIT_EXCEPTIONS = "Ensure that all exceptions can be caught, including implicit exceptions.";
4247

4348
/**
4449
* Documents the reason why the annotated code must not be inlined.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
package com.oracle.svm.core.classinitialization;
2626

27+
import static com.oracle.svm.core.NeverInline.CALLER_CATCHES_IMPLICIT_EXCEPTIONS;
28+
2729
import java.util.concurrent.locks.Condition;
2830
import java.util.concurrent.locks.ReentrantLock;
2931

@@ -419,7 +421,7 @@ private static void reachInterfaces(DynamicHub hub) {
419421
* {@link #initLock}. However, we want to stick as close as possible to the specification, so we
420422
* explicitly don't do any optimizations in that regard.
421423
*/
422-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
424+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
423425
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+13/src/hotspot/share/oops/instanceKlass.cpp#L1184-L1364")
424426
private void tryInitialize0(DynamicHub hub) {
425427
assert !Platform.includedIn(NATIVE_ONLY.class) || StackOverflowCheck.singleton().isYellowZoneAvailable();
@@ -590,7 +592,7 @@ private void setInitThread() {
590592
* thread which encounters the class being initialized, it would wrongly be considered reentrant
591593
* initialization and enable use of the incompletely initialized class.
592594
*/
593-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
595+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
594596
private void setInitThread0() {
595597
assert initThread.isNull();
596598
if (ContinuationSupport.isSupported() && JavaThreads.isCurrentThreadVirtual()) {
@@ -608,7 +610,7 @@ private void clearInitThread() {
608610
}
609611
}
610612

611-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
613+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
612614
private void clearInitThread0() {
613615
assert initThread == CurrentIsolate.getCurrentThread();
614616
initThread = Word.nullPointer();
@@ -618,7 +620,7 @@ private void clearInitThread0() {
618620
}
619621

620622
/** Eagerly initialize superinterfaces that declare default methods. May throw exceptions. */
621-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
623+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
622624
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+13/src/hotspot/share/oops/instanceKlass.cpp#L1099-L1117")
623625
private static void initializeSuperInterfaces(DynamicHub hub) {
624626
assert hub.hasDefaultMethods() : "caller should have checked this";
@@ -653,7 +655,7 @@ private static Throwable createExceptionInInitializerObject(Throwable exception)
653655
}
654656
}
655657

656-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
658+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
657659
private static ExceptionInInitializerError createExceptionInInitializerObject0(Throwable exception) {
658660
return new ExceptionInInitializerError(exception);
659661
}
@@ -672,7 +674,7 @@ private void setInitializationStateAndNotify(InitState state) {
672674
}
673675
}
674676

675-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
677+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
676678
private void setInitializationStateAndNotify0(InitState state) {
677679
initLock.lock();
678680
try {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CEntryPointSnippets.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package com.oracle.svm.core.graal.snippets;
2626

27+
import static com.oracle.svm.core.NeverInline.CALLER_CATCHES_IMPLICIT_EXCEPTIONS;
2728
import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE;
2829
import static com.oracle.svm.core.graal.nodes.WriteCodeBaseNode.writeCurrentVMCodeBase;
2930
import static com.oracle.svm.core.graal.nodes.WriteCurrentVMThreadNode.writeCurrentVMThread;
@@ -385,7 +386,7 @@ private static int initializeIsolateInterruptibly0(CEntryPointCreateIsolateParam
385386
}
386387
}
387388

388-
@NeverInline("GR-24649")
389+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
389390
private static int initializeIsolateInterruptibly1(CEntryPointCreateIsolateParameters parameters) {
390391
/* Initialize the isolate id (the id is needed for isolate teardown). */
391392
long initStateAddr = FIRST_ISOLATE_INIT_STATE.get().rawValue();

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package com.oracle.svm.core.heap;
2626

27+
import static com.oracle.svm.core.NeverInline.CALLER_CATCHES_IMPLICIT_EXCEPTIONS;
2728
import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE;
2829

2930
import java.lang.ref.Reference;
@@ -69,7 +70,7 @@ public static void processPendingReferencesInRegularThread() {
6970
}
7071
}
7172

72-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
73+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
7374
static void processCleaners() {
7475
// Note: (sun.misc|jdk.internal).Cleaner objects are invoked in pending reference processing
7576

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceInternals.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package com.oracle.svm.core.heap;
2626

27+
import static com.oracle.svm.core.NeverInline.CALLER_CATCHES_IMPLICIT_EXCEPTIONS;
2728
import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.EXTREMELY_FAST_PATH_PROBABILITY;
2829
import static jdk.graal.compiler.nodes.extended.BranchProbabilityNode.probability;
2930

@@ -179,12 +180,12 @@ public static void initializeLocking() {
179180
MonitorSupport.singleton().ensureInitialized(processPendingLock);
180181
}
181182

182-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
183+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
183184
public static void waitForPendingReferences() throws InterruptedException {
184185
Heap.getHeap().waitForReferencePendingList();
185186
}
186187

187-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
188+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
188189
@SuppressFBWarnings(value = "NN_NAKED_NOTIFY", justification = "Notifies on progress, not a specific state change.")
189190
public static void processPendingReferences() {
190191
/*

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Cleaner.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
package com.oracle.svm.core.heap;
2626

27+
import static com.oracle.svm.core.NeverInline.CALLER_CATCHES_IMPLICIT_EXCEPTIONS;
28+
2729
import java.lang.ref.Cleaner;
2830
import java.lang.ref.ReferenceQueue;
2931

@@ -50,7 +52,7 @@ public final class Target_java_lang_ref_Cleaner {
5052
@TargetClass(className = "java.lang.ref.Cleaner$Cleanable")
5153
final class Target_java_lang_ref_Cleaner_Cleanable {
5254
@AnnotateOriginal
53-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
55+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
5456
native void clean();
5557
}
5658

@@ -96,7 +98,7 @@ final class Target_jdk_internal_ref_PhantomCleanable {
9698
int index;
9799

98100
@AnnotateOriginal
99-
@NeverInline("Ensure that every exception can be caught, including implicit exceptions.")
101+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
100102
/* final */ native void clean();
101103
}
102104

substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedCompilationExceptionDispatch.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
package com.oracle.svm.graal.isolated;
2626

27+
import static com.oracle.svm.core.NeverInline.CALLER_CATCHES_IMPLICIT_EXCEPTIONS;
28+
2729
import java.io.ByteArrayOutputStream;
2830
import java.io.PrintWriter;
2931

@@ -111,7 +113,7 @@ protected final int handleException(Throwable t) {
111113
return 0;
112114
}
113115

114-
@NeverInline("Ensure that an exception thrown from this method can always be caught.")
116+
@NeverInline(CALLER_CATCHES_IMPLICIT_EXCEPTIONS)
115117
private boolean dispatchExceptionToOtherIsolate(Throwable t) {
116118
ByteArrayOutputStream os = new ByteArrayOutputStream();
117119
try (PrintWriter pw = new PrintWriter(os)) {

0 commit comments

Comments
 (0)