RFR: 8367413: Refactor types in Arguments::set_heap_size() [v6]
Albert Mingkun Yang
ayang at openjdk.org
Wed Oct 8 11:25:05 UTC 2025
On Wed, 8 Oct 2025 09:57:38 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:
>> Hello,
>>
>> There are several integer types used when setting the heap size ergonomically in `Arguments::set_heap_size()`, such as julong, uint64_t and size_t. It's not clear if this code works as intended on a 32-bit VM with more than 4GB physical memory. There might be issues when converting to/from size_t and uint64_t that we don't handle properly. I suggest we should be more robust and have more control over transitions between potentially smaller types.
>>
>> Additionally, I've gone ahead and added comments which I think makes it easier to understand what's going on in this function. I've tried my best to leave the existing behavior unchanged, apart from type conversion.
>>
>> Testing:
>> * Oracle's tier1-8 on all Oracle supported platforms
>
> Joel Sikström has updated the pull request incrementally with one additional commit since the last revision:
>
> Make limit_by_size_t_max to a static function in arguments.cpp
Marked as reviewed by ayang (Reviewer).
src/hotspot/share/runtime/arguments.cpp line 1510:
> 1508: static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
> 1509:
> 1510: static size_t limit_by_size_t_max(uint64_t value) {
I wonder if `clamp_by_size_t_max` sounds better. Up to you.
-------------
PR Review: https://git.openjdk.org/jdk/pull/27224#pullrequestreview-3314359536
PR Review Comment: https://git.openjdk.org/jdk/pull/27224#discussion_r2413529193
More information about the hotspot-gc-dev
mailing list