Skip to content

Commit cb63603

Browse files
committed
[GR-68179] Introduce NeverInlineTrivial option
PullRequest: graal/21685
2 parents b19143c + c9f20fc commit cb63603

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,9 @@ public static long getTearDownFailureNanos() {
902902
@Option(help = "file:doc-files/NeverInlineHelp.txt", type = OptionType.Debug)//
903903
public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> NeverInline = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build());
904904

905+
@Option(help = "file:doc-files/NeverInlineHelp.txt")//
906+
public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> NeverInlineTrivial = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build());
907+
905908
@Option(help = "Maximum number of nodes in a method so that it is considered trivial.")//
906909
public static final HostedOptionKey<Integer> MaxNodesInTrivialMethod = new HostedOptionKey<>(20);
907910

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public ConcurrentLinkedQueue<String> getMethodCallLocations(String methodName) {
9999
}
100100
}
101101

102-
private static final Set<String> neverInlineMethods = Set.of(
102+
private static final Set<String> neverInlineTrivialMethods = Set.of(
103103
"java.lang.invoke.MethodHandles$Lookup.unreflectGetter",
104104
"java.lang.invoke.MethodHandles$Lookup.unreflectSetter",
105105
"java.io.ObjectInputStream.readObject",
@@ -363,8 +363,8 @@ public static void parseDynamicAccessOptions(EconomicMap<OptionKey<?>, Object> h
363363
}
364364
});
365365
if (!classLoaderSupport.dynamicAccessSelectorsEmpty()) {
366-
for (String method : neverInlineMethods) {
367-
SubstrateOptions.NeverInline.update(hostedValues, method);
366+
for (String method : neverInlineTrivialMethods) {
367+
SubstrateOptions.NeverInlineTrivial.update(hostedValues, method);
368368
}
369369
}
370370
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,9 @@ public boolean hasNeverInlineDirective(ResolvedJavaMethod method) {
844844
return false;
845845
}
846846

847-
return SubstrateOptions.NeverInline.getValue().values().stream().anyMatch(re -> MethodFilter.parse(re).matches(method));
847+
return SubstrateOptions.NeverInline.getValue().values().stream()
848+
.map(MethodFilter::parse)
849+
.anyMatch(filter -> filter.matches(method));
848850
}
849851

850852
private InlineBeforeAnalysisPolicy inlineBeforeAnalysisPolicy(MultiMethod.MultiMethodKey multiMethodKey) {
@@ -1216,7 +1218,10 @@ public boolean neverInlineTrivial(AnalysisMethod caller, AnalysisMethod callee)
12161218
return true;
12171219
}
12181220
}
1219-
return false;
1221+
if (!SubstrateOptions.NeverInlineTrivial.hasBeenSet()) {
1222+
return false;
1223+
}
1224+
return SubstrateOptions.NeverInlineTrivial.getValue().values().stream().anyMatch(re -> MethodFilter.parse(re).matches(callee));
12201225
}
12211226

12221227
private static boolean shouldEvaluateNeverInlineTrivialOnlyWith(Class<?>[] onlyWith) {

0 commit comments

Comments
 (0)