Mercurial > hg > truffle
changeset 10604:953a0d51a11f
ObjectEqualsNode: fix comparison of virtual boolean against constant object
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Wed, 03 Jul 2013 16:19:15 +0200 |
parents | 2e7e7a22940f |
children | f0551e15a416 57b9a8c7cea8 |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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