RFR: 8139457: Array bases are aligned at HeapWord granularity [v4]
Roman Kennke
rkennke at openjdk.org
Thu Dec 15 13:15:09 UTC 2022
On Mon, 5 Dec 2022 13:41:58 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> src/hotspot/share/oops/arrayOop.hpp line 141:
>>
>>> 139:
>>> 140: const size_t max_size_bytes = align_down(SIZE_MAX - base_offset_in_bytes(type), MinObjAlignmentInBytes);
>>> 141: const size_t max_elements_per_size_t = max_size_bytes / type2aelembytes(type);
>>
>> Can we add an assert for max_size_bytes % type2aelembytes(type) == 0?
>
> Also, this is pre-existing, but I wonder why this section exists for 64-bit. Regardless of the array type, we will cap out below and return INT_MAX-2 or -3, depending on UseCCP. Why even bother calculating this? Am I missing something?
Yes, indeed. I improved the calculation, and it now only reduces INT_MAX for element types where it is actually needed (64-bit-types on 64bit builds, and >=32-bit-types on 32-bit-builds). Smaller types would not cause the overflow (see also tests in test_arrayOop.cpp, which I also improved a little).
-------------
PR: https://git.openjdk.org/jdk/pull/11044
More information about the hotspot-dev
mailing list