A Noob Question of C1 LIR branch

Tobias Hartmann tobias.hartmann at oracle.com
Wed Mar 8 12:05:05 UTC 2023


Hi,

I think the problem is that you are adding control flow within a basic block that is invisible to
the register allocator. A similar issue is described here:
https://mail.openjdk.org/pipermail/hotspot-compiler-dev/2018-September/030745.html

Branching to a stub and jumping right back to the next instruction is okay but anything more
complicated can lead to spilling/restoring in-between. In your case, the register allocator adds a

mov    0x28(%rsp),%rsi

between the two jumps.

Best regards,
Tobias

On 08.03.23 02:14, tianle qiu wrote:
> Hi,
> In my Phd project, I am messing around with barriers and notice a weird behavior of branching. It
> might be that I am doing it wrong. Typically, a barrier will do a check and then jump to slow case
> if necessary. The code often looks like: 
> 
> __ branch(lir_cond_notEqual, T_INT, slow);
> __ branch_destination(slow->continuation());
> 
> (These two lines are copied from G1BarrierSetC1::pre_barrier).
> But if I changed those two lines to:
> 
> __ branch(lir_cond_equal, T_INT, slow->continuation());
> __ jump(slow);
> __ branch_destination(slow->continuation());
> 
> Then hotspot cannot bootstrap, causing build failure. I know in practice no one is going to write
> code like that, but it does look weird. They should be logically equivalent.
> By the way, I am using the latest jdk11u master branch. Any suggestions would be appreciated. Thanks 


More information about the hotspot-compiler-dev mailing list