RFR: 8294982: Implementation of Classfile API [v43]
Paul Sandoz
psandoz at openjdk.org
Tue Mar 7 16:10:24 UTC 2023
On Tue, 7 Mar 2023 14:35:22 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/classfile/impl/EntryMap.java line 176:
>>
>>> 174: }
>>> 175:
>>> 176: public static long nextPowerOfTwo( long x ) {
>>
>> If you like you can change the implementation to be:
>>
>> x = -1 >>> Long.numberOfLeadingZeros(x - 1);
>> return x + 1;
>>
>> See `ConcurrentHashMap`.
>
> `Long:numberOfLeadingZeros` implementation uses more method calls, conditional statements and binary operations. I would prefer to stick with the current implementation for its speed and simplicity.
`numberOfLeadingZeros` is an intrinsic, so it will compile down to a machine instruction. Up to you.
-------------
PR: https://git.openjdk.org/jdk/pull/10982
More information about the build-dev
mailing list