Mercurial > hg > truffle
changeset 19151:f41186c896cd
More folding on creation for object equality node.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 05 Feb 2015 04:16:48 +0100 |
parents | bb25b153433c |
children | 5fce692f65c8 3b2e98f9e47c |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/PointerEqualsNode.java |
diffstat | 2 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Thu Feb 05 04:10:59 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Thu Feb 05 04:16:48 2015 +0100 @@ -44,6 +44,10 @@ if (result != null) { return result; } else { + result = findSynonym(x, y); + if (result != null) { + return result; + } return new ObjectEqualsNode(x, y); } } @@ -85,7 +89,7 @@ /* * One of the two objects has identity, the other doesn't. In code, this looks like * "Integer.valueOf(a) == new Integer(b)", which is always false. - * + * * In other words: an object created via valueOf can never be equal to one created * by new in the same compilation unit. */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/PointerEqualsNode.java Thu Feb 05 04:10:59 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/PointerEqualsNode.java Thu Feb 05 04:16:48 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,14 @@ @Override public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) { + LogicNode result = findSynonym(forX, forY); + if (result != null) { + return result; + } + return super.canonical(tool, forX, forY); + } + + public static LogicNode findSynonym(ValueNode forX, ValueNode forY) { if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY)) { return LogicConstantNode.tautology(); } else if (forX.stamp().alwaysDistinct(forY.stamp())) { @@ -48,8 +56,9 @@ return new IsNullNode(forY); } else if (((AbstractPointerStamp) forY.stamp()).alwaysNull()) { return new IsNullNode(forX); + } else { + return null; } - return super.canonical(tool, forX, forY); } @Override