comparison 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
comparison
equal deleted inserted replaced
19519:108fbab4e0e8 19524:9c4168877444
30 * code generation and the Truffle compiler produces for failing assertions a stack trace that 30 * code generation and the Truffle compiler produces for failing assertions a stack trace that
31 * identifies the code position of the assertion in the context of the current compilation. 31 * identifies the code position of the assertion in the context of the current compilation.
32 * 32 *
33 */ 33 */
34 public class CompilerAsserts { 34 public class CompilerAsserts {
35
36 /** 35 /**
37 * Assertion that this code position should never be reached during compilation. It can be used 36 * Assertion that this code position should never be reached during compilation. It can be used
38 * for exceptional code paths or rare code paths that should never be included in a compilation 37 * for exceptional code paths or rare code paths that should never be included in a compilation
39 * unit. See {@link CompilerDirectives#transferToInterpreter()} for the corresponding compiler 38 * unit. See {@link CompilerDirectives#transferToInterpreter()} for the corresponding compiler
40 * directive. 39 * directive.
41 */ 40 */
42 public static void neverPartOfCompilation() { 41 public static void neverPartOfCompilation() {
42 neverPartOfCompilation("");
43 } 43 }
44 44
45 public static void neverPartOfCompilation(@SuppressWarnings("unused") String message) { 45 /**
46 * Assertion that this code position should never be reached during compilation. It can be used
47 * for exceptional code paths or rare code paths that should never be included in a compilation
48 * unit. See {@link CompilerDirectives#transferToInterpreter()} for the corresponding compiler
49 * directive.
50 *
51 * @param message text associated with the bailout exception
52 */
53 public static void neverPartOfCompilation(String message) {
54 CompilerDirectives.bailout(message);
46 } 55 }
47 56
48 /** 57 /**
49 * Assertion that the corresponding value is reduced to a constant during compilation. 58 * Assertion that the corresponding value is reduced to a constant during compilation.
50 * 59 *
51 * @param value the value that must be constant during compilation 60 * @param value the value that must be constant during compilation
52 * @return the value given as parameter
53 */ 61 */
54 public static boolean compilationConstant(boolean value) { 62 public static <T> void compilationConstant(Object value) {
55 return value; 63 if (!CompilerDirectives.isCompilationConstant(value)) {
56 } 64 neverPartOfCompilation("Value is not compilation constant");
57 65 }
58 /**
59 * Assertion that the corresponding value is reduced to a constant during compilation.
60 *
61 * @param value the value that must be constant during compilation
62 * @return the value given as parameter
63 */
64 public static byte compilationConstant(byte value) {
65 return value;
66 }
67
68 /**
69 * Assertion that the corresponding value is reduced to a constant during compilation.
70 *
71 * @param value the value that must be constant during compilation
72 * @return the value given as parameter
73 */
74 public static char compilationConstant(char value) {
75 return value;
76 }
77
78 /**
79 * Assertion that the corresponding value is reduced to a constant during compilation.
80 *
81 * @param value the value that must be constant during compilation
82 * @return the value given as parameter
83 */
84 public static short compilationConstant(short value) {
85 return value;
86 }
87
88 /**
89 * Assertion that the corresponding value is reduced to a constant during compilation.
90 *
91 * @param value the value that must be constant during compilation
92 * @return the value given as parameter
93 */
94 public static int compilationConstant(int value) {
95 return value;
96 }
97
98 /**
99 * Assertion that the corresponding value is reduced to a constant during compilation.
100 *
101 * @param value the value that must be constant during compilation
102 * @return the value given as parameter
103 */
104 public static long compilationConstant(long value) {
105 return value;
106 }
107
108 /**
109 * Assertion that the corresponding value is reduced to a constant during compilation.
110 *
111 * @param value the value that must be constant during compilation
112 * @return the value given as parameter
113 */
114 public static float compilationConstant(float value) {
115 return value;
116 }
117
118 /**
119 * Assertion that the corresponding value is reduced to a constant during compilation.
120 *
121 * @param value the value that must be constant during compilation
122 * @return the value given as parameter
123 */
124 public static double compilationConstant(double value) {
125 return value;
126 }
127
128 /**
129 * Assertion that the corresponding value is reduced to a constant during compilation.
130 *
131 * @param value the value that must be constant during compilation
132 * @return the value given as parameter
133 */
134 public static Object compilationConstant(Object value) {
135 return value;
136 } 66 }
137 } 67 }