RFR: 8237521: Memory Access API fixes for 32-bit
david.holmes at oracle.com
Fri Jan 24 22:34:10 UTC 2020
On 24/01/2020 7:58 pm, Nick Gasson wrote:
> 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:
> Need to check bytes >= 0 before aligning up so that allocateMemory(-1)
> still throws an IllegalArgumentException.
That looks good to me.
> Tested with jdk_foreign and runtime/Unsafe/.
Probably needs a bit more testing. IIRC the direct buffers use this API
so they would be a good test subject. Or perhaps Maurizio can run this
through our CI tier1-3 before pushing?
More information about the hotspot-runtime-dev