RFR: 8343700: ceil_log2 should not loop endlessly [v5]

Sonia Zaldana Calles szaldana at openjdk.org
Mon Nov 18 19:02:15 UTC 2024


On Fri, 15 Nov 2024 23:50:19 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Sonia Zaldana Calles has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   fixing assert
>
> src/hotspot/share/utilities/powerOfTwo.hpp line 134:
> 
>> 132:       break;
>> 133:     }
>> 134:   }
> 
> But I think this could all be much "simpler"?  I think this works:
> 
> template<typename T, ENABLE_IF(std::is_integral<T>::value)>
> int ceil_log2(T value) {
>   assert(value > T(0), "Invalid value");
>   return log2i_graceful(value - 1) + 1;
> }

Sure, I updated to your suggestion instead.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22074#discussion_r1847103282


More information about the hotspot-dev mailing list