Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java @ 11303:28da427847c5
New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 14 Aug 2013 11:52:15 +0200 |
parents | 494b818b527c |
children | da412706d0fd |
comparison
equal
deleted
inserted
replaced
11301:8bcae501c51b | 11303:28da427847c5 |
---|---|
150 public static <T> T unsafeCast(Object value, Class<T> clazz) { | 150 public static <T> T unsafeCast(Object value, Class<T> clazz) { |
151 return (T) value; | 151 return (T) value; |
152 } | 152 } |
153 | 153 |
154 /** | 154 /** |
155 * Associates the given type token with the given value for the case that condition is true. | |
156 * | |
157 * @param condition the custom type check | |
158 * @param value the value that is of the given custom type after the check | |
159 * @param customType the custom type that should be associated with the value | |
160 * @return the type check condition | |
161 */ | |
162 public static boolean customTypeCheck(boolean condition, Object value, Object customType) { | |
163 return condition; | |
164 } | |
165 | |
166 /** | |
167 * Treats the given value as a value of the given class. The class must evaluate to a constant. | |
168 * If the compiler can prove that the given value is of the given custom type, the cast is safe. | |
169 * | |
170 * @param value the value that is known to have the specified type | |
171 * @param clazz the specified type of the value | |
172 * @param customType the custom type that if present on a value makes this unsafe cast safe | |
173 * @return the value | |
174 */ | |
175 @SuppressWarnings("unchecked") | |
176 @Unsafe | |
177 public static <T> T unsafeCast(Object value, Class<T> clazz, Object customType) { | |
178 return (T) value; | |
179 } | |
180 | |
181 /** | |
182 * Proxies a sun.misc.Unsafe instance into an instance that adds a custom location identity on | |
183 * its accesses. This means that the accesses on these kind of location identities can only | |
184 * alias among themselves. It also allows to specify a custom type for the receiver values of | |
185 * follow-up unsafe accesses. Both the custom type and the location identity must evaluate to a | |
186 * constant. Furthermore, you should use the new sun.misc.Unsafe instance immediately for one | |
187 * read or write access via a sun.misc.Unsafe method and not store it anywhere. | |
188 * | |
189 * @param unsafe the instance of sun.misc.Unsafe | |
190 * @param customType the expected type of the receiver object of follow-up unsafe accesses | |
191 * @param locationIdentity the location identity token that can be used for improved global | |
192 * value numbering or null | |
193 * @return the accessed value | |
194 */ | |
195 @Unsafe | |
196 public static sun.misc.Unsafe unsafeCustomization(sun.misc.Unsafe unsafe, Object customType, Object locationIdentity) { | |
197 return unsafe; | |
198 } | |
199 | |
200 /** | |
155 * Marks methods that are considered slowpath and should therefore not be inlined by default. | 201 * Marks methods that are considered slowpath and should therefore not be inlined by default. |
156 */ | 202 */ |
157 @Retention(RetentionPolicy.RUNTIME) | 203 @Retention(RetentionPolicy.RUNTIME) |
158 @Target({ElementType.METHOD}) | 204 @Target({ElementType.METHOD}) |
159 public @interface SlowPath { | 205 public @interface SlowPath { |