RFR: 8257815: Replace global log2 functions with efficient implementations

Stefan Karlsson stefank at openjdk.java.net
Wed Dec 9 08:18:33 UTC 2020


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

>>> 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?
>> 
>> I agree (including renaming exact_log2).
>
> So how about:
> log2i
> log2i_exact
> log2i_graceful
> I'm not married to the `log2i_graceful`, but with a goal to get rid of it maybe that's ok?

The name sounds good to me. I don't mind if you find a better name for the graceful version. As a follow-up we might want to add a log2i_accept_zero, with assert(v >= 0). There are a few places where we want to accept 0, but not negative values. In those places I think that name would be more telling and allow for a faster read-through of the code.

BTW, I'm fine with some name churn in follow-up patches if you want to push this soon.

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

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


More information about the hotspot-dev mailing list