comparison 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
comparison
equal deleted inserted replaced
12444:b6e3b44ab44f 12445:66efe95dd46b
73 } 73 }
74 return true; 74 return true;
75 } 75 }
76 76
77 public static ConstantNode forConstant(Constant constant, MetaAccessProvider metaAccess, Graph graph) { 77 public static ConstantNode forConstant(Constant constant, MetaAccessProvider metaAccess, Graph graph) {
78 if (constant.getKind() == Kind.Object) { 78 if (constant.getKind().getStackKind() == Kind.Int && constant.getKind() != Kind.Int) {
79 return forInt(constant.asInt(), graph);
80 } else if (constant.getKind() == Kind.Object) {
79 return graph.unique(new ConstantNode(constant, metaAccess)); 81 return graph.unique(new ConstantNode(constant, metaAccess));
80 } else { 82 } else {
81 return graph.unique(new ConstantNode(constant)); 83 return graph.unique(new ConstantNode(constant));
82 } 84 }
83 } 85 }
140 * @param i the boolean value for which to create the instruction 142 * @param i the boolean value for which to create the instruction
141 * @param graph 143 * @param graph
142 * @return a node representing the boolean 144 * @return a node representing the boolean
143 */ 145 */
144 public static ConstantNode forBoolean(boolean i, Graph graph) { 146 public static ConstantNode forBoolean(boolean i, Graph graph) {
145 return graph.unique(new ConstantNode(Constant.forBoolean(i))); 147 return graph.unique(new ConstantNode(Constant.forInt(i ? 1 : 0)));
146 } 148 }
147 149
148 /** 150 /**
149 * Returns a node for a byte constant. 151 * Returns a node for a byte constant.
150 * 152 *
151 * @param i the byte value for which to create the instruction 153 * @param i the byte value for which to create the instruction
152 * @param graph 154 * @param graph
153 * @return a node representing the byte 155 * @return a node representing the byte
154 */ 156 */
155 public static ConstantNode forByte(byte i, Graph graph) { 157 public static ConstantNode forByte(byte i, Graph graph) {
156 return graph.unique(new ConstantNode(Constant.forByte(i))); 158 return graph.unique(new ConstantNode(Constant.forInt(i)));
157 } 159 }
158 160
159 /** 161 /**
160 * Returns a node for a char constant. 162 * Returns a node for a char constant.
161 * 163 *
162 * @param i the char value for which to create the instruction 164 * @param i the char value for which to create the instruction
163 * @param graph 165 * @param graph
164 * @return a node representing the char 166 * @return a node representing the char
165 */ 167 */
166 public static ConstantNode forChar(char i, Graph graph) { 168 public static ConstantNode forChar(char i, Graph graph) {
167 return graph.unique(new ConstantNode(Constant.forChar(i))); 169 return graph.unique(new ConstantNode(Constant.forInt(i)));
168 } 170 }
169 171
170 /** 172 /**
171 * Returns a node for a short constant. 173 * Returns a node for a short constant.
172 * 174 *
173 * @param i the short value for which to create the instruction 175 * @param i the short value for which to create the instruction
174 * @param graph 176 * @param graph
175 * @return a node representing the short 177 * @return a node representing the short
176 */ 178 */
177 public static ConstantNode forShort(short i, Graph graph) { 179 public static ConstantNode forShort(short i, Graph graph) {
178 return graph.unique(new ConstantNode(Constant.forShort(i))); 180 return graph.unique(new ConstantNode(Constant.forInt(i)));
179 } 181 }
180 182
181 /** 183 /**
182 * Returns a node for an object constant. 184 * Returns a node for an object constant.
183 * 185 *
215 } 217 }
216 218
217 public static ConstantNode defaultForKind(Kind kind, Graph graph) { 219 public static ConstantNode defaultForKind(Kind kind, Graph graph) {
218 switch (kind) { 220 switch (kind) {
219 case Boolean: 221 case Boolean:
220 return ConstantNode.forBoolean(false, graph);
221 case Byte: 222 case Byte:
222 case Char: 223 case Char:
223 case Short: 224 case Short:
224 case Int: 225 case Int:
225 return ConstantNode.forInt(0, graph); 226 return ConstantNode.forInt(0, graph);