Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java @ 20084:1bc27c390bce
add InlineIntrinsicsDuringParsing option with a default value of true
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 30 Mar 2015 17:51:05 +0200 |
parents | 906367e494ca |
children | 6361fa2e3321 |
rev | line source |
---|---|
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import org.junit.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import com.oracle.truffle.api.dsl.*; |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
29 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.DoubleEvaluatedNodeFactory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
30 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.EvaluatedNodeFactory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
31 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedGenerationFactory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
32 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs0Factory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
33 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs1Factory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
34 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs2Factory; |
13272
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
35 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs3Factory; |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
36 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs4Factory; |
13273
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
37 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.TestEvaluatedVarArgs5Factory; |
19292
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
38 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.UseDoubleEvaluated1NodeFactory; |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
39 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.UseDoubleEvaluated2NodeFactory; |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
40 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.UseEvaluatedNodeFactory; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
41 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
42 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ChildrenNode; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
43 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
44 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 import com.oracle.truffle.api.frame.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 import com.oracle.truffle.api.nodes.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 public class ExecuteEvaluatedTest { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 @Test |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 public void testSingleEvaluated() { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 ArgumentNode arg0 = new ArgumentNode(0); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 CallTarget callTarget = TestHelper.createCallTarget(UseEvaluatedNodeFactory.create(arg0, EvaluatedNodeFactory.create(null))); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13273
diff
changeset
|
55 Assert.assertEquals(43, callTarget.call(new Object[]{42})); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 Assert.assertEquals(1, arg0.getInvocationCount()); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 @NodeChild("exp") |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 abstract static class EvaluatedNode extends ValueNode { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 @Specialization |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 int doExecuteWith(int exp) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 return exp + 1; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 public abstract Object executeEvaluated(VirtualFrame frame, Object targetValue); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 public abstract int executeIntEvaluated(VirtualFrame frame, Object targetValue) throws UnexpectedResultException; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 @NodeChildren({@NodeChild("exp0"), @NodeChild(value = "exp1", type = EvaluatedNode.class, executeWith = "exp0")}) |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 abstract static class UseEvaluatedNode extends ValueNode { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 @Specialization |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 int call(int exp0, int exp1) { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
77 Assert.assertEquals(exp0 + 1, exp1); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 return exp1; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 @Test |
19292
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
83 public void testDoubleEvaluated1() { |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 ArgumentNode arg0 = new ArgumentNode(0); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
85 ArgumentNode arg1 = new ArgumentNode(1); |
19292
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
86 CallTarget callTarget = TestHelper.createCallTarget(UseDoubleEvaluated1NodeFactory.create(arg0, arg1, DoubleEvaluatedNodeFactory.create(null, null))); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
87 |
19292
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
88 Assert.assertEquals(42, callTarget.call(new Object[]{43, 1})); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 Assert.assertEquals(1, arg0.getInvocationCount()); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 Assert.assertEquals(1, arg1.getInvocationCount()); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 @NodeChildren({@NodeChild("exp0"), @NodeChild("exp1")}) |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 abstract static class DoubleEvaluatedNode extends ValueNode { |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 @Specialization |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
97 int doExecuteWith(int exp0, int exp1) { |
19292
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
98 return exp0 - exp1; |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
99 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
100 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
101 public abstract Object executeEvaluated(VirtualFrame frame, Object exp0, Object exp1); |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 public abstract int executeIntEvaluated(VirtualFrame frame, Object exp0, Object exp1) throws UnexpectedResultException; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
104 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
105 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
106 @NodeChildren({@NodeChild("exp0"), @NodeChild("exp1"), @NodeChild(value = "exp2", type = DoubleEvaluatedNode.class, executeWith = {"exp0", "exp1"})}) |
19292
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
107 abstract static class UseDoubleEvaluated1Node extends ValueNode { |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
108 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 @Specialization |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
110 int call(int exp0, int exp1, int exp2) { |
19292
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
111 Assert.assertEquals(exp0 - exp1, exp2); |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
112 return exp2; |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
113 } |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
114 } |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
115 |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
116 @Test |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
117 public void testDoubleEvaluated2() { |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
118 ArgumentNode arg0 = new ArgumentNode(0); |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
119 ArgumentNode arg1 = new ArgumentNode(1); |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
120 CallTarget callTarget = TestHelper.createCallTarget(UseDoubleEvaluated2NodeFactory.create(arg0, arg1, DoubleEvaluatedNodeFactory.create(null, null))); |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
121 |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
122 Assert.assertEquals(42, callTarget.call(new Object[]{1, 43})); |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
123 Assert.assertEquals(1, arg0.getInvocationCount()); |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
124 Assert.assertEquals(1, arg1.getInvocationCount()); |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
125 } |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
126 |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
127 @NodeChildren({@NodeChild("exp0"), @NodeChild("exp1"), @NodeChild(value = "exp2", type = DoubleEvaluatedNode.class, executeWith = {"exp1", "exp0"})}) |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
128 abstract static class UseDoubleEvaluated2Node extends ValueNode { |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
129 |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
130 @Specialization |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
131 int call(int exp0, int exp1, int exp2) { |
906367e494ca
Truffle-DSL: fix invalid parameter order for executeWith with non-linear execution.
Christian Humer <christian.humer@gmail.com>
parents:
18776
diff
changeset
|
132 Assert.assertEquals(exp1 - exp0, exp2); |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
133 return exp2; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
134 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
135 } |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
136 |
11445
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
137 @Test |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
138 public void testEvaluatedGeneration() throws UnexpectedResultException { |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
139 TestRootNode<TestEvaluatedGeneration> root = TestHelper.createRoot(TestEvaluatedGenerationFactory.getInstance()); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
140 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
141 Assert.assertEquals(42, root.getNode().executeEvaluated1(null, 42)); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
142 Assert.assertEquals(42, root.getNode().executeEvaluated2(null, 42)); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
143 Assert.assertEquals(42, root.getNode().executeEvaluated3(null, 42)); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
144 Assert.assertEquals(42, root.getNode().executeEvaluated4(null, 42)); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
145 } |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
146 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
147 @NodeChildren({@NodeChild("exp0")}) |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
148 abstract static class TestEvaluatedGeneration extends ValueNode { |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
149 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
150 public abstract Object executeEvaluated1(VirtualFrame frame, Object value); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
151 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
152 public abstract Object executeEvaluated2(VirtualFrame frame, int value); |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
153 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
154 public abstract int executeEvaluated3(VirtualFrame frame, Object value) throws UnexpectedResultException; |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
155 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
156 public abstract int executeEvaluated4(VirtualFrame frame, int value) throws UnexpectedResultException; |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
157 |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
158 @Specialization |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
159 int call(int exp0) { |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
160 return exp0; |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
161 } |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
162 } |
5fbd1ba4a5f3
Truffle-DSL: execute evaluated methods can now be declared using any type in the typesystem as parameters.
Christian Humer <christian.humer@gmail.com>
parents:
10597
diff
changeset
|
163 |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
164 @Test |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
165 public void test0VarArgs1() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
166 TestRootNode<TestEvaluatedVarArgs0> root = TestHelper.createRoot(TestEvaluatedVarArgs0Factory.getInstance()); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
167 Assert.assertEquals(42, root.getNode().execute1(null)); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
168 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
169 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
170 abstract static class TestEvaluatedVarArgs0 extends ChildrenNode { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
171 |
18776
c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
172 @Override |
c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
173 public final Object execute(VirtualFrame frame) { |
c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
174 return execute1(frame); |
c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
175 } |
c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
176 |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
177 public abstract Object execute1(VirtualFrame frame, Object... value); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
178 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
179 @Specialization |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
180 int call() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
181 return 42; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
182 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
183 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
184 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
185 @Test |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
186 public void test1VarArgs1() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
187 TestRootNode<TestEvaluatedVarArgs1> root = TestHelper.createRoot(TestEvaluatedVarArgs1Factory.getInstance()); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
188 Assert.assertEquals(42, root.getNode().execute1(null, 42)); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
189 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
190 |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
191 @Test(expected = Throwable.class) |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
192 public void test1VarArgs2() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
193 TestRootNode<TestEvaluatedVarArgs2> root = TestHelper.createRoot(TestEvaluatedVarArgs2Factory.getInstance()); |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
194 root.getNode().execute1(null); |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
195 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
196 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
197 abstract static class TestEvaluatedVarArgs1 extends ChildrenNode { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
198 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
199 public abstract Object execute1(VirtualFrame frame, Object... value); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
200 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
201 @Specialization |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
202 int call(int exp0) { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
203 return exp0; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
204 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
205 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
206 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
207 @Test |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
208 public void test2VarArgs1() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
209 TestRootNode<TestEvaluatedVarArgs2> root = TestHelper.createRoot(TestEvaluatedVarArgs2Factory.getInstance()); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
210 Assert.assertEquals(42, root.getNode().execute1(null, 21, 21)); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
211 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
212 |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
213 @Test(expected = Throwable.class) |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
214 public void test2VarArgs2() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
215 TestRootNode<TestEvaluatedVarArgs2> root = TestHelper.createRoot(TestEvaluatedVarArgs2Factory.getInstance()); |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
216 root.getNode().execute1(null, 42); |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
217 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
218 |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
219 @Test(expected = Throwable.class) |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
220 public void test2VarArgs3() { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
221 TestRootNode<TestEvaluatedVarArgs2> root = TestHelper.createRoot(TestEvaluatedVarArgs2Factory.getInstance()); |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
14991
diff
changeset
|
222 root.getNode().execute1(null); |
13271
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
223 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
224 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
225 abstract static class TestEvaluatedVarArgs2 extends ChildrenNode { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
226 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
227 public abstract Object execute1(VirtualFrame frame, Object... value); |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
228 |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
229 @Specialization |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
230 int call(int exp0, int exp1) { |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
231 return exp0 + exp1; |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
232 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
233 } |
2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
Christian Humer <christian.humer@gmail.com>
parents:
11445
diff
changeset
|
234 |
13272
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
235 @Test |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
236 public void test3VarArgs1() { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
237 TestRootNode<TestEvaluatedVarArgs3> root = TestHelper.createRoot(TestEvaluatedVarArgs3Factory.getInstance()); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
238 Assert.assertEquals(42, root.getNode().execute1(null, 42)); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
239 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
240 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
241 @NodeChild |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
242 abstract static class TestEvaluatedVarArgs3 extends ValueNode { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
243 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
244 public abstract Object execute1(VirtualFrame frame, Object... value); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
245 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
246 @Specialization |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
247 int call(int exp0) { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
248 return exp0; |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
249 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
250 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
251 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
252 @Test |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
253 public void test4VarArgs1() { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
254 TestRootNode<TestEvaluatedVarArgs4> root = TestHelper.createRoot(TestEvaluatedVarArgs4Factory.getInstance()); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
255 Assert.assertEquals(42, root.getNode().execute1(null, 21, 21)); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
256 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
257 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
258 @NodeChildren({@NodeChild, @NodeChild}) |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
259 abstract static class TestEvaluatedVarArgs4 extends ValueNode { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
260 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
261 public abstract Object execute1(VirtualFrame frame, Object... value); |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
262 |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
263 @Specialization |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
264 int call(int exp0, int exp1) { |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
265 return exp0 + exp1; |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
266 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
267 } |
0b8335a4fb13
Truffle-DSL: more testing for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13271
diff
changeset
|
268 |
13273
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
269 @Test |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
270 public void test5VarArgs1() { |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
271 TestRootNode<TestEvaluatedVarArgs5> root = TestHelper.createRoot(TestEvaluatedVarArgs5Factory.getInstance()); |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
272 Assert.assertEquals(42, root.getNode().execute1(null)); |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
273 } |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
274 |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
275 abstract static class TestEvaluatedVarArgs5 extends ValueNode { |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
276 |
18776
c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
277 @Override |
c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
278 public final Object execute(VirtualFrame frame) { |
c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
279 return execute1(frame); |
c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
280 } |
c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
281 |
13273
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
282 public abstract Object execute1(VirtualFrame frame, Object... value); |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
283 |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
284 @Specialization |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
285 int call() { |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
286 return 42; |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
287 } |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
288 } |
17b116b80aba
Truffle-DSL: added another test case for generating execute methods with varargs.
Christian Humer <christian.humer@gmail.com>
parents:
13272
diff
changeset
|
289 |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
290 } |