comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/unsafe/UnsafeAccess.java @ 21951:9c8c0937da41

Moving all sources into truffle subdirectory
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 17 Jun 2015 10:58:08 +0200
parents graal/com.oracle.truffle.api/src/com/oracle/truffle/api/unsafe/UnsafeAccess.java@3b2fd35f41b0
children
comparison
equal deleted inserted replaced
21950:2a5011c7e641 21951:9c8c0937da41
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 }