< prev index next >

src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template

Print this page
rev 14353 : 8155258: VarHandle implementation improvements
Reviewed-by:
rev 14354 : 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package
Reviewed-by:

*** 23,32 **** --- 23,33 ---- * questions. */ package java.lang.invoke; import jdk.internal.misc.Unsafe; + import jdk.internal.util.Preconditions; import jdk.internal.vm.annotation.ForceInline; import java.nio.ByteBuffer; import java.nio.ReadOnlyBufferException; import java.util.Objects;
*** 79,89 **** return accessMode.at.accessModeType(byte[].class, $type$.class, int.class); } @ForceInline static int index(byte[] ba, int index) { ! return Objects.checkIndex(index, ba.length - ALIGN, null); } @ForceInline static long address(byte[] ba, int index) { long address = ((long) index) + Unsafe.ARRAY_BYTE_BASE_OFFSET; --- 80,90 ---- return accessMode.at.accessModeType(byte[].class, $type$.class, int.class); } @ForceInline static int index(byte[] ba, int index) { ! return Preconditions.checkIndex(index, ba.length - ALIGN, null); } @ForceInline static long address(byte[] ba, int index) { long address = ((long) index) + Unsafe.ARRAY_BYTE_BASE_OFFSET;
*** 305,322 **** return accessMode.at.accessModeType(ByteBuffer.class, $type$.class, int.class); } @ForceInline static int index(ByteBuffer bb, int index) { ! return Objects.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null); } @ForceInline static int indexRO(ByteBuffer bb, int index) { if (UNSAFE.getBoolean(bb, BYTE_BUFFER_IS_READ_ONLY)) throw new ReadOnlyBufferException(); ! return Objects.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null); } @ForceInline static long address(ByteBuffer bb, int index) { long address = ((long) index) + UNSAFE.getLong(bb, BUFFER_ADDRESS); --- 306,323 ---- return accessMode.at.accessModeType(ByteBuffer.class, $type$.class, int.class); } @ForceInline static int index(ByteBuffer bb, int index) { ! return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null); } @ForceInline static int indexRO(ByteBuffer bb, int index) { if (UNSAFE.getBoolean(bb, BYTE_BUFFER_IS_READ_ONLY)) throw new ReadOnlyBufferException(); ! return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null); } @ForceInline static long address(ByteBuffer bb, int index) { long address = ((long) index) + UNSAFE.getLong(bb, BUFFER_ADDRESS);
< prev index next >