Mercurial > hg > truffle
diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java @ 12445:66efe95dd46b
Make sure constants have the correct stack kind and unsafe accesses the correct access kind.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 16 Oct 2013 03:02:03 +0200 |
parents | 9ad59f7fd57e |
children | af39ea2dc39d |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java Tue Oct 15 13:51:27 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java Wed Oct 16 03:02:03 2013 +0200 @@ -75,7 +75,9 @@ } public static ConstantNode forConstant(Constant constant, MetaAccessProvider metaAccess, Graph graph) { - if (constant.getKind() == Kind.Object) { + if (constant.getKind().getStackKind() == Kind.Int && constant.getKind() != Kind.Int) { + return forInt(constant.asInt(), graph); + } else if (constant.getKind() == Kind.Object) { return graph.unique(new ConstantNode(constant, metaAccess)); } else { return graph.unique(new ConstantNode(constant)); @@ -142,7 +144,7 @@ * @return a node representing the boolean */ public static ConstantNode forBoolean(boolean i, Graph graph) { - return graph.unique(new ConstantNode(Constant.forBoolean(i))); + return graph.unique(new ConstantNode(Constant.forInt(i ? 1 : 0))); } /** @@ -153,7 +155,7 @@ * @return a node representing the byte */ public static ConstantNode forByte(byte i, Graph graph) { - return graph.unique(new ConstantNode(Constant.forByte(i))); + return graph.unique(new ConstantNode(Constant.forInt(i))); } /** @@ -164,7 +166,7 @@ * @return a node representing the char */ public static ConstantNode forChar(char i, Graph graph) { - return graph.unique(new ConstantNode(Constant.forChar(i))); + return graph.unique(new ConstantNode(Constant.forInt(i))); } /** @@ -175,7 +177,7 @@ * @return a node representing the short */ public static ConstantNode forShort(short i, Graph graph) { - return graph.unique(new ConstantNode(Constant.forShort(i))); + return graph.unique(new ConstantNode(Constant.forInt(i))); } /** @@ -217,7 +219,6 @@ public static ConstantNode defaultForKind(Kind kind, Graph graph) { switch (kind) { case Boolean: - return ConstantNode.forBoolean(false, graph); case Byte: case Char: case Short: