PageRenderTime 40ms CodeModel.GetById 28ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/test/kilim/test/ex/ExYieldSub.j

http://github.com/kilim/kilim
Unknown | 299 lines | 248 code | 51 blank | 0 comment | 0 complexity | f62bd8c54474bd483c6987352774f64d MD5 | raw file
  1.class public synchronized kilim/test/ex/ExYieldSub
  2.super kilim/test/ex/ExYieldBase
  3
  4; -------------------------------------------------------------
  5.method public <init>()V
  6; -------------------------------------------------------------
  7
  8    aload 0
  9    invokespecial kilim/test/ex/ExYieldBase/<init>()V
 10    return
 11    .limit stack 1
 12    .limit locals 1
 13.end method
 14
 15; -------------------------------------------------------------
 16.method public execute()V
 17; -------------------------------------------------------------
 18    .throws kilim/Pausable
 19
 20    aload 0
 21    iconst_0
 22    putfield kilim/test/ex/ExYieldSub/doPause Z
 23    aload 0
 24    invokespecial kilim/test/ex/ExYieldSub/test()V
 25    aload 0
 26    iconst_1
 27    putfield kilim/test/ex/ExYieldSub/doPause Z
 28    aload 0
 29    invokespecial kilim/test/ex/ExYieldSub/test()V
 30    return
 31    .limit stack 2
 32    .limit locals 1
 33.end method
 34
 35; -------------------------------------------------------------
 36.method private test()V
 37; -------------------------------------------------------------
 38    .throws kilim/Pausable
 39
 40    aload 0
 41    getfield kilim/test/ex/ExYieldSub/testCase I
 42    tableswitch  0
 43        L0
 44        L1
 45        L2
 46        L3
 47        default: L0
 48  L0:
 49    getstatic kilim/test/ex/ExYieldSub/fd D
 50    getstatic kilim/test/ex/ExYieldSub/ff F
 51    aload 0
 52    getfield kilim/test/ex/ExYieldSub/doPause Z
 53    invokestatic kilim/test/ex/ExYieldSub/nonPausableJSRs(DFZ)V    
 54    goto L4
 55
 56  L1:
 57    getstatic kilim/test/ex/ExYieldSub/fd D
 58    getstatic kilim/test/ex/ExYieldSub/ff F
 59    aload 0
 60    getfield kilim/test/ex/ExYieldSub/doPause Z
 61    invokestatic kilim/test/ex/ExYieldSub/singlePausable(DFZ)V
 62    goto L4
 63
 64  L2:
 65    getstatic kilim/test/ex/ExYieldSub/fc C
 66    getstatic kilim/test/ex/ExYieldSub/fl J
 67    aload 0
 68    getfield kilim/test/ex/ExYieldSub/doPause Z
 69    invokestatic kilim/test/ex/ExYieldSub/multiplePausable(CJZ)V
 70    goto L4
 71
 72  L3:
 73    getstatic kilim/test/ex/ExYieldBase/fd D
 74    getstatic kilim/test/ex/ExYieldBase/fs Ljava/lang/String;
 75    getstatic kilim/test/ex/ExYieldBase/fl J
 76    aload 0
 77    getfield kilim/test/ex/ExYieldSub/doPause Z
 78    invokestatic kilim/test/ex/ExYieldSub/mixedPausable(DLjava/lang/Object;JZ)V
 79
 80  L4:
 81    return
 82    .limit stack 10
 83    .limit locals 1
 84.end method
 85
 86; -------------------------------------------------------------
 87.method public static nonPausableJSRs(DFZ)V
 88; nonPausableJSRs(double d, float f, boolean doPause)
 89; -------------------------------------------------------------
 90    ; load stack before jsr. This gets consumed by SUB2 when SUB 1 calls it.
 91
 92    dload 0
 93    fload 2
 94    jsr L1
 95
 96    return
 97
 98  L1:
 99    astore 4
100    dload 0
101    invokestatic kilim/test/ex/ExYieldBase/verify(D)V
102    fload 2
103    invokestatic kilim/test/ex/ExYieldBase/verify(F)V
104    jsr L2
105    ret 4
106
107  L2:
108    astore 5
109    invokestatic kilim/test/ex/ExYieldBase/verify(F)V
110    invokestatic kilim/test/ex/ExYieldBase/verify(D)V
111    ret 5
112    
113    .limit stack 10
114    .limit locals 6
115.end method
116
117    
118; -------------------------------------------------------------
119.method public static singlePausable(DFZ)V
120; single(double d, float f, boolean doPause)
121; -------------------------------------------------------------
122    .throws kilim/Pausable
123
124    ; load stack before JSR
125    dload 0
126    fload 2
127    jsr L
128    
129    ; make sure local vars haven't been tampered with
130    dload 0
131    invokestatic kilim/test/ex/ExYieldBase/verify(D)V
132    fload 2
133    invokestatic kilim/test/ex/ExYieldBase/verify(F)V
134    return
135
136   L:
137    astore 4                                              ; ret address
138    iload 3
139    ifeq L1                                               ; if doPause
140    ldc2_w 10
141    invokestatic kilim/Task/sleep(J)V                     ;    Task.sleep(10)
142   L1:
143    ; verify stack is preserved
144    invokestatic kilim/test/ex/ExYieldBase/verify(F)V
145    invokestatic kilim/test/ex/ExYieldBase/verify(D)V
146
147    ; verify local vars are preserved
148    dload 0
149    invokestatic kilim/test/ex/ExYieldBase/verify(D)V
150    fload 2
151    invokestatic kilim/test/ex/ExYieldBase/verify(F)V
152
153    ret 4
154    .limit stack 10
155    .limit locals 5
156.end method
157
158; -------------------------------------------------------------
159.method public static multiplePausable(CJZ)V
160; -------------------------------------------------------------
161    .throws kilim/Pausable
162
163    ; load stack before JSR
164    iload 0
165    lload 1
166    jsr SUB1
167
168    lload 1
169    iload 0
170    jsr SUB2
171
172    iload 0
173    lload 1
174    jsr SUB1
175
176    ; make sure local vars haven't been tampered with
177    iload 0
178    invokestatic kilim/test/ex/ExYieldBase/verify(I)V
179    lload 1
180    invokestatic kilim/test/ex/ExYieldBase/verify(J)V
181    return
182
183  ; SUB1 consumes long then int on stack, and leaves it empty
184  SUB1:
185    astore 4                                              ; ret address
186    iload 3
187    ifeq L1                                               ; if doPause
188    ldc2_w 10
189    invokestatic kilim/Task/sleep(J)V                     ;    Task.sleep(10)
190
191  L1:
192    ; verify stack is preserved
193    invokestatic kilim/test/ex/ExYieldBase/verify(J)V
194    invokestatic kilim/test/ex/ExYieldBase/verify(I)V
195
196    ; verify local vars are preserved
197    iload 0
198    invokestatic kilim/test/ex/ExYieldBase/verify(I)V
199    lload 1
200    invokestatic kilim/test/ex/ExYieldBase/verify(J)V
201    ret 4
202
203  ; SUB2 consumes int then long on stack, and leaves it empty
204  SUB2:
205    astore 4                                              ; ret address
206    iload 3
207    ifeq L2                                               ; if doPause
208    ldc2_w 10
209    invokestatic kilim/Task/sleep(J)V                     ;    Task.sleep(10)
210
211  L2:
212    ; verify stack is preserved
213    invokestatic kilim/test/ex/ExYieldBase/verify(I)V
214    invokestatic kilim/test/ex/ExYieldBase/verify(J)V
215
216    ; verify local vars are preserved
217    iload 0
218    invokestatic kilim/test/ex/ExYieldBase/verify(I)V
219    lload 1
220    invokestatic kilim/test/ex/ExYieldBase/verify(J)V
221    ret 4
222
223    .limit stack 10
224    .limit locals 5
225.end method
226
227
228; -------------------------------------------------------------
229.method public static mixedPausable(DLjava/lang/Object;JZ)V
230; -------------------------------------------------------------
231    .throws kilim/Pausable
232
233    ; throw in some constants in the stack
234    sipush 10
235    bipush 10
236    ldc 10.0
237    ldc2_w 10.0
238    ldc2_w 10
239    ldc "10"
240    ; some duplicates
241    dup
242    dload 0
243    ; stack has S B F D J Str Str D
244    ; The subroutines below don't touch the stack, so we'll verify 
245    ; if they have been preserved at the end.
246
247    jsr NonPausableSub
248
249    jsr PausableSub
250
251    jsr NonPausableSub
252
253    jsr PausableSub
254
255    ; make sure local vars haven't been tampered with
256    dload 0
257    invokestatic kilim/test/ex/ExYieldBase/verify(D)V
258    aload 2
259    checkcast java/lang/String
260    invokestatic kilim/test/ex/ExYieldBase/verify(Ljava/lang/String;)V
261
262    ; make sure all stack vars are preserved.
263    invokestatic kilim/test/ex/ExYieldBase/verify(D)V
264    invokestatic kilim/test/ex/ExYieldBase/verify(Ljava/lang/String;)V
265    invokestatic kilim/test/ex/ExYieldBase/verify(Ljava/lang/String;)V
266    invokestatic kilim/test/ex/ExYieldBase/verify(J)V    
267    invokestatic kilim/test/ex/ExYieldBase/verify(D)V
268    invokestatic kilim/test/ex/ExYieldBase/verify(F)V
269    invokestatic kilim/test/ex/ExYieldBase/verify(I)V
270    invokestatic kilim/test/ex/ExYieldBase/verify(S)V
271
272    return
273
274  NonPausableSub:
275    ; just to test that if the entry and exit are in the same BB
276    ; it is ok.
277    astore 6  
278    ret 6
279
280  PausableSub:
281    astore 6                                              ; ret address
282    iload 5
283    ifeq NOSLEEP                                          ; if doPause
284    ldc2_w 10
285    invokestatic kilim/Task/sleep(J)V                     ;    Task.sleep(10)
286
287  NOSLEEP:
288    ; verify sample local vars are preserved
289    lload 3
290    invokestatic kilim/test/ex/ExYieldBase/verify(J)V
291    dload 0
292    invokestatic kilim/test/ex/ExYieldBase/verify(D)V
293    ret 6
294
295    .limit stack 20
296    .limit locals 7
297.end method
298
299