RFR: 8237521: Memory Access API fixes for 32-bit
Nick Gasson
nick.gasson at arm.com
Fri Jan 24 09:58:53 UTC 2020
Hi David,
On 01/24/20 14:35 pm, David Holmes wrote:
>>
>> How about we align the size up to ADDRESS_SIZE (== HeapWordSize) in
>> Unsafe.allocateMemory() before the call to allocateMemoryChecks(). Like:
>>
>> bytes = ((bytes + ADDRESS_SIZE - 1) & ~(ADDRESS_SIZE - 1));
>>
>> Then it will throw an IllegalArgumentException if the result is outside
>> the size_t range. And in the native code we can just assert that the
>> `size' argument is already aligned:
>>
>> assert(is_aligned(sz, HeapWordSize), "sz not aligned");
>
> That seems quite reasonable.
>
I've done this here:
http://cr.openjdk.java.net/~ngasson/8237521/webrev.02/
Need to check bytes >= 0 before aligning up so that allocateMemory(-1)
still throws an IllegalArgumentException.
Tested with jdk_foreign and runtime/Unsafe/.
Thanks,
Nick
More information about the core-libs-dev
mailing list