From 5a1656fd89e57a4e5b37ce14a1292289617868a9 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Thu, 6 Mar 2025 10:26:47 +0100 Subject: [PATCH 1/2] svm: respect @DontInline --- .../src/com/oracle/svm/hosted/SVMHost.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java index b3ce043bd522..10980fce6cf2 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java @@ -155,6 +155,7 @@ import jdk.graal.compiler.phases.common.CanonicalizerPhase; import jdk.graal.compiler.virtual.phases.ea.PartialEscapePhase; import jdk.internal.loader.NativeLibraries; +import jdk.internal.vm.annotation.DontInline; import jdk.vm.ci.meta.DeoptimizationReason; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.ResolvedJavaField; @@ -810,6 +811,10 @@ public boolean hasNeverInlineDirective(ResolvedJavaMethod method) { return true; } + if (AnnotationAccess.isAnnotationPresent(method, DontInline.class)) { + return true; + } + if (!SubstrateOptions.NeverInline.hasBeenSet()) { return false; } From 561f55c3057f62eb15609d5e7f2177d506cb3763 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Fri, 7 Mar 2025 08:19:34 +0100 Subject: [PATCH 2/2] svm: substitute Invokers.maybeCustomize to remove @DontInline --- .../Target_java_lang_invoke_MethodType.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodType.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodType.java index 9b8cb547f194..70ca2a256850 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodType.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodType.java @@ -52,6 +52,18 @@ final class Target_java_lang_invoke_MethodType { @TargetClass(className = "java.lang.invoke.Invokers") final class Target_java_lang_invoke_Invokers { + + /** + * Substitute to remove the {@code @DontInline} from the original method. + */ + @Substitute + static void maybeCustomize(Target_java_lang_invoke_MethodHandle mh) { + /* + * MethodHandle.maybeCustomized() is _currently_ substituted by an empty method. We still + * call it here and represent the original behavior to make it future-proof. + */ + mh.maybeCustomize(); + } } @TargetClass(className = "java.lang.invoke.InvokerBytecodeGenerator")