Mercurial > hg > truffle
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java @ 17444:2834b4432586
Truffle: introduce CompilerDirectives.isCompilationConstant.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 14 Oct 2014 20:02:44 +0200 |
parents | ada0a7729b6f |
children | b4e38f4ca414 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java Tue Oct 14 20:02:44 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java Tue Oct 14 20:02:44 2014 +0200 @@ -99,6 +99,32 @@ } /** + * Returns a boolean indicating whether or not a given value is seen as constant in optimized + * code. If this method is called in the interpreter this method will always return + * <code>false</code>. This API may be used in combination with {@link #inCompiledCode()} to + * implement compilation constant assertions in the following way: + * + * <pre> + * <code> + * void assertCompilationConstant(Object value) { + * if (inCompiledCode()) { + * if (!isCompilationConstant(value)) { + * throw new AssertionError("Given value is not constant"); + * } + * } + * } + * </code> + * </pre> + * + * @param value + * @return {@code true} when given value is seen as compilation constant, {@code false} if not + * compilation constant. + */ + public static boolean isCompilationConstant(Object value) { + return false; + } + + /** * Directive for the compiler that the given runnable should only be executed in the interpreter * and ignored in the compiled code. *