RFR: 8367413: Refactor types in Arguments::set_heap_size() [v5]
Joel Sikström
jsikstro at openjdk.org
Wed Oct 8 09:57:39 UTC 2025
On Wed, 8 Oct 2025 09:47:02 GMT, Leo Korinth <lkorinth at openjdk.org> wrote:
>> src/hotspot/share/utilities/globalDefinitions.hpp line 1112:
>>
>>> 1110: return (size_t)MIN2(value, (T)std::numeric_limits<size_t>::max());
>>> 1111: }
>>> 1112:
>>
>> Maybe something more generic like this:
>>
>> // return the value of B clamped by the numeric limits of S, casted to S
>> template<class S, class B>
>> S clamp_into_from(B value) {
>> static_assert(std::numeric_limits<B>::min() <= std::numeric_limits<S>::min(), "make sure the big type min can hold the small type min");
>> static_assert(std::numeric_limits<B>::max() >= std::numeric_limits<S>::max(), "make sure the big type max can hold the small type max");
>> B v = clamp<B>(value, std::numeric_limits<S>::min(), std::numeric_limits<S>::max());
>> return static_cast<S>(v);
>> }
>>
>> and place it after clamp?
>
> I think my proposal is not optimal, please instead specialize your method to uint64_t and place it in arguments.cpp.
I agree, let's make it local to arguments.cpp.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27224#discussion_r2413274164
More information about the hotspot-gc-dev
mailing list