diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java index 934259f4c1c2..ccb2d42832e6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java @@ -913,6 +913,9 @@ public static long getTearDownFailureNanos() { @Option(help = "file:doc-files/NeverInlineHelp.txt", type = OptionType.Debug)// public static final HostedOptionKey NeverInline = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build()); + @Option(help = "file:doc-files/NeverInlineHelp.txt")// + public static final HostedOptionKey NeverInlineTrivial = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build()); + @Option(help = "Maximum number of nodes in a method so that it is considered trivial.")// public static final HostedOptionKey MaxNodesInTrivialMethod = new HostedOptionKey<>(20); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DynamicAccessDetectionFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DynamicAccessDetectionFeature.java index 837adeb26e98..06cc1d5dc228 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DynamicAccessDetectionFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DynamicAccessDetectionFeature.java @@ -99,7 +99,7 @@ public ConcurrentLinkedQueue getMethodCallLocations(String methodName) { } } - private static final Set neverInlineMethods = Set.of( + private static final Set neverInlineTrivialMethods = Set.of( "java.lang.invoke.MethodHandles$Lookup.unreflectGetter", "java.lang.invoke.MethodHandles$Lookup.unreflectSetter", "java.io.ObjectInputStream.readObject", @@ -363,8 +363,8 @@ public static void parseDynamicAccessOptions(EconomicMap, Object> h } }); if (!classLoaderSupport.dynamicAccessSelectorsEmpty()) { - for (String method : neverInlineMethods) { - SubstrateOptions.NeverInline.update(hostedValues, method); + for (String method : neverInlineTrivialMethods) { + SubstrateOptions.NeverInlineTrivial.update(hostedValues, method); } } } 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 afca15548259..bb4d27e77da9 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 @@ -829,7 +829,9 @@ public boolean hasNeverInlineDirective(ResolvedJavaMethod method) { return false; } - return SubstrateOptions.NeverInline.getValue().values().stream().anyMatch(re -> MethodFilter.parse(re).matches(method)); + return SubstrateOptions.NeverInline.getValue().values().stream() + .map(MethodFilter::parse) + .anyMatch(filter -> filter.matches(method)); } private InlineBeforeAnalysisPolicy inlineBeforeAnalysisPolicy(MultiMethod.MultiMethodKey multiMethodKey) { @@ -1108,7 +1110,10 @@ public boolean neverInlineTrivial(AnalysisMethod caller, AnalysisMethod callee) return true; } } - return false; + if (!SubstrateOptions.NeverInlineTrivial.hasBeenSet()) { + return false; + } + return SubstrateOptions.NeverInlineTrivial.getValue().values().stream().anyMatch(re -> MethodFilter.parse(re).matches(callee)); } private static boolean shouldEvaluateNeverInlineTrivialOnlyWith(Class[] onlyWith) {