# HG changeset patch # User Doug Simon # Date 1408805696 -7200 # Node ID e86071cdba96ef9db7e922e11dec3042a080a90e # Parent 3ca8ba1bfc21257eaa143b1d3abac79df7c5d6e6 restructure Node class literal verifier to easily enable tests other than identity tests diff -r 3ca8ba1bfc21 -r e86071cdba96 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyNoNodeClassLiteralIdentityTests.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyNoNodeClassLiteralIdentityTests.java Sat Aug 23 16:53:47 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyNoNodeClassLiteralIdentityTests.java Sat Aug 23 16:54:56 2014 +0200 @@ -26,9 +26,11 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; +import com.oracle.graal.graph.iterators.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.tiers.*; @@ -56,20 +58,38 @@ @Override protected boolean verify(StructuredGraph graph, PhaseContext context) { - List literals = new ArrayList<>(); + Map errors = new HashMap<>(); + for (ConstantNode c : ConstantNode.getConstantNodes(graph)) { ResolvedJavaType nodeClassType = context.getMetaAccess().lookupJavaType(Node.class); ResolvedJavaType nodeType = context.getConstantReflection().asJavaType(c.asConstant()); if (nodeType != null && nodeClassType.isAssignableFrom(nodeType)) { - if (c.usages().filter(ObjectEqualsNode.class).isNotEmpty()) { - literals.add(nodeType.toJavaName(false)); + NodeIterable usages = c.usages(); + for (Node n : usages) { + if (!(n instanceof ObjectEqualsNode)) { + continue; + } + String loc = GraphUtil.approxSourceLocation(n); + if (loc == null) { + loc = graph.method().asStackTraceElement(0).toString() + " " + n; + } + errors.put(nodeType.toJavaName(false), loc); } } } - if (literals.isEmpty()) { + if (errors.isEmpty()) { return true; } - StackTraceElement ste = graph.method().asStackTraceElement(0); - throw new VerificationError("Found illegal identity test against following Node class literals in " + graph.method().format("%h.%n(%p)") + ": " + String.join(", ", literals) + "\n " + ste); + Formatter f = new Formatter(); + boolean first = true; + for (Map.Entry e : errors.entrySet()) { + if (!first) { + f.format("%n"); + } else { + first = false; + } + f.format("Found illegal use of Node class literal %s near:%n %s", e.getKey(), e.getValue()); + } + throw new VerificationError(f.toString()); } }