Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerAsserts.java @ 19524:9c4168877444
Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 20 Feb 2015 13:58:56 +0100 |
parents | da9b9b625818 |
children | 98d7ecef3657 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerAsserts.java Fri Feb 20 01:15:31 2015 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerAsserts.java Fri Feb 20 13:58:56 2015 +0100 @@ -32,7 +32,6 @@ * */ public class CompilerAsserts { - /** * Assertion that this code position should never be reached during compilation. It can be used * for exceptional code paths or rare code paths that should never be included in a compilation @@ -40,98 +39,29 @@ * directive. */ public static void neverPartOfCompilation() { - } - - public static void neverPartOfCompilation(@SuppressWarnings("unused") String message) { - } - - /** - * Assertion that the corresponding value is reduced to a constant during compilation. - * - * @param value the value that must be constant during compilation - * @return the value given as parameter - */ - public static boolean compilationConstant(boolean value) { - return value; + neverPartOfCompilation(""); } /** - * Assertion that the corresponding value is reduced to a constant during compilation. + * Assertion that this code position should never be reached during compilation. It can be used + * for exceptional code paths or rare code paths that should never be included in a compilation + * unit. See {@link CompilerDirectives#transferToInterpreter()} for the corresponding compiler + * directive. * - * @param value the value that must be constant during compilation - * @return the value given as parameter + * @param message text associated with the bailout exception */ - public static byte compilationConstant(byte value) { - return value; - } - - /** - * Assertion that the corresponding value is reduced to a constant during compilation. - * - * @param value the value that must be constant during compilation - * @return the value given as parameter - */ - public static char compilationConstant(char value) { - return value; + public static void neverPartOfCompilation(String message) { + CompilerDirectives.bailout(message); } /** * Assertion that the corresponding value is reduced to a constant during compilation. * * @param value the value that must be constant during compilation - * @return the value given as parameter */ - public static short compilationConstant(short value) { - return value; - } - - /** - * Assertion that the corresponding value is reduced to a constant during compilation. - * - * @param value the value that must be constant during compilation - * @return the value given as parameter - */ - public static int compilationConstant(int value) { - return value; - } - - /** - * Assertion that the corresponding value is reduced to a constant during compilation. - * - * @param value the value that must be constant during compilation - * @return the value given as parameter - */ - public static long compilationConstant(long value) { - return value; - } - - /** - * Assertion that the corresponding value is reduced to a constant during compilation. - * - * @param value the value that must be constant during compilation - * @return the value given as parameter - */ - public static float compilationConstant(float value) { - return value; - } - - /** - * Assertion that the corresponding value is reduced to a constant during compilation. - * - * @param value the value that must be constant during compilation - * @return the value given as parameter - */ - public static double compilationConstant(double value) { - return value; - } - - /** - * Assertion that the corresponding value is reduced to a constant during compilation. - * - * @param value the value that must be constant during compilation - * @return the value given as parameter - */ - public static Object compilationConstant(Object value) { - return value; + public static <T> void compilationConstant(Object value) { + if (!CompilerDirectives.isCompilationConstant(value)) { + neverPartOfCompilation("Value is not compilation constant"); + } } }