RFR: 8357086: os::xxx functions returning memory size should return size_t [v17]
Anton Artemov
duke at openjdk.org
Wed Jul 30 15:22:39 UTC 2025
On Wed, 30 Jul 2025 15:12:42 GMT, Anton Artemov <duke at openjdk.org> wrote:
>> Hi,
>>
>> in this PR the output value types for functions which return memory are changed, namely:
>>
>>
>> static julong available_memory(); --> static bool available_memory(size_t& value);
>> static julong used_memory(); --> static bool used_memory(size_t& value);
>> static julong free_memory(); --> static bool free_memory(size_t& value);
>> static jlong total_swap_space(); --> static bool total_swap_space(size_t& value);
>> static jlong free_swap_space(); --> static bool free_swap_space(size_t& value);
>> static julong physical_memory(); --> static bool physical_memory(size_t& value);
>>
>>
>> The return boolean value indicates success, whereas the actual value is assigned to the input argument. The following recommended usage pattern is introduced: where applicable, and unsuccessful call is logged.
>>
>> Later, the return value can be attributed with `[[nodiscard]]` to enforce the pattern.
>>
>> Tested in GHA and Tiers 1-5.
>
> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
>
> 8357086: Addressed reviewer's comments
> I proposed the usage of (void) but you instead used static_cast. We have an overwhelmingly larger set of (void) usages so I think you should stick to using the prevalent form.
I think I addressed all points. As for `(void)` vs `static_cast<void>` conversion, the only benefit I see is shortness. But okay.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25450#issuecomment-3136808153
More information about the hotspot-dev
mailing list