# HG changeset patch # User Thomas Wuerthinger # Date 1423094696 -3600 # Node ID a884856ac5d0b020e8b8022f6deda98fca1b7e93 # Parent 149427a9a39771bbee453c4dba90e63f677a6299 Make graph equality comparison for testing purposes more robust, by sorting constants lexically. diff -r 149427a9a397 -r a884856ac5d0 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Wed Feb 04 23:33:32 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Thu Feb 05 01:04:56 2015 +0100 @@ -58,6 +58,7 @@ import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.schedule.*; +import com.oracle.graal.phases.schedule.SchedulePhase.SchedulingStrategy; import com.oracle.graal.phases.tiers.*; import com.oracle.graal.phases.util.*; import com.oracle.graal.printer.*; @@ -298,6 +299,8 @@ NodeMap canonicalId = graph.createNodeMap(); int nextId = 0; + List constantsLines = new ArrayList<>(); + StringBuilder result = new StringBuilder(); for (Block block : schedule.getCFG().getBlocks()) { result.append("Block " + block + " "); @@ -312,20 +315,36 @@ for (Node node : schedule.getBlockToNodesMap().get(block)) { if (node.isAlive()) { if (!excludeVirtual || !(node instanceof VirtualObjectNode || node instanceof ProxyNode)) { - int id; - if (canonicalId.get(node) != null) { - id = canonicalId.get(node); + if (node instanceof ConstantNode) { + String name = checkConstants ? node.toString(Verbosity.Name) : node.getClass().getSimpleName(); + String str = name + (excludeVirtual ? "\n" : " (" + node.getUsageCount() + ")\n"); + constantsLines.add(str); } else { - id = nextId++; - canonicalId.set(node, id); + int id; + if (canonicalId.get(node) != null) { + id = canonicalId.get(node); + } else { + id = nextId++; + canonicalId.set(node, id); + } + String name = node.getClass().getSimpleName(); + String str = " " + id + "|" + name + (excludeVirtual ? "\n" : " (" + node.getUsageCount() + ")\n"); + result.append(str); } - String name = node instanceof ConstantNode && checkConstants ? node.toString(Verbosity.Name) : node.getClass().getSimpleName(); - result.append(" " + id + "|" + name + (excludeVirtual ? "\n" : " (" + node.getUsageCount() + ")\n")); } } } } - return result.toString(); + + StringBuilder constantsLinesResult = new StringBuilder(); + constantsLinesResult.append(constantsLines.size() + " constants:\n"); + Collections.sort(constantsLines); + for (String s : constantsLines) { + constantsLinesResult.append(s); + constantsLinesResult.append("\n"); + } + + return constantsLines.toString() + result.toString(); } protected Backend getBackend() {