Skip to content

Commit a904175

Browse files
author
Maja Skoko
committed
Comparing analysis methods and types.
1 parent 97e4309 commit a904175

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,4 +1030,18 @@ public boolean getReturnsAllInstantiatedTypes() {
10301030
protected abstract AnalysisMethod createMultiMethod(AnalysisMethod analysisMethod, MultiMethodKey newMultiMethodKey);
10311031

10321032
public abstract boolean isImplementationInvokable();
1033+
1034+
/**
1035+
*
1036+
* Lambda function names are still not completely deterministic e.g. in name
1037+
* Lambda$7ad16f47b695d909/0x00000007c0b4c630.accept(java.lang.Object):void hash part is not
1038+
* deterministic yet. In order to avoid comparing based on that part, we need to eliminate hash
1039+
* part from name of lambda function. To read more about Lambda names check GH issue
1040+
* https://github.com/openjdk/jdk/pull/10024/.
1041+
*
1042+
*/
1043+
public static String comparableMethodSignature(AnalysisMethod method) {
1044+
String signature = method.format("%H.%n(%P):%R");
1045+
return signature.contains("$$Lambda") ? signature.replaceAll("/[0-9a-fA-Fx]*\\.", ".") : signature;
1046+
}
10331047
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisType.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,16 @@ public final String getName() {
874874
return wrapped.getName();
875875
}
876876

877+
public final String getComparableName() {
878+
/*
879+
* Avoiding non-deterministic hash part of lambda names. Example of such class name e.g.
880+
* Ljava/util/Spliterator$OfDouble$$Lambda$d28f9317da054138.0x00000007c1a64860; For more
881+
* about Lambda names check GH issue https://github.com/openjdk/jdk/pull/10024/.
882+
*/
883+
String name = getName();
884+
return name.contains("$$Lambda") ? name.replaceAll("\\.0x[0-9a-fA-Fx]*", "") : name;
885+
}
886+
877887
@Override
878888
public String toJavaName() {
879889
return qualifiedName;

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/reports/ReportUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class ReportUtils {
6161
public static final Comparator<ResolvedJavaMethod> methodComparator = Comparator.comparing(m -> m.format("%H.%n(%P):%R"));
6262
static final Comparator<AnalysisField> fieldComparator = Comparator.comparing(f -> f.format("%H.%n"));
6363
static final Comparator<InvokeInfo> invokeInfoBCIComparator = Comparator.comparing(i -> i.getPosition().getBCI());
64-
static final Comparator<InvokeInfo> invokeInfoComparator = invokeInfoBCIComparator.thenComparing(i -> comparingMethodNames(i.getTargetMethod()));
64+
static final Comparator<InvokeInfo> invokeInfoComparator = invokeInfoBCIComparator.thenComparing(i -> AnalysisMethod.comparableMethodSignature(i.getTargetMethod()));
6565
static final Comparator<BytecodePosition> positionMethodComparator = Comparator.comparing(pos -> pos.getMethod().format("%H.%n(%P):%R"));
6666
static final Comparator<BytecodePosition> positionComparator = positionMethodComparator.thenComparing(pos -> pos.getBCI());
6767

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public Pair<HostedMethod, CompilationResult> getLastCompilation() {
166166
}
167167

168168
protected static Comparator<Pair<HostedMethod, CompilationResult>> compilationsComparator() {
169-
Comparator<Pair<HostedMethod, CompilationResult>> nameComparator = Comparator.comparing(o -> AnalysisMethod.comparingMethodNames(o.getLeft().wrapped));
169+
Comparator<Pair<HostedMethod, CompilationResult>> nameComparator = Comparator.comparing(o -> AnalysisMethod.comparableMethodSignature(o.getLeft().wrapped));
170170
return nameComparator.thenComparing(o -> o.getRight().getTargetCodeSize());
171171
}
172172

0 commit comments

Comments
 (0)