Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/unsafe/UnsafeAccess.java @ 19309:c386ace07981
Truffle: move unsafe access methods out of CompilerDirectives
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Wed, 11 Feb 2015 18:19:40 +0100 |
parents | |
children | 3b2fd35f41b0 |
comparison
equal
deleted
inserted
replaced
19308:5b2589732c45 | 19309:c386ace07981 |
---|---|
1 /* | |
2 * Copyright (c) 2013, 2015, 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. Oracle designates this | |
8 * particular file as subject to the "Classpath" exception as provided | |
9 * by Oracle in the LICENSE file that accompanied this code. | |
10 * | |
11 * This code is distributed in the hope that it will be useful, but WITHOUT | |
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 * version 2 for more details (a copy is included in the LICENSE file that | |
15 * accompanied this code). | |
16 * | |
17 * You should have received a copy of the GNU General Public License version | |
18 * 2 along with this work; if not, write to the Free Software Foundation, | |
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
20 * | |
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
22 * or visit www.oracle.com if you need additional information or have any | |
23 * questions. | |
24 */ | |
25 package com.oracle.truffle.api.unsafe; | |
26 | |
27 public interface UnsafeAccess { | |
28 | |
29 /** | |
30 * Casts the given value to the value of the given type without any checks. The class must | |
31 * evaluate to a constant. The condition parameter gives a hint to the compiler under which | |
32 * circumstances this cast can be moved to an earlier location in the program. | |
33 * | |
34 * @param value the value that is known to have the specified type | |
35 * @param type the specified new type of the value | |
36 * @param condition the condition that makes this cast safe also at an earlier location of the | |
37 * program | |
38 * @param nonNull whether value is known to never be null | |
39 * @return the value to be casted to the new type | |
40 */ | |
41 <T> T uncheckedCast(Object value, Class<T> type, boolean condition, boolean nonNull); | |
42 | |
43 /** | |
44 * Unsafe access to a boolean value within an object. The condition parameter gives a hint to | |
45 * the compiler under which circumstances this access can be moved to an earlier location in the | |
46 * program. The location identity gives a hint to the compiler for improved global value | |
47 * numbering. | |
48 * | |
49 * @param receiver the object that is accessed | |
50 * @param offset the offset at which to access the object in bytes | |
51 * @param condition the condition that makes this access safe also at an earlier location in the | |
52 * program | |
53 * @param locationIdentity the location identity token that can be used for improved global | |
54 * value numbering or null | |
55 * @return the accessed value | |
56 */ | |
57 boolean getBoolean(Object receiver, long offset, boolean condition, Object locationIdentity); | |
58 | |
59 /** | |
60 * Unsafe access to a byte value within an object. The condition parameter gives a hint to the | |
61 * compiler under which circumstances this access can be moved to an earlier location in the | |
62 * program. The location identity gives a hint to the compiler for improved global value | |
63 * numbering. | |
64 * | |
65 * @param receiver the object that is accessed | |
66 * @param offset the offset at which to access the object in bytes | |
67 * @param condition the condition that makes this access safe also at an earlier location in the | |
68 * program | |
69 * @param locationIdentity the location identity token that can be used for improved global | |
70 * value numbering or null | |
71 * @return the accessed value | |
72 */ | |
73 byte getByte(Object receiver, long offset, boolean condition, Object locationIdentity); | |
74 | |
75 /** | |
76 * Unsafe access to a short value within an object. The condition parameter gives a hint to the | |
77 * compiler under which circumstances this access can be moved to an earlier location in the | |
78 * program. The location identity gives a hint to the compiler for improved global value | |
79 * numbering. | |
80 * | |
81 * @param receiver the object that is accessed | |
82 * @param offset the offset at which to access the object in bytes | |
83 * @param condition the condition that makes this access safe also at an earlier location in the | |
84 * program | |
85 * @param locationIdentity the location identity token that can be used for improved global | |
86 * value numbering or null | |
87 * @return the accessed value | |
88 */ | |
89 short getShort(Object receiver, long offset, boolean condition, Object locationIdentity); | |
90 | |
91 /** | |
92 * Unsafe access to an int value within an object. The condition parameter gives a hint to the | |
93 * compiler under which circumstances this access can be moved to an earlier location in the | |
94 * program. The location identity gives a hint to the compiler for improved global value | |
95 * numbering. | |
96 * | |
97 * @param receiver the object that is accessed | |
98 * @param offset the offset at which to access the object in bytes | |
99 * @param condition the condition that makes this access safe also at an earlier location in the | |
100 * program | |
101 * @param locationIdentity the location identity token that can be used for improved global | |
102 * value numbering or null | |
103 * @return the accessed value | |
104 */ | |
105 int getInt(Object receiver, long offset, boolean condition, Object locationIdentity); | |
106 | |
107 /** | |
108 * Unsafe access to a long value within an object. The condition parameter gives a hint to the | |
109 * compiler under which circumstances this access can be moved to an earlier location in the | |
110 * program. The location identity gives a hint to the compiler for improved global value | |
111 * numbering. | |
112 * | |
113 * @param receiver the object that is accessed | |
114 * @param offset the offset at which to access the object in bytes | |
115 * @param condition the condition that makes this access safe also at an earlier location in the | |
116 * program | |
117 * @param locationIdentity the location identity token that can be used for improved global | |
118 * value numbering or null | |
119 * @return the accessed value | |
120 */ | |
121 long getLong(Object receiver, long offset, boolean condition, Object locationIdentity); | |
122 | |
123 /** | |
124 * Unsafe access to a float value within an object. The condition parameter gives a hint to the | |
125 * compiler under which circumstances this access can be moved to an earlier location in the | |
126 * program. The location identity gives a hint to the compiler for improved global value | |
127 * numbering. | |
128 * | |
129 * @param receiver the object that is accessed | |
130 * @param offset the offset at which to access the object in bytes | |
131 * @param condition the condition that makes this access safe also at an earlier location in the | |
132 * program | |
133 * @param locationIdentity the location identity token that can be used for improved global | |
134 * value numbering or null | |
135 * @return the accessed value | |
136 */ | |
137 float getFloat(Object receiver, long offset, boolean condition, Object locationIdentity); | |
138 | |
139 /** | |
140 * Unsafe access to a double value within an object. The condition parameter gives a hint to the | |
141 * compiler under which circumstances this access can be moved to an earlier location in the | |
142 * program. The location identity gives a hint to the compiler for improved global value | |
143 * numbering. | |
144 * | |
145 * @param receiver the object that is accessed | |
146 * @param offset the offset at which to access the object in bytes | |
147 * @param condition the condition that makes this access safe also at an earlier location in the | |
148 * program | |
149 * @param locationIdentity the location identity token that can be used for improved global | |
150 * value numbering or null | |
151 * @return the accessed value | |
152 */ | |
153 double getDouble(Object receiver, long offset, boolean condition, Object locationIdentity); | |
154 | |
155 /** | |
156 * Unsafe access to an Object value within an object. The condition parameter gives a hint to | |
157 * the compiler under which circumstances this access can be moved to an earlier location in the | |
158 * program. The location identity gives a hint to the compiler for improved global value | |
159 * numbering. | |
160 * | |
161 * @param receiver the object that is accessed | |
162 * @param offset the offset at which to access the object in bytes | |
163 * @param condition the condition that makes this access safe also at an earlier location in the | |
164 * program | |
165 * @param locationIdentity the location identity token that can be used for improved global | |
166 * value numbering or null | |
167 * @return the accessed value | |
168 */ | |
169 Object getObject(Object receiver, long offset, boolean condition, Object locationIdentity); | |
170 | |
171 /** | |
172 * Write a boolean value within an object. The location identity gives a hint to the compiler | |
173 * for improved global value numbering. | |
174 * | |
175 * @param receiver the object that is written to | |
176 * @param offset the offset at which to write to the object in bytes | |
177 * @param value the value to be written | |
178 * @param locationIdentity the location identity token that can be used for improved global | |
179 * value numbering or null | |
180 */ | |
181 void putBoolean(Object receiver, long offset, boolean value, Object locationIdentity); | |
182 | |
183 /** | |
184 * Write a byte value within an object. The location identity gives a hint to the compiler for | |
185 * improved global value numbering. | |
186 * | |
187 * @param receiver the object that is written to | |
188 * @param offset the offset at which to write to the object in bytes | |
189 * @param value the value to be written | |
190 * @param locationIdentity the location identity token that can be used for improved global | |
191 * value numbering or null | |
192 */ | |
193 void putByte(Object receiver, long offset, byte value, Object locationIdentity); | |
194 | |
195 /** | |
196 * Write a short value within an object. The location identity gives a hint to the compiler for | |
197 * improved global value numbering. | |
198 * | |
199 * @param receiver the object that is written to | |
200 * @param offset the offset at which to write to the object in bytes | |
201 * @param value the value to be written | |
202 * @param locationIdentity the location identity token that can be used for improved global | |
203 * value numbering or null | |
204 */ | |
205 void putShort(Object receiver, long offset, short value, Object locationIdentity); | |
206 | |
207 /** | |
208 * Write an int value within an object. The location identity gives a hint to the compiler for | |
209 * improved global value numbering. | |
210 * | |
211 * @param receiver the object that is written to | |
212 * @param offset the offset at which to write to the object in bytes | |
213 * @param value the value to be written | |
214 * @param locationIdentity the location identity token that can be used for improved global | |
215 * value numbering or null | |
216 */ | |
217 void putInt(Object receiver, long offset, int value, Object locationIdentity); | |
218 | |
219 /** | |
220 * Write a long value within an object. The location identity gives a hint to the compiler for | |
221 * improved global value numbering. | |
222 * | |
223 * @param receiver the object that is written to | |
224 * @param offset the offset at which to write to the object in bytes | |
225 * @param value the value to be written | |
226 * @param locationIdentity the location identity token that can be used for improved global | |
227 * value numbering or null | |
228 */ | |
229 void putLong(Object receiver, long offset, long value, Object locationIdentity); | |
230 | |
231 /** | |
232 * Write a float value within an object. The location identity gives a hint to the compiler for | |
233 * improved global value numbering. | |
234 * | |
235 * @param receiver the object that is written to | |
236 * @param offset the offset at which to write to the object in bytes | |
237 * @param value the value to be written | |
238 * @param locationIdentity the location identity token that can be used for improved global | |
239 * value numbering or null | |
240 */ | |
241 void putFloat(Object receiver, long offset, float value, Object locationIdentity); | |
242 | |
243 /** | |
244 * Write a double value within an object. The location identity gives a hint to the compiler for | |
245 * improved global value numbering. | |
246 * | |
247 * @param receiver the object that is written to | |
248 * @param offset the offset at which to write to the object in bytes | |
249 * @param value the value to be written | |
250 * @param locationIdentity the location identity token that can be used for improved global | |
251 * value numbering or null | |
252 */ | |
253 void putDouble(Object receiver, long offset, double value, Object locationIdentity); | |
254 | |
255 /** | |
256 * Write an Object value within an object. The location identity gives a hint to the compiler | |
257 * for improved global value numbering. | |
258 * | |
259 * @param receiver the object that is written to | |
260 * @param offset the offset at which to write to the object in bytes | |
261 * @param value the value to be written | |
262 * @param locationIdentity the location identity token that can be used for improved global | |
263 * value numbering or null | |
264 */ | |
265 void putObject(Object receiver, long offset, Object value, Object locationIdentity); | |
266 | |
267 /** | |
268 * Unsafe access to a final boolean value within an object. The condition parameter gives a hint | |
269 * to the compiler under which circumstances this access can be moved to an earlier location in | |
270 * the program. The location identity gives a hint to the compiler for improved global value | |
271 * numbering. | |
272 * | |
273 * @param receiver the object that is accessed | |
274 * @param offset the offset at which to access the object in bytes | |
275 * @param condition the condition that makes this access safe also at an earlier location in the | |
276 * program | |
277 * @param locationIdentity the location identity token that can be used for improved global | |
278 * value numbering or null | |
279 * @return the accessed value | |
280 */ | |
281 boolean getFinalBoolean(Object receiver, long offset, boolean condition, Object locationIdentity); | |
282 | |
283 /** | |
284 * Unsafe access to a final byte value within an object. The condition parameter gives a hint to | |
285 * the compiler under which circumstances this access can be moved to an earlier location in the | |
286 * program. The location identity gives a hint to the compiler for improved global value | |
287 * numbering. | |
288 * | |
289 * @param receiver the object that is accessed | |
290 * @param offset the offset at which to access the object in bytes | |
291 * @param condition the condition that makes this access safe also at an earlier location in the | |
292 * program | |
293 * @param locationIdentity the location identity token that can be used for improved global | |
294 * value numbering or null | |
295 * @return the accessed value | |
296 */ | |
297 byte getFinalByte(Object receiver, long offset, boolean condition, Object locationIdentity); | |
298 | |
299 /** | |
300 * Unsafe access to a final short value within an object. The condition parameter gives a hint | |
301 * to the compiler under which circumstances this access can be moved to an earlier location in | |
302 * the program. The location identity gives a hint to the compiler for improved global value | |
303 * numbering. | |
304 * | |
305 * @param receiver the object that is accessed | |
306 * @param offset the offset at which to access the object in bytes | |
307 * @param condition the condition that makes this access safe also at an earlier location in the | |
308 * program | |
309 * @param locationIdentity the location identity token that can be used for improved global | |
310 * value numbering or null | |
311 * @return the accessed value | |
312 */ | |
313 short getFinalShort(Object receiver, long offset, boolean condition, Object locationIdentity); | |
314 | |
315 /** | |
316 * Unsafe access to a final int value within an object. The condition parameter gives a hint to | |
317 * the compiler under which circumstances this access can be moved to an earlier location in the | |
318 * program. The location identity gives a hint to the compiler for improved global value | |
319 * numbering. | |
320 * | |
321 * @param receiver the object that is accessed | |
322 * @param offset the offset at which to access the object in bytes | |
323 * @param condition the condition that makes this access safe also at an earlier location in the | |
324 * program | |
325 * @param locationIdentity the location identity token that can be used for improved global | |
326 * value numbering or null | |
327 * @return the accessed value | |
328 */ | |
329 int getFinalInt(Object receiver, long offset, boolean condition, Object locationIdentity); | |
330 | |
331 /** | |
332 * Unsafe access to a final long value within an object. The condition parameter gives a hint to | |
333 * the compiler under which circumstances this access can be moved to an earlier location in the | |
334 * program. The location identity gives a hint to the compiler for improved global value | |
335 * numbering. | |
336 * | |
337 * @param receiver the object that is accessed | |
338 * @param offset the offset at which to access the object in bytes | |
339 * @param condition the condition that makes this access safe also at an earlier location in the | |
340 * program | |
341 * @param locationIdentity the location identity token that can be used for improved global | |
342 * value numbering or null | |
343 * @return the accessed value | |
344 */ | |
345 long getFinalLong(Object receiver, long offset, boolean condition, Object locationIdentity); | |
346 | |
347 /** | |
348 * Unsafe access to a final float value within an object. The condition parameter gives a hint | |
349 * to the compiler under which circumstances this access can be moved to an earlier location in | |
350 * the program. The location identity gives a hint to the compiler for improved global value | |
351 * numbering. | |
352 * | |
353 * @param receiver the object that is accessed | |
354 * @param offset the offset at which to access the object in bytes | |
355 * @param condition the condition that makes this access safe also at an earlier location in the | |
356 * program | |
357 * @param locationIdentity the location identity token that can be used for improved global | |
358 * value numbering or null | |
359 * @return the accessed value | |
360 */ | |
361 float getFinalFloat(Object receiver, long offset, boolean condition, Object locationIdentity); | |
362 | |
363 /** | |
364 * Unsafe access to a final double value within an object. The condition parameter gives a hint | |
365 * to the compiler under which circumstances this access can be moved to an earlier location in | |
366 * the program. The location identity gives a hint to the compiler for improved global value | |
367 * numbering. | |
368 * | |
369 * @param receiver the object that is accessed | |
370 * @param offset the offset at which to access the object in bytes | |
371 * @param condition the condition that makes this access safe also at an earlier location in the | |
372 * program | |
373 * @param locationIdentity the location identity token that can be used for improved global | |
374 * value numbering or null | |
375 * @return the accessed value | |
376 */ | |
377 double getFinalDouble(Object receiver, long offset, boolean condition, Object locationIdentity); | |
378 | |
379 /** | |
380 * Unsafe access to a final Object value within an object. The condition parameter gives a hint | |
381 * to the compiler under which circumstances this access can be moved to an earlier location in | |
382 * the program. The location identity gives a hint to the compiler for improved global value | |
383 * numbering. | |
384 * | |
385 * @param receiver the object that is accessed | |
386 * @param offset the offset at which to access the object in bytes | |
387 * @param condition the condition that makes this access safe also at an earlier location in the | |
388 * program | |
389 * @param locationIdentity the location identity token that can be used for improved global | |
390 * value numbering or null | |
391 * @return the accessed value | |
392 */ | |
393 Object getFinalObject(Object receiver, long offset, boolean condition, Object locationIdentity); | |
394 } |