RFR: 8357086: os::xxx functions returning memory size should return size_t [v34]
David Holmes
dholmes at openjdk.org
Tue Aug 26 05:27:50 UTC 2025
On Thu, 21 Aug 2025 12:30:40 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 size_t physical_memory(size_t& value);
>>
>>
>> The return boolean value, where available, indicates success, whereas the actual value is assigned to the input argument. The following recommended usage pattern is introduced: where applicable, an unsuccessful call is logged.
>>
>> `ATTRIBUTE_NODISCARD` macro is added as a placeholder for `[[nodiscard]]`, which will be available with C++17.
>>
>> Tested in GHA and Tiers 1-5.
>
> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
>
> 8357086: Fixed method name in assert in os_windows.cpp
>
> Co-authored-by: Stefan Karlsson <stefan.karlsson at oracle.com>
One comment below but otherwise I think everything I have been concerned about has been addressed. Thanks for your patience.
src/hotspot/share/utilities/globalDefinitions.hpp line 60:
> 58:
> 59: // Dummy placeholder for use of [[nodiscard]]
> 60: #define ATTRIBUTE_NODISCARD
I think you can just use `[[nodiscard]]` directly now. We are going to allow it and the guide is just going through the official update process.
-------------
Marked as reviewed by dholmes (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/25450#pullrequestreview-3153982860
PR Review Comment: https://git.openjdk.org/jdk/pull/25450#discussion_r2299817113
More information about the hotspot-dev
mailing list