Skip to content

Commit d51db6d

Browse files
author
Maja Skoko
committed
Comparing analysis methods and types.
1 parent 50e8215 commit d51db6d

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
@@ -1003,4 +1003,18 @@ public boolean getReturnsAllInstantiatedTypes() {
10031003
protected abstract AnalysisMethod createMultiMethod(AnalysisMethod analysisMethod, MultiMethodKey newMultiMethodKey);
10041004

10051005
public abstract boolean isImplementationInvokable();
1006+
1007+
/**
1008+
*
1009+
* Lambda function names are still not completely deterministic e.g. in name
1010+
* Lambda$7ad16f47b695d909/0x00000007c0b4c630.accept(java.lang.Object):void hash part is not
1011+
* deterministic yet. In order to avoid comparing based on that part, we need to eliminate hash
1012+
* part from name of lambda function. To read more about Lambda names check GH issue
1013+
* https://github.com/openjdk/jdk/pull/10024/.
1014+
*
1015+
*/
1016+
public static String comparableMethodSignature(AnalysisMethod method) {
1017+
String signature = method.format("%H.%n(%P):%R");
1018+
return signature.contains("$$Lambda") ? signature.replaceAll("/[0-9a-fA-Fx]*\\.", ".") : signature;
1019+
}
10061020
}

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
@@ -870,6 +870,16 @@ public final String getName() {
870870
return wrapped.getName();
871871
}
872872

873+
public final String getComparableName() {
874+
/*
875+
* Avoiding non-deterministic hash part of lambda names. Example of such class name e.g.
876+
* Ljava/util/Spliterator$OfDouble$$Lambda$d28f9317da054138.0x00000007c1a64860; For more
877+
* about Lambda names check GH issue https://github.com/openjdk/jdk/pull/10024/.
878+
*/
879+
String name = getName();
880+
return name.contains("$$Lambda") ? name.replaceAll("\\.0x[0-9a-fA-Fx]*", "") : name;
881+
}
882+
873883
@Override
874884
public String toJavaName() {
875885
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.comparingMethodNames(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
@@ -167,7 +167,7 @@ public Pair<HostedMethod, CompilationResult> getLastCompilation() {
167167
}
168168

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

0 commit comments

Comments
 (0)