# HG changeset patch # User Thomas Wuerthinger # Date 1356010975 -3600 # Node ID 718f6161f3196fac9f00a9b80d8f598747807046 # Parent dc3e86fd3be12244efc3e1cf7fb8added50fcdd2 Added constant propagation to BoxNode. diff -r dc3e86fd3be1 -r 718f6161f319 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java --- 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;