Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationGroupingTest.java @ 11470:b010fd3de42d
Truffle-DSL: added a test that covers wrong a wrong else connection bug.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 30 Aug 2013 13:11:48 +0200 |
parents | 4f52b08bd2f9 |
children | a317acdd5f2c |
comparison
equal
deleted
inserted
replaced
11469:88316d1c4644 | 11470:b010fd3de42d |
---|---|
24 | 24 |
25 import org.junit.*; | 25 import org.junit.*; |
26 | 26 |
27 import com.oracle.truffle.api.*; | 27 import com.oracle.truffle.api.*; |
28 import com.oracle.truffle.api.dsl.*; | 28 import com.oracle.truffle.api.dsl.*; |
29 import com.oracle.truffle.api.dsl.test.SpecializationGroupingTestFactory.TestElseConnectionBug1Factory; | |
29 import com.oracle.truffle.api.dsl.test.SpecializationGroupingTestFactory.TestGroupingFactory; | 30 import com.oracle.truffle.api.dsl.test.SpecializationGroupingTestFactory.TestGroupingFactory; |
30 import com.oracle.truffle.api.dsl.test.TypeSystemTest.SimpleTypes; | 31 import com.oracle.truffle.api.dsl.test.TypeSystemTest.SimpleTypes; |
31 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; | 32 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; |
32 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; | 33 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
34 import com.oracle.truffle.api.frame.*; | |
33 import com.oracle.truffle.api.nodes.*; | 35 import com.oracle.truffle.api.nodes.*; |
34 | 36 |
35 /** | 37 /** |
36 * Tests execution counts of guards. While we do not make guarantees for guard invocation except for | 38 * Tests execution counts of guards. While we do not make guarantees for guard invocation except for |
37 * their execution order our implementation reduces the calls to guards as much as possible. | 39 * their execution order our implementation reduces the calls to guards as much as possible. |
152 return value1 + value2; | 154 return value1 + value2; |
153 } | 155 } |
154 | 156 |
155 } | 157 } |
156 | 158 |
159 @Test | |
160 public void testElseConnectionBug1() { | |
161 CallTarget target = TestHelper.createCallTarget(TestElseConnectionBug1Factory.create(new GenericInt())); | |
162 Assert.assertEquals(42, target.call()); | |
163 } | |
164 | |
165 @SuppressWarnings("unused") | |
166 @NodeChild(value = "genericChild", type = GenericInt.class) | |
167 public abstract static class TestElseConnectionBug1 extends ValueNode { | |
168 | |
169 @Specialization(order = 1, rewriteOn = {SlowPathException.class}, guards = "isInitialized") | |
170 public int doInteger(int value) throws SlowPathException { | |
171 throw new SlowPathException(); | |
172 } | |
173 | |
174 @Specialization(order = 3, guards = "isInitialized") | |
175 public int doObject(int value) { | |
176 return value == 42 ? value : 0; | |
177 } | |
178 | |
179 @Specialization(order = 4, guards = "!isInitialized") | |
180 public Object doUninitialized(int value) { | |
181 throw new AssertionError(); | |
182 } | |
183 | |
184 boolean isInitialized(int value) { | |
185 return true; | |
186 } | |
187 } | |
188 | |
189 public static final class GenericInt extends ValueNode { | |
190 | |
191 @Override | |
192 public Object execute(VirtualFrame frame) { | |
193 return executeInt(frame); | |
194 } | |
195 | |
196 @Override | |
197 public int executeInt(VirtualFrame frame) { | |
198 return 42; | |
199 } | |
200 | |
201 } | |
202 | |
157 private static class MockAssumption implements Assumption { | 203 private static class MockAssumption implements Assumption { |
158 | 204 |
159 int checked; | 205 int checked; |
160 | 206 |
161 private final boolean valid; | 207 private final boolean valid; |