Skip to content

Commit 8b47e25

Browse files
committed
[GR-62834] Native image should respect @jdk.internal.vm.annotation.DontInline
PullRequest: graal/20250
2 parents 0465567 + 561f55c commit 8b47e25

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodType.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ final class Target_java_lang_invoke_MethodType {
5252

5353
@TargetClass(className = "java.lang.invoke.Invokers")
5454
final class Target_java_lang_invoke_Invokers {
55+
56+
/**
57+
* Substitute to remove the {@code @DontInline} from the original method.
58+
*/
59+
@Substitute
60+
static void maybeCustomize(Target_java_lang_invoke_MethodHandle mh) {
61+
/*
62+
* MethodHandle.maybeCustomized() is _currently_ substituted by an empty method. We still
63+
* call it here and represent the original behavior to make it future-proof.
64+
*/
65+
mh.maybeCustomize();
66+
}
5567
}
5668

5769
@TargetClass(className = "java.lang.invoke.InvokerBytecodeGenerator")

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
import jdk.graal.compiler.phases.common.CanonicalizerPhase;
156156
import jdk.graal.compiler.virtual.phases.ea.PartialEscapePhase;
157157
import jdk.internal.loader.NativeLibraries;
158+
import jdk.internal.vm.annotation.DontInline;
158159
import jdk.vm.ci.meta.DeoptimizationReason;
159160
import jdk.vm.ci.meta.JavaConstant;
160161
import jdk.vm.ci.meta.ResolvedJavaField;
@@ -810,6 +811,10 @@ public boolean hasNeverInlineDirective(ResolvedJavaMethod method) {
810811
return true;
811812
}
812813

814+
if (AnnotationAccess.isAnnotationPresent(method, DontInline.class)) {
815+
return true;
816+
}
817+
813818
if (!SubstrateOptions.NeverInline.hasBeenSet()) {
814819
return false;
815820
}

0 commit comments

Comments
 (0)