2 new icmds, new exception table ordering for inlining, exception handler fix for...
authorjowenn <none@none>
Sun, 14 Nov 2004 14:48:49 +0000 (14:48 +0000)
committerjowenn <none@none>
Sun, 14 Nov 2004 14:48:49 +0000 (14:48 +0000)
31 files changed:
builtin.c
jit/i386/codegen.c
jit/inline.c
jit/inline.h
jit/jit.c
jit/jit.h
jit/parse.c
jit/reg.inc
jit/stack.c
jit/typecheck.c
nat/Runtime.c
src/native/vm/VMRuntime.c
src/vm/builtin.c
src/vm/jit/i386/codegen.c
src/vm/jit/inline/inline.c
src/vm/jit/inline/inline.h
src/vm/jit/jit.c
src/vm/jit/jit.h
src/vm/jit/parse.c
src/vm/jit/reg.inc
src/vm/jit/stack.c
src/vm/jit/verify/typecheck.c
tests/InlineExTest.java
tests/InlineExTest3.java [new file with mode: 0644]
tests/InlineExTest4.java [new file with mode: 0644]
tests/InlineSynchronized.java [new file with mode: 0644]
tests/InlineSynchronized2.java [new file with mode: 0644]
tests/InlineSynchronized3.java [new file with mode: 0644]
tests/InlineSynchronized4.java [new file with mode: 0644]
tests/InlineSynchronized5.java [new file with mode: 0644]
tests/InlineSynchronized6.java [new file with mode: 0644]

index 6f3cb300b341e97b84cd6856aec7828f086596d2..b4697ed8a2c1a0d1e56945757c7e0fca0a4d555b 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -34,7 +34,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 1490 2004-11-12 13:24:14Z twisti $
+   $Id: builtin.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -1148,6 +1148,7 @@ void builtin_monitorenter(java_objectheader *o)
        monitorEnter((threadobject *) THREADOBJECT, o);
 #endif
 #endif
+
 }
 
 /*
index b7e7167b628f85cc99aa62c0d94351c0b42a846b..141c574a339f43c20625ec6d5c9a7007b7c6f315 100644 (file)
@@ -28,7 +28,7 @@
    Authors: Andreas Krall
             Christian Thalinger
 
-   $Id: codegen.c 1461 2004-11-05 16:23:47Z twisti $
+   $Id: codegen.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -4315,6 +4315,9 @@ gen_method: {
                        store_reg_to_var_int(iptr->dst, s1);
                        break;
 
+               case ICMD_INLINE_START:
+               case ICMD_INLINE_END:
+                       break;
                default:
                        error ("Unknown pseudo command: %d", iptr->opc);
        } /* switch */
@@ -4449,6 +4452,8 @@ gen_method: {
 
                        i386_mov_imm_reg(cd, (u4) new_negativearraysizeexception, REG_ITMP1);
                        i386_call_reg(cd, REG_ITMP1);   /* return value is REG_ITMP1_XPTR */
+                       /*i386_alu_imm_reg(cd, I386_ADD, 1 * 4, REG_SP);*/
+
 
                        REMOVE_NATIVE_STACKINFO;
 
@@ -4494,6 +4499,8 @@ gen_method: {
 
                        i386_mov_imm_reg(cd, (u4) new_classcastexception, REG_ITMP1);
                        i386_call_reg(cd, REG_ITMP1);   /* return value is REG_ITMP1_XPTR */
+                       /*i386_alu_imm_reg(cd, I386_ADD, 1 * 4, REG_SP);*/
+
 
                        REMOVE_NATIVE_STACKINFO;
 
index 7afd8a6b21f78e8aa69ddd265d1ef517b5c59168..37f0d6ab12536ae4a259d95cbf6e0dac51b5aa1d 100644 (file)
@@ -28,7 +28,7 @@ globals moved to structure and passed as parameter
 
    Authors: Dieter Thuernbeck
 
-   $Id: inline.c 1494 2004-11-12 13:34:26Z twisti $
+   $Id: inline.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -496,7 +496,7 @@ inlining_methodinfo *inlining_analyse_method(methodinfo *m,
 
                        switch (opcode) {
                        case JAVA_INVOKEVIRTUAL:
-                               if (!inlinevirtuals)
+                               if (!inlinevirtuals) 
                                        break;
                         /*log_text("\nINLINE INVOKEVIRTUAL :\t");*/
                        case JAVA_INVOKESPECIAL:
@@ -544,6 +544,7 @@ inlining_methodinfo *inlining_analyse_method(methodinfo *m,
 
                                                if (!is_unique_method(imi->class, imi, imr->name, imr->descriptor))
                                                        break;
+                                                
                                        }
 
                                        /*if (imi->flags & ACC_NATIVE) log_text("Native method,no inlining");*/
@@ -592,7 +593,7 @@ inlining_methodinfo *inlining_analyse_method(methodinfo *m,
        } /* for */
        
        newnode->stopgp = gp;
-
+        label_index[jcodelength]=gp;
         if (DEBUGi==true) {
          printf ("\nResult of inlining analysis of: ");
          IMETHINFO(m);
index 6c40deb6748e3201bf91e03d8e9c619aad90bfd5..c8c086fbeec7f2bbc391af320c1e428ca5008bb1 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Dieter Thuernbeck
 
-   $Id: inline.h 1494 2004-11-12 13:34:26Z twisti $
+   $Id: inline.h 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -37,9 +37,9 @@
 #include "global.h"
 #include "toolbox/list.h"
 
-#define INLINING_MAXDEPTH       1
-#define INLINING_MAXCODESIZE    32
-#define INLINING_MAXMETHODS     8
+#define INLINING_MAXDEPTH       2  /*1*/ 
+#define INLINING_MAXCODESIZE    128 /*32*/
+#define INLINING_MAXMETHODS     32 /*8*/
 
 
 /*typedef struct {
index 6399a8fd3b1176f0f9e1d52a5d104393b628d695..455b2abf9dd920a42e4ea51dc276dae831fb0de5 100644 (file)
--- a/jit/jit.c
+++ b/jit/jit.c
@@ -29,7 +29,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: jit.c 1494 2004-11-12 13:34:26Z twisti $
+   $Id: jit.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -923,7 +923,9 @@ char *icmd_names[256] = {
        "UNDEF236","UNDEF237","UNDEF238","UNDEF239","UNDEF240",
        "UNDEF","UNDEF","UNDEF","UNDEF","UNDEF",
        "UNDEF246","UNDEF247","UNDEF248","UNDEF249","UNDEF250",
-       "UNDEF251","UNDEF252",
+
+       "INLINE_START", /*          251 */
+        "INLINE_END", /*            252"*/
 
        "BUILTIN3     ", /*             253 */
        "BUILTIN2     ", /*             254 */
@@ -1152,8 +1154,9 @@ char *opcode_names[256] = {
        "UNDEF236","UNDEF237","UNDEF238","UNDEF239","UNDEF240",
        "UNDEF","UNDEF","UNDEF","UNDEF","UNDEF",
        "UNDEF246","UNDEF247","UNDEF248","UNDEF249","UNDEF250",
-       "UNDEF251","UNDEF252",
 
+       "INLINE_START", /*              251 */
+        "INLINE_END",  /*               252 */
        "BUILTIN3     ", /*             253 */
        "BUILTIN2     ", /*             254 */
        "BUILTIN1     "  /*             255 */
index 8c128be32b7b34654e3bed8f18c75d2c49b707f1..24d95dd7f71c845826117689d601c16094cb7254 100644 (file)
--- a/jit/jit.h
+++ b/jit/jit.h
@@ -29,7 +29,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: jit.h 1494 2004-11-12 13:34:26Z twisti $
+   $Id: jit.h 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -112,7 +112,7 @@ struct instruction {
        u2          line;           /* line number in source file                 */
        methodinfo *method;         /* needed for inlining. can't be done on      */
                                    /* basic block level, since an inlined        */
-                                   /* function doesn't start necessarily start   */
+                                   /* function doesn't necessarily start         */
                                    /* a new block                                */
 };
 
@@ -779,6 +779,8 @@ extern int jcommandsize[256];
 
 #define ICMD_SASTORECONST     211
 
+#define ICMD_INLINE_START     251       /* before the first instruction of an inlined method */
+#define ICMD_INLINE_END       252       /* after the last instruction of an inlined method */
 #define ICMD_BUILTIN3         253       /* internal opcode */
 #define ICMD_BUILTIN2         254       /* internal opcode */
 #define ICMD_BUILTIN1         255       /* internal opcode */
index 530008a9154ad41eae8770fef65dfc9957b050ea..49eb4cef6ba0d687b3d2688bee443fc41e40f6bf 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Carolyn Oates
             Edwin Steiner
 
-   $Id: parse.c 1494 2004-11-12 13:34:26Z twisti $
+   $Id: parse.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -361,7 +361,7 @@ static exceptiontable* fillextable(methodinfo *m,
                int *label_index, int *block_count, 
                t_inlining_globals *inline_env)
 {
-       int b_count, i, p;
+       int b_count, i, p, src, insertBlock;
        
        if (exceptiontablelength == 0) 
                return extable;
@@ -375,41 +375,47 @@ static exceptiontable* fillextable(methodinfo *m,
 
        b_count = *block_count;
 
-       for (i = 0; i < exceptiontablelength; i++) {
+       for (src = exceptiontablelength-1; src >=0; src--) {
                /* printf("Excepiont table index: %d\n",i); */
-               p = raw_extable[i].startpc;
+               p = raw_extable[src].startpc;
                if (label_index != NULL) p = label_index[p];
-               extable[i].startpc = p;
+               extable->startpc = p;
                bound_check(p);
                block_insert(p);
                
 /*** if (DEBUG==true){printf("---------------------block_inserted:b_count=%i m->basicblockindex[(p=%i)]=%i=%p\n",b_count,p,m->basicblockindex[(p)],m->basicblockindex[(p)]); 
   fflush(stdout); } ***/   
-               p = raw_extable[i].endpc; /* see JVM Spec 4.7.3 */
-               if (p < raw_extable[i].startpc)
+               p = raw_extable[src].endpc; /* see JVM Spec 4.7.3 */
+               if (p <= raw_extable[src].startpc)
                        panic("Invalid exception handler range");
-               if (p > m->jcodelength) { 
+
+               if (p >inline_env->method->jcodelength) {
                        panic("Invalid exception handler end is after code end");
                }
+               if (p<inline_env->method->jcodelength) insertBlock=1; else insertBlock=0;
+                /*if (label_index !=NULL) printf("%s:translating endpc:%ld to %ld, label_index:%p\n",m->name->text,p,label_index[p],label_index); else
+                       printf("%s:fillextab: endpc:%ld\n",m->name->text,p);*/
                if (label_index != NULL) p = label_index[p];
-               extable[i].endpc = p;
+               extable->endpc = p;
                bound_check1(p);
-               if (p < m->jcodelength) {
-                       block_insert(p); }
+               /*if (p < inline_env->method->jcodelength) {
+                       block_insert(p); }*/
+                if (insertBlock) block_insert(p);
 
-               p = raw_extable[i].handlerpc;
+               p = raw_extable[src].handlerpc;
                if (label_index != NULL) p = label_index[p];
-               extable[i].handlerpc = p;
+               extable->handlerpc = p;
                bound_check(p);
                block_insert(p);
 
-               extable[i].catchtype  = raw_extable[i].catchtype;
-               extable[i].next = NULL;
-               extable[i].down = &extable[i + 1];
+               extable->catchtype  = raw_extable[src].catchtype;
+               extable->next = NULL;
+               extable->down = &extable[1];
+               extable--;
        }
 
        *block_count = b_count;
-       return &extable[i];  /* return the next free xtable* */
+       return extable; /*&extable[i];*/  /* return the next free xtable* */
 }
 
 
@@ -526,7 +532,7 @@ if (m->exceptiontablelength > 0)
        */
 
        nextex = fillextable(m, 
-         cd->exceptiontable, m->exceptiontable, m->exceptiontablelength, 
+         &(cd->exceptiontable[cd->exceptiontablelength-1]), m->exceptiontable, m->exceptiontablelength, 
           label_index, &b_count, inline_env);
        s_count = 1 + m->exceptiontablelength; /* initialize stack element counter   */
 
@@ -643,6 +649,8 @@ DEBUGMETH(inline_env->method);
                        }
 
 
+                        OP(ICMD_INLINE_START);
+
                        if (inlinfo->inlinedmethods == NULL) {
                                gp = -1;
                        } else {
@@ -661,6 +669,8 @@ DEBUGMETH(inline_env->method);
                {
                        printf("Parse p=%i<%i<%i<   opcode=<%i> %s\n",
                           p, gp, inline_env->jcodelength, opcode, opcode_names[opcode]);
+                       if (label_index)
+                               printf("label_index[%ld]=%ld\n",p,label_index[p]);
                }
         /*
 printf("basicblockindex[gp=%i]=%i=%p ipc=%i=%p shifted ipc=%i=%p\n",
@@ -1672,7 +1682,9 @@ if (DEBUG4==true)
                        /*                printf("setting gp from %d to %d\n",gp, inlinfo->stopgp); */
                        gp = inlinfo->stopgp; 
                        inlining_restore_compiler_variables();
+                       OP(ICMD_INLINE_END);
 /*label_index = inlinfo->label_index;*/
+
 if (DEBUG==true) {
 printf("AFTER RESTORE : "); fflush(stdout);
 DEBUGMETH(inline_env->method);
@@ -1793,7 +1805,7 @@ DEBUGMETH(inline_env->method);
                        cd->exceptiontable[i].start = m->basicblocks + m->basicblockindex[p];
 
                        p = cd->exceptiontable[i].endpc;
-                       cd->exceptiontable[i].end = (p == m->jcodelength) ? (m->basicblocks + m->basicblockcount + 1) : (m->basicblocks + m->basicblockindex[p]);
+                       cd->exceptiontable[i].end = (p == inline_env->method->jcodelength) ? (m->basicblocks + m->basicblockcount /*+ 1*/) : (m->basicblocks + m->basicblockindex[p]);
 
                        p = cd->exceptiontable[i].handlerpc;
                        cd->exceptiontable[i].handler = m->basicblocks + m->basicblockindex[p];
index 0a67f9959261753a7eba2e9086e34de6a429acd6..a05f2e315ab10b10c321ae6d8a5235afb1cb88b5 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Stefan Ring
             Christian Thalinger
 
-   $Id: reg.inc 1466 2004-11-08 11:24:50Z twisti $
+   $Id: reg.inc 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -867,6 +867,8 @@ static void allocate_scratch_registers(methodinfo *m, registerdata *rd)
                                case ICMD_RET:
                                case ICMD_RETURN:
                                case ICMD_GOTO:
+                               case ICMD_INLINE_START:
+                               case ICMD_INLINE_END:
                                        break;
 
                                        /* pop 0 push 1 const */
index 809e69183e4fcf7524fa548a9991fc100d994b20..1eac20c5865422da6fe5c2f8eb1066b1990aa3d1 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: stack.c 1456 2004-11-05 14:33:14Z twisti $
+   $Id: stack.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -1778,6 +1778,10 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                                        }
                                                        break;
                                                }
+                                       case ICMD_INLINE_START:
+                                       case ICMD_INLINE_END:
+                                               SETDST;
+                                               break;
 
                                        case ICMD_BUILTIN3:
                                                /* DEBUG */ /*dolog("builtin3");*/
@@ -1898,8 +1902,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                if (m->basicblockcount > count_max_basic_blocks)
                        count_max_basic_blocks = m->basicblockcount;
                count_basic_blocks += m->basicblockcount;
-               if (m->instructioncount > count_max_javainstr)
-                       count_max_javainstr = m->instructioncount;
+               if (m->instructioncount > count_max_javainstr)                  count_max_javainstr = m->instructioncount;
                count_javainstr += m->instructioncount;
                if (m->stackcount > count_upper_bound_new_stack)
                        count_upper_bound_new_stack = m->stackcount;
@@ -2490,6 +2493,12 @@ void show_icmd(instruction *iptr, bool deadcode)
                }
                break;
 
+       case ICMD_INLINE_START:
+               printf("\t\t\t%s.%s%s",iptr->method->class->name->text,iptr->method->name->text,iptr->method->descriptor->text);
+               break;
+       case ICMD_INLINE_END:
+               break;
+
        case ICMD_BUILTIN3:
        case ICMD_BUILTIN2:
        case ICMD_BUILTIN1:
@@ -2617,10 +2626,10 @@ void show_icmd(instruction *iptr, bool deadcode)
                break;
        }
 /*     printf(" Line number: %d, method:",iptr->line); */
-        printf("\t\t");
+/*        printf("\t\t");
        utf_display(iptr->method->class->name); 
        printf("."); 
-       utf_display(iptr->method->name); 
+       utf_display(iptr->method->name); */
 }
 
 
index 4aa4b33aeb191add569bcbbb70241cc6e83deecf..11cf0a2f93e399464f06ba2dceb2061fd80968c2 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Edwin Steiner
 
-   $Id: typecheck.c 1483 2004-11-11 14:40:10Z twisti $
+   $Id: typecheck.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -497,7 +497,7 @@ typestate_merge(stackptr deststack,typevector *destloc,
 
 
 static bool
-typestate_reach(methodinfo *m, void *localbuf,
+typestate_reach(codegendata *cd, registerdata *rd,void *localbuf,
                                basicblock *current,
                                basicblock *destblock,
                                stackptr ystack,typevector *yloc,
@@ -510,7 +510,7 @@ typestate_reach(methodinfo *m, void *localbuf,
        LOG1("reaching block L%03d",destblock->debug_nr);
        TYPECHECK_COUNT(stat_reached);
        
-       destidx = destblock - m->basicblocks;
+       destidx = destblock - cd->method->basicblocks;
        destloc = MGET_TYPEVECTOR(localbuf,destidx,locsize);
 
        /* When branching backwards we have to check for uninitialized objects */
@@ -518,19 +518,24 @@ typestate_reach(methodinfo *m, void *localbuf,
        if (destblock <= current) {
                stackptr sp;
                int i;
-               
-               TYPECHECK_COUNT(stat_backwards);
-        LOG("BACKWARDS!");
-        for (sp = ystack; sp; sp=sp->prev)
-            if (sp->type == TYPE_ADR &&
-                TYPEINFO_IS_NEWOBJECT(sp->typeinfo))
-                panic("Branching backwards with uninitialized object on stack");
-
-        for (i=0; i<locsize; ++i)
-            if (yloc->td[i].type == TYPE_ADR &&
-                TYPEINFO_IS_NEWOBJECT(yloc->td[i].info))
-                panic("Branching backwards with uninitialized object in local variable");
-    }
+#warning FIXME FOR INLINING
+               if (!useinlining) {
+                       TYPECHECK_COUNT(stat_backwards);
+                       LOG("BACKWARDS!");
+                       for (sp = ystack; sp; sp=sp->prev)
+                               if (sp->type == TYPE_ADR &&
+                               TYPEINFO_IS_NEWOBJECT(sp->typeinfo)) {
+                                       show_icmd_method(cd->method,cd,rd);
+                               printf("current: %ld, dest: %ld\n",current->debug_nr,destblock->debug_nr);
+                               panic("Branching backwards with uninitialized object on stack");
+                       }
+
+                       for (i=0; i<locsize; ++i)
+                               if (yloc->td[i].type == TYPE_ADR &&
+                               TYPEINFO_IS_NEWOBJECT(yloc->td[i].info))
+                                       panic("Branching backwards with uninitialized object in local variable");
+               }
+       }
        
        if (destblock->flags == BBTYPECHECK_UNDEF) {
                /* The destblock has never been reached before */
@@ -564,7 +569,7 @@ typestate_reach(methodinfo *m, void *localbuf,
 
 
 static bool
-typestate_ret(methodinfo *m, void *localbuf,
+typestate_ret(codegendata *cd,registerdata *rd, void *localbuf,
                          basicblock *current,
                          stackptr ystack,typevector *yloc,
                          int retindex,int locsize)
@@ -582,7 +587,7 @@ typestate_ret(methodinfo *m, void *localbuf,
 
                selected = typevectorset_select(&yvec,retindex,destblock);
                
-               repeat |= typestate_reach(m, localbuf,current,destblock,
+               repeat |= typestate_reach(cd, rd,  localbuf,current,destblock,
                                                                  ystack,selected,locsize,true);
        }
        return repeat;
@@ -767,7 +772,7 @@ is_accessible(int flags,classinfo *definingclass,classinfo *implementingclass, c
  */
 #define TYPECHECK_REACH                                                 \
     do {                                                                \
-    repeat |= typestate_reach(m, localbuf,bptr,tbptr,dst,               \
+    repeat |= typestate_reach(cd,rd, localbuf,bptr,tbptr,dst,               \
                                                          localset,numlocals,jsrencountered);       \
     LOG("done.");                                                       \
     } while (0)
@@ -1549,7 +1554,7 @@ methodinfo *typecheck(methodinfo *m, codegendata *cd, registerdata *rd)
                                                  if (bptr + 1 == (m->basicblocks + m->basicblockcount + 1))
                                                          panic("Illegal instruction: JSR at end of bytecode");
                                                  typestack_put_retaddr(dst,bptr+1,localset);
-                                                 repeat |= typestate_reach(m, localbuf,bptr,tbptr,dst,
+                                                 repeat |= typestate_reach(cd, rd,localbuf,bptr,tbptr,dst,
                                                                                                        localset,numlocals,true);
 
                                                  superblockend = true;
@@ -1560,7 +1565,7 @@ methodinfo *typecheck(methodinfo *m, codegendata *cd, registerdata *rd)
                                                  if (!typevectorset_checkretaddr(localset,iptr->op1))
                               panic("illegal instruction: RET using non-returnAddress variable");
 
-                                                 repeat |= typestate_ret(m, localbuf,bptr,curstack,
+                                                 repeat |= typestate_ret(cd,rd, localbuf,bptr,curstack,
                                                                                                  localset,iptr->op1,numlocals);
 
                           superblockend = true;
@@ -2075,7 +2080,7 @@ methodinfo *typecheck(methodinfo *m, codegendata *cd, registerdata *rd)
                                                        cls = handlers[i]->catchtype;
                                                        excstack.typeinfo.typeclass = (cls) ? cls
                                                                : class_java_lang_Throwable;
-                                                       repeat |= typestate_reach(m, localbuf,bptr,
+                                                       repeat |= typestate_reach(cd,rd, localbuf,bptr,
                                                                                                          handlers[i]->handler,
                                                                                                          &excstack,localset,
                                                                                                          numlocals,
index ad42162666f009773f4fc22dbe00fb2e7b84df05..57df799cabe85d3ba3e6bb7d02bfe7519cf81a52 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Joseph Wenninger
             Christian Thalinger
 
-   $Id: Runtime.c 1494 2004-11-12 13:34:26Z twisti $
+   $Id: Runtime.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -306,7 +306,9 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass cla
        int buffer_len;
        utf *data;
 
+#ifdef JOWENN_DEBUG
        log_text("Java_java_lang_VMRuntime_nativeLoad");
+#endif
 
        data = javastring_toutf(par1, 0);
        
@@ -315,9 +317,9 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass cla
                return 1;
        }
        
+#if JOWENN_DEBUG       
        buffer_len = utf_strlen(data) + 40;
 
-               
        buffer = MNEW(char, buffer_len);
        strcpy(buffer, "Java_java_lang_VMRuntime_nativeLoad:");
        utf_sprint(buffer + strlen((char *) data), data);
@@ -325,7 +327,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass cla
         
   
        MFREE(buffer, char, buffer_len);
-
+#endif
 
 #ifndef STATIC_CLASSPATH
        /*here it could be interesting to store the references in a list eg for nicely cleaning up or for certain platforms*/
@@ -460,6 +462,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMRuntime_insertSystemProperties(JNIEnv *e
        /* XXX do we need this one? */
        { "java.protocol.handler.pkgs", "gnu.java.net.protocol"}
 #endif
+       insert_property(m,p,"java.protocol.handler.pkgs","gnu.java.net.protocol");
 
        /* insert properties defined on commandline */
 
index 8f8c6b996ec7d067decd51f7472a1fe306821af0..2d5e67fffabfee506f79bf414954658ffab8f878 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Joseph Wenninger
             Christian Thalinger
 
-   $Id: VMRuntime.c 1494 2004-11-12 13:34:26Z twisti $
+   $Id: VMRuntime.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -306,7 +306,9 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass cla
        int buffer_len;
        utf *data;
 
+#ifdef JOWENN_DEBUG
        log_text("Java_java_lang_VMRuntime_nativeLoad");
+#endif
 
        data = javastring_toutf(par1, 0);
        
@@ -315,9 +317,9 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass cla
                return 1;
        }
        
+#if JOWENN_DEBUG       
        buffer_len = utf_strlen(data) + 40;
 
-               
        buffer = MNEW(char, buffer_len);
        strcpy(buffer, "Java_java_lang_VMRuntime_nativeLoad:");
        utf_sprint(buffer + strlen((char *) data), data);
@@ -325,7 +327,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass cla
         
   
        MFREE(buffer, char, buffer_len);
-
+#endif
 
 #ifndef STATIC_CLASSPATH
        /*here it could be interesting to store the references in a list eg for nicely cleaning up or for certain platforms*/
@@ -460,6 +462,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMRuntime_insertSystemProperties(JNIEnv *e
        /* XXX do we need this one? */
        { "java.protocol.handler.pkgs", "gnu.java.net.protocol"}
 #endif
+       insert_property(m,p,"java.protocol.handler.pkgs","gnu.java.net.protocol");
 
        /* insert properties defined on commandline */
 
index 6f3cb300b341e97b84cd6856aec7828f086596d2..b4697ed8a2c1a0d1e56945757c7e0fca0a4d555b 100644 (file)
@@ -34,7 +34,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 1490 2004-11-12 13:24:14Z twisti $
+   $Id: builtin.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -1148,6 +1148,7 @@ void builtin_monitorenter(java_objectheader *o)
        monitorEnter((threadobject *) THREADOBJECT, o);
 #endif
 #endif
+
 }
 
 /*
index b7e7167b628f85cc99aa62c0d94351c0b42a846b..141c574a339f43c20625ec6d5c9a7007b7c6f315 100644 (file)
@@ -28,7 +28,7 @@
    Authors: Andreas Krall
             Christian Thalinger
 
-   $Id: codegen.c 1461 2004-11-05 16:23:47Z twisti $
+   $Id: codegen.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -4315,6 +4315,9 @@ gen_method: {
                        store_reg_to_var_int(iptr->dst, s1);
                        break;
 
+               case ICMD_INLINE_START:
+               case ICMD_INLINE_END:
+                       break;
                default:
                        error ("Unknown pseudo command: %d", iptr->opc);
        } /* switch */
@@ -4449,6 +4452,8 @@ gen_method: {
 
                        i386_mov_imm_reg(cd, (u4) new_negativearraysizeexception, REG_ITMP1);
                        i386_call_reg(cd, REG_ITMP1);   /* return value is REG_ITMP1_XPTR */
+                       /*i386_alu_imm_reg(cd, I386_ADD, 1 * 4, REG_SP);*/
+
 
                        REMOVE_NATIVE_STACKINFO;
 
@@ -4494,6 +4499,8 @@ gen_method: {
 
                        i386_mov_imm_reg(cd, (u4) new_classcastexception, REG_ITMP1);
                        i386_call_reg(cd, REG_ITMP1);   /* return value is REG_ITMP1_XPTR */
+                       /*i386_alu_imm_reg(cd, I386_ADD, 1 * 4, REG_SP);*/
+
 
                        REMOVE_NATIVE_STACKINFO;
 
index 7afd8a6b21f78e8aa69ddd265d1ef517b5c59168..37f0d6ab12536ae4a259d95cbf6e0dac51b5aa1d 100644 (file)
@@ -28,7 +28,7 @@ globals moved to structure and passed as parameter
 
    Authors: Dieter Thuernbeck
 
-   $Id: inline.c 1494 2004-11-12 13:34:26Z twisti $
+   $Id: inline.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -496,7 +496,7 @@ inlining_methodinfo *inlining_analyse_method(methodinfo *m,
 
                        switch (opcode) {
                        case JAVA_INVOKEVIRTUAL:
-                               if (!inlinevirtuals)
+                               if (!inlinevirtuals) 
                                        break;
                         /*log_text("\nINLINE INVOKEVIRTUAL :\t");*/
                        case JAVA_INVOKESPECIAL:
@@ -544,6 +544,7 @@ inlining_methodinfo *inlining_analyse_method(methodinfo *m,
 
                                                if (!is_unique_method(imi->class, imi, imr->name, imr->descriptor))
                                                        break;
+                                                
                                        }
 
                                        /*if (imi->flags & ACC_NATIVE) log_text("Native method,no inlining");*/
@@ -592,7 +593,7 @@ inlining_methodinfo *inlining_analyse_method(methodinfo *m,
        } /* for */
        
        newnode->stopgp = gp;
-
+        label_index[jcodelength]=gp;
         if (DEBUGi==true) {
          printf ("\nResult of inlining analysis of: ");
          IMETHINFO(m);
index 6c40deb6748e3201bf91e03d8e9c619aad90bfd5..c8c086fbeec7f2bbc391af320c1e428ca5008bb1 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Dieter Thuernbeck
 
-   $Id: inline.h 1494 2004-11-12 13:34:26Z twisti $
+   $Id: inline.h 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -37,9 +37,9 @@
 #include "global.h"
 #include "toolbox/list.h"
 
-#define INLINING_MAXDEPTH       1
-#define INLINING_MAXCODESIZE    32
-#define INLINING_MAXMETHODS     8
+#define INLINING_MAXDEPTH       2  /*1*/ 
+#define INLINING_MAXCODESIZE    128 /*32*/
+#define INLINING_MAXMETHODS     32 /*8*/
 
 
 /*typedef struct {
index 6399a8fd3b1176f0f9e1d52a5d104393b628d695..455b2abf9dd920a42e4ea51dc276dae831fb0de5 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: jit.c 1494 2004-11-12 13:34:26Z twisti $
+   $Id: jit.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -923,7 +923,9 @@ char *icmd_names[256] = {
        "UNDEF236","UNDEF237","UNDEF238","UNDEF239","UNDEF240",
        "UNDEF","UNDEF","UNDEF","UNDEF","UNDEF",
        "UNDEF246","UNDEF247","UNDEF248","UNDEF249","UNDEF250",
-       "UNDEF251","UNDEF252",
+
+       "INLINE_START", /*          251 */
+        "INLINE_END", /*            252"*/
 
        "BUILTIN3     ", /*             253 */
        "BUILTIN2     ", /*             254 */
@@ -1152,8 +1154,9 @@ char *opcode_names[256] = {
        "UNDEF236","UNDEF237","UNDEF238","UNDEF239","UNDEF240",
        "UNDEF","UNDEF","UNDEF","UNDEF","UNDEF",
        "UNDEF246","UNDEF247","UNDEF248","UNDEF249","UNDEF250",
-       "UNDEF251","UNDEF252",
 
+       "INLINE_START", /*              251 */
+        "INLINE_END",  /*               252 */
        "BUILTIN3     ", /*             253 */
        "BUILTIN2     ", /*             254 */
        "BUILTIN1     "  /*             255 */
index 8c128be32b7b34654e3bed8f18c75d2c49b707f1..24d95dd7f71c845826117689d601c16094cb7254 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: jit.h 1494 2004-11-12 13:34:26Z twisti $
+   $Id: jit.h 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -112,7 +112,7 @@ struct instruction {
        u2          line;           /* line number in source file                 */
        methodinfo *method;         /* needed for inlining. can't be done on      */
                                    /* basic block level, since an inlined        */
-                                   /* function doesn't start necessarily start   */
+                                   /* function doesn't necessarily start         */
                                    /* a new block                                */
 };
 
@@ -779,6 +779,8 @@ extern int jcommandsize[256];
 
 #define ICMD_SASTORECONST     211
 
+#define ICMD_INLINE_START     251       /* before the first instruction of an inlined method */
+#define ICMD_INLINE_END       252       /* after the last instruction of an inlined method */
 #define ICMD_BUILTIN3         253       /* internal opcode */
 #define ICMD_BUILTIN2         254       /* internal opcode */
 #define ICMD_BUILTIN1         255       /* internal opcode */
index 530008a9154ad41eae8770fef65dfc9957b050ea..49eb4cef6ba0d687b3d2688bee443fc41e40f6bf 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Carolyn Oates
             Edwin Steiner
 
-   $Id: parse.c 1494 2004-11-12 13:34:26Z twisti $
+   $Id: parse.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -361,7 +361,7 @@ static exceptiontable* fillextable(methodinfo *m,
                int *label_index, int *block_count, 
                t_inlining_globals *inline_env)
 {
-       int b_count, i, p;
+       int b_count, i, p, src, insertBlock;
        
        if (exceptiontablelength == 0) 
                return extable;
@@ -375,41 +375,47 @@ static exceptiontable* fillextable(methodinfo *m,
 
        b_count = *block_count;
 
-       for (i = 0; i < exceptiontablelength; i++) {
+       for (src = exceptiontablelength-1; src >=0; src--) {
                /* printf("Excepiont table index: %d\n",i); */
-               p = raw_extable[i].startpc;
+               p = raw_extable[src].startpc;
                if (label_index != NULL) p = label_index[p];
-               extable[i].startpc = p;
+               extable->startpc = p;
                bound_check(p);
                block_insert(p);
                
 /*** if (DEBUG==true){printf("---------------------block_inserted:b_count=%i m->basicblockindex[(p=%i)]=%i=%p\n",b_count,p,m->basicblockindex[(p)],m->basicblockindex[(p)]); 
   fflush(stdout); } ***/   
-               p = raw_extable[i].endpc; /* see JVM Spec 4.7.3 */
-               if (p < raw_extable[i].startpc)
+               p = raw_extable[src].endpc; /* see JVM Spec 4.7.3 */
+               if (p <= raw_extable[src].startpc)
                        panic("Invalid exception handler range");
-               if (p > m->jcodelength) { 
+
+               if (p >inline_env->method->jcodelength) {
                        panic("Invalid exception handler end is after code end");
                }
+               if (p<inline_env->method->jcodelength) insertBlock=1; else insertBlock=0;
+                /*if (label_index !=NULL) printf("%s:translating endpc:%ld to %ld, label_index:%p\n",m->name->text,p,label_index[p],label_index); else
+                       printf("%s:fillextab: endpc:%ld\n",m->name->text,p);*/
                if (label_index != NULL) p = label_index[p];
-               extable[i].endpc = p;
+               extable->endpc = p;
                bound_check1(p);
-               if (p < m->jcodelength) {
-                       block_insert(p); }
+               /*if (p < inline_env->method->jcodelength) {
+                       block_insert(p); }*/
+                if (insertBlock) block_insert(p);
 
-               p = raw_extable[i].handlerpc;
+               p = raw_extable[src].handlerpc;
                if (label_index != NULL) p = label_index[p];
-               extable[i].handlerpc = p;
+               extable->handlerpc = p;
                bound_check(p);
                block_insert(p);
 
-               extable[i].catchtype  = raw_extable[i].catchtype;
-               extable[i].next = NULL;
-               extable[i].down = &extable[i + 1];
+               extable->catchtype  = raw_extable[src].catchtype;
+               extable->next = NULL;
+               extable->down = &extable[1];
+               extable--;
        }
 
        *block_count = b_count;
-       return &extable[i];  /* return the next free xtable* */
+       return extable; /*&extable[i];*/  /* return the next free xtable* */
 }
 
 
@@ -526,7 +532,7 @@ if (m->exceptiontablelength > 0)
        */
 
        nextex = fillextable(m, 
-         cd->exceptiontable, m->exceptiontable, m->exceptiontablelength, 
+         &(cd->exceptiontable[cd->exceptiontablelength-1]), m->exceptiontable, m->exceptiontablelength, 
           label_index, &b_count, inline_env);
        s_count = 1 + m->exceptiontablelength; /* initialize stack element counter   */
 
@@ -643,6 +649,8 @@ DEBUGMETH(inline_env->method);
                        }
 
 
+                        OP(ICMD_INLINE_START);
+
                        if (inlinfo->inlinedmethods == NULL) {
                                gp = -1;
                        } else {
@@ -661,6 +669,8 @@ DEBUGMETH(inline_env->method);
                {
                        printf("Parse p=%i<%i<%i<   opcode=<%i> %s\n",
                           p, gp, inline_env->jcodelength, opcode, opcode_names[opcode]);
+                       if (label_index)
+                               printf("label_index[%ld]=%ld\n",p,label_index[p]);
                }
         /*
 printf("basicblockindex[gp=%i]=%i=%p ipc=%i=%p shifted ipc=%i=%p\n",
@@ -1672,7 +1682,9 @@ if (DEBUG4==true)
                        /*                printf("setting gp from %d to %d\n",gp, inlinfo->stopgp); */
                        gp = inlinfo->stopgp; 
                        inlining_restore_compiler_variables();
+                       OP(ICMD_INLINE_END);
 /*label_index = inlinfo->label_index;*/
+
 if (DEBUG==true) {
 printf("AFTER RESTORE : "); fflush(stdout);
 DEBUGMETH(inline_env->method);
@@ -1793,7 +1805,7 @@ DEBUGMETH(inline_env->method);
                        cd->exceptiontable[i].start = m->basicblocks + m->basicblockindex[p];
 
                        p = cd->exceptiontable[i].endpc;
-                       cd->exceptiontable[i].end = (p == m->jcodelength) ? (m->basicblocks + m->basicblockcount + 1) : (m->basicblocks + m->basicblockindex[p]);
+                       cd->exceptiontable[i].end = (p == inline_env->method->jcodelength) ? (m->basicblocks + m->basicblockcount /*+ 1*/) : (m->basicblocks + m->basicblockindex[p]);
 
                        p = cd->exceptiontable[i].handlerpc;
                        cd->exceptiontable[i].handler = m->basicblocks + m->basicblockindex[p];
index 0a67f9959261753a7eba2e9086e34de6a429acd6..a05f2e315ab10b10c321ae6d8a5235afb1cb88b5 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Stefan Ring
             Christian Thalinger
 
-   $Id: reg.inc 1466 2004-11-08 11:24:50Z twisti $
+   $Id: reg.inc 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -867,6 +867,8 @@ static void allocate_scratch_registers(methodinfo *m, registerdata *rd)
                                case ICMD_RET:
                                case ICMD_RETURN:
                                case ICMD_GOTO:
+                               case ICMD_INLINE_START:
+                               case ICMD_INLINE_END:
                                        break;
 
                                        /* pop 0 push 1 const */
index 809e69183e4fcf7524fa548a9991fc100d994b20..1eac20c5865422da6fe5c2f8eb1066b1990aa3d1 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: stack.c 1456 2004-11-05 14:33:14Z twisti $
+   $Id: stack.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -1778,6 +1778,10 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                                        }
                                                        break;
                                                }
+                                       case ICMD_INLINE_START:
+                                       case ICMD_INLINE_END:
+                                               SETDST;
+                                               break;
 
                                        case ICMD_BUILTIN3:
                                                /* DEBUG */ /*dolog("builtin3");*/
@@ -1898,8 +1902,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                if (m->basicblockcount > count_max_basic_blocks)
                        count_max_basic_blocks = m->basicblockcount;
                count_basic_blocks += m->basicblockcount;
-               if (m->instructioncount > count_max_javainstr)
-                       count_max_javainstr = m->instructioncount;
+               if (m->instructioncount > count_max_javainstr)                  count_max_javainstr = m->instructioncount;
                count_javainstr += m->instructioncount;
                if (m->stackcount > count_upper_bound_new_stack)
                        count_upper_bound_new_stack = m->stackcount;
@@ -2490,6 +2493,12 @@ void show_icmd(instruction *iptr, bool deadcode)
                }
                break;
 
+       case ICMD_INLINE_START:
+               printf("\t\t\t%s.%s%s",iptr->method->class->name->text,iptr->method->name->text,iptr->method->descriptor->text);
+               break;
+       case ICMD_INLINE_END:
+               break;
+
        case ICMD_BUILTIN3:
        case ICMD_BUILTIN2:
        case ICMD_BUILTIN1:
@@ -2617,10 +2626,10 @@ void show_icmd(instruction *iptr, bool deadcode)
                break;
        }
 /*     printf(" Line number: %d, method:",iptr->line); */
-        printf("\t\t");
+/*        printf("\t\t");
        utf_display(iptr->method->class->name); 
        printf("."); 
-       utf_display(iptr->method->name); 
+       utf_display(iptr->method->name); */
 }
 
 
index 4aa4b33aeb191add569bcbbb70241cc6e83deecf..11cf0a2f93e399464f06ba2dceb2061fd80968c2 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Edwin Steiner
 
-   $Id: typecheck.c 1483 2004-11-11 14:40:10Z twisti $
+   $Id: typecheck.c 1506 2004-11-14 14:48:49Z jowenn $
 
 */
 
@@ -497,7 +497,7 @@ typestate_merge(stackptr deststack,typevector *destloc,
 
 
 static bool
-typestate_reach(methodinfo *m, void *localbuf,
+typestate_reach(codegendata *cd, registerdata *rd,void *localbuf,
                                basicblock *current,
                                basicblock *destblock,
                                stackptr ystack,typevector *yloc,
@@ -510,7 +510,7 @@ typestate_reach(methodinfo *m, void *localbuf,
        LOG1("reaching block L%03d",destblock->debug_nr);
        TYPECHECK_COUNT(stat_reached);
        
-       destidx = destblock - m->basicblocks;
+       destidx = destblock - cd->method->basicblocks;
        destloc = MGET_TYPEVECTOR(localbuf,destidx,locsize);
 
        /* When branching backwards we have to check for uninitialized objects */
@@ -518,19 +518,24 @@ typestate_reach(methodinfo *m, void *localbuf,
        if (destblock <= current) {
                stackptr sp;
                int i;
-               
-               TYPECHECK_COUNT(stat_backwards);
-        LOG("BACKWARDS!");
-        for (sp = ystack; sp; sp=sp->prev)
-            if (sp->type == TYPE_ADR &&
-                TYPEINFO_IS_NEWOBJECT(sp->typeinfo))
-                panic("Branching backwards with uninitialized object on stack");
-
-        for (i=0; i<locsize; ++i)
-            if (yloc->td[i].type == TYPE_ADR &&
-                TYPEINFO_IS_NEWOBJECT(yloc->td[i].info))
-                panic("Branching backwards with uninitialized object in local variable");
-    }
+#warning FIXME FOR INLINING
+               if (!useinlining) {
+                       TYPECHECK_COUNT(stat_backwards);
+                       LOG("BACKWARDS!");
+                       for (sp = ystack; sp; sp=sp->prev)
+                               if (sp->type == TYPE_ADR &&
+                               TYPEINFO_IS_NEWOBJECT(sp->typeinfo)) {
+                                       show_icmd_method(cd->method,cd,rd);
+                               printf("current: %ld, dest: %ld\n",current->debug_nr,destblock->debug_nr);
+                               panic("Branching backwards with uninitialized object on stack");
+                       }
+
+                       for (i=0; i<locsize; ++i)
+                               if (yloc->td[i].type == TYPE_ADR &&
+                               TYPEINFO_IS_NEWOBJECT(yloc->td[i].info))
+                                       panic("Branching backwards with uninitialized object in local variable");
+               }
+       }
        
        if (destblock->flags == BBTYPECHECK_UNDEF) {
                /* The destblock has never been reached before */
@@ -564,7 +569,7 @@ typestate_reach(methodinfo *m, void *localbuf,
 
 
 static bool
-typestate_ret(methodinfo *m, void *localbuf,
+typestate_ret(codegendata *cd,registerdata *rd, void *localbuf,
                          basicblock *current,
                          stackptr ystack,typevector *yloc,
                          int retindex,int locsize)
@@ -582,7 +587,7 @@ typestate_ret(methodinfo *m, void *localbuf,
 
                selected = typevectorset_select(&yvec,retindex,destblock);
                
-               repeat |= typestate_reach(m, localbuf,current,destblock,
+               repeat |= typestate_reach(cd, rd,  localbuf,current,destblock,
                                                                  ystack,selected,locsize,true);
        }
        return repeat;
@@ -767,7 +772,7 @@ is_accessible(int flags,classinfo *definingclass,classinfo *implementingclass, c
  */
 #define TYPECHECK_REACH                                                 \
     do {                                                                \
-    repeat |= typestate_reach(m, localbuf,bptr,tbptr,dst,               \
+    repeat |= typestate_reach(cd,rd, localbuf,bptr,tbptr,dst,               \
                                                          localset,numlocals,jsrencountered);       \
     LOG("done.");                                                       \
     } while (0)
@@ -1549,7 +1554,7 @@ methodinfo *typecheck(methodinfo *m, codegendata *cd, registerdata *rd)
                                                  if (bptr + 1 == (m->basicblocks + m->basicblockcount + 1))
                                                          panic("Illegal instruction: JSR at end of bytecode");
                                                  typestack_put_retaddr(dst,bptr+1,localset);
-                                                 repeat |= typestate_reach(m, localbuf,bptr,tbptr,dst,
+                                                 repeat |= typestate_reach(cd, rd,localbuf,bptr,tbptr,dst,
                                                                                                        localset,numlocals,true);
 
                                                  superblockend = true;
@@ -1560,7 +1565,7 @@ methodinfo *typecheck(methodinfo *m, codegendata *cd, registerdata *rd)
                                                  if (!typevectorset_checkretaddr(localset,iptr->op1))
                               panic("illegal instruction: RET using non-returnAddress variable");
 
-                                                 repeat |= typestate_ret(m, localbuf,bptr,curstack,
+                                                 repeat |= typestate_ret(cd,rd, localbuf,bptr,curstack,
                                                                                                  localset,iptr->op1,numlocals);
 
                           superblockend = true;
@@ -2075,7 +2080,7 @@ methodinfo *typecheck(methodinfo *m, codegendata *cd, registerdata *rd)
                                                        cls = handlers[i]->catchtype;
                                                        excstack.typeinfo.typeclass = (cls) ? cls
                                                                : class_java_lang_Throwable;
-                                                       repeat |= typestate_reach(m, localbuf,bptr,
+                                                       repeat |= typestate_reach(cd,rd, localbuf,bptr,
                                                                                                          handlers[i]->handler,
                                                                                                          &excstack,localset,
                                                                                                          numlocals,
index 46fc543337cd624f2f37551f982564d7bca3202f..c89ec81c16d6b2fd17179ab1bc22c320671024b3 100644 (file)
@@ -13,6 +13,7 @@ public class InlineExTest {
                        System.out.println("ERROR EXCEPTION EXPECTED");
                } catch (Exception e) {
                        System.out.println(e);
+                       System.out.println("End of outer exception handler");
                        System.exit(0);
                }
                System.out.println("SHOULD NOT BE REACHED");
diff --git a/tests/InlineExTest3.java b/tests/InlineExTest3.java
new file mode 100644 (file)
index 0000000..6b5e33e
--- /dev/null
@@ -0,0 +1,17 @@
+public class InlineExTest3 {
+       public static void internal() throws Exception {
+               System.out.println("INTERNAL");
+       }
+
+       public static void main(String args[]) {
+               try {
+                       internal();
+                       throw new Exception("ex");
+                       //System.out.println("ERROR EXCEPTION EXPECTED");
+               } catch (Exception e) {
+                       System.out.println(e);
+                       System.exit(0);
+               }
+       //      System.out.println("SHOULD NOT BE REACHED");
+       }
+}
diff --git a/tests/InlineExTest4.java b/tests/InlineExTest4.java
new file mode 100644 (file)
index 0000000..57904b8
--- /dev/null
@@ -0,0 +1,21 @@
+public class InlineExTest4 {
+       public static void internal() throws Exception {
+               try {
+                       throw new Exception("*");
+               } catch (Exception e) {
+                       throw new Exception("*"+e.getMessage());
+               }
+       }
+
+       public static void main(String args[]) {
+               try {
+                       internal();
+                       System.out.println("ERROR EXCEPTION EXPECTED");
+               } catch (Throwable  e) {
+                       System.out.println(e);
+                       System.out.println("End of outer exception handler");
+                       System.exit(0);
+               }
+               System.out.println("SHOULD NOT BE REACHED");
+       }
+}
diff --git a/tests/InlineSynchronized.java b/tests/InlineSynchronized.java
new file mode 100644 (file)
index 0000000..30e652c
--- /dev/null
@@ -0,0 +1,22 @@
+public class InlineSynchronized {
+
+       public static void testit(InlineSynchronized o) throws Exception {
+               synchronized(o) {
+                       System.out.println("Within protected section, about to throw an exception");
+                       throw new Exception("");
+               }
+       }
+       public static void main(String args[]) {
+               InlineSynchronized o=new InlineSynchronized();
+               try {
+                       try {
+                               testit(o);
+                       } catch (Exception e) {
+                               System.out.println("First catch");
+                               testit(o);
+                       }
+               } catch (Exception e) {
+                       System.out.println("Second catch");
+               }
+       }
+}
diff --git a/tests/InlineSynchronized2.java b/tests/InlineSynchronized2.java
new file mode 100644 (file)
index 0000000..b36ea54
--- /dev/null
@@ -0,0 +1,43 @@
+public class InlineSynchronized2 extends Thread{
+
+       private InlineSynchronized2 m_o;
+       String m_name;
+       public InlineSynchronized2(String name, InlineSynchronized2 o) {
+               super(name);
+               m_o=o;
+               m_name=name;
+       }
+
+       public void run() {
+               while (true) {
+                       try {
+                               try {
+                                       testit(m_o);
+                               } catch (Exception e) {
+                                       System.out.println(m_name+":First catch");
+                                       testit(m_o);
+                               }
+                       } catch (Exception e) {
+                               System.out.println(m_name+":Second catch");
+                       }
+                       try {
+                               sleep(2000);
+                       } catch (Exception e) {}
+               }
+       }
+       public static void testit(InlineSynchronized2 o) throws Exception {
+               synchronized(o) {
+                       System.out.println("Within protected section, about to throw an exception");
+                       throw new Exception("");
+               }
+       }
+       public static void main(String args[]) {
+               InlineSynchronized2 o=new InlineSynchronized2("dummy",null);
+               InlineSynchronized2 o1=new InlineSynchronized2("1",o);
+               InlineSynchronized2 o2=new InlineSynchronized2("2",o);
+               InlineSynchronized2 o3=new InlineSynchronized2("3",o);
+               o1.start();
+               o2.start();
+               o3.start();
+       }
+}
diff --git a/tests/InlineSynchronized3.java b/tests/InlineSynchronized3.java
new file mode 100644 (file)
index 0000000..d8c666d
--- /dev/null
@@ -0,0 +1,34 @@
+public class InlineSynchronized3 extends Thread{
+
+       private InlineSynchronized3 m_o;
+       String m_name;
+       public InlineSynchronized3(String name, InlineSynchronized3 o) {
+               super(name);
+               m_o=o;
+               m_name=name;
+       }
+
+       public void run() {
+               while (true) {
+                       testit(m_o);
+                       System.out.println("("+m_name+")");
+                       try {
+                               sleep(2000);
+                       } catch (Exception e) {}
+               }
+       }
+       public static void testit(InlineSynchronized3 o) {
+               synchronized(o) {
+                       System.out.println("Within protected section, about to throw an exception");
+               }
+       }
+       public static void main(String args[]) {
+               InlineSynchronized3 o=new InlineSynchronized3("dummy",null);
+               InlineSynchronized3 o1=new InlineSynchronized3("1",o);
+               InlineSynchronized3 o2=new InlineSynchronized3("2",o);
+               InlineSynchronized3 o3=new InlineSynchronized3("3",o);
+               o1.start();
+               o2.start();
+               o3.start();
+       }
+}
diff --git a/tests/InlineSynchronized4.java b/tests/InlineSynchronized4.java
new file mode 100644 (file)
index 0000000..13ecd0d
--- /dev/null
@@ -0,0 +1,40 @@
+public class InlineSynchronized4 extends Thread{
+
+       private InlineSynchronized4 m_o;
+       String m_name;
+       public InlineSynchronized4(String name, InlineSynchronized4 o) {
+               super(name);
+               m_o=o;
+               m_name=name;
+       }
+
+       public void run() {
+               while (true) {
+                       testit(m_o);
+                       System.out.println("("+m_name+")");
+                       try {
+                               sleep(2000);
+                       } catch (Exception e) {}
+               }
+       }
+       public static void testit(InlineSynchronized4 o){
+               try {
+                       synchronized(o) {
+                               System.out.println("Within protected section, about to throw an exception");
+                               throw new Exception("");
+                       }
+               }
+               catch (Exception e) {
+                       System.out.println("Exception caught");
+               }
+       }
+       public static void main(String args[]) {
+               InlineSynchronized4 o=new InlineSynchronized4("dummy",null);
+               InlineSynchronized4 o1=new InlineSynchronized4("1",o);
+               InlineSynchronized4 o2=new InlineSynchronized4("2",o);
+               InlineSynchronized4 o3=new InlineSynchronized4("3",o);
+               o1.start();
+               o2.start();
+               o3.start();
+       }
+}
diff --git a/tests/InlineSynchronized5.java b/tests/InlineSynchronized5.java
new file mode 100644 (file)
index 0000000..79867b6
--- /dev/null
@@ -0,0 +1,48 @@
+public class InlineSynchronized5 extends Thread{
+
+       private InlineSynchronized5 m_o;
+       String m_name;
+       public InlineSynchronized5(String name, InlineSynchronized5 o) {
+               super(name);
+               m_o=o;
+               m_name=name;
+       }
+
+       public void run() {
+               while (true) {
+                       try {
+                               try {
+                                       testit(m_o);
+                               } catch (Exception e) {
+                                       System.out.println(m_name+":First catch");
+                                       testit(m_o);
+                               }
+                       } catch (Exception e) {
+                               System.out.println(m_name+":Second catch");
+                       }
+                       try {
+                               sleep(2000);
+                       } catch (Exception e) {}
+               }
+       }
+       public static void testit(InlineSynchronized5 o) throws Exception {
+               try {
+                       synchronized(o) {
+                               System.out.println("Within protected section, about to throw an exception");
+                               throw new Exception("");
+                       }
+               } catch (Exception e) {
+                       System.out.println("Exception caught, rethrowing");
+                       throw e;
+               }
+       }
+       public static void main(String args[]) {
+               InlineSynchronized5 o=new InlineSynchronized5("dummy",null);
+               InlineSynchronized5 o1=new InlineSynchronized5("1",o);
+               InlineSynchronized5 o2=new InlineSynchronized5("2",o);
+               InlineSynchronized5 o3=new InlineSynchronized5("3",o);
+               o1.start();
+               o2.start();
+               o3.start();
+       }
+}
diff --git a/tests/InlineSynchronized6.java b/tests/InlineSynchronized6.java
new file mode 100644 (file)
index 0000000..4bb201a
--- /dev/null
@@ -0,0 +1,41 @@
+public class InlineSynchronized6 extends Thread{
+
+       private InlineSynchronized6 m_o;
+       String m_name;
+       public InlineSynchronized6(String name, InlineSynchronized6 o) {
+               super(name);
+               m_o=o;
+               m_name=name;
+       }
+
+       public void run() {
+               while (true) {
+                       try {
+                               try {
+                                       testit(m_o);
+                               } catch (Exception e) {
+                                       System.out.println(m_name+":First catch");
+                                       testit(m_o);
+                               }
+                       } catch (Exception e) {
+                               System.out.println(m_name+":Second catch");
+                       }
+                       try {
+                               sleep(2000);
+                       } catch (Exception e) {}
+               }
+       }
+       public static synchronized void testit(InlineSynchronized6 o) throws Exception {
+                       System.out.println("Within protected section, about to throw an exception");
+                       throw new Exception("");
+       }
+       public static void main(String args[]) {
+               InlineSynchronized6 o=new InlineSynchronized6("dummy",null);
+               InlineSynchronized6 o1=new InlineSynchronized6("1",o);
+               InlineSynchronized6 o2=new InlineSynchronized6("2",o);
+               InlineSynchronized6 o3=new InlineSynchronized6("3",o);
+               o1.start();
+               o2.start();
+               o3.start();
+       }
+}