While looking into an issue with a Graal bailout because the OSR entry point appeared to be unreachable I noticed that when C1 profiles if bytecodes it increments the backedge counter on every execution of the if instead of just on the backedge. For a simple loop like this:
public class dowhile {
public static void main(String[] args) {
for (int i = 0; i < 10000000; i++) {
testDoWhile();
}
}
public static volatile boolean repeatLoop;
static volatile int sideEffect;
public static void testDoWhile() {
do {
sideEffect++;
} while (repeatLoop);
}
}
HotSpot ends up requesting an OSR compile:
<task_queued compile_id='16' compile_kind='osr' method='dowhile testDoWhile ()V' bytes='15' count='224300' backedge_count='163840' iicount='224300' osr_bci='0' level='4' stamp='0.576' comment='tiered' hot_count='163840'/>