Test multiple levels of nesting and exception handler range splitting. Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- regression/jvm/SubroutineTest.j | 92 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 92 insertions(+), 0 deletions(-)
diff --git a/regression/jvm/SubroutineTest.j b/regression/jvm/SubroutineTest.j index a44576f..a438831 100644 --- a/regression/jvm/SubroutineTest.j +++ b/regression/jvm/SubroutineTest.j @@ -31,8 +31,100 @@ subroutine: ret_w 1 .end method +; This test checks correct exception handler range split When JSR S +; instruction is protected by an exception handler which does not +; protect the S body then exception handler range must be split so +; that it does not cover the JSR instruction. Otherwise exception +; thrown from S could be incorrectly caught by handler protecting +; the JSR instruction. +.method public static testExceptionRangeSplit()V + .limit locals 2 + .catch java/lang/RuntimeException from c_start to c_end using handler + .catch java/lang/Exception from sub_start to sub_end using sub_handler + +c_start: + jsr_w subroutine +c_end: + return +handler: + pop + invokestatic jvm/TestCase/fail()V + return + +subroutine: + astore 1 +sub_start: + new java/lang/RuntimeException + dup + invokevirtual java/lang/RuntimeException/<init>()V + athrow +sub_end: + goto sub_out +sub_handler: + pop +sub_out: + ret 1 +.end method + +; This method contains 3 nested subroutines. +.method public static testNestedSubroutines()V + .limit locals 7 + + iconst_0 + istore 4 + iconst_0 + istore 5 + iconst_0 + istore 6 + + jsr s1 + jsr s2 + goto l1 +s1: + astore 1 + iinc 4 1 + jsr s2 + jsr s3 + goto s1_out +s2: + astore 2 + iinc 5 1 + jsr s3 + goto s2_out +s3: + astore 3 + iinc 6 1 + ret 3 +s2_out: + ret 2 +s1_out: + ret 1 + +l1: + jsr s3 + + ; S1 counter + iload 4 + iconst_1 + invokestatic jvm/TestCase/assertEquals(II)V + + ; S2 counter + iload 5 + iconst_2 + invokestatic jvm/TestCase/assertEquals(II)V + + ; S3 counter + iload 6 + iconst_4 + invokestatic jvm/TestCase/assertEquals(II)V + + return +.end method + .method public static main([Ljava/lang/String;)V invokestatic jvm/SubroutineTest/testSingleSubroutine()V invokestatic jvm/SubroutineTest/testWideInstructions()V + invokestatic jvm/SubroutineTest/testExceptionRangeSplit()V + invokestatic jvm/SubroutineTest/testNestedSubroutines()V return .end method -- 1.6.0.6 ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel