RFR: 8343700: ceil_log2 should not loop endlessly [v3]
Kim Barrett
kbarrett at openjdk.org
Thu Nov 14 08:37:16 UTC 2024
On Wed, 13 Nov 2024 19:58:32 GMT, Sonia Zaldana Calles <szaldana at openjdk.org> wrote:
>> Hi all,
>>
>> This PR addresses [8343700](https://bugs.openjdk.org/browse/JDK-8343700) where ceil_log2 looped endlessly if the input value has the highest bit set.
>>
>> I also dealt with the case where we try to find ceil_log2(1) which would've returned 1 as opposed to 0.
>>
>> Cheers,
>> Sonia
>
> Sonia Zaldana Calles has updated the pull request incrementally with one additional commit since the last revision:
>
> Starting ret at 0
Changes requested by kbarrett (Reviewer).
src/hotspot/share/utilities/powerOfTwo.hpp line 125:
> 123: // Find log2 value greater than this input
> 124: template <typename T, ENABLE_IF(std::is_integral<T>::value)>
> 125: inline T ceil_log2(T value) {
Pre-existing: It's a mistake that this function's return type is T. It should be int, like all the other log2
variants in this file. Maybe it should be near those.
src/hotspot/share/utilities/powerOfTwo.hpp line 126:
> 124: template <typename T, ENABLE_IF(std::is_integral<T>::value)>
> 125: inline T ceil_log2(T value) {
> 126: assert(value > 0, "Invalid value");
This assert doesn't help when T is an unsigned type.
-------------
PR Review: https://git.openjdk.org/jdk/pull/22074#pullrequestreview-2435354618
PR Review Comment: https://git.openjdk.org/jdk/pull/22074#discussion_r1841765688
PR Review Comment: https://git.openjdk.org/jdk/pull/22074#discussion_r1841763247
More information about the hotspot-dev
mailing list