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

Claes Redestad redestad at openjdk.java.net
Wed Dec 9 22:27:36 UTC 2020


On Wed, 9 Dec 2020 19:26:47 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Issue with using count_trailing_zeros with 64-bit values on 32-bit, revert and add TODO
>
> src/hotspot/cpu/x86/vm_version_x86.cpp line 784:
> 
>> 782:               cpu_family(), _model, _stepping, os::cpu_microcode_revision());
>> 783:   assert(res > 0, "not enough temporary space allocated");
>> 784:   assert(log2i_exact((uint64_t)CPU_MAX_FEATURE) + 1 == sizeof(_features_names) / sizeof(char*), "wrong size features_names");
> 
> If you want to get rid of this cast (and the one added to interp_masm_x86.cpp, you could register your log2i functions to accept enums:
> -template <typename T, ENABLE_IF(std::is_integral<T>::value)>
> +template <typename T, ENABLE_IF(std::is_integral<T>::value || std::is_enum<T>::value)>

Good, but feels the extra conditions in the template function is hurting readability more than the single cast - and we should probably apply this more consistently if we go down this route. Mind if I leave this for a follow-up?

I've adressed your other review comments. Thanks for being thorough!

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

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


More information about the hotspot-dev mailing list