RFR: 8357086: os::xxx functions returning memory size should return size_t [v4]
Stefan Karlsson
stefank at openjdk.org
Wed Jun 11 08:38:32 UTC 2025
On Fri, 30 May 2025 08:24:42 GMT, Anton Artemov <duke at openjdk.org> wrote:
>> Hi,
>>
>> in this PR the output value type for functions which return memory are changed, namely:
>>
>>
>> static julong available_memory(); --> static size_t available_memory();
>> static julong used_memory(); --> static size_t used_memory();
>> static julong free_memory(); --> static size_t free_memory();
>> static jlong total_swap_space(); --> static ptrdiff_t total_swap_space();
>> static jlong free_swap_space(); --> static ptrdiff_t free_swap_space();
>> static julong physical_memory(); --> static size_t physical_memory();
>>
>>
>> The changes are done so that the other parts of the code have minimal impact.
>> Tested in GHA and Tiers 1-4.
>
> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
>
> 8357086: Fixed spaces in formatting in gc-related code.
Are you up for making an experiment that changes `total_swap_space` and `free_swap_space` to return two values: one the actual value in `size_t` and the other an error code that gets set whenever we hit an error?
The two proposed alternatives for this would be:
1) returning something containing the two values (struct, Pair, Tuple, array, ...)
2) Return the size_t and using an an out put parameter to signal an error (or vice versa)
I think the fan-out of that will not be too bad and the likely outcome is that it is clearer that the code is propagating errors.
-------------
Changes requested by stefank (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/25450#pullrequestreview-2916176235
More information about the hotspot-dev
mailing list