Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationGroupingTest.java @ 19283:08aa0372dad4
Truffle-DSL: implement new guard expression syntax.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 23 Jan 2015 02:55:23 +0100 |
parents | a665483c3881 |
children | f4792a544170 |
comparison
equal
deleted
inserted
replaced
19282:ae81dd154fb6 | 19283:08aa0372dad4 |
---|---|
56 TestGrouping.true2 = 0; | 56 TestGrouping.true2 = 0; |
57 TestGrouping.false2 = 0; | 57 TestGrouping.false2 = 0; |
58 TestGrouping.true3 = 0; | 58 TestGrouping.true3 = 0; |
59 | 59 |
60 Assert.assertEquals(42, TestHelper.executeWith(root, 21, 21)); | 60 Assert.assertEquals(42, TestHelper.executeWith(root, 21, 21)); |
61 Assert.assertEquals(4, TestGrouping.true1); | 61 Assert.assertEquals(5, TestGrouping.true1); |
62 Assert.assertEquals(0, TestGrouping.false1); | 62 Assert.assertEquals(0, TestGrouping.false1); |
63 Assert.assertEquals(4, TestGrouping.true2); | 63 Assert.assertEquals(5, TestGrouping.true2); |
64 Assert.assertEquals(5, TestGrouping.false2); | 64 Assert.assertEquals(5, TestGrouping.false2); |
65 Assert.assertEquals(5, TestGrouping.true3); | 65 Assert.assertEquals(5, TestGrouping.true3); |
66 Assert.assertEquals(10, SimpleTypes.intCheck); | 66 Assert.assertEquals(10, SimpleTypes.intCheck); |
67 Assert.assertEquals(8, SimpleTypes.intCast); | 67 Assert.assertEquals(8, SimpleTypes.intCast); |
68 Assert.assertEquals(4, a1.checked); | 68 Assert.assertEquals(4, a1.checked); |
69 Assert.assertEquals(4, a3.checked); | 69 Assert.assertEquals(4, a3.checked); |
70 | 70 |
71 Assert.assertEquals(42, TestHelper.executeWith(root, 21, 21)); | 71 Assert.assertEquals(42, TestHelper.executeWith(root, 21, 21)); |
72 Assert.assertEquals(5, TestGrouping.true1); | 72 Assert.assertEquals(6, TestGrouping.true1); |
73 Assert.assertEquals(0, TestGrouping.false1); | 73 Assert.assertEquals(0, TestGrouping.false1); |
74 Assert.assertEquals(5, TestGrouping.true2); | 74 Assert.assertEquals(6, TestGrouping.true2); |
75 Assert.assertEquals(6, TestGrouping.false2); | 75 Assert.assertEquals(6, TestGrouping.false2); |
76 Assert.assertEquals(6, TestGrouping.true3); | 76 Assert.assertEquals(6, TestGrouping.true3); |
77 | 77 |
78 Assert.assertEquals(5, a1.checked); | 78 Assert.assertEquals(5, a1.checked); |
79 Assert.assertEquals(5, a3.checked); | 79 Assert.assertEquals(5, a3.checked); |
121 @Specialization | 121 @Specialization |
122 public int fail(int value1, String value2) { | 122 public int fail(int value1, String value2) { |
123 throw new AssertionError(); | 123 throw new AssertionError(); |
124 } | 124 } |
125 | 125 |
126 @Specialization(guards = {"true1", "true2", "!false2", "true3"}, assumptions = {"a1", "a3"}, rewriteOn = RuntimeException.class) | 126 @Specialization(guards = {"true1(value1)", "true2(value1)", "!false2(value1)", "true3(value1)"}, assumptions = {"a1", "a3"}, rewriteOn = RuntimeException.class) |
127 public int throwRewrite(int value1, int value2) { | 127 public int throwRewrite(int value1, int value2) { |
128 throw new RuntimeException(); | 128 throw new RuntimeException(); |
129 } | 129 } |
130 | 130 |
131 @Specialization(guards = {"true1", "true2", "!false2", "true3"}, contains = "throwRewrite", assumptions = {"a1", "a3"}) | 131 @Specialization(guards = {"true1(value1)", "true2(value1)", "!false2(value1)", "true3(value1)"}, contains = "throwRewrite", assumptions = {"a1", "a3"}) |
132 public int success(int value1, int value2) { | 132 public int success(int value1, int value2) { |
133 return value1 + value2; | 133 return value1 + value2; |
134 } | 134 } |
135 | 135 |
136 @Specialization(guards = {"true1", "true2", "!false2", "!true3"}, assumptions = {"a1", "a3"}) | 136 @Specialization(guards = {"true1(value1)", "true2(value1)", "!false2(value1)", "!true3(value1)"}, assumptions = {"a1", "a3"}) |
137 public int fail5(int value1, int value2) { | 137 public int fail5(int value1, int value2) { |
138 throw new AssertionError(); | 138 throw new AssertionError(); |
139 } | 139 } |
140 | 140 |
141 @Specialization(guards = {"true1", "true2", "false2"}, assumptions = {"a1", "a3"}) | 141 @Specialization(guards = {"true1(value1)", "true2(value1)", "false2(value1)"}, assumptions = {"a1", "a3"}) |
142 public int fail4(int value1, int value2) { | 142 public int fail4(int value1, int value2) { |
143 throw new AssertionError(); | 143 throw new AssertionError(); |
144 } | 144 } |
145 | 145 |
146 @Specialization(guards = {"true1", "true2"}, assumptions = {"a1", "a3"}) | 146 @Specialization(guards = {"true1(value1)", "true2(value1)"}, assumptions = {"a1", "a3"}) |
147 public int fail2break(int value1, int value2) { | 147 public int fail2break(int value1, int value2) { |
148 throw new AssertionError(); | 148 throw new AssertionError(); |
149 } | 149 } |
150 | 150 |
151 @Specialization(guards = {"true1", "false1"}) | 151 @Specialization(guards = {"true1(value1)", "false1(value1, value2)"}) |
152 public int fail1(int value1, int value2) { | 152 public int fail1(int value1, int value2) { |
153 throw new AssertionError(); | 153 throw new AssertionError(); |
154 } | 154 } |
155 | 155 |
156 } | 156 } |
163 | 163 |
164 @SuppressWarnings("unused") | 164 @SuppressWarnings("unused") |
165 @NodeChild(value = "genericChild", type = GenericInt.class) | 165 @NodeChild(value = "genericChild", type = GenericInt.class) |
166 public abstract static class TestElseConnectionBug1 extends ValueNode { | 166 public abstract static class TestElseConnectionBug1 extends ValueNode { |
167 | 167 |
168 @Specialization(rewriteOn = {SlowPathException.class}, guards = "isInitialized") | 168 @Specialization(rewriteOn = {SlowPathException.class}, guards = "isInitialized(value)") |
169 public int do1(int value) throws SlowPathException { | 169 public int do1(int value) throws SlowPathException { |
170 throw new SlowPathException(); | 170 throw new SlowPathException(); |
171 } | 171 } |
172 | 172 |
173 @Specialization(contains = "do1", guards = "isInitialized") | 173 @Specialization(contains = "do1", guards = "isInitialized(value)") |
174 public int do2(int value) { | 174 public int do2(int value) { |
175 return value == 42 ? value : 0; | 175 return value == 42 ? value : 0; |
176 } | 176 } |
177 | 177 |
178 @Specialization(guards = "!isInitialized") | 178 @Specialization(guards = "!isInitialized(value)") |
179 public Object do3(int value) { | 179 public Object do3(int value) { |
180 throw new AssertionError(); | 180 throw new AssertionError(); |
181 } | 181 } |
182 | 182 |
183 boolean isInitialized(int value) { | 183 boolean isInitialized(int value) { |
206 | 206 |
207 @SuppressWarnings("unused") | 207 @SuppressWarnings("unused") |
208 @NodeChild | 208 @NodeChild |
209 public abstract static class TestElseConnectionBug2 extends ValueNode { | 209 public abstract static class TestElseConnectionBug2 extends ValueNode { |
210 | 210 |
211 @Specialization(guards = "guard0") | 211 @Specialization(guards = "guard0(value)") |
212 public int do1(int value) { | 212 public int do1(int value) { |
213 throw new AssertionError(); | 213 throw new AssertionError(); |
214 } | 214 } |
215 | 215 |
216 @Specialization(guards = "guard1") | 216 @Specialization(guards = "guard1(value)") |
217 public int do2(int value) { | 217 public int do2(int value) { |
218 throw new AssertionError(); | 218 throw new AssertionError(); |
219 } | 219 } |
220 | 220 |
221 @Specialization(guards = "!guard0") | 221 @Specialization(guards = "!guard0(value)") |
222 public int do3(int value) { | 222 public int do3(int value) { |
223 return value; | 223 return value; |
224 } | 224 } |
225 | 225 |
226 boolean guard0(int value) { | 226 boolean guard0(int value) { |