Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ public class TestVectorizationMismatchedAccess {
private final static WhiteBox wb = WhiteBox.getWhiteBox();

public static void main(String[] args) {
if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) {
throw new RuntimeException("fix test that was written for a little endian platform");
}
TestFramework.runWithFlags("--add-modules", "java.base", "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED");
}

Expand All @@ -77,6 +74,14 @@ public static void main(String[] args) {
}
}

// Method to adjust the value for the native byte order
static private long handleByteOrder(long value) {
if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) {
value = Long.reverseBytes(value);
}
return value;
}

static private void runAndVerify(Runnable test, int offset) {
System.arraycopy(verifyLongArray, 0, longArray, 0, longArray.length);
Arrays.fill(byteArray, (byte)0);
Expand Down Expand Up @@ -154,7 +159,7 @@ static private void runAndVerify3(Runnable test, int offset) {
// might get fixed with JDK-8325155.
public static void testByteLong1a(byte[] dest, long[] src) {
for (int i = 0; i < src.length; i++) {
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, src[i]);
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, handleByteOrder(src[i]));
}
}

Expand All @@ -165,7 +170,7 @@ public static void testByteLong1a(byte[] dest, long[] src) {
// 32-bit: address has ConvL2I for cast of long to address, not supported.
public static void testByteLong1b(byte[] dest, long[] src) {
for (int i = 0; i < src.length; i++) {
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i, src[i]);
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i, handleByteOrder(src[i]));
}
}

Expand All @@ -175,7 +180,7 @@ public static void testByteLong1b(byte[] dest, long[] src) {
public static void testByteLong1c(byte[] dest, long[] src) {
long base = 64; // make sure it is big enough and 8 byte aligned (required for 32-bit)
for (int i = 0; i < src.length - 8; i++) {
UNSAFE.putLongUnaligned(dest, base + 8 * i, src[i]);
UNSAFE.putLongUnaligned(dest, base + 8 * i, handleByteOrder(src[i]));
}
}

Expand All @@ -187,7 +192,7 @@ public static void testByteLong1c(byte[] dest, long[] src) {
public static void testByteLong1d(byte[] dest, long[] src) {
long base = 64; // make sure it is big enough and 8 byte aligned (required for 32-bit)
for (int i = 0; i < src.length - 8; i++) {
UNSAFE.putLongUnaligned(dest, base + 8L * i, src[i]);
UNSAFE.putLongUnaligned(dest, base + 8L * i, handleByteOrder(src[i]));
}
}

Expand All @@ -207,7 +212,7 @@ public static void testByteLong1_runner() {
// might get fixed with JDK-8325155.
public static void testByteLong2a(byte[] dest, long[] src) {
for (int i = 1; i < src.length; i++) {
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), src[i]);
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), handleByteOrder(src[i]));
}
}

Expand All @@ -218,7 +223,7 @@ public static void testByteLong2a(byte[] dest, long[] src) {
// 32-bit: address has ConvL2I for cast of long to address, not supported.
public static void testByteLong2b(byte[] dest, long[] src) {
for (int i = 1; i < src.length; i++) {
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i - 1), src[i]);
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i - 1), handleByteOrder(src[i]));
}
}

Expand All @@ -236,7 +241,7 @@ public static void testByteLong2_runner() {
// might get fixed with JDK-8325155.
public static void testByteLong3a(byte[] dest, long[] src) {
for (int i = 0; i < src.length - 1; i++) {
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), src[i]);
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), handleByteOrder(src[i]));
}
}

Expand All @@ -247,7 +252,7 @@ public static void testByteLong3a(byte[] dest, long[] src) {
// 32-bit: address has ConvL2I for cast of long to address, not supported.
public static void testByteLong3b(byte[] dest, long[] src) {
for (int i = 0; i < src.length - 1; i++) {
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + 1), src[i]);
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + 1), handleByteOrder(src[i]));
}
}

Expand All @@ -267,7 +272,7 @@ public static void testByteLong3_runner() {
// AlignVector cannot guarantee that invar is aligned.
public static void testByteLong4a(byte[] dest, long[] src, int start, int stop) {
for (int i = start; i < stop; i++) {
UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, src[i]);
UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, handleByteOrder(src[i]));
}
}

Expand All @@ -280,7 +285,7 @@ public static void testByteLong4a(byte[] dest, long[] src, int start, int stop)
// AlignVector cannot guarantee that invar is aligned.
public static void testByteLong4b(byte[] dest, long[] src, int start, int stop) {
for (int i = start; i < stop; i++) {
UNSAFE.putLongUnaligned(dest, 8L * i + baseOffset, src[i]);
UNSAFE.putLongUnaligned(dest, 8L * i + baseOffset, handleByteOrder(src[i]));
}
}

Expand All @@ -299,7 +304,7 @@ public static void testByteLong4_runner() {
// might get fixed with JDK-8325155.
public static void testByteLong5a(byte[] dest, long[] src, int start, int stop) {
for (int i = start; i < stop; i++) {
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), src[i]);
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), handleByteOrder(src[i]));
}
}

Expand All @@ -310,7 +315,7 @@ public static void testByteLong5a(byte[] dest, long[] src, int start, int stop)
// 32-bit: address has ConvL2I for cast of long to address, not supported.
public static void testByteLong5b(byte[] dest, long[] src, int start, int stop) {
for (int i = start; i < stop; i++) {
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + baseOffset), src[i]);
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + baseOffset), handleByteOrder(src[i]));
}
}

Expand Down Expand Up @@ -454,7 +459,7 @@ public static void testByteByte5_runner() {
// See: JDK-8331576
public static void testOffHeapLong1a(long dest, long[] src) {
for (int i = 0; i < src.length; i++) {
UNSAFE.putLongUnaligned(null, dest + 8 * i, src[i]);
UNSAFE.putLongUnaligned(null, dest + 8 * i, handleByteOrder(src[i]));
}
}

Expand All @@ -465,7 +470,7 @@ public static void testOffHeapLong1a(long dest, long[] src) {
// See: JDK-8331576
public static void testOffHeapLong1b(long dest, long[] src) {
for (int i = 0; i < src.length; i++) {
UNSAFE.putLongUnaligned(null, dest + 8L * i, src[i]);
UNSAFE.putLongUnaligned(null, dest + 8L * i, handleByteOrder(src[i]));
}
}

Expand All @@ -482,7 +487,7 @@ public static void testOffHeapLong1_runner() {
// See: JDK-8331576
public static void testOffHeapLong2a(long dest, long[] src) {
for (int i = 1; i < src.length; i++) {
UNSAFE.putLongUnaligned(null, dest + 8 * (i - 1), src[i]);
UNSAFE.putLongUnaligned(null, dest + 8 * (i - 1), handleByteOrder(src[i]));
}
}

Expand All @@ -493,7 +498,7 @@ public static void testOffHeapLong2a(long dest, long[] src) {
// See: JDK-8331576
public static void testOffHeapLong2b(long dest, long[] src) {
for (int i = 1; i < src.length; i++) {
UNSAFE.putLongUnaligned(null, dest + 8L * (i - 1), src[i]);
UNSAFE.putLongUnaligned(null, dest + 8L * (i - 1), handleByteOrder(src[i]));
}
}

Expand All @@ -510,7 +515,7 @@ public static void testOffHeapLong2_runner() {
// See: JDK-8331576
public static void testOffHeapLong3a(long dest, long[] src) {
for (int i = 0; i < src.length - 1; i++) {
UNSAFE.putLongUnaligned(null, dest + 8 * (i + 1), src[i]);
UNSAFE.putLongUnaligned(null, dest + 8 * (i + 1), handleByteOrder(src[i]));
}
}

Expand All @@ -521,7 +526,7 @@ public static void testOffHeapLong3a(long dest, long[] src) {
// See: JDK-8331576
public static void testOffHeapLong3b(long dest, long[] src) {
for (int i = 0; i < src.length - 1; i++) {
UNSAFE.putLongUnaligned(null, dest + 8L * (i + 1), src[i]);
UNSAFE.putLongUnaligned(null, dest + 8L * (i + 1), handleByteOrder(src[i]));
}
}

Expand All @@ -540,7 +545,7 @@ public static void testOffHeapLong3_runner() {
// AlignVector cannot guarantee that invar is aligned.
public static void testOffHeapLong4a(long dest, long[] src, int start, int stop) {
for (int i = start; i < stop; i++) {
UNSAFE.putLongUnaligned(null, dest + 8 * i + baseOffset, src[i]);
UNSAFE.putLongUnaligned(null, dest + 8 * i + baseOffset, handleByteOrder(src[i]));
}
}

Expand All @@ -553,7 +558,7 @@ public static void testOffHeapLong4a(long dest, long[] src, int start, int stop)
// AlignVector cannot guarantee that invar is aligned.
public static void testOffHeapLong4b(long dest, long[] src, int start, int stop) {
for (int i = start; i < stop; i++) {
UNSAFE.putLongUnaligned(null, dest + 8L * i + baseOffset, src[i]);
UNSAFE.putLongUnaligned(null, dest + 8L * i + baseOffset, handleByteOrder(src[i]));
}
}

Expand Down