RFR: 8240615: is_power_of_2() has Undefined Behaviour and is inconsistent
Andrew Haley
aph at redhat.com
Mon Mar 9 15:42:12 UTC 2020
On 3/9/20 2:46 PM, Doerr, Martin wrote:
> Sorry, my comment about log2_int + log2_jint was not precise.
>
> The comment
> "If x < 0, the function returns 31 on a 32-bit machine and 63 on a 64-bit machine."
> belongs to log2_intptr,
Indeed.
> but it also applies to log2_int + log2_jint which is not desirable IMHO.
> I guess using zero extend would be better for these 2 functions:
> "If x < 0, the function returns 31 on all machines."
As far as I can see, log2_jint() does the right thing: it returns
31 for 0x8000_0000-0xffff_ffff, and it does this with no undefined
behaviour.
--
Andrew Haley (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the hotspot-runtime-dev
mailing list