Mercurial > hg > truffle
changeset 7308:718f6161f319
Added constant propagation to BoxNode.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 20 Dec 2012 14:42:55 +0100 |
parents | dc3e86fd3be1 |
children | 75c18356504d |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java |
diffstat | 1 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java Thu Dec 20 14:38:06 2012 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java Thu Dec 20 14:42:55 2012 +0100 @@ -65,6 +65,33 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { + + if (source.isConstant()) { + Constant sourceConstant = source.asConstant(); + switch (sourceKind) { + case Boolean: + return ConstantNode.forObject(Boolean.valueOf(sourceConstant.asBoolean()), tool.runtime(), graph()); + case Byte: + return ConstantNode.forObject(Byte.valueOf((byte) sourceConstant.asInt()), tool.runtime(), graph()); + case Char: + return ConstantNode.forObject(Character.valueOf((char) sourceConstant.asInt()), tool.runtime(), graph()); + case Short: + return ConstantNode.forObject(Short.valueOf((short) sourceConstant.asInt()), tool.runtime(), graph()); + case Int: + return ConstantNode.forObject(Integer.valueOf(sourceConstant.asInt()), tool.runtime(), graph()); + case Long: + return ConstantNode.forObject(Long.valueOf(sourceConstant.asLong()), tool.runtime(), graph()); + case Float: + return ConstantNode.forObject(Float.valueOf(sourceConstant.asFloat()), tool.runtime(), graph()); + case Double: + return ConstantNode.forObject(Double.valueOf(sourceConstant.asDouble()), tool.runtime(), graph()); + default: + assert false : "Unexpected source kind for boxing"; + break; + + } + } + for (Node usage : usages()) { if (usage != stateAfter()) { return this;