RFR: JDK-8270308: Amalloc aligns size but not return value (take 2) [v2]
Kim Barrett
kbarrett at openjdk.java.net
Sat Jul 24 09:00:02 UTC 2021
On Thu, 22 Jul 2021 12:59:42 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> Can you just assert that size > 0 for Amalloc?
>
> Unfortunately not, since that is actually done. I would have to hunt down callers which do this. That is maybe worthwhile, but would be a larger change.
The latest version doesn't seem any better than the previous. It could still return a misaligned value in the same circumstance, just more slowly because of the additional branch.
Under what circumstances can _hwm not be 64bit aligned? What needs to be done to prevent it? It looks to me that if Arena::grow were to align its size argument, then it all falls out, assuming std::max_align_t is also appropriately aligned. Add asserts in Chunk allocation. Add a static assert that std::max_align_t is appropriately aligned and leave it to the person porting to the very weird platform to figure out what to do if it fails. And I think that's sufficient.
(While use of alignof and std::max_align_t are not currently discussed in the HotSpot Style Guide, I would have no objection to their use when the alternative is something more complicated and less robust. And feel free to propose corresponding post facto changes to style guide.)
-------------
PR: https://git.openjdk.java.net/jdk/pull/4835
More information about the hotspot-dev
mailing list