/* * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package java.lang.invoke; import jdk.internal.access.foreign.MemorySegmentProxy; import jdk.internal.misc.ScopedMemoryAccess; import jdk.internal.vm.annotation.ForceInline; import java.lang.ref.Reference; import java.util.Objects; import static java.lang.invoke.MethodHandleStatics.UNSAFE; #warn final class MemoryAccessVarHandle$Type$Helper extends MemoryAccessVarHandleBase { static final boolean BE = UNSAFE.isBigEndian(); static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess(); static final int VM_ALIGN = $BoxType$.BYTES - 1; static final VarForm FORM = new VarForm(MemoryAccessVarHandle$Type$Helper.class, MemorySegmentProxy.class, $type$.class, long.class); MemoryAccessVarHandle$Type$Helper(boolean skipAlignmentMaskCheck, boolean be, long length, long alignmentMask, boolean exact) { super(FORM, skipAlignmentMaskCheck, be, length, alignmentMask, exact); } @Override final MethodType accessModeTypeUncached(VarHandle.AccessType accessType) { return accessType.accessModeType(MemorySegmentProxy.class, $type$.class, long.class); } @Override public MemoryAccessVarHandle$Type$Helper withInvokeExactBehavior() { return hasInvokeExactBehavior() ? this : new MemoryAccessVarHandle$Type$Helper(skipAlignmentMaskCheck, be, length, alignmentMask, true); } @Override public MemoryAccessVarHandle$Type$Helper withInvokeBehavior() { return !hasInvokeExactBehavior() ? this : new MemoryAccessVarHandle$Type$Helper(skipAlignmentMaskCheck, be, length, alignmentMask, false); } #if[floatingPoint] @ForceInline static $rawType$ convEndian(boolean big, $type$ v) { $rawType$ rv = $Type$.$type$ToRaw$RawType$Bits(v); return big == BE ? rv : $RawBoxType$.reverseBytes(rv); } @ForceInline static $type$ convEndian(boolean big, $rawType$ rv) { rv = big == BE ? rv : $RawBoxType$.reverseBytes(rv); return $Type$.$rawType$BitsTo$Type$(rv); } #else[floatingPoint] #if[byte] @ForceInline static $type$ convEndian(boolean big, $type$ n) { return n; } #else[byte] @ForceInline static $type$ convEndian(boolean big, $type$ n) { return big == BE ? n : $BoxType$.reverseBytes(n); } #end[byte] #end[floatingPoint] @ForceInline static MemorySegmentProxy checkAddress(Object obb, long offset, long length, boolean ro) { MemorySegmentProxy oo = (MemorySegmentProxy)Objects.requireNonNull(obb); oo.checkAccess(offset, length, ro); return oo; } @ForceInline static long offset(boolean skipAlignmentMaskCheck, MemorySegmentProxy bb, long offset, long alignmentMask) { long address = offsetNoVMAlignCheck(skipAlignmentMaskCheck, bb, offset, alignmentMask); if ((address & VM_ALIGN) != 0) { throw MemoryAccessVarHandleBase.newIllegalStateExceptionForMisalignedAccess(address); } return address; } @ForceInline static long offsetNoVMAlignCheck(boolean skipAlignmentMaskCheck, MemorySegmentProxy bb, long offset, long alignmentMask) { long base = bb.unsafeGetOffset(); long address = base + offset; if (skipAlignmentMaskCheck) { //note: the offset portion has already been aligned-checked, by construction if ((base & alignmentMask) != 0) { throw MemoryAccessVarHandleBase.newIllegalStateExceptionForMisalignedAccess(address); } } else { if ((address & alignmentMask) != 0) { throw MemoryAccessVarHandleBase.newIllegalStateExceptionForMisalignedAccess(address); } } return address; } @ForceInline static $type$ get(VarHandle ob, Object obb, long base) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, true); #if[floatingPoint] $rawType$ rawValue = SCOPED_MEMORY_ACCESS.get$RawType$Unaligned(bb.scope(), bb.unsafeGetBase(), offsetNoVMAlignCheck(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), handle.be); return $Type$.$rawType$BitsTo$Type$(rawValue); #else[floatingPoint] #if[byte] return SCOPED_MEMORY_ACCESS.get$Type$(bb.scope(), bb.unsafeGetBase(), offsetNoVMAlignCheck(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask)); #else[byte] return SCOPED_MEMORY_ACCESS.get$Type$Unaligned(bb.scope(), bb.unsafeGetBase(), offsetNoVMAlignCheck(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), handle.be); #end[byte] #end[floatingPoint] } @ForceInline static void set(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); #if[floatingPoint] SCOPED_MEMORY_ACCESS.put$RawType$Unaligned(bb.scope(), bb.unsafeGetBase(), offsetNoVMAlignCheck(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), $Type$.$type$ToRaw$RawType$Bits(value), handle.be); #else[floatingPoint] #if[byte] SCOPED_MEMORY_ACCESS.put$Type$(bb.scope(), bb.unsafeGetBase(), offsetNoVMAlignCheck(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); #else[byte] SCOPED_MEMORY_ACCESS.put$Type$Unaligned(bb.scope(), bb.unsafeGetBase(), offsetNoVMAlignCheck(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value, handle.be); #end[byte] #end[floatingPoint] } @ForceInline static $type$ getVolatile(VarHandle ob, Object obb, long base) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, true); return convEndian(handle.be, SCOPED_MEMORY_ACCESS.get$RawType$Volatile(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask))); } @ForceInline static void setVolatile(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); SCOPED_MEMORY_ACCESS.put$RawType$Volatile(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, value)); } @ForceInline static $type$ getAcquire(VarHandle ob, Object obb, long base) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, true); return convEndian(handle.be, SCOPED_MEMORY_ACCESS.get$RawType$Acquire(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask))); } @ForceInline static void setRelease(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); SCOPED_MEMORY_ACCESS.put$RawType$Release(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, value)); } @ForceInline static $type$ getOpaque(VarHandle ob, Object obb, long base) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, true); return convEndian(handle.be, SCOPED_MEMORY_ACCESS.get$RawType$Opaque(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask))); } @ForceInline static void setOpaque(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); SCOPED_MEMORY_ACCESS.put$RawType$Opaque(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, value)); } #if[CAS] @ForceInline static boolean compareAndSet(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return SCOPED_MEMORY_ACCESS.compareAndSet$RawType$(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, expected), convEndian(handle.be, value)); } @ForceInline static $type$ compareAndExchange(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return convEndian(handle.be, SCOPED_MEMORY_ACCESS.compareAndExchange$RawType$(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, expected), convEndian(handle.be, value))); } @ForceInline static $type$ compareAndExchangeAcquire(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return convEndian(handle.be, SCOPED_MEMORY_ACCESS.compareAndExchange$RawType$Acquire(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, expected), convEndian(handle.be, value))); } @ForceInline static $type$ compareAndExchangeRelease(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return convEndian(handle.be, SCOPED_MEMORY_ACCESS.compareAndExchange$RawType$Release(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, expected), convEndian(handle.be, value))); } @ForceInline static boolean weakCompareAndSetPlain(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$Plain(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, expected), convEndian(handle.be, value)); } @ForceInline static boolean weakCompareAndSet(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, expected), convEndian(handle.be, value)); } @ForceInline static boolean weakCompareAndSetAcquire(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$Acquire(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, expected), convEndian(handle.be, value)); } @ForceInline static boolean weakCompareAndSetRelease(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$Release(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, expected), convEndian(handle.be, value)); } @ForceInline static $type$ getAndSet(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return convEndian(handle.be, SCOPED_MEMORY_ACCESS.getAndSet$RawType$(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, value))); } @ForceInline static $type$ getAndSetAcquire(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return convEndian(handle.be, SCOPED_MEMORY_ACCESS.getAndSet$RawType$Acquire(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, value))); } @ForceInline static $type$ getAndSetRelease(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); return convEndian(handle.be, SCOPED_MEMORY_ACCESS.getAndSet$RawType$Release(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), convEndian(handle.be, value))); } #end[CAS] #if[AtomicAdd] @ForceInline static $type$ getAndAdd(VarHandle ob, Object obb, long base, $type$ delta) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndAdd$RawType$(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), delta); } else { return getAndAddConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), delta); } } @ForceInline static $type$ getAndAddAcquire(VarHandle ob, Object obb, long base, $type$ delta) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndAdd$RawType$Acquire(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), delta); } else { return getAndAddConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), delta); } } @ForceInline static $type$ getAndAddRelease(VarHandle ob, Object obb, long base, $type$ delta) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndAdd$RawType$Release(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), delta); } else { return getAndAddConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), delta); } } @ForceInline static $type$ getAndAddConvEndianWithCAS(MemorySegmentProxy bb, long offset, $type$ delta) { $type$ nativeExpectedValue, expectedValue; Object base = bb.unsafeGetBase(); do { nativeExpectedValue = SCOPED_MEMORY_ACCESS.get$RawType$Volatile(bb.scope(),base, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); } while (!SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$(bb.scope(),base, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); return expectedValue; } #end[AtomicAdd] #if[Bitwise] @ForceInline static $type$ getAndBitwiseOr(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndBitwiseOr$RawType$(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } else { return getAndBitwiseOrConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } } @ForceInline static $type$ getAndBitwiseOrRelease(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndBitwiseOr$RawType$Release(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } else { return getAndBitwiseOrConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } } @ForceInline static $type$ getAndBitwiseOrAcquire(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndBitwiseOr$RawType$Acquire(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } else { return getAndBitwiseOrConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } } @ForceInline static $type$ getAndBitwiseOrConvEndianWithCAS(MemorySegmentProxy bb, long offset, $type$ value) { $type$ nativeExpectedValue, expectedValue; Object base = bb.unsafeGetBase(); do { nativeExpectedValue = SCOPED_MEMORY_ACCESS.get$RawType$Volatile(bb.scope(),base, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); } while (!SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$(bb.scope(),base, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); return expectedValue; } @ForceInline static $type$ getAndBitwiseAnd(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndBitwiseAnd$RawType$(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } else { return getAndBitwiseAndConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } } @ForceInline static $type$ getAndBitwiseAndRelease(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndBitwiseAnd$RawType$Release(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } else { return getAndBitwiseAndConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } } @ForceInline static $type$ getAndBitwiseAndAcquire(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndBitwiseAnd$RawType$Acquire(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } else { return getAndBitwiseAndConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } } @ForceInline static $type$ getAndBitwiseAndConvEndianWithCAS(MemorySegmentProxy bb, long offset, $type$ value) { $type$ nativeExpectedValue, expectedValue; Object base = bb.unsafeGetBase(); do { nativeExpectedValue = SCOPED_MEMORY_ACCESS.get$RawType$Volatile(bb.scope(),base, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); } while (!SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$(bb.scope(),base, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); return expectedValue; } @ForceInline static $type$ getAndBitwiseXor(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndBitwiseXor$RawType$(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } else { return getAndBitwiseXorConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } } @ForceInline static $type$ getAndBitwiseXorRelease(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndBitwiseXor$RawType$Release(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } else { return getAndBitwiseXorConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } } @ForceInline static $type$ getAndBitwiseXorAcquire(VarHandle ob, Object obb, long base, $type$ value) { MemoryAccessVarHandleBase handle = (MemoryAccessVarHandleBase)ob; MemorySegmentProxy bb = checkAddress(obb, base, handle.length, false); if (handle.be == BE) { return SCOPED_MEMORY_ACCESS.getAndBitwiseXor$RawType$Acquire(bb.scope(), bb.unsafeGetBase(), offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } else { return getAndBitwiseXorConvEndianWithCAS(bb, offset(handle.skipAlignmentMaskCheck, bb, base, handle.alignmentMask), value); } } @ForceInline static $type$ getAndBitwiseXorConvEndianWithCAS(MemorySegmentProxy bb, long offset, $type$ value) { $type$ nativeExpectedValue, expectedValue; Object base = bb.unsafeGetBase(); do { nativeExpectedValue = SCOPED_MEMORY_ACCESS.get$RawType$Volatile(bb.scope(),base, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); } while (!SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$(bb.scope(),base, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); return expectedValue; } #end[Bitwise] }