RFR: 8257815: Replace global log2 functions with efficient implementations

Stefan Karlsson stefank at openjdk.java.net
Tue Dec 8 16:20:30 UTC 2020


On Tue, 8 Dec 2020 15:19:48 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>>> Do you guys test on big endian? To be sure I'll run this through our landscape.
>> 
>> Some big endian testing would be much appreciated.
>> 
>> I'm redesigning the `log2i` function based on Kim's feedback, which might hit a few road bumps so I'm pushing it through some local sanity testing. Hold on.
>
> Revamped the non-exact variants as `ilog2` + `ilog2_graceful`. The former has `value > 0` as a precondition, the second accepts any value and is used when it's not obvious the input can be assumed to be a non-zero, positive value.  I hope this is an acceptable compromise to reinstating the `log2_int`, `log2_long` etc variants.
> 
> I've gone through all usage to see if there are some additional places where we now need to use the graceful variant, and will do another pass later after I've rested my eyes and the changes have worked through a few tiers of testing.

I'm not sure about the ilog2 name.
1) If it's commonly used elsewhere then we're begging for a name clashes.
2) I don't like the discoverability of that name. If I write code where I need log2 then I'll look for functions named log2* not *log2. I know that's already a problem with exact_log2, but maybe that function also could be renamed?

These are not hard objects, but maybe others agree?

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

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


More information about the hotspot-dev mailing list