Mercurial > hg > truffle
changeset 17390:5949340cc50e
only optimize identity-less comparisons for Integer and Long
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Thu, 09 Oct 2014 14:43:52 +0200 |
parents | 763a34f283f9 |
children | e890b86b397d |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java |
diffstat | 1 files changed, 12 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Thu Oct 09 13:26:17 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Thu Oct 09 14:43:52 2014 +0200 @@ -122,13 +122,18 @@ */ tool.replaceWithValue(LogicConstantNode.contradiction(graph())); } else if (!xIdentity && !yIdentity) { - // both are virtual without identity: check contents - assert stateX.getVirtualObject().entryCount() == 1 && stateY.getVirtualObject().entryCount() == 1; - assert stateX.getVirtualObject().type().equals(stateY.getVirtualObject().type()); - assert stateX.getVirtualObject().entryKind(0).getStackKind() == Kind.Int || stateX.getVirtualObject().entryKind(0) == Kind.Long; - IntegerEqualsNode equals = IntegerEqualsNode.create(stateX.getEntry(0), stateY.getEntry(0)); - tool.addNode(equals); - tool.replaceWithValue(equals); + ResolvedJavaType type = stateX.getVirtualObject().type(); + if (type.equals(stateY.getVirtualObject().type())) { + MetaAccessProvider metaAccess = tool.getMetaAccessProvider(); + if (type.equals(metaAccess.lookupJavaType(Integer.class)) || type.equals(metaAccess.lookupJavaType(Long.class))) { + // both are virtual without identity: check contents + assert stateX.getVirtualObject().entryCount() == 1 && stateY.getVirtualObject().entryCount() == 1; + assert stateX.getVirtualObject().entryKind(0).getStackKind() == Kind.Int || stateX.getVirtualObject().entryKind(0) == Kind.Long; + IntegerEqualsNode equals = IntegerEqualsNode.create(stateX.getEntry(0), stateY.getEntry(0)); + tool.addNode(equals); + tool.replaceWithValue(equals); + } + } } else { // both are virtual with identity: check if they refer to the same object tool.replaceWithValue(LogicConstantNode.forBoolean(stateX == stateY, graph()));