author | alanb |
Thu, 01 Dec 2016 08:57:53 +0000 | |
changeset 42338 | a60f280f803c |
parent 40734 | 48879ea67e2a |
child 45518 | 4a116dd82fb5 |
permissions | -rw-r--r-- |
36934 | 1 |
/* |
2 |
* Copyright (c) 2015, 2016, 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 java.lang.invoke; |
|
26 |
||
27 |
import jdk.internal.misc.Unsafe; |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
28 |
import jdk.internal.util.Preconditions; |
36934 | 29 |
import jdk.internal.vm.annotation.ForceInline; |
30 |
||
31 |
import java.nio.ByteBuffer; |
|
32 |
import java.nio.ReadOnlyBufferException; |
|
33 |
import java.util.Objects; |
|
34 |
||
35 |
import static java.lang.invoke.MethodHandleStatics.UNSAFE; |
|
36 |
||
37 |
#warn |
|
38 |
||
39 |
final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { |
|
40 |
||
41 |
static final int ALIGN = $BoxType$.BYTES - 1; |
|
42 |
||
43 |
#if[floatingPoint] |
|
44 |
@ForceInline |
|
45 |
static $rawType$ convEndian(boolean big, $type$ v) { |
|
46 |
$rawType$ rv = $Type$.$type$ToRaw$RawType$Bits(v); |
|
47 |
return big == BE ? rv : $RawBoxType$.reverseBytes(rv); |
|
48 |
} |
|
49 |
||
50 |
@ForceInline |
|
51 |
static $type$ convEndian(boolean big, $rawType$ rv) { |
|
52 |
rv = big == BE ? rv : $RawBoxType$.reverseBytes(rv); |
|
53 |
return $Type$.$rawType$BitsTo$Type$(rv); |
|
54 |
} |
|
55 |
#else[floatingPoint] |
|
56 |
@ForceInline |
|
57 |
static $type$ convEndian(boolean big, $type$ n) { |
|
58 |
return big == BE ? n : $BoxType$.reverseBytes(n); |
|
59 |
} |
|
60 |
#end[floatingPoint] |
|
61 |
||
62 |
||
37792 | 63 |
private static abstract class ByteArrayViewVarHandle extends VarHandle { |
36934 | 64 |
final boolean be; |
65 |
||
37792 | 66 |
ByteArrayViewVarHandle(VarForm form, boolean be) { |
67 |
super(form); |
|
36934 | 68 |
this.be = be; |
69 |
} |
|
70 |
} |
|
71 |
||
72 |
static final class ArrayHandle extends ByteArrayViewVarHandle { |
|
73 |
||
74 |
ArrayHandle(boolean be) { |
|
37792 | 75 |
super(ArrayHandle.FORM, be); |
76 |
} |
|
77 |
||
78 |
@Override |
|
79 |
final MethodType accessModeTypeUncached(AccessMode accessMode) { |
|
80 |
return accessMode.at.accessModeType(byte[].class, $type$.class, int.class); |
|
36934 | 81 |
} |
82 |
||
83 |
@ForceInline |
|
84 |
static int index(byte[] ba, int index) { |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
85 |
return Preconditions.checkIndex(index, ba.length - ALIGN, null); |
36934 | 86 |
} |
87 |
||
88 |
@ForceInline |
|
89 |
static long address(byte[] ba, int index) { |
|
90 |
long address = ((long) index) + Unsafe.ARRAY_BYTE_BASE_OFFSET; |
|
91 |
if ((address & ALIGN) != 0) |
|
92 |
throw newIllegalStateExceptionForMisalignedAccess(index); |
|
93 |
return address; |
|
94 |
} |
|
95 |
||
96 |
@ForceInline |
|
97 |
static $type$ get(ArrayHandle handle, Object oba, int index) { |
|
98 |
byte[] ba = (byte[]) oba; |
|
99 |
#if[floatingPoint] |
|
100 |
$rawType$ rawValue = UNSAFE.get$RawType$Unaligned( |
|
101 |
ba, |
|
102 |
((long) index(ba, index)) + Unsafe.ARRAY_BYTE_BASE_OFFSET, |
|
103 |
handle.be); |
|
104 |
return $Type$.$rawType$BitsTo$Type$(rawValue); |
|
105 |
#else[floatingPoint] |
|
106 |
return UNSAFE.get$Type$Unaligned( |
|
107 |
ba, |
|
108 |
((long) index(ba, index)) + Unsafe.ARRAY_BYTE_BASE_OFFSET, |
|
109 |
handle.be); |
|
110 |
#end[floatingPoint] |
|
111 |
} |
|
112 |
||
113 |
@ForceInline |
|
114 |
static void set(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
115 |
byte[] ba = (byte[]) oba; |
|
116 |
#if[floatingPoint] |
|
117 |
UNSAFE.put$RawType$Unaligned( |
|
118 |
ba, |
|
119 |
((long) index(ba, index)) + Unsafe.ARRAY_BYTE_BASE_OFFSET, |
|
120 |
$Type$.$type$ToRaw$RawType$Bits(value), |
|
121 |
handle.be); |
|
122 |
#else[floatingPoint] |
|
123 |
UNSAFE.put$RawType$Unaligned( |
|
124 |
ba, |
|
125 |
((long) index(ba, index)) + Unsafe.ARRAY_BYTE_BASE_OFFSET, |
|
126 |
value, |
|
127 |
handle.be); |
|
128 |
#end[floatingPoint] |
|
129 |
} |
|
130 |
||
131 |
@ForceInline |
|
132 |
static $type$ getVolatile(ArrayHandle handle, Object oba, int index) { |
|
133 |
byte[] ba = (byte[]) oba; |
|
134 |
return convEndian(handle.be, |
|
135 |
UNSAFE.get$RawType$Volatile( |
|
136 |
ba, |
|
137 |
address(ba, index(ba, index)))); |
|
138 |
} |
|
139 |
||
140 |
@ForceInline |
|
141 |
static void setVolatile(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
142 |
byte[] ba = (byte[]) oba; |
|
143 |
UNSAFE.put$RawType$Volatile( |
|
144 |
ba, |
|
145 |
address(ba, index(ba, index)), |
|
146 |
convEndian(handle.be, value)); |
|
147 |
} |
|
148 |
||
149 |
@ForceInline |
|
150 |
static $type$ getAcquire(ArrayHandle handle, Object oba, int index) { |
|
151 |
byte[] ba = (byte[]) oba; |
|
152 |
return convEndian(handle.be, |
|
153 |
UNSAFE.get$RawType$Acquire( |
|
154 |
ba, |
|
155 |
address(ba, index(ba, index)))); |
|
156 |
} |
|
157 |
||
158 |
@ForceInline |
|
159 |
static void setRelease(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
160 |
byte[] ba = (byte[]) oba; |
|
161 |
UNSAFE.put$RawType$Release( |
|
162 |
ba, |
|
163 |
address(ba, index(ba, index)), |
|
164 |
convEndian(handle.be, value)); |
|
165 |
} |
|
166 |
||
167 |
@ForceInline |
|
168 |
static $type$ getOpaque(ArrayHandle handle, Object oba, int index) { |
|
169 |
byte[] ba = (byte[]) oba; |
|
170 |
return convEndian(handle.be, |
|
171 |
UNSAFE.get$RawType$Opaque( |
|
172 |
ba, |
|
173 |
address(ba, index(ba, index)))); |
|
174 |
} |
|
175 |
||
176 |
@ForceInline |
|
177 |
static void setOpaque(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
178 |
byte[] ba = (byte[]) oba; |
|
179 |
UNSAFE.put$RawType$Opaque( |
|
180 |
ba, |
|
181 |
address(ba, index(ba, index)), |
|
182 |
convEndian(handle.be, value)); |
|
183 |
} |
|
184 |
#if[CAS] |
|
185 |
||
186 |
@ForceInline |
|
187 |
static boolean compareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { |
|
188 |
byte[] ba = (byte[]) oba; |
|
189 |
return UNSAFE.compareAndSwap$RawType$( |
|
190 |
ba, |
|
191 |
address(ba, index(ba, index)), |
|
192 |
convEndian(handle.be, expected), convEndian(handle.be, value)); |
|
193 |
} |
|
194 |
||
195 |
@ForceInline |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
38382
diff
changeset
|
196 |
static $type$ compareAndExchange(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { |
36934 | 197 |
byte[] ba = (byte[]) oba; |
198 |
return convEndian(handle.be, |
|
199 |
UNSAFE.compareAndExchange$RawType$Volatile( |
|
200 |
ba, |
|
201 |
address(ba, index(ba, index)), |
|
202 |
convEndian(handle.be, expected), convEndian(handle.be, value))); |
|
203 |
} |
|
204 |
||
205 |
@ForceInline |
|
206 |
static $type$ compareAndExchangeAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { |
|
207 |
byte[] ba = (byte[]) oba; |
|
208 |
return convEndian(handle.be, |
|
209 |
UNSAFE.compareAndExchange$RawType$Acquire( |
|
210 |
ba, |
|
211 |
address(ba, index(ba, index)), |
|
212 |
convEndian(handle.be, expected), convEndian(handle.be, value))); |
|
213 |
} |
|
214 |
||
215 |
@ForceInline |
|
216 |
static $type$ compareAndExchangeRelease(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { |
|
217 |
byte[] ba = (byte[]) oba; |
|
218 |
return convEndian(handle.be, |
|
219 |
UNSAFE.compareAndExchange$RawType$Release( |
|
220 |
ba, |
|
221 |
address(ba, index(ba, index)), |
|
222 |
convEndian(handle.be, expected), convEndian(handle.be, value))); |
|
223 |
} |
|
224 |
||
225 |
@ForceInline |
|
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
226 |
static boolean weakCompareAndSetPlain(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { |
36934 | 227 |
byte[] ba = (byte[]) oba; |
228 |
return UNSAFE.weakCompareAndSwap$RawType$( |
|
229 |
ba, |
|
230 |
address(ba, index(ba, index)), |
|
231 |
convEndian(handle.be, expected), convEndian(handle.be, value)); |
|
232 |
} |
|
233 |
||
234 |
@ForceInline |
|
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
235 |
static boolean weakCompareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { |
37719
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
236 |
byte[] ba = (byte[]) oba; |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38367
diff
changeset
|
237 |
return UNSAFE.weakCompareAndSwap$RawType$Volatile( |
37719
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
238 |
ba, |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
239 |
address(ba, index(ba, index)), |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
240 |
convEndian(handle.be, expected), convEndian(handle.be, value)); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
241 |
} |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
242 |
|
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
243 |
@ForceInline |
36934 | 244 |
static boolean weakCompareAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { |
245 |
byte[] ba = (byte[]) oba; |
|
246 |
return UNSAFE.weakCompareAndSwap$RawType$Acquire( |
|
247 |
ba, |
|
248 |
address(ba, index(ba, index)), |
|
249 |
convEndian(handle.be, expected), convEndian(handle.be, value)); |
|
250 |
} |
|
251 |
||
252 |
@ForceInline |
|
253 |
static boolean weakCompareAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { |
|
254 |
byte[] ba = (byte[]) oba; |
|
255 |
return UNSAFE.weakCompareAndSwap$RawType$Release( |
|
256 |
ba, |
|
257 |
address(ba, index(ba, index)), |
|
258 |
convEndian(handle.be, expected), convEndian(handle.be, value)); |
|
259 |
} |
|
260 |
||
261 |
@ForceInline |
|
262 |
static $type$ getAndSet(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
263 |
byte[] ba = (byte[]) oba; |
|
264 |
return convEndian(handle.be, |
|
265 |
UNSAFE.getAndSet$RawType$( |
|
266 |
ba, |
|
267 |
address(ba, index(ba, index)), |
|
268 |
convEndian(handle.be, value))); |
|
269 |
} |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
270 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
271 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
272 |
static $type$ getAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
273 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
274 |
return convEndian(handle.be, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
275 |
UNSAFE.getAndSet$RawType$Acquire( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
276 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
277 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
278 |
convEndian(handle.be, value))); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
279 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
280 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
281 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
282 |
static $type$ getAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
283 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
284 |
return convEndian(handle.be, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
285 |
UNSAFE.getAndSet$RawType$Release( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
286 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
287 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
288 |
convEndian(handle.be, value))); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
289 |
} |
36934 | 290 |
#end[CAS] |
291 |
#if[AtomicAdd] |
|
292 |
||
293 |
@ForceInline |
|
38382
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
294 |
static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ delta) { |
36934 | 295 |
byte[] ba = (byte[]) oba; |
38382
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
296 |
if (handle.be == BE) { |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
297 |
return UNSAFE.getAndAdd$RawType$( |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
298 |
ba, |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
299 |
address(ba, index(ba, index)), |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
300 |
delta); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
301 |
} else { |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
302 |
return getAndAddConvEndianWithCAS(ba, index, delta); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
303 |
} |
36934 | 304 |
} |
305 |
||
306 |
@ForceInline |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
307 |
static $type$ getAndAddAcquire(ArrayHandle handle, Object oba, int index, $type$ delta) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
308 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
309 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
310 |
return UNSAFE.getAndAdd$RawType$Acquire( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
311 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
312 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
313 |
delta); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
314 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
315 |
return getAndAddConvEndianWithCAS(ba, index, delta); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
316 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
317 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
318 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
319 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
320 |
static $type$ getAndAddRelease(ArrayHandle handle, Object oba, int index, $type$ delta) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
321 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
322 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
323 |
return UNSAFE.getAndAdd$RawType$Release( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
324 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
325 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
326 |
delta); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
327 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
328 |
return getAndAddConvEndianWithCAS(ba, index, delta); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
329 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
330 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
331 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
332 |
@ForceInline |
38382
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
333 |
static $type$ getAndAddConvEndianWithCAS(byte[] ba, int index, $type$ delta) { |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
334 |
$type$ nativeExpectedValue, expectedValue; |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
335 |
long offset = address(ba, index(ba, index)); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
336 |
do { |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
337 |
nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
338 |
expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
339 |
} while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
340 |
nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
341 |
return expectedValue; |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
342 |
} |
36934 | 343 |
#end[AtomicAdd] |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
344 |
#if[Bitwise] |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
345 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
346 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
347 |
static $type$ getAndBitwiseOr(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
348 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
349 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
350 |
return UNSAFE.getAndBitwiseOr$RawType$( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
351 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
352 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
353 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
354 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
355 |
return getAndBitwiseOrConvEndianWithCAS(ba, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
356 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
357 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
358 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
359 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
360 |
static $type$ getAndBitwiseOrRelease(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
361 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
362 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
363 |
return UNSAFE.getAndBitwiseOr$RawType$Release( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
364 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
365 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
366 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
367 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
368 |
return getAndBitwiseOrConvEndianWithCAS(ba, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
369 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
370 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
371 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
372 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
373 |
static $type$ getAndBitwiseOrAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
374 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
375 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
376 |
return UNSAFE.getAndBitwiseOr$RawType$Acquire( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
377 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
378 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
379 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
380 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
381 |
return getAndBitwiseOrConvEndianWithCAS(ba, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
382 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
383 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
384 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
385 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
386 |
static $type$ getAndBitwiseOrConvEndianWithCAS(byte[] ba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
387 |
$type$ nativeExpectedValue, expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
388 |
long offset = address(ba, index(ba, index)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
389 |
do { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
390 |
nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
391 |
expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
392 |
} while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
393 |
nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
394 |
return expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
395 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
396 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
397 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
398 |
static $type$ getAndBitwiseAnd(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
399 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
400 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
401 |
return UNSAFE.getAndBitwiseAnd$RawType$( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
402 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
403 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
404 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
405 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
406 |
return getAndBitwiseAndConvEndianWithCAS(ba, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
407 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
408 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
409 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
410 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
411 |
static $type$ getAndBitwiseAndRelease(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
412 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
413 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
414 |
return UNSAFE.getAndBitwiseAnd$RawType$Release( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
415 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
416 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
417 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
418 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
419 |
return getAndBitwiseAndConvEndianWithCAS(ba, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
420 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
421 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
422 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
423 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
424 |
static $type$ getAndBitwiseAndAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
425 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
426 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
427 |
return UNSAFE.getAndBitwiseAnd$RawType$Acquire( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
428 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
429 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
430 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
431 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
432 |
return getAndBitwiseAndConvEndianWithCAS(ba, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
433 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
434 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
435 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
436 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
437 |
static $type$ getAndBitwiseAndConvEndianWithCAS(byte[] ba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
438 |
$type$ nativeExpectedValue, expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
439 |
long offset = address(ba, index(ba, index)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
440 |
do { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
441 |
nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
442 |
expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
443 |
} while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
444 |
nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
445 |
return expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
446 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
447 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
448 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
449 |
static $type$ getAndBitwiseXor(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
450 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
451 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
452 |
return UNSAFE.getAndBitwiseXor$RawType$( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
453 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
454 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
455 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
456 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
457 |
return getAndBitwiseXorConvEndianWithCAS(ba, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
458 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
459 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
460 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
461 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
462 |
static $type$ getAndBitwiseXorRelease(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
463 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
464 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
465 |
return UNSAFE.getAndBitwiseXor$RawType$Release( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
466 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
467 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
468 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
469 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
470 |
return getAndBitwiseXorConvEndianWithCAS(ba, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
471 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
472 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
473 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
474 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
475 |
static $type$ getAndBitwiseXorAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
476 |
byte[] ba = (byte[]) oba; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
477 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
478 |
return UNSAFE.getAndBitwiseXor$RawType$Acquire( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
479 |
ba, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
480 |
address(ba, index(ba, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
481 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
482 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
483 |
return getAndBitwiseXorConvEndianWithCAS(ba, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
484 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
485 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
486 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
487 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
488 |
static $type$ getAndBitwiseXorConvEndianWithCAS(byte[] ba, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
489 |
$type$ nativeExpectedValue, expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
490 |
long offset = address(ba, index(ba, index)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
491 |
do { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
492 |
nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
493 |
expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
494 |
} while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
495 |
nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
496 |
return expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
497 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
498 |
#end[Bitwise] |
37792 | 499 |
|
500 |
static final VarForm FORM = new VarForm(ArrayHandle.class, byte[].class, $type$.class, int.class); |
|
36934 | 501 |
} |
502 |
||
503 |
||
504 |
static final class ByteBufferHandle extends ByteArrayViewVarHandle { |
|
505 |
||
506 |
ByteBufferHandle(boolean be) { |
|
37792 | 507 |
super(ByteBufferHandle.FORM, be); |
508 |
} |
|
509 |
||
510 |
@Override |
|
511 |
final MethodType accessModeTypeUncached(AccessMode accessMode) { |
|
512 |
return accessMode.at.accessModeType(ByteBuffer.class, $type$.class, int.class); |
|
36934 | 513 |
} |
514 |
||
515 |
@ForceInline |
|
516 |
static int index(ByteBuffer bb, int index) { |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
517 |
return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null); |
36934 | 518 |
} |
519 |
||
520 |
@ForceInline |
|
521 |
static int indexRO(ByteBuffer bb, int index) { |
|
522 |
if (UNSAFE.getBoolean(bb, BYTE_BUFFER_IS_READ_ONLY)) |
|
523 |
throw new ReadOnlyBufferException(); |
|
38356
1e4ecca97792
8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
psandoz
parents:
36934
diff
changeset
|
524 |
return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null); |
36934 | 525 |
} |
526 |
||
527 |
@ForceInline |
|
528 |
static long address(ByteBuffer bb, int index) { |
|
529 |
long address = ((long) index) + UNSAFE.getLong(bb, BUFFER_ADDRESS); |
|
530 |
if ((address & ALIGN) != 0) |
|
531 |
throw newIllegalStateExceptionForMisalignedAccess(index); |
|
532 |
return address; |
|
533 |
} |
|
534 |
||
535 |
@ForceInline |
|
536 |
static $type$ get(ByteBufferHandle handle, Object obb, int index) { |
|
537 |
ByteBuffer bb = (ByteBuffer) obb; |
|
538 |
#if[floatingPoint] |
|
539 |
$rawType$ rawValue = UNSAFE.get$RawType$Unaligned( |
|
540 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
541 |
((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS), |
|
542 |
handle.be); |
|
543 |
return $Type$.$rawType$BitsTo$Type$(rawValue); |
|
544 |
#else[floatingPoint] |
|
545 |
return UNSAFE.get$Type$Unaligned( |
|
546 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
547 |
((long) index(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS), |
|
548 |
handle.be); |
|
549 |
#end[floatingPoint] |
|
550 |
} |
|
551 |
||
552 |
@ForceInline |
|
553 |
static void set(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
554 |
ByteBuffer bb = (ByteBuffer) obb; |
|
555 |
#if[floatingPoint] |
|
556 |
UNSAFE.put$RawType$Unaligned( |
|
557 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
558 |
((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS), |
|
559 |
$Type$.$type$ToRaw$RawType$Bits(value), |
|
560 |
handle.be); |
|
561 |
#else[floatingPoint] |
|
562 |
UNSAFE.put$Type$Unaligned( |
|
563 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
564 |
((long) indexRO(bb, index)) + UNSAFE.getLong(bb, BUFFER_ADDRESS), |
|
565 |
value, |
|
566 |
handle.be); |
|
567 |
#end[floatingPoint] |
|
568 |
} |
|
569 |
||
570 |
@ForceInline |
|
571 |
static $type$ getVolatile(ByteBufferHandle handle, Object obb, int index) { |
|
572 |
ByteBuffer bb = (ByteBuffer) obb; |
|
573 |
return convEndian(handle.be, |
|
574 |
UNSAFE.get$RawType$Volatile( |
|
575 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
576 |
address(bb, index(bb, index)))); |
|
577 |
} |
|
578 |
||
579 |
@ForceInline |
|
580 |
static void setVolatile(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
581 |
ByteBuffer bb = (ByteBuffer) obb; |
|
582 |
UNSAFE.put$RawType$Volatile( |
|
583 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
584 |
address(bb, indexRO(bb, index)), |
|
585 |
convEndian(handle.be, value)); |
|
586 |
} |
|
587 |
||
588 |
@ForceInline |
|
589 |
static $type$ getAcquire(ByteBufferHandle handle, Object obb, int index) { |
|
590 |
ByteBuffer bb = (ByteBuffer) obb; |
|
591 |
return convEndian(handle.be, |
|
592 |
UNSAFE.get$RawType$Acquire( |
|
593 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
594 |
address(bb, index(bb, index)))); |
|
595 |
} |
|
596 |
||
597 |
@ForceInline |
|
598 |
static void setRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
599 |
ByteBuffer bb = (ByteBuffer) obb; |
|
600 |
UNSAFE.put$RawType$Release( |
|
601 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
602 |
address(bb, indexRO(bb, index)), |
|
603 |
convEndian(handle.be, value)); |
|
604 |
} |
|
605 |
||
606 |
@ForceInline |
|
607 |
static $type$ getOpaque(ByteBufferHandle handle, Object obb, int index) { |
|
608 |
ByteBuffer bb = (ByteBuffer) obb; |
|
609 |
return convEndian(handle.be, |
|
610 |
UNSAFE.get$RawType$Opaque( |
|
611 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
612 |
address(bb, index(bb, index)))); |
|
613 |
} |
|
614 |
||
615 |
@ForceInline |
|
616 |
static void setOpaque(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
617 |
ByteBuffer bb = (ByteBuffer) obb; |
|
618 |
UNSAFE.put$RawType$Opaque( |
|
619 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
620 |
address(bb, indexRO(bb, index)), |
|
621 |
convEndian(handle.be, value)); |
|
622 |
} |
|
623 |
#if[CAS] |
|
624 |
||
625 |
@ForceInline |
|
626 |
static boolean compareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { |
|
627 |
ByteBuffer bb = (ByteBuffer) obb; |
|
628 |
return UNSAFE.compareAndSwap$RawType$( |
|
629 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
630 |
address(bb, indexRO(bb, index)), |
|
631 |
convEndian(handle.be, expected), convEndian(handle.be, value)); |
|
632 |
} |
|
633 |
||
634 |
@ForceInline |
|
39472
6df82f4c63ac
8154737: Rename VarHandle.compareAndExchangeVolatile to VarHandle.compareAndExchange
psandoz
parents:
38382
diff
changeset
|
635 |
static $type$ compareAndExchange(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { |
36934 | 636 |
ByteBuffer bb = (ByteBuffer) obb; |
637 |
return convEndian(handle.be, |
|
638 |
UNSAFE.compareAndExchange$RawType$Volatile( |
|
639 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
640 |
address(bb, indexRO(bb, index)), |
|
641 |
convEndian(handle.be, expected), convEndian(handle.be, value))); |
|
642 |
} |
|
643 |
||
644 |
@ForceInline |
|
645 |
static $type$ compareAndExchangeAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { |
|
646 |
ByteBuffer bb = (ByteBuffer) obb; |
|
647 |
return convEndian(handle.be, |
|
648 |
UNSAFE.compareAndExchange$RawType$Acquire( |
|
649 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
650 |
address(bb, indexRO(bb, index)), |
|
651 |
convEndian(handle.be, expected), convEndian(handle.be, value))); |
|
652 |
} |
|
653 |
||
654 |
@ForceInline |
|
655 |
static $type$ compareAndExchangeRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { |
|
656 |
ByteBuffer bb = (ByteBuffer) obb; |
|
657 |
return convEndian(handle.be, |
|
658 |
UNSAFE.compareAndExchange$RawType$Release( |
|
659 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
660 |
address(bb, indexRO(bb, index)), |
|
661 |
convEndian(handle.be, expected), convEndian(handle.be, value))); |
|
662 |
} |
|
663 |
||
664 |
@ForceInline |
|
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
665 |
static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { |
36934 | 666 |
ByteBuffer bb = (ByteBuffer) obb; |
667 |
return UNSAFE.weakCompareAndSwap$RawType$( |
|
668 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
669 |
address(bb, indexRO(bb, index)), |
|
670 |
convEndian(handle.be, expected), convEndian(handle.be, value)); |
|
671 |
} |
|
672 |
||
673 |
@ForceInline |
|
40734
48879ea67e2a
8162108: Rename weakCompareAndSetVolatile to weakCompareAndSet
psandoz
parents:
40733
diff
changeset
|
674 |
static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { |
37719
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
675 |
ByteBuffer bb = (ByteBuffer) obb; |
38372
017d7578731c
8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles
shade
parents:
38367
diff
changeset
|
676 |
return UNSAFE.weakCompareAndSwap$RawType$Volatile( |
37719
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
677 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
678 |
address(bb, indexRO(bb, index)), |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
679 |
convEndian(handle.be, expected), convEndian(handle.be, value)); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
680 |
} |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
681 |
|
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
36934
diff
changeset
|
682 |
@ForceInline |
36934 | 683 |
static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { |
684 |
ByteBuffer bb = (ByteBuffer) obb; |
|
685 |
return UNSAFE.weakCompareAndSwap$RawType$Acquire( |
|
686 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
687 |
address(bb, indexRO(bb, index)), |
|
688 |
convEndian(handle.be, expected), convEndian(handle.be, value)); |
|
689 |
} |
|
690 |
||
691 |
@ForceInline |
|
692 |
static boolean weakCompareAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { |
|
693 |
ByteBuffer bb = (ByteBuffer) obb; |
|
694 |
return UNSAFE.weakCompareAndSwap$RawType$Release( |
|
695 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
696 |
address(bb, indexRO(bb, index)), |
|
697 |
convEndian(handle.be, expected), convEndian(handle.be, value)); |
|
698 |
} |
|
699 |
||
700 |
@ForceInline |
|
701 |
static $type$ getAndSet(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
702 |
ByteBuffer bb = (ByteBuffer) obb; |
|
703 |
return convEndian(handle.be, |
|
704 |
UNSAFE.getAndSet$RawType$( |
|
705 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
706 |
address(bb, indexRO(bb, index)), |
|
707 |
convEndian(handle.be, value))); |
|
708 |
} |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
709 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
710 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
711 |
static $type$ getAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
712 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
713 |
return convEndian(handle.be, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
714 |
UNSAFE.getAndSet$RawType$Acquire( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
715 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
716 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
717 |
convEndian(handle.be, value))); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
718 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
719 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
720 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
721 |
static $type$ getAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
722 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
723 |
return convEndian(handle.be, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
724 |
UNSAFE.getAndSet$RawType$Release( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
725 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
726 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
727 |
convEndian(handle.be, value))); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
728 |
} |
36934 | 729 |
#end[CAS] |
730 |
#if[AtomicAdd] |
|
731 |
||
732 |
@ForceInline |
|
38382
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
733 |
static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ delta) { |
36934 | 734 |
ByteBuffer bb = (ByteBuffer) obb; |
38382
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
735 |
if (handle.be == BE) { |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
736 |
return UNSAFE.getAndAdd$RawType$( |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
737 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
738 |
address(bb, indexRO(bb, index)), |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
739 |
delta); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
740 |
} else { |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
741 |
return getAndAddConvEndianWithCAS(bb, index, delta); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
742 |
} |
36934 | 743 |
} |
744 |
||
745 |
@ForceInline |
|
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
746 |
static $type$ getAndAddAcquire(ByteBufferHandle handle, Object obb, int index, $type$ delta) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
747 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
748 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
749 |
return UNSAFE.getAndAdd$RawType$Acquire( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
750 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
751 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
752 |
delta); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
753 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
754 |
return getAndAddConvEndianWithCAS(bb, index, delta); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
755 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
756 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
757 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
758 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
759 |
static $type$ getAndAddRelease(ByteBufferHandle handle, Object obb, int index, $type$ delta) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
760 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
761 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
762 |
return UNSAFE.getAndAdd$RawType$Release( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
763 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
764 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
765 |
delta); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
766 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
767 |
return getAndAddConvEndianWithCAS(bb, index, delta); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
768 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
769 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
770 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
771 |
@ForceInline |
38382
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
772 |
static $type$ getAndAddConvEndianWithCAS(ByteBuffer bb, int index, $type$ delta) { |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
773 |
$type$ nativeExpectedValue, expectedValue; |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
774 |
Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
775 |
long offset = address(bb, indexRO(bb, index)); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
776 |
do { |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
777 |
nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
778 |
expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
779 |
} while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
780 |
nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
781 |
return expectedValue; |
98d5a441bc2f
8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
psandoz
parents:
38372
diff
changeset
|
782 |
} |
36934 | 783 |
#end[AtomicAdd] |
40732
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
784 |
#if[Bitwise] |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
785 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
786 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
787 |
static $type$ getAndBitwiseOr(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
788 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
789 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
790 |
return UNSAFE.getAndBitwiseOr$RawType$( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
791 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
792 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
793 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
794 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
795 |
return getAndBitwiseOrConvEndianWithCAS(bb, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
796 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
797 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
798 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
799 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
800 |
static $type$ getAndBitwiseOrRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
801 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
802 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
803 |
return UNSAFE.getAndBitwiseOr$RawType$Release( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
804 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
805 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
806 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
807 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
808 |
return getAndBitwiseOrConvEndianWithCAS(bb, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
809 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
810 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
811 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
812 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
813 |
static $type$ getAndBitwiseOrAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
814 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
815 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
816 |
return UNSAFE.getAndBitwiseOr$RawType$Acquire( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
817 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
818 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
819 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
820 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
821 |
return getAndBitwiseOrConvEndianWithCAS(bb, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
822 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
823 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
824 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
825 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
826 |
static $type$ getAndBitwiseOrConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
827 |
$type$ nativeExpectedValue, expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
828 |
Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
829 |
long offset = address(bb, indexRO(bb, index)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
830 |
do { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
831 |
nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
832 |
expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
833 |
} while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
834 |
nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
835 |
return expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
836 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
837 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
838 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
839 |
static $type$ getAndBitwiseAnd(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
840 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
841 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
842 |
return UNSAFE.getAndBitwiseAnd$RawType$( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
843 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
844 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
845 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
846 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
847 |
return getAndBitwiseAndConvEndianWithCAS(bb, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
848 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
849 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
850 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
851 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
852 |
static $type$ getAndBitwiseAndRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
853 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
854 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
855 |
return UNSAFE.getAndBitwiseAnd$RawType$Release( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
856 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
857 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
858 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
859 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
860 |
return getAndBitwiseAndConvEndianWithCAS(bb, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
861 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
862 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
863 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
864 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
865 |
static $type$ getAndBitwiseAndAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
866 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
867 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
868 |
return UNSAFE.getAndBitwiseAnd$RawType$Acquire( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
869 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
870 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
871 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
872 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
873 |
return getAndBitwiseAndConvEndianWithCAS(bb, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
874 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
875 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
876 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
877 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
878 |
static $type$ getAndBitwiseAndConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
879 |
$type$ nativeExpectedValue, expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
880 |
Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
881 |
long offset = address(bb, indexRO(bb, index)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
882 |
do { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
883 |
nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
884 |
expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
885 |
} while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
886 |
nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
887 |
return expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
888 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
889 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
890 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
891 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
892 |
static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
893 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
894 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
895 |
return UNSAFE.getAndBitwiseXor$RawType$( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
896 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
897 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
898 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
899 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
900 |
return getAndBitwiseXorConvEndianWithCAS(bb, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
901 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
902 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
903 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
904 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
905 |
static $type$ getAndBitwiseXorRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
906 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
907 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
908 |
return UNSAFE.getAndBitwiseXor$RawType$Release( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
909 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
910 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
911 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
912 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
913 |
return getAndBitwiseXorConvEndianWithCAS(bb, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
914 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
915 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
916 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
917 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
918 |
static $type$ getAndBitwiseXorAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
919 |
ByteBuffer bb = (ByteBuffer) obb; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
920 |
if (handle.be == BE) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
921 |
return UNSAFE.getAndBitwiseXor$RawType$Acquire( |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
922 |
UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
923 |
address(bb, indexRO(bb, index)), |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
924 |
value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
925 |
} else { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
926 |
return getAndBitwiseXorConvEndianWithCAS(bb, index, value); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
927 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
928 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
929 |
|
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
930 |
@ForceInline |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
931 |
static $type$ getAndBitwiseXorConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
932 |
$type$ nativeExpectedValue, expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
933 |
Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
934 |
long offset = address(bb, indexRO(bb, index)); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
935 |
do { |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
936 |
nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
937 |
expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
938 |
} while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
939 |
nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
940 |
return expectedValue; |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
941 |
} |
2fd9cf42bb3c
8161444: VarHandles should provide access bitwise atomics
psandoz
parents:
39472
diff
changeset
|
942 |
#end[Bitwise] |
37792 | 943 |
|
944 |
static final VarForm FORM = new VarForm(ByteBufferHandle.class, ByteBuffer.class, $type$.class, int.class); |
|
36934 | 945 |
} |
946 |
} |