RFR: JDK-8270308: Amalloc aligns size but not return value (take 2) [v3]

Thomas Stuefe stuefe at openjdk.java.net
Sat Jul 24 15:37:03 UTC 2021


On Sat, 24 Jul 2021 13:48:25 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> Sorry about the typo. I meant to ask, how can `_max` not be 64bit aligned. As that is what the comment is claiming can happen, and that is where things can go wrong. If grow() were to align the allocation size then I don't think that can happen and all would be good.

Oh, okay. I see what you mean. Arena::_max is not 64-bit aligned currently, but maybe that is easier to fix than I thought:

Arena::_max  depeds on the chunk length (the payload length). I would not want to align Arena::_max itself, because there are too many entry points (all that save restore code directly modifies it). 

But maybe the chunk length itself? The chunk length is either handed in as initsize parameter to `Arena::Arena(MEMFLAGS memflag, size_t init_size);`, which can be anything. But we could align it without problem. We already do, to word size. Could align to 64bit instead.

Or, chunk length is one of the default chunk lengths - `Chunk::size, tinysize` etc. Those are not aligned correctly, since that `slack` offset which we use to keep waste low if libc uses buddy allocation is not aligned correctly. Its 20. If we make it 24, its 64-bit aligned, and all default chunk lengths are 64-bit aligned. 

I think that may work. I have to check. It would certainly be cleaner.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4835


More information about the hotspot-dev mailing list