RFR: 8236634: Memory Access API tests fail on 32-bit
Nick Gasson
nick.gasson at arm.com
Tue Jan 7 08:21:53 UTC 2020
Hi,
Please review this set of fixes for the new memory access API on 32-bit
Arm/x86.
Bug: https://bugs.openjdk.java.net/browse/JDK-8236634
Webrev: http://cr.openjdk.java.net/~ngasson/8236634/webrev.0/
libNativeAccess.c fails to build with warnings enabled due to casting
pointers to integers of different widths. Added an intermediate cast to
uintptr_t to silence this.
TestArrays::testTooBigForArray calls MemorySegment.allocateNative with
size Integer.MAX_VALUE * 2 (0xFFFF_FFFE). This gets passed to
Unsafe_AllocateMemory0 which aligns the size up to HeapWordSize. But
on a 32-bit system this overflows the value of size_t, resulting in a
call to os::malloc(0). Added an overflow check after the call to
align_up().
MemorySegment::makeNativeSegment assumes that the result of
Unsafe::allocateMemory will always be at least 16 byte aligned. But on a
32-bit system the result can be 8 byte aligned. Made the MAX_ALIGN
constant conditional on the address size.
Several of the tests in TestByteBuffer.java allocate a byte[] array on
the heap and then read or write Java long/double from the array base
address. On a 32-bit system the array data is located immediately after
12 bytes of header so these eight byte accesses are misaligned. I made a
minimal fix here to just skip the long/double cases on 32-bit systems.
Tested jdk_foreign on x86_32, arm32, x86_64, and aarch64.
Thanks,
Nick
More information about the core-libs-dev
mailing list