Skip to content

Commit c21d8c5

Browse files
Improve UninterruptibleAnnotationChecker.
1 parent 15b1965 commit c21d8c5

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/UninterruptibleAnnotationChecker.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.oracle.svm.core.NeverInline;
4646
import com.oracle.svm.core.SubstrateOptions;
4747
import com.oracle.svm.core.Uninterruptible;
48+
import com.oracle.svm.core.classinitialization.EnsureClassInitializedNode;
4849
import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
4950
import com.oracle.svm.core.option.HostedOptionKey;
5051
import com.oracle.svm.core.os.RawFileOperationSupport;
@@ -73,8 +74,7 @@ private static UninterruptibleAnnotationChecker singleton() {
7374

7475
public static void checkAfterParsing(ResolvedJavaMethod method, StructuredGraph graph) {
7576
if (Uninterruptible.Utils.isUninterruptible(method) && graph != null) {
76-
singleton().checkNoAllocation(method, graph);
77-
singleton().checkNoSynchronization(method, graph);
77+
singleton().checkGraph(method, graph);
7878
}
7979
}
8080

@@ -133,7 +133,7 @@ private void checkSpecifiedOptions(HostedMethod method, Uninterruptible annotati
133133
"Otherwise, use exactly the reason from above.");
134134
}
135135

136-
if (annotation.mayBeInlined()) {
136+
if (annotation.mayBeInlined() && annotation.calleeMustBe()) {
137137
if (!annotation.reason().equals(Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE) && !AnnotationAccess.isAnnotationPresent(method, AlwaysInline.class)) {
138138
violations.add("Method " + method.format("%H.%n(%p)") + " is annotated with @Uninterruptible('mayBeInlined = true') which allows the method to be inlined into interruptible code. " +
139139
"If the method has an inherent reason for being uninterruptible, besides being called from uninterruptible code, then please remove 'mayBeInlined = true'. " +
@@ -259,18 +259,14 @@ private void checkCallers(HostedMethod caller, Uninterruptible callerAnnotation,
259259
}
260260
}
261261

262-
private void checkNoAllocation(ResolvedJavaMethod method, StructuredGraph graph) {
262+
private void checkGraph(ResolvedJavaMethod method, StructuredGraph graph) {
263263
for (Node node : graph.getNodes()) {
264264
if (isAllocationNode(node)) {
265265
violations.add("Uninterruptible method " + method.format("%H.%n(%p)") + " is not allowed to allocate.");
266-
}
267-
}
268-
}
269-
270-
private void checkNoSynchronization(ResolvedJavaMethod method, StructuredGraph graph) {
271-
for (Node node : graph.getNodes()) {
272-
if (node instanceof MonitorEnterNode) {
266+
} else if (node instanceof MonitorEnterNode) {
273267
violations.add("Uninterruptible method " + method.format("%H.%n(%p)") + " is not allowed to use 'synchronized'.");
268+
} else if (node instanceof EnsureClassInitializedNode) {
269+
violations.add("Uninterruptible method " + method.format("%H.%n(%p)") + " not allowed to do class initialization.");
274270
}
275271
}
276272
}

0 commit comments

Comments
 (0)