On Mon, 22 Jun 2026 21:12:04 GMT, Chen Liang <[email protected]> wrote:

>> src/java.base/share/classes/java/lang/invoke/ArrayVarHandle.java line 147:
>> 
>>> 145:             int aoffset = (int) UNSAFE.arrayInstanceBaseOffset(array);
>>> 146:             int ascale = UNSAFE.arrayInstanceIndexScale(array);
>>> 147:             int ashift = 31 - Integer.numberOfLeadingZeros(ascale);
>> 
>> Why not use `numberOfTrailingZeroes` here as well? (Just like for 
>> `REFERENCE_SHIFT`)
>> Suggestion:
>> 
>>             int ashift = Integer.numberOfTrailingZeros(ascale);
>
> I think this is some old code that doesn't assume the scale has exactly one 
> bit set?

Ok, I'm assuming since it's used as a shift, it's a power of 2.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31123#discussion_r3456000623

Reply via email to