United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-5074608 Counted loop in the test is not recognized by C2
JDK-5074608 : Counted loop in the test is not recognized by C2

Details
Type:
Bug
Submit Date:
2004-07-15
Status:
Resolved
Updated Date:
2005-09-22
Project Name:
JDK
Resolved Date:
2005-09-22
Component:
hotspot
OS:
solaris_9
Sub-Component:
compiler
CPU:
sparc
Priority:
P4
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports

Sub Tasks

Description
C2 generates Safepoint polling in the counted loop in the next example.

% cat Test.java
class Test {
    static int val = 0;

    public static int foo(int val) {
       return val + 1000;
    }

    public static void test() {
       for (int i = 0; i < 100; i++) {
          val = i;
          if (val == 50) {
             val = foo(val);      
          }         
       }
    }

    public static void main(String argv[]) {
       for (int i=0; i < 15000; i++) 
         test();
       System.out.println("value = "  + val);
    }
 
 }
% java_g -server -version
java version "1.5.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b58)
Java HotSpot(TM) Server VM (build 1.5.0-beta3-b58-debug, mixed mode)
% javac Test.java
% java_g -server -XX:+PrintCompilation -XX:CompileOnly=Test.test -XX:+PrintOptoAssembly -Xbatch -XX:-Inline -XX:CICompilerCount=1 Test
VM option '+PrintCompilation'
VM option 'CompileOnly=Test.test'
VM option '+PrintOptoAssembly'
VM option '-Inline'
VM option 'CICompilerCount=1'
  1   b   Test::test (36 bytes)
{method} 
 - klass: {other class}
 - method holder:     'Test'
 - constants:         0xfec62020{constant pool}
 - access:            0xc1000009  public static 
 - name:              'test'
 - signature:         '()V'
...
020   B2: #     B4 B3 <- B1 B7  Loop: B2-B7 inner  Freq: 4.44445
# Lrgs use/def'd in loop: {1,3-9}
020 +   CMP    R_O0,#50
024     BPeq   ccr,B4  P=0.009950 C=4.422000
024     STW    R_O0,[R_L0 + #296]
024
02c   B3: #     B6 <- B2        Loop: B2-B7 inner  Freq: 4.378
02c +   BA     B6
02c     ADD    R_O0,#1,R_O0
02c
034   B4: #     B9 B5 <- B2     Loop: B2-B7 inner  Freq: 0.0439999
034     CALL,static  ; NOP ==>  Test::foo
        # Test::test @ bci:23  L0=#50
        # R_L0=Oop 
03c
03c   B5: #     B6 <- B4        Loop: B2-B7 inner  Freq: 0.043999
03c +   STW    R_O0,[R_L0 + #296]
040     MOV    #51,R_O0
040
044   B6: #     B8 B7 <- B5 B3  Loop: B2-B7 inner  Freq: 4.422
044 +   LDUW   [R_L2],R_G0      ! Safepoint: poll for GC        # Test::test @ bci:32  L0=R_O0
        # R_L0=Oop 
048 +   CMP    R_O0,#100
04c     BPge   ccr,B8  P=0.010000 C=4.422000
04c
054   B7: #     B2 <- B6        Loop: B2-B7 inner  Freq: 4.37778
054 +   BA     B2
054
05c   B8: #     N1 <- B6  Freq: 0.04422
05c     SETHI  #PollAddr,L0     ! Load Polling address
        LDUW   [L0],G0  !Poll for Safepointing
        RET
        RESTORE
06c +   RET
        NOP

                                    

Comments
EVALUATION


###@###.### 2004-07-15

The loop is not recognized as counted and the call do not dominate 
the loop's end. So the safepoint polling is generated at the end of the loop.
We need to fix it for performance.

                                     
2004-09-02
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mustang


                                     
2004-09-02
SUGGESTED FIX

http://analemma.sfbay.sun.com/net/prt-archiver.sfbay/data/archived_workspaces/main/c2_baseline/2005/20050915095202.nips.ifeq/workspace/webrevs/webrev-2005.09.15/index.html
                                     
2005-09-15



Hardware and Software, Engineered to Work Together