RFR: 8240615: is_power_of_2() has Undefined Behaviour and is inconsistent

Vladimir Kozlov vladimir.kozlov at oracle.com
Tue Mar 10 18:06:40 UTC 2020


Why you did not cast constant to (julong) in btrL_mem_imm() x86_64.ad?

I looked through C1 and C2 code usage of is_power_of_2(). And it is not clear to me if we handle MAX and MIN values 
correctly in some cases (mulnode.cpp, divnode.cpp). But it is a different issue.

I think your is_power_of_2() change should be fine for C2 and C1 code.

Thanks,
Vladimir

On 3/10/20 8:04 AM, Andrew Haley wrote:
> On 3/9/20 12:20 PM, Stefan Karlsson wrote:
>> On 2020-03-09 11:54, Andrew Haley wrote:
>>> So, my plan is to push http://cr.openjdk.java.net/~aph/8240615-1/ and
>>> subsequently patch a few AArch64 cases plus the x86_64 immL_Pow2 and
>>> immL_NotPow2 cases that we already identified.
>>>
>>> I do not intend to do bulk changes to any other clients of
>>> is_power_of_2() because it's often unclear exactly what behaviour is
>>> required, and I'd risk breaking something.
>>>
>>> OK?
>>
>> I would prefer if the x86_64 and aarch64 patches were pushed first, or
>> folded into this patch. Otherwise, we knowingly introduce a regression
>> by pushing the proposed patch above. However, I'll leave it up to the
>> compiler devs/maintainers to decide if this is OK.
> 
>   http://cr.openjdk.java.net/~aph/8240615-2/
> 
> OK?
> 


More information about the hotspot-runtime-dev mailing list