Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Specialization.java @ 19300:67ab244ab689
Truffle-DSL: fix formatting issues.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 11 Feb 2015 18:33:49 +0100 |
parents | 3a37116ef37f |
children | 48bdad77afcd |
comparison
equal
deleted
inserted
replaced
19299:8e4f683e16d9 | 19300:67ab244ab689 |
---|---|
156 * <pre> | 156 * <pre> |
157 * @Specialization(rewriteOn = ArithmeticException.class) | 157 * @Specialization(rewriteOn = ArithmeticException.class) |
158 * int doAddNoOverflow(int a, int b) { | 158 * int doAddNoOverflow(int a, int b) { |
159 * return ExactMath.addExact(a, b); | 159 * return ExactMath.addExact(a, b); |
160 * } | 160 * } |
161 * | |
162 * @Specialization | 161 * @Specialization |
163 * long doAddWithOverflow(int a, int b) { | 162 * long doAddWithOverflow(int a, int b) { |
164 * return a + b; | 163 * return a + b; |
165 * } | 164 * } |
166 * ... | 165 * ... |
167 * | |
168 * Example executions: | 166 * Example executions: |
169 * execute(Integer.MAX_VALUE - 1, 1) => doAddNoOverflow(Integer.MAX_VALUE - 1, 1) | 167 * execute(Integer.MAX_VALUE - 1, 1) => doAddNoOverflow(Integer.MAX_VALUE - 1, 1) |
170 * execute(Integer.MAX_VALUE, 1) => doAddNoOverflow(Integer.MAX_VALUE, 1) | 168 * execute(Integer.MAX_VALUE, 1) => doAddNoOverflow(Integer.MAX_VALUE, 1) |
171 * => throws ArithmeticException | 169 * => throws ArithmeticException |
172 * => doAddWithOverflow(Integer.MAX_VALUE, 1) | 170 * => doAddWithOverflow(Integer.MAX_VALUE, 1) |
194 * <pre> | 192 * <pre> |
195 * @Specialization(guards = "b == 2") | 193 * @Specialization(guards = "b == 2") |
196 * void doDivPowerTwo(int a, int b) { | 194 * void doDivPowerTwo(int a, int b) { |
197 * return a >> 1; | 195 * return a >> 1; |
198 * } | 196 * } |
199 * | |
200 * @Specialization(contains ="doDivPowerTwo", guards = "b > 0") | 197 * @Specialization(contains ="doDivPowerTwo", guards = "b > 0") |
201 * void doDivPositive(int a, int b) { | 198 * void doDivPositive(int a, int b) { |
202 * return a / b; | 199 * return a / b; |
203 * } | 200 * } |
204 * ... | 201 * ... |
205 * | |
206 * Example executions with contains="doDivPowerTwo": | 202 * Example executions with contains="doDivPowerTwo": |
207 * execute(4, 2) => doDivPowerTwo(4, 2) | 203 * execute(4, 2) => doDivPowerTwo(4, 2) |
208 * execute(9, 3) => doDivPositive(9, 3) // doDivPowerTwo instances get removed | 204 * execute(9, 3) => doDivPositive(9, 3) // doDivPowerTwo instances get removed |
209 * execute(4, 2) => doDivPositive(4, 2) | 205 * execute(4, 2) => doDivPositive(4, 2) |
210 * | |
211 * Same executions without contains="doDivPowerTwo" | 206 * Same executions without contains="doDivPowerTwo" |
212 * execute(4, 2) => doDivPowerTwo(4, 2) | 207 * execute(4, 2) => doDivPowerTwo(4, 2) |
213 * execute(9, 3) => doDivPositive(9, 3) | 208 * execute(9, 3) => doDivPositive(9, 3) |
214 * execute(4, 2) => doDivPowerTwo(4, 2) | 209 * execute(4, 2) => doDivPowerTwo(4, 2) |
215 * </pre> | 210 * </pre> |
251 * <pre> | 246 * <pre> |
252 * static boolean acceptOperand(int operand) { | 247 * static boolean acceptOperand(int operand) { |
253 * assert operand <= 42; | 248 * assert operand <= 42; |
254 * return operand & 1 == 1; | 249 * return operand & 1 == 1; |
255 * } | 250 * } |
256 * | |
257 * @Specialization(guards = {"operand <= 42", "acceptOperand(operand)"}) | 251 * @Specialization(guards = {"operand <= 42", "acceptOperand(operand)"}) |
258 * void doSpecialization(int operand) {...} | 252 * void doSpecialization(int operand) {...} |
259 * </pre> | 253 * </pre> |
260 * | 254 * |
261 * </p> | 255 * </p> |
299 * } | 293 * } |
300 * static abstract class Shape() { | 294 * static abstract class Shape() { |
301 * abstract Assumption getUnmodifiedAssuption(); | 295 * abstract Assumption getUnmodifiedAssuption(); |
302 * ... | 296 * ... |
303 * } | 297 * } |
304 * | |
305 * @Specialization(guards = "operand.getShape() == cachedShape", assumptions = "cachedShape.getUnmodifiedAssumption()") | 298 * @Specialization(guards = "operand.getShape() == cachedShape", assumptions = "cachedShape.getUnmodifiedAssumption()") |
306 * void doAssumeUnmodifiedShape(DynamicObject operand, @Cached("operand.getShape()") Shape cachedShape) {...} | 299 * void doAssumeUnmodifiedShape(DynamicObject operand, @Cached("operand.getShape()") Shape cachedShape) {...} |
307 * </pre> | 300 * </pre> |
308 * | 301 * |
309 * </p> | 302 * </p> |
343 * | 336 * |
344 * <pre> | 337 * <pre> |
345 * static int getCacheLimit() { | 338 * static int getCacheLimit() { |
346 * return Integer.parseInt(System.getProperty("language.cacheLimit")); | 339 * return Integer.parseInt(System.getProperty("language.cacheLimit")); |
347 * } | 340 * } |
348 * | |
349 * @Specialization(guards = "operand == cachedOperand", limit = "getCacheLimit()") | 341 * @Specialization(guards = "operand == cachedOperand", limit = "getCacheLimit()") |
350 * void doCached(Object operand, @Cached("operand") Object cachedOperand) {...} | 342 * void doCached(Object operand, @Cached("operand") Object cachedOperand) {...} |
351 * </pre> | 343 * </pre> |
352 * | 344 * |
353 * </p> | 345 * </p> |