8331865: Consolidate size and alignment checks in LayoutPath

Reviewed-by: psandoz, jvernee
This commit is contained in:
Maurizio Cimadamore 2024-05-29 11:12:30 +00:00
parent 6d718ae51a
commit c003c1207f
12 changed files with 166 additions and 133 deletions

View file

@ -625,12 +625,12 @@ public sealed interface MemoryLayout
* (this layout), or an {@link IllegalArgumentException} is thrown. Note
* that the alignment constraint of the root layout can be more strict
* (but not less) than the alignment constraint of the selected value layout.</li>
* <li>The offset of the access operation (computed as above) must fall inside
* the spatial bounds of the accessed memory segment, or an
* {@link IndexOutOfBoundsException} is thrown. This is the case when
* {@code O + A <= S}, where {@code O} is the accessed offset (computed as above),
* {@code A} is the size of the selected layout and {@code S} is the size of the
* accessed memory segment.</li>
* <li>The access operation must fall inside the spatial bounds of the accessed
* memory segment, or an {@link IndexOutOfBoundsException} is thrown. This is the case
* when {@code B + A <= S}, where {@code B} is the base offset (defined above),
* {@code A} is the size of this layout and {@code S} is the size of the
* accessed memory segment. Note that the size of this layout might be <em>bigger</em>
* than the size of the accessed layout (e.g. when accessing a struct member).</li>
* <li>If the provided layout path has an open path element whose size is {@code S},
* its corresponding trailing {@code long} coordinate value {@code I} must be
* {@code 0 <= I < S}, or an {@link IndexOutOfBoundsException} is thrown.</li>
@ -753,12 +753,12 @@ public sealed interface MemoryLayout
* (this layout), or an {@link IllegalArgumentException} is thrown. Note
* that the alignment constraint of the root layout can be more strict
* (but not less) than the alignment constraint of the selected value layout.</li>
* <li>The offset of the access operation (computed as above) must fall inside
* the spatial bounds of the accessed memory segment, or an
* {@link IndexOutOfBoundsException} is thrown. This is the case when
* {@code O + A <= S}, where {@code O} is the accessed offset (computed as above),
* {@code A} is the size of the selected layout and {@code S} is the size of the
* accessed memory segment.</li>
* <li>The access operation must fall inside the spatial bounds of the accessed
* memory segment, or an {@link IndexOutOfBoundsException} is thrown. This is the case
* when {@code B + A <= S}, where {@code B} is the base offset (defined above),
* {@code A} is the size of this layout and {@code S} is the size of the
* accessed memory segment. Note that the size of this layout might be <em>bigger</em>
* than the size of the accessed layout (e.g. when accessing a struct member).</li>
* <li>If the provided layout path has an open path element whose size is {@code S},
* its corresponding trailing {@code long} coordinate value {@code I} must be
* {@code 0 <= I < S}, or an {@link IndexOutOfBoundsException} is thrown.</li>
@ -822,12 +822,12 @@ public sealed interface MemoryLayout
* (this layout), or an {@link IllegalArgumentException} will be issued. Note
* that the alignment constraint of the root layout can be more strict
* (but not less) than the alignment constraint of the selected layout.</li>
* <li>The start offset of the slicing operation (computed as above) must fall
* inside the spatial bounds of the accessed memory segment, or an
* {@link IndexOutOfBoundsException} is thrown. This is the case when
* {@code O + A <= S}, where {@code O} is the start offset of
* the slicing operation (computed as above), {@code A} is the size of the
* selected layout and {@code S} is the size of the accessed memory segment.</li>
* <li>The slicing operation must fall inside the spatial bounds of the accessed
* memory segment, or an {@link IndexOutOfBoundsException} is thrown. This is the case
* when {@code B + A <= S}, where {@code B} is the base offset (defined above),
* {@code A} is the size of this layout and {@code S} is the size of the
* accessed memory segment. Note that the size of this layout might be <em>bigger</em>
* than the size of the accessed layout (e.g. when accessing a struct member).</li>
* <li>If the provided layout path has an open path element whose size is {@code S},
* its corresponding trailing {@code long} coordinate value {@code I} must be
* {@code 0 <= I < S}, or an {@link IndexOutOfBoundsException} is thrown.</li>

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, 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
@ -25,8 +25,6 @@
package java.lang.invoke;
import jdk.internal.foreign.Utils;
/**
* Base class for memory segment var handle view implementations.
*/
@ -42,23 +40,15 @@ abstract sealed class VarHandleSegmentViewBase extends VarHandle permits
/** endianness **/
final boolean be;
/** access size (in bytes, computed from var handle carrier type) **/
final long length;
/** alignment constraint (in bytes, expressed as a bit mask) **/
final long alignmentMask;
VarHandleSegmentViewBase(VarForm form, boolean be, long length, long alignmentMask, boolean exact) {
VarHandleSegmentViewBase(VarForm form, boolean be, long alignmentMask, boolean exact) {
super(form, exact);
this.be = be;
this.length = length;
this.alignmentMask = alignmentMask;
}
static IllegalArgumentException newIllegalArgumentExceptionForMisalignedAccess(long address) {
return new IllegalArgumentException("Misaligned access at address: " + Utils.toHexString(address));
}
static UnsupportedOperationException newUnsupportedAccessModeForAlignment(long alignment) {
return new UnsupportedOperationException("Unsupported access mode for alignment: " + alignment);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, 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
@ -306,6 +306,9 @@ final class VarHandles {
* The resulting var handle will take a memory segment as first argument (the segment to be dereferenced),
* and a {@code long} as second argument (the offset into the segment).
*
* Note: the returned var handle does not perform any size or alignment check. It is up to clients
* to adapt the returned var handle and insert the appropriate checks.
*
* @param carrier the Java carrier type.
* @param alignmentMask alignment requirement to be checked upon access. In bytes. Expressed as a mask.
* @param byteOrder the byte order.
@ -316,24 +319,23 @@ final class VarHandles {
if (!carrier.isPrimitive() || carrier == void.class || carrier == boolean.class) {
throw new IllegalArgumentException("Invalid carrier: " + carrier.getName());
}
long size = Utils.byteWidthOfPrimitive(carrier);
boolean be = byteOrder == ByteOrder.BIG_ENDIAN;
boolean exact = VAR_HANDLE_SEGMENT_FORCE_EXACT;
if (carrier == byte.class) {
return maybeAdapt(new VarHandleSegmentAsBytes(be, size, alignmentMask, exact));
return maybeAdapt(new VarHandleSegmentAsBytes(be, alignmentMask, exact));
} else if (carrier == char.class) {
return maybeAdapt(new VarHandleSegmentAsChars(be, size, alignmentMask, exact));
return maybeAdapt(new VarHandleSegmentAsChars(be, alignmentMask, exact));
} else if (carrier == short.class) {
return maybeAdapt(new VarHandleSegmentAsShorts(be, size, alignmentMask, exact));
return maybeAdapt(new VarHandleSegmentAsShorts(be, alignmentMask, exact));
} else if (carrier == int.class) {
return maybeAdapt(new VarHandleSegmentAsInts(be, size, alignmentMask, exact));
return maybeAdapt(new VarHandleSegmentAsInts(be, alignmentMask, exact));
} else if (carrier == float.class) {
return maybeAdapt(new VarHandleSegmentAsFloats(be, size, alignmentMask, exact));
return maybeAdapt(new VarHandleSegmentAsFloats(be, alignmentMask, exact));
} else if (carrier == long.class) {
return maybeAdapt(new VarHandleSegmentAsLongs(be, size, alignmentMask, exact));
return maybeAdapt(new VarHandleSegmentAsLongs(be, alignmentMask, exact));
} else if (carrier == double.class) {
return maybeAdapt(new VarHandleSegmentAsDoubles(be, size, alignmentMask, exact));
return maybeAdapt(new VarHandleSegmentAsDoubles(be, alignmentMask, exact));
} else {
throw new IllegalStateException("Cannot get here");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, 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
@ -47,8 +47,8 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
static final VarForm FORM = new VarForm(VarHandleSegmentAs$Type$s.class, MemorySegment.class, $type$.class, long.class);
VarHandleSegmentAs$Type$s(boolean be, long length, long alignmentMask, boolean exact) {
super(FORM, be, length, alignmentMask, exact);
VarHandleSegmentAs$Type$s(boolean be, long alignmentMask, boolean exact) {
super(FORM, be, alignmentMask, exact);
}
@Override
@ -60,14 +60,14 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
public VarHandleSegmentAs$Type$s withInvokeExactBehavior() {
return hasInvokeExactBehavior() ?
this :
new VarHandleSegmentAs$Type$s(be, length, alignmentMask, true);
new VarHandleSegmentAs$Type$s(be, alignmentMask, true);
}
@Override
public VarHandleSegmentAs$Type$s withInvokeBehavior() {
return !hasInvokeExactBehavior() ?
this :
new VarHandleSegmentAs$Type$s(be, length, alignmentMask, false);
new VarHandleSegmentAs$Type$s(be, alignmentMask, false);
}
#if[floatingPoint]
@ -97,9 +97,9 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
#end[floatingPoint]
@ForceInline
static AbstractMemorySegmentImpl checkAddress(Object obb, long offset, long length, boolean ro) {
static AbstractMemorySegmentImpl checkReadOnly(Object obb, boolean ro) {
AbstractMemorySegmentImpl oo = (AbstractMemorySegmentImpl)Objects.requireNonNull(obb);
oo.checkAccess(offset, length, ro);
oo.checkReadOnly(ro);
return oo;
}
@ -108,39 +108,34 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
if ((alignmentMask & NON_PLAIN_ACCESS_MIN_ALIGN_MASK) != NON_PLAIN_ACCESS_MIN_ALIGN_MASK) {
throw VarHandleSegmentViewBase.newUnsupportedAccessModeForAlignment(alignmentMask + 1);
}
return offsetPlain(bb, offset, alignmentMask);
return offsetPlain(bb, offset);
}
@ForceInline
static long offsetPlain(AbstractMemorySegmentImpl bb, long offset, long alignmentMask) {
static long offsetPlain(AbstractMemorySegmentImpl bb, long offset) {
long base = bb.unsafeGetOffset();
long address = base + offset;
long maxAlignMask = bb.maxAlignMask();
if (((address | maxAlignMask) & alignmentMask) != 0) {
throw VarHandleSegmentViewBase.newIllegalArgumentExceptionForMisalignedAccess(address);
}
return address;
return base + offset;
}
@ForceInline
static $type$ get(VarHandle ob, Object obb, long base) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, true);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, true);
#if[floatingPoint]
$rawType$ rawValue = SCOPED_MEMORY_ACCESS.get$RawType$Unaligned(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetPlain(bb, base, handle.alignmentMask),
offsetPlain(bb, base),
handle.be);
return $Type$.$rawType$BitsTo$Type$(rawValue);
#else[floatingPoint]
#if[byte]
return SCOPED_MEMORY_ACCESS.get$Type$(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetPlain(bb, base, handle.alignmentMask));
offsetPlain(bb, base));
#else[byte]
return SCOPED_MEMORY_ACCESS.get$Type$Unaligned(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetPlain(bb, base, handle.alignmentMask),
offsetPlain(bb, base),
handle.be);
#end[byte]
#end[floatingPoint]
@ -149,23 +144,23 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static void set(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
#if[floatingPoint]
SCOPED_MEMORY_ACCESS.put$RawType$Unaligned(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetPlain(bb, base, handle.alignmentMask),
offsetPlain(bb, base),
$Type$.$type$ToRaw$RawType$Bits(value),
handle.be);
#else[floatingPoint]
#if[byte]
SCOPED_MEMORY_ACCESS.put$Type$(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetPlain(bb, base, handle.alignmentMask),
offsetPlain(bb, base),
value);
#else[byte]
SCOPED_MEMORY_ACCESS.put$Type$Unaligned(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetPlain(bb, base, handle.alignmentMask),
offsetPlain(bb, base),
value,
handle.be);
#end[byte]
@ -175,7 +170,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getVolatile(VarHandle ob, Object obb, long base) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, true);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, true);
return convEndian(handle.be,
SCOPED_MEMORY_ACCESS.get$RawType$Volatile(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -185,7 +180,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static void setVolatile(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
SCOPED_MEMORY_ACCESS.put$RawType$Volatile(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetNonPlain(bb, base, handle.alignmentMask),
@ -195,7 +190,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAcquire(VarHandle ob, Object obb, long base) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, true);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, true);
return convEndian(handle.be,
SCOPED_MEMORY_ACCESS.get$RawType$Acquire(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -205,7 +200,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static void setRelease(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
SCOPED_MEMORY_ACCESS.put$RawType$Release(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetNonPlain(bb, base, handle.alignmentMask),
@ -215,7 +210,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getOpaque(VarHandle ob, Object obb, long base) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, true);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, true);
return convEndian(handle.be,
SCOPED_MEMORY_ACCESS.get$RawType$Opaque(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -225,7 +220,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static void setOpaque(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
SCOPED_MEMORY_ACCESS.put$RawType$Opaque(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetNonPlain(bb, base, handle.alignmentMask),
@ -236,7 +231,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static boolean compareAndSet(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return SCOPED_MEMORY_ACCESS.compareAndSet$RawType$(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetNonPlain(bb, base, handle.alignmentMask),
@ -246,7 +241,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ compareAndExchange(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return convEndian(handle.be,
SCOPED_MEMORY_ACCESS.compareAndExchange$RawType$(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -257,7 +252,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ compareAndExchangeAcquire(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return convEndian(handle.be,
SCOPED_MEMORY_ACCESS.compareAndExchange$RawType$Acquire(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -268,7 +263,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ compareAndExchangeRelease(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return convEndian(handle.be,
SCOPED_MEMORY_ACCESS.compareAndExchange$RawType$Release(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -279,7 +274,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static boolean weakCompareAndSetPlain(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$Plain(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetNonPlain(bb, base, handle.alignmentMask),
@ -289,7 +284,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static boolean weakCompareAndSet(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetNonPlain(bb, base, handle.alignmentMask),
@ -299,7 +294,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static boolean weakCompareAndSetAcquire(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$Acquire(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetNonPlain(bb, base, handle.alignmentMask),
@ -309,7 +304,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static boolean weakCompareAndSetRelease(VarHandle ob, Object obb, long base, $type$ expected, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return SCOPED_MEMORY_ACCESS.weakCompareAndSet$RawType$Release(bb.sessionImpl(),
bb.unsafeGetBase(),
offsetNonPlain(bb, base, handle.alignmentMask),
@ -319,7 +314,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndSet(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return convEndian(handle.be,
SCOPED_MEMORY_ACCESS.getAndSet$RawType$(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -330,7 +325,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndSetAcquire(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return convEndian(handle.be,
SCOPED_MEMORY_ACCESS.getAndSet$RawType$Acquire(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -341,7 +336,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndSetRelease(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
return convEndian(handle.be,
SCOPED_MEMORY_ACCESS.getAndSet$RawType$Release(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -354,7 +349,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndAdd(VarHandle ob, Object obb, long base, $type$ delta) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndAdd$RawType$(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -368,7 +363,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndAddAcquire(VarHandle ob, Object obb, long base, $type$ delta) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndAdd$RawType$Acquire(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -382,7 +377,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndAddRelease(VarHandle ob, Object obb, long base, $type$ delta) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndAdd$RawType$Release(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -410,7 +405,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndBitwiseOr(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndBitwiseOr$RawType$(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -424,7 +419,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndBitwiseOrRelease(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndBitwiseOr$RawType$Release(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -438,7 +433,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndBitwiseOrAcquire(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndBitwiseOr$RawType$Acquire(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -464,7 +459,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndBitwiseAnd(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndBitwiseAnd$RawType$(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -478,7 +473,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndBitwiseAndRelease(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndBitwiseAnd$RawType$Release(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -492,7 +487,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndBitwiseAndAcquire(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndBitwiseAnd$RawType$Acquire(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -519,7 +514,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndBitwiseXor(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndBitwiseXor$RawType$(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -533,7 +528,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndBitwiseXorRelease(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndBitwiseXor$RawType$Release(bb.sessionImpl(),
bb.unsafeGetBase(),
@ -547,7 +542,7 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static $type$ getAndBitwiseXorAcquire(VarHandle ob, Object obb, long base, $type$ value) {
VarHandleSegmentViewBase handle = (VarHandleSegmentViewBase)ob;
AbstractMemorySegmentImpl bb = checkAddress(obb, base, handle.length, false);
AbstractMemorySegmentImpl bb = checkReadOnly(obb, false);
if (handle.be == BE) {
return SCOPED_MEMORY_ACCESS.getAndBitwiseXor$RawType$Acquire(bb.sessionImpl(),
bb.unsafeGetBase(),