Some tests that are helping with SESE garbage collection, incidentally the mlp regres...
[IRC.git] / Robust / src / Tests / oooJava / regression / test.java
1 public class Foo {
2   public int z;
3
4   public Foo( int z ) {
5     this.z = z;
6   }  
7 }
8
9 public class Test {
10
11   public static void main( String args[] ) {
12     if( args.length == 0 ) {
13       System.out.println( "give an integer workload argument, please!" );
14       System.exit( 0 );
15     }
16     int x = Integer.parseInt( args[0] );
17     Foo f = new Foo( x + 1000 );
18     int s = doSomeWork( x, f );
19     int t = moreWork( x, f );
20     nullMethodBodyFinalNode();
21     int r = s+t;
22     System.out.println( "s = "+s+
23                         ", t = "+t+
24                         ", r = "+r );
25   }
26
27   public static int doSomeWork( int x, Foo f ) {
28     float delta = 1.0f;
29     int out = 0;
30     for( int i = 0; i < x; ++i ) {
31       sese calc {
32         Foo g = new Foo( i );
33         int sum = 0;
34         for( int j = 0; j <= i % 10; ++j ) {
35           sum = calculateStuff( sum, 1, 0 );
36         }        
37       }
38       sese forceVirtualReal {
39         if( i % 7 == 0 ) {
40           sum = sum + (i % 20);
41         }        
42         for( int z = 0; z < x % 50; ++z ) {
43           if( i % 2 == 0 ) {
44             delta += 1.0f;
45           }
46         }
47         g.z = sum + 1000;
48       }
49       sese arrayAlloc {
50         int tempArray[] = new int[x];
51         for( int k = 0; k < x/20; ++k ) {
52           tempArray[k] = g.z / (i+1);          
53         }        
54       }
55       sese gather {
56         int inter = 1;
57         for( int k = 0; k < x/20; ++k ) {
58           inter = inter + tempArray[k];
59         }             
60         sum = sum + inter / 10;
61       }
62       sese modobj {
63         g.z = g.z + f.z;
64       }
65       if( i % 11 == 0 ) {
66         sese change {
67           for( int k = 0; k < i*2; ++k ) {
68             sum = calculateStuff( sum, k, 1 );
69           }
70           sum = sum + 1;
71         }       
72         
73         for( int l = 0; l < 3; ++l ) {
74           sum = calculateStuff( sum, 2, 2 );
75         }       
76       } 
77       sese prnt {
78         if( i == x - 1 ) {
79           out = x + i + sum + (int)delta + g.z;
80         }
81       }
82     }
83     return out;
84   }
85
86   public static int calculateStuff( int sum, int num, int mode ) {
87     int answer = sum;    
88     sese makePlaceholderStallAfter {
89       sum = sum + 1;
90     }
91     sum = sum + 1;
92     if( mode == 0 ) {
93       sese mode1 {
94         answer = sum + num;
95       }
96     } else if( mode == 1 ) {
97       sese mode2 {
98         answer = sum + (num/2);
99       }
100     } else {
101       sese mode3 {
102         answer = sum / num;
103       }
104     }    
105     return answer;
106   }
107
108   public static int moreWork( int x, Foo f ) {
109
110     int total = 0;
111
112     for( int j = 0; j < x; ++j ) {
113       sese doe {
114         Foo g = new Foo( j );
115         int prod = 1;
116       }
117       sese rae {
118         if( j % 7 == 0 ) {
119           prod = prod * j;
120         }
121         g.z = prod / x;
122       }
123       sese mi {
124         g.z = g.z + f.z;
125       }
126       if( j % 3 == 0 ) {
127         sese fa {
128           prod = prod / 2;
129         }
130       }
131
132       total = total + prod - g.z;
133     }
134
135     return total;
136   }
137
138   public static void nullMethodBodyFinalNode() {
139     int y = 1;
140     sese nothing {
141       int x = 0;
142     }
143     y = x;
144     if( x > y ) {
145       return;
146     } else {
147       return;
148     }
149   }
150 }