Skip to content
Open
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 @@ -1030,4 +1030,18 @@ public boolean getReturnsAllInstantiatedTypes() {
protected abstract AnalysisMethod createMultiMethod(AnalysisMethod analysisMethod, MultiMethodKey newMultiMethodKey);

public abstract boolean isImplementationInvokable();

/**
*
* Lambda function names are still not completely deterministic e.g. in name
* Lambda$7ad16f47b695d909/0x00000007c0b4c630.accept(java.lang.Object):void hash part is not
* deterministic yet. In order to avoid comparing based on that part, we need to eliminate hash
* part from name of lambda function. To read more about Lambda names check GH issue
* https://github.com/openjdk/jdk/pull/10024/.
*
*/
public static String comparableMethodSignature(AnalysisMethod method) {
String signature = method.format("%H.%n(%P):%R");
return signature.contains("$$Lambda") ? signature.replaceAll("/[0-9a-fA-Fx]*\\.", ".") : signature;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,16 @@ public final String getName() {
return wrapped.getName();
}

public final String getComparableName() {
/*
* Avoiding non-deterministic hash part of lambda names. Example of such class name e.g.
* Ljava/util/Spliterator$OfDouble$$Lambda$d28f9317da054138.0x00000007c1a64860; For more
* about Lambda names check GH issue https://github.com/openjdk/jdk/pull/10024/.
*/
String name = getName();
return name.contains("$$Lambda") ? name.replaceAll("\\.0x[0-9a-fA-Fx]*", "") : name;
}

@Override
public String toJavaName() {
return qualifiedName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class ReportUtils {
public static final Comparator<ResolvedJavaMethod> methodComparator = Comparator.comparing(m -> m.format("%H.%n(%P):%R"));
static final Comparator<AnalysisField> fieldComparator = Comparator.comparing(f -> f.format("%H.%n"));
static final Comparator<InvokeInfo> invokeInfoBCIComparator = Comparator.comparing(i -> i.getPosition().getBCI());
static final Comparator<InvokeInfo> invokeInfoComparator = invokeInfoBCIComparator.thenComparing(i -> comparingMethodNames(i.getTargetMethod()));
static final Comparator<InvokeInfo> invokeInfoComparator = invokeInfoBCIComparator.thenComparing(i -> AnalysisMethod.comparableMethodSignature(i.getTargetMethod()));
static final Comparator<BytecodePosition> positionMethodComparator = Comparator.comparing(pos -> pos.getMethod().format("%H.%n(%P):%R"));
static final Comparator<BytecodePosition> positionComparator = positionMethodComparator.thenComparing(pos -> pos.getBCI());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,13 @@ public Pair<HostedMethod, CompilationResult> getLastCompilation() {
return orderedCompilations.get(orderedCompilations.size() - 1);
}

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

protected List<Pair<HostedMethod, CompilationResult>> computeCompilationOrder(Map<HostedMethod, CompilationResult> compilationMap) {
return compilationMap.entrySet().stream().map(e -> Pair.create(e.getKey(), e.getValue())).sorted(Comparator.comparing(o -> o.getLeft().wrapped.format("%H.%n(%P):%R")))
.collect(Collectors.toList());
return compilationMap.entrySet().stream().map(e -> Pair.create(e.getKey(), e.getValue())).sorted(compilationsComparator()).collect(Collectors.toList());
}

public List<Pair<HostedMethod, CompilationResult>> getOrderedCompilations() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,5 +630,7 @@ public int compare(HostedMethod o1, HostedMethod o2) {
* keeps the order unchanged and therefore keeps the field order we get from the hosting VM.
*/
static final Comparator<HostedField> FIELD_COMPARATOR_RELAXED = Comparator.comparing(HostedField::getJavaKind).reversed();
static final Comparator<HostedField> FIELD_COMPARATOR_RELAXED_WITH_NAME = Comparator.comparing(HostedField::getJavaKind).reversed()
.thenComparing(m -> m.getDeclaringClass().wrapped.getComparableName()).thenComparing(HostedField::getName);

}
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void build(DebugContext debug) {
hUniverse.orderedMethods = new ArrayList<>(hUniverse.methods.values());
Collections.sort(hUniverse.orderedMethods, HostedUniverse.METHOD_COMPARATOR);
hUniverse.orderedFields = new ArrayList<>(hUniverse.fields.values());
Collections.sort(hUniverse.orderedFields, HostedUniverse.FIELD_COMPARATOR_RELAXED);
Collections.sort(hUniverse.orderedFields, HostedUniverse.FIELD_COMPARATOR_RELAXED_WITH_NAME);
profilingInformationBuildTask.join();
}
}
Expand Down Expand Up @@ -637,7 +637,7 @@ private void layoutStaticFields() {
}

// Sort so that a) all Object fields are consecutive, and b) bigger types come first.
Collections.sort(fields, HostedUniverse.FIELD_COMPARATOR_RELAXED);
Collections.sort(fields, HostedUniverse.FIELD_COMPARATOR_RELAXED_WITH_NAME);

ObjectLayout layout = ConfigurationValues.getObjectLayout();

Expand Down