Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteGroupingTest.java @ 21373:e5df47e0efb8
Bugfix: ForeignCallNode needs bci
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Thu, 14 May 2015 15:57:55 -0700 |
parents | 6361fa2e3321 |
children | b1530a6cce8c |
rev | line source |
---|---|
20940
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import org.junit.*; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 import org.junit.experimental.theories.*; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import org.junit.runner.*; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import org.junit.runners.Parameterized.Parameters; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 import static org.junit.Assert.*; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 import com.oracle.truffle.api.dsl.*; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 import com.oracle.truffle.api.dsl.test.ExecuteGroupingTestFactory.ExecuteGrouping1NodeGen; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 import com.oracle.truffle.api.frame.*; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 import com.oracle.truffle.api.nodes.*; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 /* |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 * This test aims to test the reuse of execute methods with evaluated parameters as much as possible. |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 */ |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 @SuppressWarnings("unused") |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 @RunWith(Theories.class) |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 public class ExecuteGroupingTest { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 @DataPoints public static final Object[] parameters = new Object[]{1, 2}; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 static final class ExecuteGroupingChild extends Node { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 int invocationCount = 0; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 private final Object returnValue; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 public ExecuteGroupingChild(Object returnValue) { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 this.returnValue = returnValue; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 Object execute() { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 invocationCount++; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 return returnValue; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 @Theory |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 public void testExecuteGrouping1Node(Object a, Object b, Object c) throws UnexpectedResultException { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 ExecuteGroupingChild child0 = new ExecuteGroupingChild(a); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 ExecuteGroupingChild child1 = new ExecuteGroupingChild(b); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 ExecuteGroupingChild child2 = new ExecuteGroupingChild(c); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 int result = ((int) a) + ((int) b) + ((int) c); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(child0, child1, child2)).execute()); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(child0, child1, child2)).execute((VirtualFrame) null)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(null, child1, child2)).execute(a)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(null, child1, child2)).executeInt(a)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(null, null, child2)).execute(a, b)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
77 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(null, null, child2)).execute((int) a, b)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(null, null, child2)).execute(a, (int) b)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(null, null, child2)).execute((int) a, (int) b)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(null, null, child2)).executeInt((int) a, (int) b)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(null, null, null)).execute(a, b, c)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(null, null, null)).execute((int) a, (int) b, c)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 assertEquals(result, TestHelper.createRoot(ExecuteGrouping1NodeGen.create(null, null, null)).execute((int) a, (int) b, (int) c)); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
85 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
87 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 @NodeChildren({@NodeChild(type = ExecuteGroupingChild.class), @NodeChild(type = ExecuteGroupingChild.class), @NodeChild(type = ExecuteGroupingChild.class)}) |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 abstract static class ExecuteGrouping1Node extends Node { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 abstract Object execute(); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 int executeInt() throws UnexpectedResultException { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 Object value = execute(); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 if (value instanceof Integer) { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 return (int) value; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
97 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
98 throw new UnexpectedResultException(value); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
99 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
100 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
101 abstract double executeDouble() throws UnexpectedResultException; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 abstract Object execute(VirtualFrame frame); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
104 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
105 abstract Object execute(Object o1); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
106 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
107 abstract int executeInt(Object o1) throws UnexpectedResultException; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
108 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 abstract Object execute(Object o1, Object o2); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
110 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
111 abstract Object execute(int o1, int o2); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
112 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
113 abstract Object execute(int o1, int o2, Object o3); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
114 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
115 abstract int executeInt(int o1, int o2) throws UnexpectedResultException; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
116 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
117 abstract Object execute(Object o1, int o2); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
118 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
119 abstract Object execute(int o1, Object o2); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
120 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
121 abstract Object execute(Object o1, Object o2, Object o3); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
122 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
123 abstract Object execute(int o1, int o2, int o3); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
124 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
125 @Specialization |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
126 int s1(int a, int b, int c) { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
127 return a + b + c; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
128 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
129 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
130 @Specialization |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
131 int s2(Object a, Object b, Object c) { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
132 return ((int) a) + ((int) b) + ((int) c); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
133 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
134 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
135 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
136 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
137 abstract static class StrangeReturnCase extends Node { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
138 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
139 // we don't know how to implement executeDouble |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
140 public abstract double executeDouble(); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
141 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
142 public int executeInt() { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
143 return 42; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
144 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
145 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
146 @Specialization(rewriteOn = RuntimeException.class) |
20984
6361fa2e3321
Truffle-DSL: further fixes for polymorphic execute signatures.
Christian Humer <christian.humer@oracle.com>
parents:
20940
diff
changeset
|
147 double s1() { |
20940
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
148 return 42; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
149 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
150 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
151 @Specialization |
20984
6361fa2e3321
Truffle-DSL: further fixes for polymorphic execute signatures.
Christian Humer <christian.humer@oracle.com>
parents:
20940
diff
changeset
|
152 double s2() { |
20940
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
153 return 42; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
154 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
155 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
156 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
157 |
20984
6361fa2e3321
Truffle-DSL: further fixes for polymorphic execute signatures.
Christian Humer <christian.humer@oracle.com>
parents:
20940
diff
changeset
|
158 @ExpectError("Incompatible abstract execute methods found %") |
20940
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
159 abstract static class IncompatibleAbstract1 extends Node { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
160 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
161 // we don't know how to implement executeDouble |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
162 abstract double executeDouble(); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
163 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
164 abstract int executeInt(); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
165 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
166 @Specialization |
20984
6361fa2e3321
Truffle-DSL: further fixes for polymorphic execute signatures.
Christian Humer <christian.humer@oracle.com>
parents:
20940
diff
changeset
|
167 double s1() { |
20940
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
168 return 42; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
169 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
170 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
171 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
172 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
173 abstract static class IncompatibleAbstract2 extends Node { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
174 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
175 abstract double executeDouble(); |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
176 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
177 // we can resolve duplicate path errors by making an execute method final |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
178 @SuppressWarnings("static-method") |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
179 public final int executeInt() { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
180 return 42; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
181 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
182 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
183 @ExpectError("The provided return type \"int\" does not match expected return type \"double\".%") |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
184 @Specialization(rewriteOn = RuntimeException.class) |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
185 int s1() { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
186 return 42; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
187 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
188 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
189 @Specialization |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
190 double s2() { |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
191 return 42; |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
192 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
193 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
194 } |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
195 |
476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
196 } |