* Removed all Id tags.
[cacao.git] / src / vm / jit / cfg.c
index 2aebf4797fa4e4515938fc315fd85a1f1d2df732..4163852371c5261bf9242c1c3aedd4d00928f033 100644 (file)
@@ -28,8 +28,6 @@
 
    Changes: Edwin Steiner
 
-   $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
-
 */
 
 
@@ -114,7 +112,6 @@ static void cfg_insert_predecessors(basicblock *bptr, basicblock *pbptr)
 
 bool cfg_build(jitdata *jd)
 {
-       methodinfo      *m;
        basicblock      *bptr;
        basicblock      *tbptr;
        basicblock      *ntbptr;
@@ -123,15 +120,11 @@ bool cfg_build(jitdata *jd)
        lookup_target_t *lookup;
        s4               i;
 
-       /* get required compiler data */
-
-       m = jd->m;
-
        /* process all basic blocks to find the predecessor/successor counts */
 
-       bptr = jd->new_basicblocks;
+       bptr = jd->basicblocks;
 
-       for (bptr = jd->new_basicblocks; bptr != NULL; bptr = bptr->next) {
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
                if ((bptr->icount == 0) || (bptr->flags == BBUNDEF))
                        continue;
 
@@ -141,7 +134,7 @@ bool cfg_build(jitdata *jd)
 
                while (iptr->opc == ICMD_NOP) {
                        if (iptr == bptr->iinstr)
-                               continue;
+                               break;
                        iptr--;
                }
 
@@ -241,7 +234,11 @@ bool cfg_build(jitdata *jd)
                        bptr->successorcount++;
 
                        tbptr = bptr->next;
-                       tbptr->predecessorcount++;
+
+                       /* An exception handler has no predecessors. */
+
+                       if (tbptr->type != BBTYPE_EXH)
+                               tbptr->predecessorcount++;
                        break;
                }
        }
@@ -249,9 +246,9 @@ bool cfg_build(jitdata *jd)
        /* Second iteration to allocate the arrays and insert the basic
           block pointers. */
 
-       bptr = jd->new_basicblocks;
+       bptr = jd->basicblocks;
 
-       for (bptr = jd->new_basicblocks; bptr != NULL; bptr = bptr->next) {
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
                if ((bptr->icount == 0) || (bptr->flags == BBUNDEF))
                        continue;
 
@@ -261,7 +258,7 @@ bool cfg_build(jitdata *jd)
 
                while (iptr->opc == ICMD_NOP) {
                        if (iptr == bptr->iinstr)
-                               continue;
+                               break;
                        iptr--;
                }
 
@@ -399,10 +396,14 @@ goto_tail:
                        bptr->successors[0] = tbptr;
                        bptr->successorcount++;
 
-                       cfg_allocate_predecessors(tbptr);
+                       /* An exception handler has no predecessors. */
 
-                       tbptr->predecessors[tbptr->predecessorcount] = bptr;
-                       tbptr->predecessorcount++;
+                       if (tbptr->type != BBTYPE_EXH) {
+                               cfg_allocate_predecessors(tbptr);
+
+                               tbptr->predecessors[tbptr->predecessorcount] = bptr;
+                               tbptr->predecessorcount++;
+                       }
                        break;
                }
        }