# HG changeset patch # User Doug Simon # Date 1415203650 -3600 # Node ID 0f23e16288c5f3827611067844eeaf35dd79d102 # Parent e1b2489393f4afed117ba407a24554c2423c3db0 prevent use of identity for ArithmeticOpTable and ArithmeticOpTable.Op diff -r e1b2489393f4 -r 0f23e16288c5 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticOpTable.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticOpTable.java Wed Nov 05 17:04:18 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticOpTable.java Wed Nov 05 17:07:30 2014 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.compiler.common.type; +import static com.oracle.graal.api.meta.MetaUtil.*; + import java.util.*; import java.util.function.*; import java.util.stream.*; @@ -240,6 +242,15 @@ return floatConvert[op.ordinal()]; } + public static String toString(Op... ops) { + return Arrays.asList(ops).stream().map(o -> o == null ? "null" : o.operator + "{" + getSimpleName(o.getClass(), false) + "}").collect(Collectors.joining(",")); + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[" + toString(neg, add, sub, mul, div, rem, not, and, or, xor, zeroExtend, signExtend, narrow) + ",floatConvert[" + toString(floatConvert) + "]]"; + } + public abstract static class Op { private final String operator; @@ -252,6 +263,22 @@ public String toString() { return operator; } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj != null && getClass() == obj.getClass()) { + return obj.toString().equals(toString()); + } + return false; + } + + @Override + public int hashCode() { + return toString().hashCode(); + } } /** @@ -410,6 +437,20 @@ public Constant getZero(Stamp stamp) { return null; } + + @Override + public String toString() { + if (associative) { + if (commutative) { + return super.toString() + "[AC]"; + } else { + return super.toString() + "[A]"; + } + } else if (commutative) { + return super.toString() + "[C]"; + } + return super.toString(); + } } public abstract static class FloatConvertOp extends UnaryOp { diff -r e1b2489393f4 -r 0f23e16288c5 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticStamp.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticStamp.java Wed Nov 05 17:04:18 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticStamp.java Wed Nov 05 17:07:30 2014 +0100 @@ -53,7 +53,7 @@ if (!(obj instanceof ArithmeticStamp)) { return false; } - ArithmeticStamp other = (ArithmeticStamp) obj; - return this.ops == other.ops; + assert this.ops.toString().equals(((ArithmeticStamp) obj).ops.toString()); + return true; } } diff -r e1b2489393f4 -r 0f23e16288c5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Wed Nov 05 17:04:18 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Wed Nov 05 17:07:30 2014 +0100 @@ -38,6 +38,7 @@ import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.CompilerThreadFactory.DebugConfigAccess; +import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.java.*; @@ -208,6 +209,8 @@ new VerifyUsageWithEquals(JavaField.class).apply(graph, context); new VerifyUsageWithEquals(LocationIdentity.class).apply(graph, context); new VerifyUsageWithEquals(LIRKind.class).apply(graph, context); + new VerifyUsageWithEquals(ArithmeticOpTable.class).apply(graph, context); + new VerifyUsageWithEquals(ArithmeticOpTable.Op.class).apply(graph, context); } new VerifyDebugUsage().apply(graph, context); } diff -r e1b2489393f4 -r 0f23e16288c5 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryArithmeticNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryArithmeticNode.java Wed Nov 05 17:04:18 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryArithmeticNode.java Wed Nov 05 17:07:30 2014 +0100 @@ -47,7 +47,7 @@ protected final BinaryOp getOp(ValueNode forX, ValueNode forY) { ArithmeticOpTable table = ArithmeticOpTable.forStamp(forX.stamp()); - assert table == ArithmeticOpTable.forStamp(forY.stamp()); + assert table.toString().equals(ArithmeticOpTable.forStamp(forY.stamp()).toString()); return getOp.apply(table); }