Skip to content

[GR-68179] Introduce NeverInlineTrivial option #11844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,9 @@ public static long getTearDownFailureNanos() {
@Option(help = "file:doc-files/NeverInlineHelp.txt", type = OptionType.Debug)//
public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> NeverInline = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build());

@Option(help = "file:doc-files/NeverInlineHelp.txt")//
public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> 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<Integer> MaxNodesInTrivialMethod = new HostedOptionKey<>(20);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public ConcurrentLinkedQueue<String> getMethodCallLocations(String methodName) {
}
}

private static final Set<String> neverInlineMethods = Set.of(
private static final Set<String> neverInlineTrivialMethods = Set.of(
"java.lang.invoke.MethodHandles$Lookup.unreflectGetter",
"java.lang.invoke.MethodHandles$Lookup.unreflectSetter",
"java.io.ObjectInputStream.readObject",
Expand Down Expand Up @@ -363,8 +363,8 @@ public static void parseDynamicAccessOptions(EconomicMap<OptionKey<?>, Object> h
}
});
if (!classLoaderSupport.dynamicAccessSelectorsEmpty()) {
for (String method : neverInlineMethods) {
SubstrateOptions.NeverInline.update(hostedValues, method);
for (String method : neverInlineTrivialMethods) {
SubstrateOptions.NeverInlineTrivial.update(hostedValues, method);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down