8283122: [AIX, s390] UnsafeCopyMemory 'Mismatched' Tests Fail on Big Endian Systems
Reviewed-by: thartmann, stuefe
This commit is contained in:
parent
2cddf3f539
commit
4de72014d3
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2022 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
|
||||
@ -36,11 +36,14 @@
|
||||
package compiler.unsafe;
|
||||
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import java.nio.ByteOrder;
|
||||
import static jdk.test.lib.Asserts.assertEQ;
|
||||
|
||||
public class UnsafeCopyMemory {
|
||||
static private Unsafe UNSAFE = Unsafe.getUnsafe();
|
||||
|
||||
static final boolean IS_BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
|
||||
|
||||
// On-heap arrays
|
||||
static int[] srcArr = new int[1];
|
||||
static int[] dstArr = new int[1];
|
||||
@ -104,8 +107,12 @@ public class UnsafeCopyMemory {
|
||||
srcArr [readIdx] = v1;
|
||||
dstArrL[writeIdx] = v2;
|
||||
|
||||
// On LE systems, low-order bytes of long and int overlap, but
|
||||
// on BE systems, they differ by the size of an int.
|
||||
long mismatchedOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (IS_BIG_ENDIAN ? 4 : 0);
|
||||
|
||||
UNSAFE.copyMemory(srcArr, Unsafe.ARRAY_INT_BASE_OFFSET,
|
||||
dstArrL, Unsafe.ARRAY_LONG_BASE_OFFSET, 4); // mismatched
|
||||
dstArrL, mismatchedOffset, 4); // mismatched
|
||||
long r = resArrL[0]; // snapshot
|
||||
|
||||
srcArr[readIdx] = v3;
|
||||
@ -156,6 +163,7 @@ public class UnsafeCopyMemory {
|
||||
|
||||
Object srcArrLocal = (flag ? srcArrIntLocal : srcArrLongLocal);
|
||||
long srcOffset = (flag ? Unsafe.ARRAY_INT_BASE_OFFSET : Unsafe.ARRAY_LONG_BASE_OFFSET);
|
||||
srcOffset += (!flag && IS_BIG_ENDIAN ? 4 : 0);
|
||||
|
||||
srcArrIntLocal[0] = v1;
|
||||
srcArrLongLocal[0] = v1;
|
||||
@ -179,6 +187,7 @@ public class UnsafeCopyMemory {
|
||||
|
||||
Object dstArrLocal = (flag ? dstArrIntLocal : dstArrLongLocal);
|
||||
long dstOffset = (flag ? Unsafe.ARRAY_INT_BASE_OFFSET : Unsafe.ARRAY_LONG_BASE_OFFSET);
|
||||
dstOffset += (!flag && IS_BIG_ENDIAN ? 4 : 0);
|
||||
|
||||
srcArr[readIdx] = v1;
|
||||
dstArrIntLocal[0] = v2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user