RFR: 8253779: Amalloc may be wasting space by overaligning

Coleen Phillimore coleenp at openjdk.java.net
Fri Jul 9 00:38:50 UTC 2021


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

>> [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.

1, 3.  Ok, turned to else if with appropriate brackets.
2. Both of these places have a call check_for_overflow that checks that so rearranging the code leads to casts since _hwm and _max are char* and x is size_t.

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

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


More information about the hotspot-dev mailing list