Skip to content

Commit 13844c9

Browse files
committed
Introduce NeverInlineTrivial option and fix -H:TrackDynamicAccess=all gathering entries from non-application class and module paths
1 parent 80d7490 commit 13844c9

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
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
@@ -913,6 +913,9 @@ public static long getTearDownFailureNanos() {
913913
@Option(help = "file:doc-files/NeverInlineHelp.txt", type = OptionType.Debug)//
914914
public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> NeverInline = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build());
915915

916+
@Option(help = "Never trivially inline provided methods. Uses the same method pattern syntax as the 'NeverInline' option.") public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> NeverInlineTrivial = new HostedOptionKey<>(
917+
AccumulatingLocatableMultiOptionValue.Strings.build());
918+
916919
@Option(help = "Maximum number of nodes in a method so that it is considered trivial.")//
917920
public static final HostedOptionKey<Integer> MaxNodesInTrivialMethod = new HostedOptionKey<>(20);
918921

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

Lines changed: 3 additions & 4 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",
@@ -108,7 +108,6 @@ public ConcurrentLinkedQueue<String> getMethodCallLocations(String methodName) {
108108
"java.lang.ClassLoader.loadClass",
109109
"java.lang.foreign.Linker.nativeLinker");
110110

111-
public static final String GRAAL_SUBPATH = File.separator + "graal" + File.separator;
112111
public static final String TRACK_ALL = "all";
113112

114113
private static final String OUTPUT_DIR_NAME = "dynamic-access";
@@ -364,8 +363,8 @@ public static void parseDynamicAccessOptions(EconomicMap<OptionKey<?>, Object> h
364363
}
365364
});
366365
if (!classLoaderSupport.dynamicAccessSelectorsEmpty()) {
367-
for (String method : neverInlineMethods) {
368-
SubstrateOptions.NeverInline.update(hostedValues, method);
366+
for (String method : neverInlineTrivialMethods) {
367+
SubstrateOptions.NeverInlineTrivial.update(hostedValues, method);
369368
}
370369
}
371370
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,14 +1180,8 @@ public void setPreserveAll(ValueWithOrigin<String> valueWithOrigin) {
11801180

11811181
public void setTrackAllDynamicAccess(ValueWithOrigin<String> valueWithOrigin) {
11821182
var origin = new IncludeOptionsSupport.ExtendedOptionWithOrigin(new IncludeOptionsSupport.ExtendedOption("", DynamicAccessDetectionFeature.TRACK_ALL), valueWithOrigin);
1183-
classpath().stream()
1184-
.map(Path::toString)
1185-
.filter(path -> !path.contains(DynamicAccessDetectionFeature.GRAAL_SUBPATH))
1186-
.forEach(entry -> dynamicAccessSelectors.addClassPathEntry(entry, origin));
1187-
modulepath().stream()
1188-
.map(Path::toString)
1189-
.filter(path -> !path.contains(DynamicAccessDetectionFeature.GRAAL_SUBPATH))
1190-
.forEach(entry -> dynamicAccessSelectors.addModule(entry, origin));
1183+
getModulePathsFinder().findAll().forEach(m -> dynamicAccessSelectors.addModule(m.descriptor().name(), origin));
1184+
dynamicAccessSelectors.addModule(ALL_UNNAMED, origin);
11911185
}
11921186

11931187
public Stream<Class<?>> getClassesToIncludeUnconditionally() {

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
@@ -829,7 +829,9 @@ public boolean hasNeverInlineDirective(ResolvedJavaMethod method) {
829829
return false;
830830
}
831831

832-
return SubstrateOptions.NeverInline.getValue().values().stream().anyMatch(re -> MethodFilter.parse(re).matches(method));
832+
return SubstrateOptions.NeverInline.getValue().values().stream()
833+
.map(MethodFilter::parse)
834+
.anyMatch(filter -> filter.matches(method));
833835
}
834836

835837
private InlineBeforeAnalysisPolicy inlineBeforeAnalysisPolicy(MultiMethod.MultiMethodKey multiMethodKey) {
@@ -1108,7 +1110,10 @@ public boolean neverInlineTrivial(AnalysisMethod caller, AnalysisMethod callee)
11081110
return true;
11091111
}
11101112
}
1111-
return false;
1113+
if (!SubstrateOptions.NeverInlineTrivial.hasBeenSet()) {
1114+
return false;
1115+
}
1116+
return SubstrateOptions.NeverInlineTrivial.getValue().values().stream().anyMatch(re -> MethodFilter.parse(re).matches(callee));
11121117
}
11131118

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

0 commit comments

Comments
 (0)