comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerAsserts.java @ 9244:8f540423a5be

Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 23 Apr 2013 11:20:53 +0200
parents
children 494b818b527c
comparison
equal deleted inserted replaced
9243:136cc8fd8890 9244:8f540423a5be
1 /*
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package com.oracle.truffle.api;
24
25 /**
26 * Assertions about the code produced by the Truffle compiler. All operations have no effect when
27 * either executed in the interpreter or in the compiled code. The assertions are checked during
28 * code generation and the Truffle compiler produces for failing assertions a stack trace that
29 * identifies the code position of the assertion in the context of the current compilation.
30 *
31 */
32 public class CompilerAsserts {
33
34 /**
35 * Assertion that this code position should never be reached during compilation. It can be used
36 * for exceptional code paths or rare code paths that should never be included in a compilation
37 * unit. See {@link CompilerDirectives#transferToInterpreter()} for the corresponding compiler
38 * directive.
39 */
40 public static void neverPartOfCompilation() {
41 }
42
43 /**
44 * Assertion that the corresponding value is reduced to a constant during compilation.
45 *
46 * @param value the value that must be constant during compilation
47 * @return the value given as parameter
48 */
49 public static boolean compilationConstant(boolean value) {
50 return value;
51 }
52
53 /**
54 * Assertion that the corresponding value is reduced to a constant during compilation.
55 *
56 * @param value the value that must be constant during compilation
57 * @return the value given as parameter
58 */
59 public static byte compilationConstant(byte value) {
60 return value;
61 }
62
63 /**
64 * Assertion that the corresponding value is reduced to a constant during compilation.
65 *
66 * @param value the value that must be constant during compilation
67 * @return the value given as parameter
68 */
69 public static char compilationConstant(char value) {
70 return value;
71 }
72
73 /**
74 * Assertion that the corresponding value is reduced to a constant during compilation.
75 *
76 * @param value the value that must be constant during compilation
77 * @return the value given as parameter
78 */
79 public static short compilationConstant(short value) {
80 return value;
81 }
82
83 /**
84 * Assertion that the corresponding value is reduced to a constant during compilation.
85 *
86 * @param value the value that must be constant during compilation
87 * @return the value given as parameter
88 */
89 public static int compilationConstant(int value) {
90 return value;
91 }
92
93 /**
94 * Assertion that the corresponding value is reduced to a constant during compilation.
95 *
96 * @param value the value that must be constant during compilation
97 * @return the value given as parameter
98 */
99 public static long compilationConstant(long value) {
100 return value;
101 }
102
103 /**
104 * Assertion that the corresponding value is reduced to a constant during compilation.
105 *
106 * @param value the value that must be constant during compilation
107 * @return the value given as parameter
108 */
109 public static float compilationConstant(float value) {
110 return value;
111 }
112
113 /**
114 * Assertion that the corresponding value is reduced to a constant during compilation.
115 *
116 * @param value the value that must be constant during compilation
117 * @return the value given as parameter
118 */
119 public static double compilationConstant(double value) {
120 return value;
121 }
122
123 /**
124 * Assertion that the corresponding value is reduced to a constant during compilation.
125 *
126 * @param value the value that must be constant during compilation
127 * @return the value given as parameter
128 */
129 public static Object compilationConstant(Object value) {
130 return value;
131 }
132 }