265 UNSAFE.getAndSet$RawType$( |
265 UNSAFE.getAndSet$RawType$( |
266 ba, |
266 ba, |
267 address(ba, index(ba, index)), |
267 address(ba, index(ba, index)), |
268 convEndian(handle.be, value))); |
268 convEndian(handle.be, value))); |
269 } |
269 } |
|
270 |
|
271 @ForceInline |
|
272 static $type$ getAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
273 byte[] ba = (byte[]) oba; |
|
274 return convEndian(handle.be, |
|
275 UNSAFE.getAndSet$RawType$Acquire( |
|
276 ba, |
|
277 address(ba, index(ba, index)), |
|
278 convEndian(handle.be, value))); |
|
279 } |
|
280 |
|
281 @ForceInline |
|
282 static $type$ getAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
283 byte[] ba = (byte[]) oba; |
|
284 return convEndian(handle.be, |
|
285 UNSAFE.getAndSet$RawType$Release( |
|
286 ba, |
|
287 address(ba, index(ba, index)), |
|
288 convEndian(handle.be, value))); |
|
289 } |
270 #end[CAS] |
290 #end[CAS] |
271 #if[AtomicAdd] |
291 #if[AtomicAdd] |
272 |
292 |
273 @ForceInline |
293 @ForceInline |
274 static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ delta) { |
294 static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ delta) { |
275 byte[] ba = (byte[]) oba; |
295 byte[] ba = (byte[]) oba; |
276 if (handle.be == BE) { |
296 if (handle.be == BE) { |
277 return UNSAFE.getAndAdd$RawType$( |
297 return UNSAFE.getAndAdd$RawType$( |
|
298 ba, |
|
299 address(ba, index(ba, index)), |
|
300 delta); |
|
301 } else { |
|
302 return getAndAddConvEndianWithCAS(ba, index, delta); |
|
303 } |
|
304 } |
|
305 |
|
306 @ForceInline |
|
307 static $type$ getAndAddAcquire(ArrayHandle handle, Object oba, int index, $type$ delta) { |
|
308 byte[] ba = (byte[]) oba; |
|
309 if (handle.be == BE) { |
|
310 return UNSAFE.getAndAdd$RawType$Acquire( |
|
311 ba, |
|
312 address(ba, index(ba, index)), |
|
313 delta); |
|
314 } else { |
|
315 return getAndAddConvEndianWithCAS(ba, index, delta); |
|
316 } |
|
317 } |
|
318 |
|
319 @ForceInline |
|
320 static $type$ getAndAddRelease(ArrayHandle handle, Object oba, int index, $type$ delta) { |
|
321 byte[] ba = (byte[]) oba; |
|
322 if (handle.be == BE) { |
|
323 return UNSAFE.getAndAdd$RawType$Release( |
278 ba, |
324 ba, |
279 address(ba, index(ba, index)), |
325 address(ba, index(ba, index)), |
280 delta); |
326 delta); |
281 } else { |
327 } else { |
282 return getAndAddConvEndianWithCAS(ba, index, delta); |
328 return getAndAddConvEndianWithCAS(ba, index, delta); |
298 @ForceInline |
344 @ForceInline |
299 static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ delta) { |
345 static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ delta) { |
300 return getAndAdd(handle, oba, index, delta) + delta; |
346 return getAndAdd(handle, oba, index, delta) + delta; |
301 } |
347 } |
302 #end[AtomicAdd] |
348 #end[AtomicAdd] |
|
349 #if[Bitwise] |
|
350 |
|
351 @ForceInline |
|
352 static $type$ getAndBitwiseOr(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
353 byte[] ba = (byte[]) oba; |
|
354 if (handle.be == BE) { |
|
355 return UNSAFE.getAndBitwiseOr$RawType$( |
|
356 ba, |
|
357 address(ba, index(ba, index)), |
|
358 value); |
|
359 } else { |
|
360 return getAndBitwiseOrConvEndianWithCAS(ba, index, value); |
|
361 } |
|
362 } |
|
363 |
|
364 @ForceInline |
|
365 static $type$ getAndBitwiseOrRelease(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
366 byte[] ba = (byte[]) oba; |
|
367 if (handle.be == BE) { |
|
368 return UNSAFE.getAndBitwiseOr$RawType$Release( |
|
369 ba, |
|
370 address(ba, index(ba, index)), |
|
371 value); |
|
372 } else { |
|
373 return getAndBitwiseOrConvEndianWithCAS(ba, index, value); |
|
374 } |
|
375 } |
|
376 |
|
377 @ForceInline |
|
378 static $type$ getAndBitwiseOrAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
379 byte[] ba = (byte[]) oba; |
|
380 if (handle.be == BE) { |
|
381 return UNSAFE.getAndBitwiseOr$RawType$Acquire( |
|
382 ba, |
|
383 address(ba, index(ba, index)), |
|
384 value); |
|
385 } else { |
|
386 return getAndBitwiseOrConvEndianWithCAS(ba, index, value); |
|
387 } |
|
388 } |
|
389 |
|
390 @ForceInline |
|
391 static $type$ getAndBitwiseOrConvEndianWithCAS(byte[] ba, int index, $type$ value) { |
|
392 $type$ nativeExpectedValue, expectedValue; |
|
393 long offset = address(ba, index(ba, index)); |
|
394 do { |
|
395 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); |
|
396 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
|
397 } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, |
|
398 nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); |
|
399 return expectedValue; |
|
400 } |
|
401 |
|
402 @ForceInline |
|
403 static $type$ getAndBitwiseAnd(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
404 byte[] ba = (byte[]) oba; |
|
405 if (handle.be == BE) { |
|
406 return UNSAFE.getAndBitwiseAnd$RawType$( |
|
407 ba, |
|
408 address(ba, index(ba, index)), |
|
409 value); |
|
410 } else { |
|
411 return getAndBitwiseAndConvEndianWithCAS(ba, index, value); |
|
412 } |
|
413 } |
|
414 |
|
415 @ForceInline |
|
416 static $type$ getAndBitwiseAndRelease(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
417 byte[] ba = (byte[]) oba; |
|
418 if (handle.be == BE) { |
|
419 return UNSAFE.getAndBitwiseAnd$RawType$Release( |
|
420 ba, |
|
421 address(ba, index(ba, index)), |
|
422 value); |
|
423 } else { |
|
424 return getAndBitwiseAndConvEndianWithCAS(ba, index, value); |
|
425 } |
|
426 } |
|
427 |
|
428 @ForceInline |
|
429 static $type$ getAndBitwiseAndAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
430 byte[] ba = (byte[]) oba; |
|
431 if (handle.be == BE) { |
|
432 return UNSAFE.getAndBitwiseAnd$RawType$Acquire( |
|
433 ba, |
|
434 address(ba, index(ba, index)), |
|
435 value); |
|
436 } else { |
|
437 return getAndBitwiseAndConvEndianWithCAS(ba, index, value); |
|
438 } |
|
439 } |
|
440 |
|
441 @ForceInline |
|
442 static $type$ getAndBitwiseAndConvEndianWithCAS(byte[] ba, int index, $type$ value) { |
|
443 $type$ nativeExpectedValue, expectedValue; |
|
444 long offset = address(ba, index(ba, index)); |
|
445 do { |
|
446 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); |
|
447 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
|
448 } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, |
|
449 nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); |
|
450 return expectedValue; |
|
451 } |
|
452 |
|
453 @ForceInline |
|
454 static $type$ getAndBitwiseXor(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
455 byte[] ba = (byte[]) oba; |
|
456 if (handle.be == BE) { |
|
457 return UNSAFE.getAndBitwiseXor$RawType$( |
|
458 ba, |
|
459 address(ba, index(ba, index)), |
|
460 value); |
|
461 } else { |
|
462 return getAndBitwiseXorConvEndianWithCAS(ba, index, value); |
|
463 } |
|
464 } |
|
465 |
|
466 @ForceInline |
|
467 static $type$ getAndBitwiseXorRelease(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
468 byte[] ba = (byte[]) oba; |
|
469 if (handle.be == BE) { |
|
470 return UNSAFE.getAndBitwiseXor$RawType$Release( |
|
471 ba, |
|
472 address(ba, index(ba, index)), |
|
473 value); |
|
474 } else { |
|
475 return getAndBitwiseXorConvEndianWithCAS(ba, index, value); |
|
476 } |
|
477 } |
|
478 |
|
479 @ForceInline |
|
480 static $type$ getAndBitwiseXorAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { |
|
481 byte[] ba = (byte[]) oba; |
|
482 if (handle.be == BE) { |
|
483 return UNSAFE.getAndBitwiseXor$RawType$Acquire( |
|
484 ba, |
|
485 address(ba, index(ba, index)), |
|
486 value); |
|
487 } else { |
|
488 return getAndBitwiseXorConvEndianWithCAS(ba, index, value); |
|
489 } |
|
490 } |
|
491 |
|
492 @ForceInline |
|
493 static $type$ getAndBitwiseXorConvEndianWithCAS(byte[] ba, int index, $type$ value) { |
|
494 $type$ nativeExpectedValue, expectedValue; |
|
495 long offset = address(ba, index(ba, index)); |
|
496 do { |
|
497 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); |
|
498 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
|
499 } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, |
|
500 nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); |
|
501 return expectedValue; |
|
502 } |
|
503 #end[Bitwise] |
303 |
504 |
304 static final VarForm FORM = new VarForm(ArrayHandle.class, byte[].class, $type$.class, int.class); |
505 static final VarForm FORM = new VarForm(ArrayHandle.class, byte[].class, $type$.class, int.class); |
305 } |
506 } |
306 |
507 |
307 |
508 |
508 UNSAFE.getAndSet$RawType$( |
709 UNSAFE.getAndSet$RawType$( |
509 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
710 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
510 address(bb, indexRO(bb, index)), |
711 address(bb, indexRO(bb, index)), |
511 convEndian(handle.be, value))); |
712 convEndian(handle.be, value))); |
512 } |
713 } |
|
714 |
|
715 @ForceInline |
|
716 static $type$ getAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
717 ByteBuffer bb = (ByteBuffer) obb; |
|
718 return convEndian(handle.be, |
|
719 UNSAFE.getAndSet$RawType$Acquire( |
|
720 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
721 address(bb, indexRO(bb, index)), |
|
722 convEndian(handle.be, value))); |
|
723 } |
|
724 |
|
725 @ForceInline |
|
726 static $type$ getAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
727 ByteBuffer bb = (ByteBuffer) obb; |
|
728 return convEndian(handle.be, |
|
729 UNSAFE.getAndSet$RawType$Release( |
|
730 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
731 address(bb, indexRO(bb, index)), |
|
732 convEndian(handle.be, value))); |
|
733 } |
513 #end[CAS] |
734 #end[CAS] |
514 #if[AtomicAdd] |
735 #if[AtomicAdd] |
515 |
736 |
516 @ForceInline |
737 @ForceInline |
517 static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ delta) { |
738 static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ delta) { |
518 ByteBuffer bb = (ByteBuffer) obb; |
739 ByteBuffer bb = (ByteBuffer) obb; |
519 if (handle.be == BE) { |
740 if (handle.be == BE) { |
520 return UNSAFE.getAndAdd$RawType$( |
741 return UNSAFE.getAndAdd$RawType$( |
|
742 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
743 address(bb, indexRO(bb, index)), |
|
744 delta); |
|
745 } else { |
|
746 return getAndAddConvEndianWithCAS(bb, index, delta); |
|
747 } |
|
748 } |
|
749 |
|
750 @ForceInline |
|
751 static $type$ getAndAddAcquire(ByteBufferHandle handle, Object obb, int index, $type$ delta) { |
|
752 ByteBuffer bb = (ByteBuffer) obb; |
|
753 if (handle.be == BE) { |
|
754 return UNSAFE.getAndAdd$RawType$Acquire( |
|
755 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
756 address(bb, indexRO(bb, index)), |
|
757 delta); |
|
758 } else { |
|
759 return getAndAddConvEndianWithCAS(bb, index, delta); |
|
760 } |
|
761 } |
|
762 |
|
763 @ForceInline |
|
764 static $type$ getAndAddRelease(ByteBufferHandle handle, Object obb, int index, $type$ delta) { |
|
765 ByteBuffer bb = (ByteBuffer) obb; |
|
766 if (handle.be == BE) { |
|
767 return UNSAFE.getAndAdd$RawType$Release( |
521 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
768 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
522 address(bb, indexRO(bb, index)), |
769 address(bb, indexRO(bb, index)), |
523 delta); |
770 delta); |
524 } else { |
771 } else { |
525 return getAndAddConvEndianWithCAS(bb, index, delta); |
772 return getAndAddConvEndianWithCAS(bb, index, delta); |
542 @ForceInline |
789 @ForceInline |
543 static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ delta) { |
790 static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ delta) { |
544 return getAndAdd(handle, obb, index, delta) + delta; |
791 return getAndAdd(handle, obb, index, delta) + delta; |
545 } |
792 } |
546 #end[AtomicAdd] |
793 #end[AtomicAdd] |
|
794 #if[Bitwise] |
|
795 |
|
796 @ForceInline |
|
797 static $type$ getAndBitwiseOr(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
798 ByteBuffer bb = (ByteBuffer) obb; |
|
799 if (handle.be == BE) { |
|
800 return UNSAFE.getAndBitwiseOr$RawType$( |
|
801 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
802 address(bb, indexRO(bb, index)), |
|
803 value); |
|
804 } else { |
|
805 return getAndBitwiseOrConvEndianWithCAS(bb, index, value); |
|
806 } |
|
807 } |
|
808 |
|
809 @ForceInline |
|
810 static $type$ getAndBitwiseOrRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
811 ByteBuffer bb = (ByteBuffer) obb; |
|
812 if (handle.be == BE) { |
|
813 return UNSAFE.getAndBitwiseOr$RawType$Release( |
|
814 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
815 address(bb, indexRO(bb, index)), |
|
816 value); |
|
817 } else { |
|
818 return getAndBitwiseOrConvEndianWithCAS(bb, index, value); |
|
819 } |
|
820 } |
|
821 |
|
822 @ForceInline |
|
823 static $type$ getAndBitwiseOrAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
824 ByteBuffer bb = (ByteBuffer) obb; |
|
825 if (handle.be == BE) { |
|
826 return UNSAFE.getAndBitwiseOr$RawType$Acquire( |
|
827 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
828 address(bb, indexRO(bb, index)), |
|
829 value); |
|
830 } else { |
|
831 return getAndBitwiseOrConvEndianWithCAS(bb, index, value); |
|
832 } |
|
833 } |
|
834 |
|
835 @ForceInline |
|
836 static $type$ getAndBitwiseOrConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { |
|
837 $type$ nativeExpectedValue, expectedValue; |
|
838 Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); |
|
839 long offset = address(bb, indexRO(bb, index)); |
|
840 do { |
|
841 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); |
|
842 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
|
843 } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, |
|
844 nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); |
|
845 return expectedValue; |
|
846 } |
|
847 |
|
848 @ForceInline |
|
849 static $type$ getAndBitwiseAnd(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
850 ByteBuffer bb = (ByteBuffer) obb; |
|
851 if (handle.be == BE) { |
|
852 return UNSAFE.getAndBitwiseAnd$RawType$( |
|
853 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
854 address(bb, indexRO(bb, index)), |
|
855 value); |
|
856 } else { |
|
857 return getAndBitwiseAndConvEndianWithCAS(bb, index, value); |
|
858 } |
|
859 } |
|
860 |
|
861 @ForceInline |
|
862 static $type$ getAndBitwiseAndRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
863 ByteBuffer bb = (ByteBuffer) obb; |
|
864 if (handle.be == BE) { |
|
865 return UNSAFE.getAndBitwiseAnd$RawType$Release( |
|
866 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
867 address(bb, indexRO(bb, index)), |
|
868 value); |
|
869 } else { |
|
870 return getAndBitwiseAndConvEndianWithCAS(bb, index, value); |
|
871 } |
|
872 } |
|
873 |
|
874 @ForceInline |
|
875 static $type$ getAndBitwiseAndAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
876 ByteBuffer bb = (ByteBuffer) obb; |
|
877 if (handle.be == BE) { |
|
878 return UNSAFE.getAndBitwiseAnd$RawType$Acquire( |
|
879 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
880 address(bb, indexRO(bb, index)), |
|
881 value); |
|
882 } else { |
|
883 return getAndBitwiseAndConvEndianWithCAS(bb, index, value); |
|
884 } |
|
885 } |
|
886 |
|
887 @ForceInline |
|
888 static $type$ getAndBitwiseAndConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { |
|
889 $type$ nativeExpectedValue, expectedValue; |
|
890 Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); |
|
891 long offset = address(bb, indexRO(bb, index)); |
|
892 do { |
|
893 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); |
|
894 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
|
895 } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, |
|
896 nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); |
|
897 return expectedValue; |
|
898 } |
|
899 |
|
900 |
|
901 @ForceInline |
|
902 static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
903 ByteBuffer bb = (ByteBuffer) obb; |
|
904 if (handle.be == BE) { |
|
905 return UNSAFE.getAndBitwiseXor$RawType$( |
|
906 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
907 address(bb, indexRO(bb, index)), |
|
908 value); |
|
909 } else { |
|
910 return getAndBitwiseXorConvEndianWithCAS(bb, index, value); |
|
911 } |
|
912 } |
|
913 |
|
914 @ForceInline |
|
915 static $type$ getAndBitwiseXorRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
916 ByteBuffer bb = (ByteBuffer) obb; |
|
917 if (handle.be == BE) { |
|
918 return UNSAFE.getAndBitwiseXor$RawType$Release( |
|
919 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
920 address(bb, indexRO(bb, index)), |
|
921 value); |
|
922 } else { |
|
923 return getAndBitwiseXorConvEndianWithCAS(bb, index, value); |
|
924 } |
|
925 } |
|
926 |
|
927 @ForceInline |
|
928 static $type$ getAndBitwiseXorAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { |
|
929 ByteBuffer bb = (ByteBuffer) obb; |
|
930 if (handle.be == BE) { |
|
931 return UNSAFE.getAndBitwiseXor$RawType$Acquire( |
|
932 UNSAFE.getObject(bb, BYTE_BUFFER_HB), |
|
933 address(bb, indexRO(bb, index)), |
|
934 value); |
|
935 } else { |
|
936 return getAndBitwiseXorConvEndianWithCAS(bb, index, value); |
|
937 } |
|
938 } |
|
939 |
|
940 @ForceInline |
|
941 static $type$ getAndBitwiseXorConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { |
|
942 $type$ nativeExpectedValue, expectedValue; |
|
943 Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); |
|
944 long offset = address(bb, indexRO(bb, index)); |
|
945 do { |
|
946 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); |
|
947 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); |
|
948 } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, |
|
949 nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); |
|
950 return expectedValue; |
|
951 } |
|
952 #end[Bitwise] |
547 |
953 |
548 static final VarForm FORM = new VarForm(ByteBufferHandle.class, ByteBuffer.class, $type$.class, int.class); |
954 static final VarForm FORM = new VarForm(ByteBufferHandle.class, ByteBuffer.class, $type$.class, int.class); |
549 } |
955 } |
550 } |
956 } |