RFR: 8253779: Amalloc may be wasting space by overaligning

Kim Barrett kbarrett at openjdk.java.net
Thu Jul 8 22:52:56 UTC 2021


On Thu, 8 Jul 2021 22:17:07 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> src/hotspot/share/memory/arena.hpp line 159:
>> 
>>> 157:     assert((x & (sizeof(char*)-1)) == 0, "misaligned size");
>>> 158:     debug_only(if (UseMallocOnly) return malloc(x);)
>>> 159:     if (!check_for_overflow(x, "Arena::Amalloc_4", alloc_failmode))
>> 
>> [pre-existing] Missing brackets for the multiline `if` is contrary to the style guide.  Similarly in Amalloc.
>
> [pre-existing: I can't comment directly on line 161, so adding here.]
> `if (_hwm + x > _max)` has a risk of overflow if x is excessively large. Better is `if (_max - _hwm < x)`.  Similarly in Amalloc.

[pre-existing. I can't comment directly on line 161, so adding here.]
The `if` to range check `x` could be an `else if`.  Similarly in Amalloc.

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

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


More information about the hotspot-dev mailing list