RFR: 8257815: Replace global log2 functions with efficient implementations [v6]

Claes Redestad redestad at openjdk.java.net
Wed Dec 9 18:26:11 UTC 2020


On Wed, 9 Dec 2020 10:19:30 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   x->value
>
> src/hotspot/share/utilities/powerOfTwo.hpp line 78:
> 
>> 76:                        "x must be a power of 2: " UINT64_FORMAT,
>> 77:                        (uint64_t)static_cast<typename std::make_unsigned<T>::type>(value));
>> 78:   return ilog2(value);
> 
> `count_trailing_zeros(value);` is more direct.

This broke down on 32-bit JVMs. Reason is that `count_trailing_zeros` takes a `uintx`, so the 64-bit argument in vm_version_x86.cpp will be downcast to 32-bit and end up as zero. I reverted the changes, filed https://bugs.openjdk.java.net/browse/JDK-8257985 and added a TODO to log2i_exact

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

PR: https://git.openjdk.java.net/jdk/pull/1663


More information about the hotspot-dev mailing list