|
45 | 45 | import com.oracle.svm.core.NeverInline; |
46 | 46 | import com.oracle.svm.core.SubstrateOptions; |
47 | 47 | import com.oracle.svm.core.Uninterruptible; |
| 48 | +import com.oracle.svm.core.classinitialization.EnsureClassInitializedNode; |
48 | 49 | import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; |
49 | 50 | import com.oracle.svm.core.option.HostedOptionKey; |
50 | 51 | import com.oracle.svm.core.os.RawFileOperationSupport; |
@@ -73,8 +74,7 @@ private static UninterruptibleAnnotationChecker singleton() { |
73 | 74 |
|
74 | 75 | public static void checkAfterParsing(ResolvedJavaMethod method, StructuredGraph graph) { |
75 | 76 | if (Uninterruptible.Utils.isUninterruptible(method) && graph != null) { |
76 | | - singleton().checkNoAllocation(method, graph); |
77 | | - singleton().checkNoSynchronization(method, graph); |
| 77 | + singleton().checkGraph(method, graph); |
78 | 78 | } |
79 | 79 | } |
80 | 80 |
|
@@ -133,7 +133,7 @@ private void checkSpecifiedOptions(HostedMethod method, Uninterruptible annotati |
133 | 133 | "Otherwise, use exactly the reason from above."); |
134 | 134 | } |
135 | 135 |
|
136 | | - if (annotation.mayBeInlined()) { |
| 136 | + if (annotation.mayBeInlined() && annotation.calleeMustBe()) { |
137 | 137 | if (!annotation.reason().equals(Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE) && !AnnotationAccess.isAnnotationPresent(method, AlwaysInline.class)) { |
138 | 138 | violations.add("Method " + method.format("%H.%n(%p)") + " is annotated with @Uninterruptible('mayBeInlined = true') which allows the method to be inlined into interruptible code. " + |
139 | 139 | "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, |
259 | 259 | } |
260 | 260 | } |
261 | 261 |
|
262 | | - private void checkNoAllocation(ResolvedJavaMethod method, StructuredGraph graph) { |
| 262 | + private void checkGraph(ResolvedJavaMethod method, StructuredGraph graph) { |
263 | 263 | for (Node node : graph.getNodes()) { |
264 | 264 | if (isAllocationNode(node)) { |
265 | 265 | 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) { |
273 | 267 | 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."); |
274 | 270 | } |
275 | 271 | } |
276 | 272 | } |
|
0 commit comments