# HG changeset patch # User Lukas Stadler # Date 1368005044 -7200 # Node ID 0f7bd899a1a894ab0ed4c9240878b83d7d32b048 # Parent 1a87230c775df6d368027b8df344bcd50660875d make ObjectEqualsNode virtualization less conservative diff -r 1a87230c775d -r 0f7bd899a1a8 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 Tue May 07 22:42:46 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Wed May 08 11:24:04 2013 +0200 @@ -70,6 +70,26 @@ return super.canonical(tool); } + 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; + final IntegerEqualsNode equals = new IntegerEqualsNode(state.getEntry(0), ConstantNode.forInt(expectedValue, graph())); + tool.customAction(new Runnable() { + + @Override + public void run() { + graph().add(equals); + } + }); + tool.replaceWithValue(equals); + } + } else { + // one of them is virtual: they can never be the same objects + tool.replaceWithValue(LogicConstantNode.contradiction(graph())); + } + } + @Override public void virtualize(VirtualizerTool tool) { State stateX = tool.getObjectState(x()); @@ -78,15 +98,9 @@ boolean yVirtual = stateY != null && stateY.getState() == EscapeState.Virtual; if (xVirtual && !yVirtual) { - if (stateX.getVirtualObject().hasIdentity()) { - // one of them is virtual: they can never be the same objects - tool.replaceWithValue(LogicConstantNode.contradiction(graph())); - } + virtualizeNonVirtualComparison(stateX, stateY != null ? stateY.getMaterializedValue() : y(), tool); } else if (!xVirtual && yVirtual) { - if (stateY.getVirtualObject().hasIdentity()) { - // one of them is virtual: they can never be the same objects - tool.replaceWithValue(LogicConstantNode.contradiction(graph())); - } + virtualizeNonVirtualComparison(stateY, stateX != null ? stateX.getMaterializedValue() : x(), tool); } else if (xVirtual && yVirtual) { boolean xIdentity = stateX.getVirtualObject().hasIdentity(); boolean yIdentity = stateY.getVirtualObject().hasIdentity();