Mercurial > hg > truffle
diff graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyUsageWithEquals.java @ 10937:87d9b5518065
Move VerifyUsageWithEquals phases into HighTier.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Fri, 02 Aug 2013 11:22:23 +0200 |
parents | 9f764fbf3b0d |
children | ef6915cf1e59 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyUsageWithEquals.java Fri Aug 02 11:05:19 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyUsageWithEquals.java Fri Aug 02 11:22:23 2013 +0200 @@ -27,23 +27,22 @@ import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; +import com.oracle.graal.phases.tiers.*; /** * For certain types object identity should not be used for object equality check. This phase checks * the correct usage of the given type. Equality checks with == or != (except null checks) results * in an {@link AssertionError}. */ -public class VerifyUsageWithEquals extends VerifyPhase { +public class VerifyUsageWithEquals extends VerifyPhase<PhaseContext> { - private MetaAccessProvider runtime; - private Class<?> klass; + private final Class<?> klass; - public VerifyUsageWithEquals(MetaAccessProvider runtime, Class<?> klass) { - this.runtime = runtime; + public VerifyUsageWithEquals(Class<?> klass) { this.klass = klass; } - private boolean isAssignableType(ValueNode node) { + private boolean isAssignableType(ValueNode node, MetaAccessProvider runtime) { if (node.stamp() instanceof ObjectStamp) { ResolvedJavaType valueType = runtime.lookupJavaType(klass); ResolvedJavaType nodeType = node.objectStamp().type(); @@ -59,8 +58,8 @@ return node.isConstant() && node.asConstant().isNull(); } - private boolean checkUsage(ValueNode x, ValueNode y) { - return isAssignableType(x) && !isNullConstant(y); + private boolean checkUsage(ValueNode x, ValueNode y, MetaAccessProvider runtime) { + return isAssignableType(x, runtime) && !isNullConstant(y); } private static boolean isEqualsMethod(StructuredGraph graph) { @@ -69,12 +68,12 @@ } @Override - protected boolean verify(StructuredGraph graph) { + protected boolean verify(StructuredGraph graph, PhaseContext context) { for (ObjectEqualsNode cn : graph.getNodes().filter(ObjectEqualsNode.class)) { if (!isEqualsMethod(graph)) { // bail out if we compare an object of type klass with == or != (except null checks) - assert !(checkUsage(cn.x(), cn.y()) && checkUsage(cn.y(), cn.x())) : "Verifcation of " + klass.getName() + " usage failed: Comparing " + cn.x() + " and" + cn.y() + " in " + - graph.method() + " must use .equals() for object equality, not '==' or '!='"; + assert !(checkUsage(cn.x(), cn.y(), context.getRuntime()) && checkUsage(cn.y(), cn.x(), context.getRuntime())) : "Verifcation of " + klass.getName() + " usage failed: Comparing " + + cn.x() + " and" + cn.y() + " in " + graph.method() + " must use .equals() for object equality, not '==' or '!='"; } } return true;