* src/vm/jit/parse.c (new_parse): MZERO basicblock array.
authortwisti <none@none>
Fri, 4 Aug 2006 14:42:57 +0000 (14:42 +0000)
committertwisti <none@none>
Fri, 4 Aug 2006 14:42:57 +0000 (14:42 +0000)
(parse): Likewise.

* src/vm/jit/jit.h (JITDATA_FLAG_REORDER): Added.
(JITDATA_HAS_FLAG_REORDER): Likewise.
(basicblock): Removed pre_count and added predecessorcount,
successorcount, predecessors, successors.
(BASICBLOCK_INIT): Don't zero fields.

* src/vm/jit/stack.c (new_stack_analyse): Renamed pre_count to
predecessorcount.
(stack_analyse): Likewise and removed predecessor count calculation.

* src/vm/jit/show.c (new_show_basicblock): Likewise.
(show_basicblock): Likewise.

* src/vm/jit/ifconv/ifconv.c (ifconv_static): Likewise.

src/vm/jit/ifconv/ifconv.c
src/vm/jit/jit.h
src/vm/jit/parse.c
src/vm/jit/show.c
src/vm/jit/stack.c

index a220fccba406e3af3738432f769ee2ce41e1d3eb..e939868bc10f5d17ef303e4d69f3ce680e8d0582 100644 (file)
@@ -205,7 +205,8 @@ bool ifconv_static(jitdata *jd)
                case ICMD_IF_ACMPNE:
                        /* basic blocks can only have 1 predecessor */
 
-                       if ((bptr[1].pre_count != 1) || (bptr[2].pre_count != 1))
+                       if ((bptr[1].predecessorcount != 1) ||
+                               (bptr[2].predecessorcount != 1))
                                break;
 
                        check(jd, bptr);
index 076cc790296c2ba9242a9ab39eb74fffb7668572..5a3f7973d6ccfc57172af08e9f2f7801bdf82632 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Christian Thalinger
                        Edwin Steiner
 
-   $Id: jit.h 5183 2006-07-26 15:20:15Z twisti $
+   $Id: jit.h 5208 2006-08-04 14:42:57Z twisti $
 
 */
 
@@ -117,6 +117,7 @@ struct jitdata {
 #define JITDATA_FLAG_INSTRUMENT          0x00000004
 
 #define JITDATA_FLAG_IFCONV              0x00000008
+#define JITDATA_FLAG_REORDER             0x00000010
 
 #define JITDATA_FLAG_SHOWINTERMEDIATE    0x20000000
 #define JITDATA_FLAG_SHOWDISASSEMBLE     0x40000000
@@ -135,6 +136,9 @@ struct jitdata {
 #define JITDATA_HAS_FLAG_IFCONV(jd) \
     ((jd)->flags & JITDATA_FLAG_IFCONV)
 
+#define JITDATA_HAS_FLAG_REORDER(jd) \
+    ((jd)->flags & JITDATA_FLAG_REORDER)
+
 #define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \
     ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE)
 
@@ -484,7 +488,12 @@ struct basicblock {
        stackptr     outstack;      /* stack at end of basic block                */
        s4           indepth;       /* stack depth at begin of basic block        */
        s4           outdepth;      /* stack depth end of basic block             */
-       s4           pre_count;     /* count of predecessor basic blocks          */
+
+       s4           predecessorcount;
+       s4           successorcount;
+       basicblock  *predecessors;  /* array of predecessor basic blocks          */
+       basicblock  *successors;    /* array of successor basic blocks            */
+
        branchref   *branchrefs;    /* list of branches to be patched             */
 
        basicblock  *next;          /* used to build a BB list (instead of array) */
@@ -496,20 +505,18 @@ struct basicblock {
        methodinfo  *method;        /* method this block belongs to               */
 };
 
-/* macro for initializing newly allocated basicblock:s                        */
+
+/* Macro for initializing newly allocated basic block's. It does not
+   need to zero fields, as we zero out the whole basic block array. */
 
 #define BASICBLOCK_INIT(bptr,m)                            \
-               do {                                               \
-                       bptr->mpc = -1;                                \
-                       bptr->flags = -1;                              \
-                       bptr->bitflags = 0;                            \
-                       bptr->lflags = 0;                              \
-                       bptr->type = BBTYPE_STD;                       \
-                       bptr->branchrefs = NULL;                       \
-                       bptr->pre_count = 0;                           \
-                       bptr->method = (m);                            \
-                       bptr->debug_nr = (m)->c_debug_nr++;            \
-               } while (0)
+       do {                                                   \
+               bptr->mpc        = -1;                             \
+               bptr->flags      = -1;                             \
+               bptr->type       = BBTYPE_STD;                     \
+               bptr->method     = (m);                            \
+               bptr->debug_nr   = (m)->c_debug_nr++;              \
+       } while (0)
                        
 
 /* branchref *****************************************************************/
index 1fa4f35c092a5934daed6c6e6b2c9d92692efe43..5f1cc9f77bb6d76a8bf9abfac3f7d1adfe999cc1 100644 (file)
@@ -31,7 +31,7 @@
             Joseph Wenninger
             Christian Thalinger
 
-   $Id: parse.c 5202 2006-08-01 13:10:48Z twisti $
+   $Id: parse.c 5208 2006-08-04 14:42:57Z twisti $
 
 */
 
@@ -1354,6 +1354,10 @@ invoke_method:
 
        bptr = jd->new_basicblocks = DMNEW(basicblock, b_count + 1);    /* one more for end ipc */
 
+       /* zero out all basic block structures */
+
+       MZERO(bptr, basicblock, b_count + 1);
+
        b_count = 0;
        jd->new_c_debug_nr = 0;
 
@@ -2585,6 +2589,10 @@ invoke_method:
 
                bptr = m->basicblocks = DMNEW(basicblock, b_count + 1);    /* one more for end ipc */
 
+               /* zero out all basic block structures */
+
+               MZERO(bptr, basicblock, b_count + 1);
+
                b_count = 0;
                m->c_debug_nr = 0;
        
index ad59431edbeeddee0da9c2be6df1761750d20996..a5d1511c7010140208b942b2851acd3f27b9cf95 100644 (file)
@@ -829,7 +829,7 @@ void new_show_basicblock(jitdata *jd, basicblock *bptr, int stage)
                }
 
                printf(", instruction count: %d, predecessors: %d):\n",
-                          bptr->icount, bptr->pre_count);
+                          bptr->icount, bptr->predecessorcount);
 
                iptr = /*XXX*/ (new_instruction *) bptr->iinstr;
 
@@ -908,7 +908,7 @@ void show_basicblock(jitdata *jd, basicblock *bptr)
                }
 
                printf(", instruction count: %d, predecessors: %d):\n",
-                          bptr->icount, bptr->pre_count);
+                          bptr->icount, bptr->predecessorcount);
 
                iptr = bptr->iinstr;
 
index bb245b600ef90c25e1023408a9698561114dea39..8125eaf2360781296fb23f77746d6d045feff6d6 100644 (file)
@@ -30,7 +30,7 @@
             Christian Thalinger
             Christian Ullrich
 
-   $Id: stack.c 5173 2006-07-25 15:57:11Z twisti $
+   $Id: stack.c 5208 2006-08-04 14:42:57Z twisti $
 
 */
 
@@ -442,12 +442,12 @@ bool new_stack_analyse(jitdata *jd)
                bptr->type = BBTYPE_EXH;
                bptr->instack = new;
                bptr->indepth = 1;
-               bptr->pre_count = 10000;
+               bptr->predecessorcount = 10000;
                STACKRESET;
                NEWXSTACK;
        }
 
-       /* count predecessors of each block **************************************/
+       /* count predecessors of each block ***************************************/
 
 #if CONDITIONAL_LOADCONST
        /* XXX move this to a separate function */
@@ -492,37 +492,37 @@ bool new_stack_analyse(jitdata *jd)
                                case ICMD_IF_ACMPEQ:
                                case ICMD_IF_ACMPNE:
                                        /* XXX add missing conditional branches */
-                                       bptr[1].pre_count++;
+                                       bptr[1].predecessorcount++;
                                        /* FALLTHROUGH */
 
                                        /* unconditional branch */
                                case ICMD_GOTO:
-                                       BLOCK_OF(iptr->dst.insindex)->pre_count++;
+                                       BLOCK_OF(iptr->dst.insindex)->predecessorcount++;
                                        break;
 
                                        /* switches */
                                case ICMD_TABLESWITCH:
                                        table = iptr->dst.table;
-                                       BLOCK_OF((table++)->insindex)->pre_count++;
+                                       BLOCK_OF((table++)->insindex)->predecessorcount++;
                                        i = iptr->sx.s23.s3.tablehigh
                                                - iptr->sx.s23.s2.tablelow + 1;
                                        while (--i >= 0) {
-                                               BLOCK_OF((table++)->insindex)->pre_count++;
+                                               BLOCK_OF((table++)->insindex)->predecessorcount++;
                                        }
                                        break;
 
                                case ICMD_LOOKUPSWITCH:
                                        lookup = iptr->dst.lookup;
-                                       BLOCK_OF(iptr->sx.s23.s3.lookupdefault.insindex)->pre_count++;
+                                       BLOCK_OF(iptr->sx.s23.s3.lookupdefault.insindex)->predecessorcount++;
                                        i = iptr->sx.s23.s2.lookupcount;
                                        while (--i >= 0) {
-                                               BLOCK_OF((lookup++)->target.insindex)->pre_count++;
+                                               BLOCK_OF((lookup++)->target.insindex)->predecessorcount++;
                                        }
                                        break;
 
                                        /* default - fall into next block */
                                default:
-                                       bptr[1].pre_count++;
+                                       bptr[1].predecessorcount++;
                                        break;
                        } /* end switch */
                } /* end basic block loop */
@@ -2879,81 +2879,11 @@ bool stack_analyse(jitdata *jd)
                bptr->type = BBTYPE_EXH;
                bptr->instack = new;
                bptr->indepth = 1;
-               bptr->pre_count = 10000;
+               bptr->predecessorcount = 10000;
                STACKRESET;
                NEWXSTACK;
        }
 
-       b_count = m->basicblockcount;
-       bptr = m->basicblocks;
-
-       while (--b_count >= 0) {
-               if (bptr->icount != 0) {
-                       iptr = bptr->iinstr + bptr->icount - 1;
-                       switch (iptr->opc) {
-                       case ICMD_RET:
-                       case ICMD_RETURN:
-                       case ICMD_IRETURN:
-                       case ICMD_LRETURN:
-                       case ICMD_FRETURN:
-                       case ICMD_DRETURN:
-                       case ICMD_ARETURN:
-                       case ICMD_ATHROW:
-                               break;
-
-                       case ICMD_IFEQ:
-                       case ICMD_IFNE:
-                       case ICMD_IFLT:
-                       case ICMD_IFGE:
-                       case ICMD_IFGT:
-                       case ICMD_IFLE:
-
-                       case ICMD_IFNULL:
-                       case ICMD_IFNONNULL:
-
-                       case ICMD_IF_ICMPEQ:
-                       case ICMD_IF_ICMPNE:
-                       case ICMD_IF_ICMPLT:
-                       case ICMD_IF_ICMPGE:
-                       case ICMD_IF_ICMPGT:
-                       case ICMD_IF_ICMPLE:
-
-                       case ICMD_IF_ACMPEQ:
-                       case ICMD_IF_ACMPNE:
-                               bptr[1].pre_count++;
-
-                       case ICMD_GOTO:
-                               m->basicblocks[m->basicblockindex[iptr->op1]].pre_count++;
-                               break;
-
-                       case ICMD_TABLESWITCH:
-                               s4ptr = iptr->val.a;
-                               m->basicblocks[m->basicblockindex[*s4ptr++]].pre_count++;
-                               i = *s4ptr++;                               /* low     */
-                               i = *s4ptr++ - i + 1;                       /* high    */
-                               while (--i >= 0) {
-                                       m->basicblocks[m->basicblockindex[*s4ptr++]].pre_count++;
-                               }
-                               break;
-                                       
-                       case ICMD_LOOKUPSWITCH:
-                               s4ptr = iptr->val.a;
-                               m->basicblocks[m->basicblockindex[*s4ptr++]].pre_count++;
-                               i = *s4ptr++;                               /* count   */
-                               while (--i >= 0) {
-                                       m->basicblocks[m->basicblockindex[s4ptr[1]]].pre_count++;
-                                       s4ptr += 2;
-                               }
-                               break;
-
-                       default:
-                               bptr[1].pre_count++;
-                               break;
-                       }
-               }
-               bptr++;
-       }
-
        do {
                loops++;
                b_count = m->basicblockcount;