Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java @ 5538:e18ba36bfebc
Renamed RiConstant => Constant.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 08 Jun 2012 23:41:02 +0200 |
parents | 816fb2492760 |
children | a891c53a295b |
comparison
equal
deleted
inserted
replaced
5537:80371cc2256d | 5538:e18ba36bfebc |
---|---|
36 import com.oracle.graal.graph.Node.Verbosity; | 36 import com.oracle.graal.graph.Node.Verbosity; |
37 import com.oracle.graal.nodes.*; | 37 import com.oracle.graal.nodes.*; |
38 import com.oracle.graal.nodes.java.*; | 38 import com.oracle.graal.nodes.java.*; |
39 import com.oracle.graal.nodes.type.*; | 39 import com.oracle.graal.nodes.type.*; |
40 import com.oracle.graal.nodes.util.*; | 40 import com.oracle.graal.nodes.util.*; |
41 import com.oracle.graal.snippets.Snippet.Constant; | 41 import com.oracle.graal.snippets.Snippet.ConstantParameter; |
42 import com.oracle.graal.snippets.Snippet.Multiple; | 42 import com.oracle.graal.snippets.Snippet.Multiple; |
43 import com.oracle.graal.snippets.Snippet.Parameter; | 43 import com.oracle.graal.snippets.Snippet.Parameter; |
44 import com.oracle.graal.snippets.nodes.*; | 44 import com.oracle.graal.snippets.nodes.*; |
45 | 45 |
46 /** | 46 /** |
47 * A snippet template is a graph created by parsing a snippet method and then | 47 * A snippet template is a graph created by parsing a snippet method and then |
48 * specialized by binding constants to the snippet's {@link Constant} parameters. | 48 * specialized by binding constants to the snippet's {@link ConstantParameter} parameters. |
49 * | 49 * |
50 * Snippet templates can be managed in a {@link Cache}. | 50 * Snippet templates can be managed in a {@link Cache}. |
51 */ | 51 */ |
52 public class SnippetTemplate { | 52 public class SnippetTemplate { |
53 | 53 |
188 | 188 |
189 int parameterCount = signature.argumentCount(false); | 189 int parameterCount = signature.argumentCount(false); |
190 Parameter[] parameterAnnotations = new Parameter[parameterCount]; | 190 Parameter[] parameterAnnotations = new Parameter[parameterCount]; |
191 ConstantNode[] placeholders = new ConstantNode[parameterCount]; | 191 ConstantNode[] placeholders = new ConstantNode[parameterCount]; |
192 for (int i = 0; i < parameterCount; i++) { | 192 for (int i = 0; i < parameterCount; i++) { |
193 Constant c = CiUtil.getParameterAnnotation(Constant.class, i, method); | 193 ConstantParameter c = CiUtil.getParameterAnnotation(ConstantParameter.class, i, method); |
194 if (c != null) { | 194 if (c != null) { |
195 String name = c.value(); | 195 String name = c.value(); |
196 Object arg = key.get(name); | 196 Object arg = key.get(name); |
197 assert arg != null : method + ": requires a constant named " + name; | 197 assert arg != null : method + ": requires a constant named " + name; |
198 RiKind kind = signature.argumentKindAt(i); | 198 RiKind kind = signature.argumentKindAt(i); |
199 assert checkConstantArgument(method, signature, i, name, arg, kind); | 199 assert checkConstantArgument(method, signature, i, name, arg, kind); |
200 replacements.put(snippetGraph.getLocal(i), ConstantNode.forCiConstant(RiConstant.forBoxed(kind, arg), runtime, snippetCopy)); | 200 replacements.put(snippetGraph.getLocal(i), ConstantNode.forCiConstant(Constant.forBoxed(kind, arg), runtime, snippetCopy)); |
201 } else { | 201 } else { |
202 Parameter p = CiUtil.getParameterAnnotation(Parameter.class, i, method); | 202 Parameter p = CiUtil.getParameterAnnotation(Parameter.class, i, method); |
203 assert p != null : method + ": parameter " + i + " must be annotated with either @Constant or @Parameter"; | 203 assert p != null : method + ": parameter " + i + " must be annotated with either @Constant or @Parameter"; |
204 String name = p.value(); | 204 String name = p.value(); |
205 if (p.multiple()) { | 205 if (p.multiple()) { |
383 if (parameter instanceof LocalNode) { | 383 if (parameter instanceof LocalNode) { |
384 if (argument instanceof ValueNode) { | 384 if (argument instanceof ValueNode) { |
385 replacements.put((LocalNode) parameter, (ValueNode) argument); | 385 replacements.put((LocalNode) parameter, (ValueNode) argument); |
386 } else { | 386 } else { |
387 RiKind kind = ((LocalNode) parameter).kind(); | 387 RiKind kind = ((LocalNode) parameter).kind(); |
388 RiConstant constant = RiConstant.forBoxed(kind, argument); | 388 Constant constant = Constant.forBoxed(kind, argument); |
389 replacements.put((LocalNode) parameter, ConstantNode.forCiConstant(constant, runtime, replaceeGraph)); | 389 replacements.put((LocalNode) parameter, ConstantNode.forCiConstant(constant, runtime, replaceeGraph)); |
390 } | 390 } |
391 } else { | 391 } else { |
392 assert parameter instanceof LocalNode[]; | 392 assert parameter instanceof LocalNode[]; |
393 LocalNode[] locals = (LocalNode[]) parameter; | 393 LocalNode[] locals = (LocalNode[]) parameter; |
396 int length = locals.length; | 396 int length = locals.length; |
397 assert Array.getLength(array) == length : length + " != " + Array.getLength(array); | 397 assert Array.getLength(array) == length : length + " != " + Array.getLength(array); |
398 for (int j = 0; j < length; j++) { | 398 for (int j = 0; j < length; j++) { |
399 LocalNode local = locals[j]; | 399 LocalNode local = locals[j]; |
400 assert local != null; | 400 assert local != null; |
401 RiConstant constant = RiConstant.forBoxed(local.kind(), Array.get(array, j)); | 401 Constant constant = Constant.forBoxed(local.kind(), Array.get(array, j)); |
402 ConstantNode element = ConstantNode.forCiConstant(constant, runtime, replaceeGraph); | 402 ConstantNode element = ConstantNode.forCiConstant(constant, runtime, replaceeGraph); |
403 replacements.put(local, element); | 403 replacements.put(local, element); |
404 } | 404 } |
405 } | 405 } |
406 } | 406 } |