Skip to content

Commit fdfb68c

Browse files
committed
8344168: Change Unsafe base offset from int to long
Reviewed-by: liach
1 parent 5d5b294 commit fdfb68c

File tree

53 files changed

+164
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+164
-154
lines changed

src/java.base/share/classes/java/lang/StringLatin1.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -715,7 +715,7 @@ static Stream<String> lines(byte[] value) {
715715
static void putCharsAt(byte[] val, int index, int c1, int c2, int c3, int c4) {
716716
assert index >= 0 && index + 3 < length(val) : "Trusted caller missed bounds check";
717717
// Don't use the putChar method, Its instrinsic will cause C2 unable to combining values into larger stores.
718-
long offset = (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
718+
long offset = Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
719719
UNSAFE.putByte(val, offset , (byte)(c1));
720720
UNSAFE.putByte(val, offset + 1, (byte)(c2));
721721
UNSAFE.putByte(val, offset + 2, (byte)(c3));
@@ -725,7 +725,7 @@ static void putCharsAt(byte[] val, int index, int c1, int c2, int c3, int c4) {
725725
static void putCharsAt(byte[] val, int index, int c1, int c2, int c3, int c4, int c5) {
726726
assert index >= 0 && index + 4 < length(val) : "Trusted caller missed bounds check";
727727
// Don't use the putChar method, Its instrinsic will cause C2 unable to combining values into larger stores.
728-
long offset = (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
728+
long offset = Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
729729
UNSAFE.putByte(val, offset , (byte)(c1));
730730
UNSAFE.putByte(val, offset + 1, (byte)(c2));
731731
UNSAFE.putByte(val, offset + 2, (byte)(c3));

src/java.base/share/classes/java/lang/invoke/VarHandles.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -196,7 +196,7 @@ static VarHandle makeArrayElementHandle(Class<?> arrayClass) {
196196

197197
Class<?> componentType = arrayClass.getComponentType();
198198

199-
int aoffset = UNSAFE.arrayBaseOffset(arrayClass);
199+
int aoffset = (int) UNSAFE.arrayBaseOffset(arrayClass);
200200
int ascale = UNSAFE.arrayIndexScale(arrayClass);
201201
int ashift = 31 - Integer.numberOfLeadingZeros(ascale);
202202

src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6383,7 +6383,7 @@ public final void compute() {
63836383
= U.objectFieldOffset(ConcurrentHashMap.class, "cellsBusy");
63846384
private static final long CELLVALUE
63856385
= U.objectFieldOffset(CounterCell.class, "value");
6386-
private static final int ABASE = U.arrayBaseOffset(Node[].class);
6386+
private static final long ABASE = U.arrayBaseOffset(Node[].class);
63876387
private static final int ASHIFT;
63886388

63896389
static {

src/java.base/share/classes/java/util/zip/CRC32C.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -222,9 +222,9 @@ private static int updateBytes(int crc, byte[] b, int off, int end) {
222222
if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) {
223223

224224
// align on 8 bytes
225-
int alignLength
225+
long alignLength
226226
= (8 - ((Unsafe.ARRAY_BYTE_BASE_OFFSET + off) & 0x7)) & 0x7;
227-
for (int alignEnd = off + alignLength; off < alignEnd; off++) {
227+
for (long alignEnd = off + alignLength; off < alignEnd; off++) {
228228
crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF];
229229
}
230230

@@ -238,11 +238,11 @@ private static int updateBytes(int crc, byte[] b, int off, int end) {
238238
int secondHalf;
239239
if (Unsafe.ADDRESS_SIZE == 4) {
240240
// On 32 bit platforms read two ints instead of a single 64bit long
241-
firstHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
242-
secondHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off
241+
firstHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
242+
secondHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off
243243
+ Integer.BYTES);
244244
} else {
245-
long value = UNSAFE.getLong(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
245+
long value = UNSAFE.getLong(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
246246
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
247247
firstHalf = (int) value;
248248
secondHalf = (int) (value >>> 32);

src/java.base/share/classes/java/util/zip/ZipUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -174,7 +174,7 @@ public static final int get16(byte[] b, int off) {
174174
Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER);
175175
Preconditions.checkIndex(off + 1, b.length, Preconditions.AIOOBE_FORMATTER);
176176
return Short.toUnsignedInt(
177-
UNSAFE.getShortUnaligned(b, off + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET, false));
177+
UNSAFE.getShortUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false));
178178
}
179179

180180
/**
@@ -185,7 +185,7 @@ public static final long get32(byte[] b, int off) {
185185
Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER);
186186
Preconditions.checkIndex(off + 3, b.length, Preconditions.AIOOBE_FORMATTER);
187187
return Integer.toUnsignedLong(
188-
UNSAFE.getIntUnaligned(b, off + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET, false));
188+
UNSAFE.getIntUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false));
189189
}
190190

191191
/**
@@ -195,7 +195,7 @@ public static final long get32(byte[] b, int off) {
195195
public static final long get64S(byte[] b, int off) {
196196
Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER);
197197
Preconditions.checkIndex(off + 7, b.length, Preconditions.AIOOBE_FORMATTER);
198-
return UNSAFE.getLongUnaligned(b, off + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET, false);
198+
return UNSAFE.getLongUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false);
199199
}
200200

201201
/**
@@ -206,7 +206,7 @@ public static final long get64S(byte[] b, int off) {
206206
public static final int get32S(byte[] b, int off) {
207207
Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER);
208208
Preconditions.checkIndex(off + 3, b.length, Preconditions.AIOOBE_FORMATTER);
209-
return UNSAFE.getIntUnaligned(b, off + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET, false);
209+
return UNSAFE.getIntUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false);
210210
}
211211

212212
/*

src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -386,16 +386,16 @@ public int getU1Unchecked(int bci) {
386386
}
387387

388388
public int getU2Unchecked(int bci) {
389-
return UNSAFE.getCharUnaligned(code.array, (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + bci, true);
389+
return UNSAFE.getCharUnaligned(code.array, Unsafe.ARRAY_BYTE_BASE_OFFSET + bci, true);
390390
}
391391

392392
public int getShortUnchecked(int bci) {
393-
return UNSAFE.getShortUnaligned(code.array, (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + bci, true);
393+
return UNSAFE.getShortUnaligned(code.array, Unsafe.ARRAY_BYTE_BASE_OFFSET + bci, true);
394394
}
395395

396396
// used after switch validation
397397
public int getIntUnchecked(int bci) {
398-
return UNSAFE.getIntUnaligned(code.array, (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + bci, true);
398+
return UNSAFE.getIntUnaligned(code.array, Unsafe.ARRAY_BYTE_BASE_OFFSET + bci, true);
399399
}
400400

401401
// non-wide branches

src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ByteBuffer makeByteBuffer() {
9393
throw new UnsupportedOperationException("Not an address to an heap-allocated byte array");
9494
}
9595
JavaNioAccess nioAccess = SharedSecrets.getJavaNioAccess();
96-
return nioAccess.newHeapByteBuffer(baseByte, (int)offset - Utils.BaseAndScale.BYTE.base(), (int) byteSize(), null);
96+
return nioAccess.newHeapByteBuffer(baseByte, (int)(offset - Utils.BaseAndScale.BYTE.base()), (int) byteSize(), null);
9797
}
9898

9999
// factories

src/java.base/share/classes/jdk/internal/foreign/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public static String toHexString(long value) {
298298
return "0x" + Long.toHexString(value);
299299
}
300300

301-
public record BaseAndScale(int base, long scale) {
301+
public record BaseAndScale(long base, long scale) {
302302

303303
public static final BaseAndScale BYTE =
304304
new BaseAndScale(Unsafe.ARRAY_BYTE_BASE_OFFSET, Unsafe.ARRAY_BYTE_INDEX_SCALE);

src/java.base/share/classes/jdk/internal/misc/Unsafe.java

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1043,8 +1043,11 @@ private void checkWritebackEnabled() {
10431043
* This constant differs from all results that will ever be returned from
10441044
* {@link #staticFieldOffset}, {@link #objectFieldOffset},
10451045
* or {@link #arrayBaseOffset}.
1046+
* <p>
1047+
* The static type is @code long} to emphasize that long arithmetic should
1048+
* always be used for offset calculations to avoid overflows.
10461049
*/
1047-
public static final int INVALID_FIELD_OFFSET = -1;
1050+
public static final long INVALID_FIELD_OFFSET = -1;
10481051

10491052
/**
10501053
* Reports the location of a given field in the storage allocation of its
@@ -1172,11 +1175,15 @@ public void ensureClassInitialized(Class<?> c) {
11721175
* for the same class, you may use that scale factor, together with this
11731176
* base offset, to form new offsets to access elements of arrays of the
11741177
* given class.
1178+
* <p>
1179+
* The return value is in the range of a {@code int}. The return type is
1180+
* {@code long} to emphasize that long arithmetic should always be used
1181+
* for offset calculations to avoid overflows.
11751182
*
11761183
* @see #getInt(Object, long)
11771184
* @see #putInt(Object, long, int)
11781185
*/
1179-
public int arrayBaseOffset(Class<?> arrayClass) {
1186+
public long arrayBaseOffset(Class<?> arrayClass) {
11801187
if (arrayClass == null) {
11811188
throw new NullPointerException();
11821189
}
@@ -1186,39 +1193,39 @@ public int arrayBaseOffset(Class<?> arrayClass) {
11861193

11871194

11881195
/** The value of {@code arrayBaseOffset(boolean[].class)} */
1189-
public static final int ARRAY_BOOLEAN_BASE_OFFSET
1196+
public static final long ARRAY_BOOLEAN_BASE_OFFSET
11901197
= theUnsafe.arrayBaseOffset(boolean[].class);
11911198

11921199
/** The value of {@code arrayBaseOffset(byte[].class)} */
1193-
public static final int ARRAY_BYTE_BASE_OFFSET
1200+
public static final long ARRAY_BYTE_BASE_OFFSET
11941201
= theUnsafe.arrayBaseOffset(byte[].class);
11951202

11961203
/** The value of {@code arrayBaseOffset(short[].class)} */
1197-
public static final int ARRAY_SHORT_BASE_OFFSET
1204+
public static final long ARRAY_SHORT_BASE_OFFSET
11981205
= theUnsafe.arrayBaseOffset(short[].class);
11991206

12001207
/** The value of {@code arrayBaseOffset(char[].class)} */
1201-
public static final int ARRAY_CHAR_BASE_OFFSET
1208+
public static final long ARRAY_CHAR_BASE_OFFSET
12021209
= theUnsafe.arrayBaseOffset(char[].class);
12031210

12041211
/** The value of {@code arrayBaseOffset(int[].class)} */
1205-
public static final int ARRAY_INT_BASE_OFFSET
1212+
public static final long ARRAY_INT_BASE_OFFSET
12061213
= theUnsafe.arrayBaseOffset(int[].class);
12071214

12081215
/** The value of {@code arrayBaseOffset(long[].class)} */
1209-
public static final int ARRAY_LONG_BASE_OFFSET
1216+
public static final long ARRAY_LONG_BASE_OFFSET
12101217
= theUnsafe.arrayBaseOffset(long[].class);
12111218

12121219
/** The value of {@code arrayBaseOffset(float[].class)} */
1213-
public static final int ARRAY_FLOAT_BASE_OFFSET
1220+
public static final long ARRAY_FLOAT_BASE_OFFSET
12141221
= theUnsafe.arrayBaseOffset(float[].class);
12151222

12161223
/** The value of {@code arrayBaseOffset(double[].class)} */
1217-
public static final int ARRAY_DOUBLE_BASE_OFFSET
1224+
public static final long ARRAY_DOUBLE_BASE_OFFSET
12181225
= theUnsafe.arrayBaseOffset(double[].class);
12191226

12201227
/** The value of {@code arrayBaseOffset(Object[].class)} */
1221-
public static final int ARRAY_OBJECT_BASE_OFFSET
1228+
public static final long ARRAY_OBJECT_BASE_OFFSET
12221229
= theUnsafe.arrayBaseOffset(Object[].class);
12231230

12241231
/**
@@ -1227,6 +1234,9 @@ public int arrayBaseOffset(Class<?> arrayClass) {
12271234
* will generally not work properly with accessors like {@link
12281235
* #getByte(Object, long)}, so the scale factor for such classes is reported
12291236
* as zero.
1237+
* <p>
1238+
* The computation of the actual memory offset should always use {@code
1239+
* long} arithmetic to avoid overflows.
12301240
*
12311241
* @see #arrayBaseOffset
12321242
* @see #getInt(Object, long)
@@ -3840,7 +3850,7 @@ private void putShortParts(Object o, long offset, byte i0, byte i1) {
38403850
private native Object staticFieldBase0(Field f);
38413851
private native boolean shouldBeInitialized0(Class<?> c);
38423852
private native void ensureClassInitialized0(Class<?> c);
3843-
private native int arrayBaseOffset0(Class<?> arrayClass);
3853+
private native int arrayBaseOffset0(Class<?> arrayClass); // public version returns long to promote correct arithmetic
38443854
private native int arrayIndexScale0(Class<?> arrayClass);
38453855
private native int getLoadAverage0(double[] loadavg, int nelems);
38463856

src/java.base/share/classes/jdk/internal/util/ArraysSupport.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -457,8 +457,8 @@ public static int mismatch(boolean[] a, int aFromIndex,
457457
if (length > 7) {
458458
if (a[aFromIndex] != b[bFromIndex])
459459
return 0;
460-
int aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex;
461-
int bOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + bFromIndex;
460+
long aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex;
461+
long bOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + bFromIndex;
462462
i = vectorizedMismatch(
463463
a, aOffset,
464464
b, bOffset,
@@ -550,8 +550,8 @@ public static int mismatch(byte[] a, int aFromIndex,
550550
if (length > 7) {
551551
if (a[aFromIndex] != b[bFromIndex])
552552
return 0;
553-
int aOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + aFromIndex;
554-
int bOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + bFromIndex;
553+
long aOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + aFromIndex;
554+
long bOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + bFromIndex;
555555
i = vectorizedMismatch(
556556
a, aOffset,
557557
b, bOffset,
@@ -599,8 +599,8 @@ public static int mismatch(char[] a, int aFromIndex,
599599
if (length > 3) {
600600
if (a[aFromIndex] != b[bFromIndex])
601601
return 0;
602-
int aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE);
603-
int bOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE);
602+
long aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE);
603+
long bOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE);
604604
i = vectorizedMismatch(
605605
a, aOffset,
606606
b, bOffset,
@@ -648,8 +648,8 @@ public static int mismatch(short[] a, int aFromIndex,
648648
if (length > 3) {
649649
if (a[aFromIndex] != b[bFromIndex])
650650
return 0;
651-
int aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE);
652-
int bOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE);
651+
long aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE);
652+
long bOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE);
653653
i = vectorizedMismatch(
654654
a, aOffset,
655655
b, bOffset,
@@ -697,8 +697,8 @@ public static int mismatch(int[] a, int aFromIndex,
697697
if (length > 1) {
698698
if (a[aFromIndex] != b[bFromIndex])
699699
return 0;
700-
int aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE);
701-
int bOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_INT_INDEX_SCALE);
700+
long aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE);
701+
long bOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_INT_INDEX_SCALE);
702702
i = vectorizedMismatch(
703703
a, aOffset,
704704
b, bOffset,
@@ -729,8 +729,8 @@ public static int mismatch(float[] a, int aFromIndex,
729729
int i = 0;
730730
if (length > 1) {
731731
if (Float.floatToRawIntBits(a[aFromIndex]) == Float.floatToRawIntBits(b[bFromIndex])) {
732-
int aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE);
733-
int bOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE);
732+
long aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE);
733+
long bOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE);
734734
i = vectorizedMismatch(
735735
a, aOffset,
736736
b, bOffset,
@@ -787,8 +787,8 @@ public static int mismatch(long[] a, int aFromIndex,
787787
}
788788
if (a[aFromIndex] != b[bFromIndex])
789789
return 0;
790-
int aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
791-
int bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
790+
long aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
791+
long bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
792792
int i = vectorizedMismatch(
793793
a, aOffset,
794794
b, bOffset,
@@ -813,8 +813,8 @@ public static int mismatch(double[] a, int aFromIndex,
813813
}
814814
int i = 0;
815815
if (Double.doubleToRawLongBits(a[aFromIndex]) == Double.doubleToRawLongBits(b[bFromIndex])) {
816-
int aOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE);
817-
int bOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE);
816+
long aOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE);
817+
long bOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE);
818818
i = vectorizedMismatch(
819819
a, aOffset,
820820
b, bOffset,

0 commit comments

Comments
 (0)