* Abstraction to Simplify Static and Dynamic Analysis" by Cyrille Artho and
* Armin Biere.
*/
public void testImplicitExitToAnotherSubroutine() {
{
Label T1 = new Label();
Label C1 = new Label();
Label S1 = new Label();
Label L = new Label();
Label C2 = new Label();
Label S2 = new Label();
Label W = new Label();
Label X = new Label();
// variable numbers:
int b = 1;
int e1 = 2;
int e2 = 3;
int r1 = 4;
int r2 = 5;
setCurrent(jsr);
ICONST_0();
ISTORE(1);
// T1: first try:
LABEL(T1);
JSR(S1);
RETURN();
// C1: exception handler for first try
LABEL(C1);
ASTORE(e1);
JSR(S1);
ALOAD(e1);
ATHROW();
// S1: first finally handler
LABEL(S1);
ASTORE(r1);
GOTO(W);
// L: body of while loop, also second try
LABEL(L);
JSR(S2);
RETURN();
// C2: exception handler for second try
LABEL(C2);
ASTORE(e2);
JSR(S2);
ALOAD(e2);
ATHROW();
// S2: second finally handler
LABEL(S2);
ASTORE(r2);
ILOAD(b);
IFNE(X);
RET(r2);
// W: test for the while loop
LABEL(W);
ILOAD(b);
IFNE(L); // falls through to X
// X: exit from finally{} block
LABEL(X);
RET(r1);
TRYCATCH(T1, C1, C1);
TRYCATCH(L, C2, C2);
END(1, 6);
}
{
Label T1 = new Label();
Label C1 = new Label();
Label S1_1a = new Label();
Label S1_1b = new Label();
Label S1_2a = new Label();
Label S1_2b = new Label();
Label L_1 = new Label();
Label L_2 = new Label();
Label C2_1 = new Label();
Label C2_2 = new Label();
Label S2_1_1a = new Label();
Label S2_1_1b = new Label();
Label S2_1_2a = new Label();
Label S2_1_2b = new Label();
Label S2_2_1a = new Label();
Label S2_2_1b = new Label();
Label S2_2_2a = new Label();
Label S2_2_2b = new Label();
Label W_1 = new Label();
Label W_2 = new Label();
Label X_1 = new Label();
Label X_2 = new Label();
// variable numbers:
int b = 1;
int e1 = 2;
int e2 = 3;
int r1 = 4;
int r2 = 5;
setCurrent(exp);
// --- Main Subroutine ---
ICONST_0();
ISTORE(1);
// T1: first try:
LABEL(T1);
ACONST_NULL();
GOTO(S1_1a);
LABEL(S1_1b);
RETURN();
// C1: exception handler for first try
LABEL(C1);
ASTORE(e1);
ACONST_NULL();
GOTO(S1_2a);
LABEL(S1_2b);
ALOAD(e1);
ATHROW();
LABEL(new Label()); // extra label emitted due to impl quirks
// --- First instantiation of first subroutine ---
// S1: first finally handler
LABEL(S1_1a);
ASTORE(r1);
GOTO(W_1);
// L_1: body of while loop, also second try
LABEL(L_1);
ACONST_NULL();
GOTO(S2_1_1a);
LABEL(S2_1_1b);
RETURN();
// C2_1: exception handler for second try
LABEL(C2_1);
ASTORE(e2);
ACONST_NULL();
GOTO(S2_1_2a);
LABEL(S2_1_2b);
ALOAD(e2);
ATHROW();
// W_1: test for the while loop
LABEL(W_1);
ILOAD(b);
IFNE(L_1); // falls through to X_1
// X_1: exit from finally{} block
LABEL(X_1);
GOTO(S1_1b);
// --- Second instantiation of first subroutine ---
// S1: first finally handler
LABEL(S1_2a);
ASTORE(r1);
GOTO(W_2);
// L_2: body of while loop, also second try
LABEL(L_2);
ACONST_NULL();
GOTO(S2_2_1a);
LABEL(S2_2_1b);
RETURN();
// C2_2: exception handler for second try
LABEL(C2_2);
ASTORE(e2);
ACONST_NULL();
GOTO(S2_2_2a);
LABEL(S2_2_2b);
ALOAD(e2);
ATHROW();
// W_2: test for the while loop
LABEL(W_2);
ILOAD(b);
IFNE(L_2); // falls through to X_2
// X_2: exit from finally{} block
LABEL(X_2);
GOTO(S1_2b);
// --- Second subroutine's 4 instantiations ---
// S2_1_1a:
LABEL(S2_1_1a);
ASTORE(r2);
ILOAD(b);
IFNE(X_1);
GOTO(S2_1_1b);
LABEL(new Label()); // extra label emitted due to impl quirks
// S2_1_2a:
LABEL(S2_1_2a);
ASTORE(r2);
ILOAD(b);
IFNE(X_1);
GOTO(S2_1_2b);
LABEL(new Label()); // extra label emitted due to impl quirks
// S2_2_1a:
LABEL(S2_2_1a);
ASTORE(r2);
ILOAD(b);
IFNE(X_2);
GOTO(S2_2_1b);
LABEL(new Label()); // extra label emitted due to impl quirks
// S2_2_2a:
LABEL(S2_2_2a);
ASTORE(r2);
ILOAD(b);
IFNE(X_2);
GOTO(S2_2_2b);
LABEL(new Label()); // extra label emitted due to impl quirks
TRYCATCH(T1, C1, C1);
TRYCATCH(L_1, C2_1, C2_1); // duplicated try/finally for each...
TRYCATCH(L_2, C2_2, C2_2); // ...instantiation of first sub