JDK-6611837 : block frequency is zero
  • Type: Bug
  • Status: Closed
  • Resolution: Fixed
  • Component: hotspot
  • Sub-Component: compiler
  • Priority: P4
  • Affected Version: 6u10,7
  • OS: solaris_9
  • CPU: sparc
  • Submit Date: 2007-10-01
  • Updated Date: 2011-03-08
  • Resolved Date: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u14Resolved 7Fixed
Description
public class Test {
    static final int arrsz = 64;
    private static int[] tbuf  = new int[arrsz];
    private static int[] tbuf2 = new int[arrsz];

    private static void test(int iter) {
      for (int i = 0; i < iter; i++) {
        System.arraycopy(tbuf, 0, tbuf2, 0, 32);
      }
    }

    public static void main(String[] args) {
      for (int i = 0; i < arrsz; i++) {
        tbuf[i]  = i;
      }
      for (int i = 0; i < 5; i++) {
        test(10000);
      }
    }
}

gamma -Xbatch -XX:+PrintCompilation -XX:+PrintOptoAssembly -XX:-CICompileOSR Test

1cc   B29: #    B40 B30 <- B5 B6  Freq: 0.026448
1cc +   MOV    R_O0,R_L0        ! spill
1d0 +   MOV    #0,R_O1
1d4     MOV    R_O2,R_L2        ! spill
1d8 +   MOV    #0,R_O3
1dc     MOV    #32,R_O4
1e0     CALL,static  ; NOP ==>  wrapper for: slow_arraycopy
        # Test::test @ bci:17  L[0]=R_I0 L[1]=R_L3 STK[0]=R_L0 STK[1]=#0 STK[2]=R_L2 STK[3]=#0 STK[4]=#32
        # L0=Oop L2=Oop L4=Oop 
1e8
1e8   B30: #    B8 <- B29  Freq: 0
        # Block is sole successor of call
1e8 +   BA     B8
1e8

=======================================================
An other case.

test/closed/compiler/6563987/Test.java
.hotspot_compiler
print Test testc

gamma -Xbatch -XX:LoopUnrollLimit=0 -XX:CICompilerCount=1 -XX:+PrintCompilation -XX:+PrintOptoAssembly -XX:-CICompileOSR Test

3c0   B47: #    B50 B48 <- B10 B17      Loop: B47-B17 inner stride: not constant  Freq: 0.181598
3c0    movl    [rsp + #28], RBX # spill
3c4    movq    RSI, [rsp + #8]  # spill
3c9    xorl    RDX, RDX # int
3cb    movq    RCX, RSI # spill
3ce    movl    R8, [rsp + #0]   # spill
3d2    movl    R9, [rsp + #4]   # spill
3d7    call,static  wrapper for: slow_arraycopy
        # Test::testc @ bci:19  L[0]=rsp + #8 L[1]=rsp + #0 L[2]=rsp + #4 L[3]=rsp + #28 L[4]=rsp + #16 L[5]=rsp + #24 L[6]=rsp + #160 L[7]=rsp + #32 L[8]=_ L[9]=RBP L[10]=_ STK[0]=rsp + #8 STK[1]=#0 STK[2]=rsp + #8 STK[3]=rsp + #0 STK[4]=rsp + #4
        # AllocatedObj(0xfffffd7f73f70088)
AllocatedObj(0xfffffd7f73f70088)

3dc
3dc   B48: #    B17 B49 <- B47  Freq: 0.181595
        # Block is sole successor of call
3dc   
3dc    incl    RBP # int
3de    cmpl    RBP, [RSP + #28 (32-bit)]
3e2    jlt     B17 # loop end  P=0.999999 C=996701.000000
3e2
3e8   B49: #    B14 <- B48  Freq: 0
3e8    jmp     B14
3e8
3ed   B50: #    B64 <- B47  Freq: 1.81598e-06
3ed    # exception oop is in rax; no code emitted
3ed    jmp     B64
3ed

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/756b58154237
2008-08-28

SUGGESTED FIX The fix might look something like this: --- block.cpp Tue Oct 2 08:59:24 2007 *************** *** 494,499 **** --- 494,501 ---- } // remap predecessor's successor to new block in->_succs.map(succ_no, block); + // Set the frequency of the new block + block->_freq = in->_freq * in->succ_prob(succ_no); // add new basic block to basic block list _blocks.insert(block_no + 1, block); _num_blocks++;
2007-10-02

EVALUATION The insert_goto_at() function fails to set the frequency for blocks inserted during block cleanup in Remove_Empty(). The bug is probably benign since I don't believe that frequencies are consulted after that point. There is an easy fix, however.
2007-10-02