# HG changeset patch # User Andreas Woess # Date 1372861155 -7200 # Node ID 953a0d51a11fcd21c97677606944e6f190491a74 # Parent 2e7e7a22940f82613f326da2d364bdc4546bb192 ObjectEqualsNode: fix comparison of virtual boolean against constant object diff -r 2e7e7a22940f -r 953a0d51a11f graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Mon Jul 01 23:50:27 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Wed Jul 03 16:19:15 2013 +0200 @@ -73,10 +73,15 @@ private void virtualizeNonVirtualComparison(State state, ValueNode other, VirtualizerTool tool) { if (!state.getVirtualObject().hasIdentity() && state.getVirtualObject().entryKind(0) == Kind.Boolean) { if (other.isConstant()) { - int expectedValue = ((Boolean) other.asConstant().asObject()) ? 1 : 0; - IntegerEqualsNode equals = new IntegerEqualsNode(state.getEntry(0), ConstantNode.forInt(expectedValue, graph())); - tool.addNode(equals); - tool.replaceWithValue(equals); + Object otherValue = other.asConstant().asObject(); + if (otherValue == Boolean.TRUE || otherValue == Boolean.FALSE) { + int expectedValue = (otherValue == Boolean.TRUE) ? 1 : 0; + IntegerEqualsNode equals = new IntegerEqualsNode(state.getEntry(0), ConstantNode.forInt(expectedValue, graph())); + tool.addNode(equals); + tool.replaceWithValue(equals); + } else { + tool.replaceWithValue(LogicConstantNode.contradiction(graph())); + } } } else { // one of them is virtual: they can never be the same objects