Mercurial > hg > graal-compiler
changeset 9606:0f7bd899a1a8
make ObjectEqualsNode virtualization less conservative
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 08 May 2013 11:24:04 +0200 |
parents | 1a87230c775d |
children | 6f208669893a |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java |
diffstat | 1 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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();