Skip to content

Commit 97e4309

Browse files
author
Maja Skoko
committed
Deterministic sort for compilations with non-unique name.
1 parent a5ef94d commit 97e4309

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageCodeCache.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,13 @@ public Pair<HostedMethod, CompilationResult> getLastCompilation() {
165165
return orderedCompilations.get(orderedCompilations.size() - 1);
166166
}
167167

168+
protected static Comparator<Pair<HostedMethod, CompilationResult>> compilationsComparator() {
169+
Comparator<Pair<HostedMethod, CompilationResult>> nameComparator = Comparator.comparing(o -> AnalysisMethod.comparingMethodNames(o.getLeft().wrapped));
170+
return nameComparator.thenComparing(o -> o.getRight().getTargetCodeSize());
171+
}
172+
168173
protected List<Pair<HostedMethod, CompilationResult>> computeCompilationOrder(Map<HostedMethod, CompilationResult> compilationMap) {
169-
return compilationMap.entrySet().stream().map(e -> Pair.create(e.getKey(), e.getValue())).sorted(Comparator.comparing(o -> o.getLeft().wrapped.format("%H.%n(%P):%R")))
170-
.collect(Collectors.toList());
174+
return compilationMap.entrySet().stream().map(e -> Pair.create(e.getKey(), e.getValue())).sorted(compilationsComparator()).collect(Collectors.toList());
171175
}
172176

173177
public List<Pair<HostedMethod, CompilationResult>> getOrderedCompilations() {

0 commit comments

Comments
 (0)