Mercurial > hg > truffle
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java @ 11312:f0c8303cf88e
Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 16 Aug 2013 01:09:03 +0200 |
parents | da412706d0fd |
children | 760e838b3560 |
comparison
equal
deleted
inserted
replaced
11311:c08d8fd6aa19 | 11312:f0c8303cf88e |
---|---|
143 * | 143 * |
144 * @param value the value that is known to have the specified type | 144 * @param value the value that is known to have the specified type |
145 * @param clazz the specified type of the value | 145 * @param clazz the specified type of the value |
146 * @return the value | 146 * @return the value |
147 */ | 147 */ |
148 @SuppressWarnings("unchecked") | |
149 @Unsafe | 148 @Unsafe |
150 public static <T> T unsafeCast(Object value, Class<T> clazz) { | 149 public static <T> T unsafeCast(Object value, Class<T> clazz) { |
151 return (T) value; | 150 return unsafeCast(value, clazz, null); |
152 } | 151 } |
153 | 152 |
154 /** | 153 /** |
155 * Associates the given type token with the given value for the case that condition is true. | 154 * Associates the given type token with the given value for the case that condition is true. |
156 * | 155 * |
170 * @param value the value that is known to have the specified type | 169 * @param value the value that is known to have the specified type |
171 * @param clazz the specified type of the value | 170 * @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 | 171 * @param customType the custom type that if present on a value makes this unsafe cast safe |
173 * @return the value | 172 * @return the value |
174 */ | 173 */ |
174 @SuppressWarnings("unchecked") | |
175 @Unsafe | 175 @Unsafe |
176 public static <T> T unsafeCast(Object value, Class<T> clazz, Object customType) { | 176 public static <T> T unsafeCast(Object value, Class<T> clazz, Object customType) { |
177 return unsafeCast(value, clazz); | 177 return (T) value; |
178 } | 178 } |
179 | 179 |
180 /** | 180 /** |
181 * Proxies a sun.misc.Unsafe instance into an instance that adds a custom location identity on | 181 * Proxies an object instance into an instance that adds a custom location identity on its |
182 * its accesses. This means that the accesses on these kind of location identities can only | 182 * accesses via sun.misc.Unsafe. This means that the accesses on these kind of location |
183 * alias among themselves. It also allows to specify a custom type for the receiver values of | 183 * identities can only alias among themselves. It also allows to specify a custom type for the |
184 * follow-up unsafe accesses. Both the custom type and the location identity must evaluate to a | 184 * receiver values of follow-up unsafe accesses. Both the custom type and the location identity |
185 * constant. Furthermore, you should use the new sun.misc.Unsafe instance immediately for one | 185 * must evaluate to a constant. Furthermore, you should use the proxied receiver object |
186 * read or write access via a sun.misc.Unsafe method and not store it anywhere. | 186 * immediately for one read or write access via a sun.misc.Unsafe method and not store it |
187 * | 187 * anywhere. |
188 * @param unsafe the instance of sun.misc.Unsafe | 188 * |
189 * @param receiver the object that is accessed via sun.misc.Unsafe | |
189 * @param customType the expected type of the receiver object of follow-up unsafe accesses | 190 * @param customType the expected type of the receiver object of follow-up unsafe accesses |
190 * @param locationIdentity the location identity token that can be used for improved global | 191 * @param locationIdentity the location identity token that can be used for improved global |
191 * value numbering or null | 192 * value numbering or null |
192 * @return the accessed value | 193 * @return the accessed value |
193 */ | 194 */ |
194 @Unsafe | 195 @Unsafe |
195 public static sun.misc.Unsafe unsafeCustomization(sun.misc.Unsafe unsafe, Object customType, Object locationIdentity) { | 196 public static Object unsafeCustomization(Object receiver, Object customType, Object locationIdentity) { |
196 return unsafe; | 197 return receiver; |
197 } | 198 } |
198 | 199 |
199 /** | 200 /** |
200 * 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. |
201 */ | 202 */ |