Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java @ 9330:e162d9e32830
Added a clazz parameter to Frame.getArguments in order to allow unsafe access to the arguments object (i.e., avoiding the null check and the type cast).
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 26 Apr 2013 17:15:10 +0200 |
parents | 5e3d1a68664e |
children | df1d665ca846 |
comparison
equal
deleted
inserted
replaced
9329:fa188fbfe3fe | 9330:e162d9e32830 |
---|---|
33 * | 33 * |
34 * <p> | 34 * <p> |
35 * A guest language can pass its own custom arguments when invoking a Truffle method by creating a | 35 * A guest language can pass its own custom arguments when invoking a Truffle method by creating a |
36 * subclass of {@link Arguments}. When invoking a call target with | 36 * subclass of {@link Arguments}. When invoking a call target with |
37 * {@link CallTarget#call(Arguments)}, the arguments can be passed. A Truffle node can access the | 37 * {@link CallTarget#call(Arguments)}, the arguments can be passed. A Truffle node can access the |
38 * arguments passed into the Truffle method by using {@link VirtualFrame#getArguments()}. | 38 * arguments passed into the Truffle method by using {@link VirtualFrame#getArguments}. |
39 * </p> | 39 * </p> |
40 * | 40 * |
41 * <p> | 41 * <p> |
42 * The arguments class should only contain fields that are declared as final. This allows the | 42 * The arguments class should only contain fields that are declared as final. This allows the |
43 * Truffle runtime to improve optimizations around guest language method calls. Also, the arguments | 43 * Truffle runtime to improve optimizations around guest language method calls. Also, the arguments |
95 TestArgumentNode(int index) { | 95 TestArgumentNode(int index) { |
96 this.index = index; | 96 this.index = index; |
97 } | 97 } |
98 | 98 |
99 int execute(VirtualFrame frame) { | 99 int execute(VirtualFrame frame) { |
100 return ((TestArguments) frame.getArguments()).values[index]; | 100 return frame.getArguments(TestArguments.class).values[index]; |
101 } | 101 } |
102 } | 102 } |
103 } | 103 } |