Merged revisions 7616-7627 via svnmerge from
[cacao.git] / src / vm / jit / stack.c
index bf20f3887697f62f47f1d8f46ab713d302e1e214..05c12ea9ad15f21bc964a9160f7d1bf92e689d2f 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: stack.c 7483 2007-03-08 13:17:40Z michi $
+   $Id: stack.c 7624 2007-04-02 16:09:44Z twisti $
 
 */
 
@@ -1116,10 +1116,14 @@ static stackptr stack_create_instack(stackdata_t *sd)
 
 static basicblock *stack_mark_reached(stackdata_t *sd, basicblock *b, stackptr curstack, int stackdepth) 
 {
+       assert(b != NULL);
+
 #if defined(STACK_VERBOSE)
        printf("stack_mark_reached(L%03d from L%03d)\n", b->nr, sd->bptr->nr);
 #endif
+
        /* mark targets of backward branches */
+
        if (b->nr <= sd->bptr->nr)
                b->bitflags |= BBFLAG_REPLACEMENT;
 
@@ -1162,10 +1166,14 @@ static basicblock *stack_mark_reached(stackdata_t *sd, basicblock *b, stackptr c
 
 static basicblock *stack_mark_reached_from_outvars(stackdata_t *sd, basicblock *b)
 {
+       assert(b != NULL);
+
 #if defined(STACK_VERBOSE)
        printf("stack_mark_reached_from_outvars(L%03d from L%03d)\n", b->nr, sd->bptr->nr);
 #endif
+
        /* mark targets of backward branches */
+
        if (b->nr <= sd->bptr->nr)
                b->bitflags |= BBFLAG_REPLACEMENT;
 
@@ -1192,9 +1200,10 @@ static basicblock *stack_mark_reached_from_outvars(stackdata_t *sd, basicblock *
 
 /* stack_reach_next_block ******************************************************
 
-   Mark the following block reached and propagate the outvars of the current block
-   and the current locals to it. This function specializes the target block, 
-   if necessary, and returns a pointer to the specialized target.
+   Mark the following block reached and propagate the outvars of the
+   current block and the current locals to it.  This function
+   specializes the target block, if necessary, and returns a pointer
+   to the specialized target.
 
    IN:
       sd...........stack analysis data
@@ -1212,7 +1221,8 @@ static bool stack_reach_next_block(stackdata_t *sd)
 
        tbptr = (sd->bptr->original) ? sd->bptr->original : sd->bptr;
        tbptr = stack_mark_reached_from_outvars(sd, tbptr->next);
-       if (!tbptr)
+
+       if (tbptr == NULL)
                return false;
 
        if (tbptr != sd->bptr->next) {
@@ -2153,11 +2163,12 @@ bool stack_analyse(jitdata *jd)
 
                /* initialize loop over basic blocks */
 
-               sd.bptr = jd->basicblocks;
+               sd.bptr       = jd->basicblocks;
                superblockend = true;
-               sd.repeat = false;
-               curstack = NULL; stackdepth = 0;
-               deadcode = true;
+               sd.repeat     = false;
+               curstack      = NULL;
+               stackdepth    = 0;
+               deadcode      = true;
 
                /* iterate over basic blocks *****************************************/
 
@@ -2171,16 +2182,20 @@ bool stack_analyse(jitdata *jd)
 
                        if (sd.bptr->flags == BBTYPECHECK_REACHED) {
                                /* re-analyse a block because its input changed */
+
                                deadcode = false;
+
                                if (!stack_reanalyse_block(&sd))
                                        return false;
+
                                superblockend = true; /* XXX */
                                continue;
                        }
 
                        if (superblockend && (sd.bptr->flags < BBREACHED)) {
-                               /* This block has not been reached so far, and we      */
-                               /* don't fall into it, so we'll have to iterate again. */
+                               /* This block has not been reached so far, and we
+                                  don't fall into it, so we'll have to iterate
+                                  again. */
 
                                sd.repeat = true;
                                continue;
@@ -2194,8 +2209,9 @@ bool stack_analyse(jitdata *jd)
                        }
 
                        if (sd.bptr->original && sd.bptr->original->flags < BBFINISHED) {
-                               /* This block is a clone and the original has not been */
-                               /* analysed, yet. Analyse it on the next iteration.    */
+                               /* This block is a clone and the original has not been
+                                  analysed, yet. Analyse it on the next
+                                  iteration. */
 
                                sd.repeat = true;
                                /* XXX superblockend? */