*** empty log message ***
authorchristian <none@none>
Thu, 17 Feb 2005 13:42:23 +0000 (13:42 +0000)
committerchristian <none@none>
Thu, 17 Feb 2005 13:42:23 +0000 (13:42 +0000)
src/vm/jit/codegen.inc
src/vm/jit/jit.c
src/vm/jit/lsra.h
src/vm/jit/lsra.inc
src/vm/statistics.c
src/vm/statistics.h

index c5452afd986cc881a031491fc77b6e36738d6fb1..352af7972d2a18c606e9bf1d7be0886d6771e6f8 100644 (file)
@@ -47,7 +47,7 @@
    memory. All functions writing values into the data area return the offset
    relative the begin of the code area (start of procedure).   
 
-   $Id: codegen.inc 1951 2005-02-17 11:41:05Z twisti $
+   $Id: codegen.inc 1953 2005-02-17 13:42:23Z christian $
 
 */
 
@@ -905,7 +905,10 @@ static int reg_of_var(registerdata *rd, stackptr v, int tempregnum)
                }
                break;
        }
-
+#ifdef STATISTICS
+       if (opt_stat)
+               count_spills_read++;
+#endif
        v->flags |= INMEMORY;
        return tempregnum;
 }
index d2f25fc381708ca5cacf04abc321a17a12b2ca24..0481f7584a290c852026b0d3a16bd3d61db8bebc 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: jit.c 1944 2005-02-15 16:30:41Z christian $
+   $Id: jit.c 1953 2005-02-17 13:42:23Z christian $
 
 */
 
@@ -1510,6 +1510,14 @@ static functionptr jit_compile_intern(methodinfo *m, codegendata *cd,
 #ifdef LSRA
        bool old_opt_lsra;
 #endif
+#ifdef STATISTICS
+       int i,type;
+       s4 len;
+       stackptr    src, src_old;
+       stackptr    dst;
+       instruction *iptr;
+       basicblock  *bptr;
+#endif
 
        /* print log message for compiled method */
 
@@ -1610,11 +1618,144 @@ static functionptr jit_compile_intern(methodinfo *m, codegendata *cd,
                        opt_lsra = false;
 /*                     log_message_method("Regalloc Fallback: ", m); */
                        regalloc( m, cd, rd );
-               } /* else log_message_method("Regalloc LSRA: ", m); */
+               } else {
+#ifdef STATISTICS
+                       if (opt_stat) count_methods_allocated_by_lsra++;
+#endif
+/*                     log_message_method("Regalloc LSRA: ", m); */
+               }
        }
        else
 #endif
+       {
+#ifdef STATISTICS
+               if (opt_stat)
+#ifdef LSRA
+                       if (!opt_lsra)
+#endif         
+                               count_locals_conflicts += (cd->maxlocals-1)*(cd->maxlocals);
+#endif         
                regalloc(m, cd, rd);
+       }
+
+#ifdef STATISTICS
+       if (opt_stat) {
+               /* count how many local variables are held in memory or register */
+               for(i=0; i < cd->maxlocals; i++)
+                       for (type=0; type <=4; type++)
+                               if (rd->locals[i][type].type != -1) { /* valid local */
+                                       if (rd->locals[i][type].flags & INMEMORY)
+                                               count_locals_spilled++;
+                                       else
+                                               count_locals_register++;
+                               }
+               /* count how many stack slots are held in memory or register */
+
+               bptr = m->basicblocks;
+               while (bptr != NULL) {
+                       if (bptr->flags >= BBREACHED) {
+
+#ifdef LSRA
+                       if (!opt_lsra) {
+#endif 
+                               /* check for memory moves from interface to BB instack */
+                               dst = bptr->instack;
+                               len = bptr->indepth;                    
+                               while (dst != NULL) {
+                                       len--;
+                                       if (dst->varkind != STACKVAR) {
+                                               if ( (dst->flags & INMEMORY) ||
+                                                        (rd->interfaces[len][dst->type].flags & INMEMORY) || 
+                                                        ( (dst->flags & INMEMORY) && 
+                                                          (rd->interfaces[len][dst->type].flags & INMEMORY) && 
+                                                          (dst->regoff != rd->interfaces[len][dst->type].regoff) ))
+                                               {
+                                                       /* one in memory or both inmemory at different offsets */
+                                                       count_mem_move_bb++;
+                                               }
+                                       }
+
+                                       dst = dst->prev;
+                               }
+
+                               /* check for memory moves from BB outstack to interface */
+                               dst = bptr->outstack;
+                               len = bptr->outdepth;
+
+                               while (dst) {
+                                       len--;
+                                       if (dst->varkind != STACKVAR) {
+                                               if ( (dst->flags & INMEMORY) || \
+                                                        (rd->interfaces[len][dst->type].flags & INMEMORY) || \
+                                                        ( (dst->flags & INMEMORY) && \
+                                                          (rd->interfaces[len][dst->type].flags & INMEMORY) && \
+                                                          (dst->regoff != rd->interfaces[len][dst->type].regoff) ))
+                                               {
+                                                       /* one in memory or both inmemory at different offsets */
+                                                       count_mem_move_bb++;
+                                               }
+                                       }
+
+                                       dst = dst->prev;
+                               }
+#ifdef LSRA
+                       }
+#endif 
+
+
+                               dst = bptr->instack;
+                               iptr = bptr->iinstr;
+                               len = bptr->icount;
+                               src_old = NULL;
+
+                               while (--len >= 0)  {
+                                       src = dst;
+                                       dst = iptr->dst;
+
+                                       if ((src!= NULL) && (src != src_old)) { /* new stackslot */
+                                               switch (src->varkind) {
+                                               case TEMPVAR:
+                                               case STACKVAR:
+                                                       if (!(src->flags & INMEMORY)) 
+                                                               count_ss_register++;
+                                                       else
+                                                               count_ss_spilled++;
+                                                       break;
+                                                       /*                                      case LOCALVAR: */
+                                                       /*                                              if (!(rd->locals[src->varnum][src->type].flags & INMEMORY)) */
+                                                       /*                                                      count_ss_register++; */
+                                                       /*                                              else */
+                                                       /*                                                      count_ss_spilled++; */
+                                                       /*                                              break; */
+                                                       /*                                      case ARGVAR: */
+                                                       /*                                              if (IS_FLT_DBL_TYPE(src->type)) { */
+                                                       /*                                                      if (src->varnum < FLT_ARG_CNT) { */
+                                                       /*                                                              count_ss_register++; */
+                                                       /*                                                              break; */
+                                                       /*                                                      } */
+                                                       /*                                              } else { */
+                                                       /* #if defined(__POWERPC__) */
+                                                       /*                                                      if (src->varnum < INT_ARG_CNT - (IS_2_WORD_TYPE(src->type) != 0)) { */
+                                                       /* #else */
+                                                       /*                                                      if (src->varnum < INT_ARG_CNT) { */
+                                                       /* #endif */
+                                                       /*                                                              count_ss_register++; */
+                                                       /*                                                              break; */
+                                                       /*                                                      } */
+                                                       /*                                              } */
+                                                       /*                                              count_ss_spilled++; */
+                                                       /*                                              break; */
+                                               }
+                                       }
+                                       src_old = src;
+                                       
+                                       iptr++;
+                               } /* while instructions */
+                       } /* if */
+                       bptr = bptr->next;
+               } /* while blocks */
+       }
+#endif
 
        if (compileverbose) {
                log_message_method("Allocating registers done: ", m);
index e7739fa04721cd9f5a5b5a72fc886431065fe20b..e9d720b40f1aef1bba34ad77dd3edf4e17b27f6a 100644 (file)
@@ -27,7 +27,7 @@
 
    Authors: Christian Ullrich
 
-   $Id: lsra.h 1944 2005-02-15 16:30:41Z christian $
+   $Id: lsra.h 1953 2005-02-17 13:42:23Z christian $
 
 */
 
@@ -141,6 +141,7 @@ typedef struct lsradata lsradata;
 
 /* function prototypes */
 bool lsra(methodinfo *, codegendata *, registerdata *, loopdata *, t_inlining_globals *);
+bool lsra_test(methodinfo *, codegendata *);
 void lsra_init(methodinfo *, codegendata *, t_inlining_globals *, lsradata *);
 bool lsra_setup(methodinfo *, codegendata *, registerdata *, lsradata *, loopdata *);
 void lsra_main(methodinfo *, lsradata *, registerdata *, codegendata *, loopdata *ld);
index d408a69f9380faf0f1371b481b3c40ac49beea31..85ce82e48802f949b19acc687b83ece886ba84ff 100644 (file)
@@ -27,7 +27,7 @@
 
    Authors: Christian Ullrich
 
-   $Id: lsra.inc 1948 2005-02-15 20:01:57Z christian $
+   $Id: lsra.inc 1953 2005-02-17 13:42:23Z christian $
 
 */
 #include <stdio.h>
@@ -39,6 +39,7 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/loop/graph.h"
 #include "vm/jit/loop/loop.h"
+#include "vm/statistics.h"
 
 /* #include "string.h" */
 
@@ -61,6 +62,11 @@ bool lsra(methodinfo *m, codegendata *cd, registerdata *rd, loopdata *ld, t_inli
 {
 
        lsradata *ls;
+#if defined(STATISTICS)
+       int *locals_start,*locals_end;
+       struct lifetime *lt;
+       int i,j;
+#endif 
 
 #if defined(LSRA_DEBUG) || defined(LSRA_DUMP_LOOPDATA)|| defined(LSRA_TESTLT)
        char name[1256], name1[1256];
@@ -87,7 +93,26 @@ bool lsra(methodinfo *m, codegendata *cd, registerdata *rd, loopdata *ld, t_inli
        lsra_init(m, cd, id, ls);
        if (!lsra_setup(m, cd, rd, ls, ld))
                return false;
-       
+
+
+#if defined(STATISTICS)
+       /* find conflicts between locals for statistics */
+       if (opt_stat) {
+               locals_start = DMNEW(int, cd->maxlocals);
+               locals_end   = DMNEW(int, cd->maxlocals);
+
+               for (lt = ls->lifetimes; lt != NULL; lt=lt->next) {
+                       if (lt->v_index >= 0) { /* -> local var */
+                               locals_start[lt->v_index] = lt->i_start;
+                               locals_end[lt->v_index]   = lt->i_end;
+                       }
+               }
+               for (i=0; i < cd->maxlocals; i++)
+                       for (j=i+1; j < cd->maxlocals; j++)
+                               if ( !((locals_end[i] < locals_start[j]) || (locals_end[j]<locals_start[i])) )
+                                       count_locals_conflicts += 2;
+        }
+#endif 
 
        /* Run LSRA */
        lsra_main(m, ls, rd, cd, ld);
@@ -112,6 +137,30 @@ void lsra_init(methodinfo *m, codegendata *cd, t_inlining_globals *id, lsradata
        ls->stackslots=NULL;
 }
 
+bool lsra_test(methodinfo *m, codegendata *cd)
+{
+       int i;
+       bool jsr;
+       instruction *ip;
+
+       /* in case of exceptionhandlers or subroutines return to regalloc */
+       if (cd->exceptiontablelength > 0)
+               return false;
+
+       jsr=false;
+       for (i=0; i< m->basicblockcount; i++) {
+               ip = m->basicblocks[i].iinstr + m->basicblocks[i].icount -1;/* set ip to last instruction       */
+               if (ip->opc == ICMD_JSR) {
+                       /* check Instack of sub */
+                       printf("SBR Instackdepth: %3i\n",m->basicblocks[m->basicblockindex[ip->op1]].indepth);
+                       jsr=true;
+               }
+       }
+
+/*     if (jsr) return false; */
+       return (!jsr);
+}
+
 bool lsra_setup(methodinfo *m, codegendata *cd, registerdata *rd, lsradata *ls, loopdata *ld)
 {
 #ifdef LSRA_DEBUG
@@ -125,8 +174,6 @@ bool lsra_setup(methodinfo *m, codegendata *cd, registerdata *rd, lsradata *ls,
        bool drop;
        struct depthElement *de;
 
-       instruction *ip;
-
        int *stack;
        int *visited;
        int stack_top;
@@ -137,24 +184,8 @@ bool lsra_setup(methodinfo *m, codegendata *cd, registerdata *rd, lsradata *ls,
        struct LoopElement *le;
 #endif
        
-       bool jsr;
-
        /* in case of exceptionhandlers or subroutines return to regalloc */
-       if (cd->exceptiontablelength > 0)
-               return false;
-
-       jsr=false;
-       for (i=0; i< m->basicblockcount; i++) {
-               ip = m->basicblocks[i].iinstr + m->basicblocks[i].icount -1;/* set ip to last instruction       */
-               if (ip->opc == ICMD_JSR) {
-                       /* check Instack of sub */
-                       printf("SBR Instackdepth: %3i\n",m->basicblocks[m->basicblockindex[ip->op1]].indepth);
-                       jsr=true;
-/*                     return false; */
-               }
-       }
-
-       if (jsr) return false;
+       if (!lsra_test(m,cd)) return false;
 
        /* Setup LSRA Data structures */
        if (opt_loops) 
@@ -189,14 +220,6 @@ bool lsra_setup(methodinfo *m, codegendata *cd, registerdata *rd, lsradata *ls,
        }
 #endif
 
-
-
-
-
-
-
-
-
        /* BBDELETED Blöcke aus loopdata->c_dTable rausschmeissen! */
        /* Exceptionhandler in loopdata->c_dTable hinzufügen       */
 #ifdef LSRA_DEBUG
@@ -513,11 +536,11 @@ void lsra_clean_Graph( methodinfo *m, codegendata *cd, lsradata *ls, loopdata *l
        int *bb_succ, *bb_visited, *ptr, index;
        exceptiontable *ex;
        struct depthElement **table;
-       bool back_edge;
-       int back_edge_nodes_found;
-       struct LoopContainer *lc;
-       struct LoopElement *le;
-       bool all_reached;
+/*     bool back_edge; */
+/*     int back_edge_nodes_found; */
+/*     struct LoopContainer *lc; */
+/*     struct LoopElement *le; */
+/*     bool all_reached; */
        bool *bb_reached;
 
        table=ld->c_dTable;
index c4f8afd95a47d4c4b451aa1064b7a5207a483848..5e84bfa03fef769752149983814204971096194c 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: statistics.c 1751 2004-12-13 08:27:03Z twisti $
+   $Id: statistics.c 1953 2005-02-17 13:42:23Z christian $
 
 */
 
@@ -74,9 +74,18 @@ int count_utf_len = 0;                  /* size of utf hash                   */
 int count_utf_new = 0;                  /* calls of utf_new                   */
 int count_utf_new_found  = 0;           /* calls of utf_new with fast return  */
 
+int count_locals_conflicts = 0;         /* register allocator statistics */
+int count_locals_spilled = 0;
+int count_locals_register = 0;
+int count_ss_spilled = 0;
+int count_ss_register = 0;
+int count_methods_allocated_by_lsra = 0;
+int count_mem_move_bb = 0;
+
 int count_jit_calls = 0;
 int count_methods = 0;
 int count_spills = 0;
+int count_spills_read = 0;
 int count_pcmd_activ = 0;
 int count_pcmd_drop = 0;
 int count_pcmd_zero = 0;
@@ -312,7 +321,9 @@ void print_stats()
        log_text(logtext);
        sprintf(logtext, "Number of Machine-Instructions: %d", count_code_len >> 2);
        log_text(logtext);
-       sprintf(logtext, "Number of Spills: %d", count_spills);
+       sprintf(logtext, "Number of Spills (write to memory): %d", count_spills);
+       log_text(logtext);
+       sprintf(logtext, "Number of Spills (read from memory): %d", count_spills_read);
        log_text(logtext);
        sprintf(logtext, "Number of Activ    Pseudocommands: %5d", count_pcmd_activ);
        log_text(logtext);
@@ -451,6 +462,21 @@ void print_stats()
        log_text(logtext);
        sprintf(logtext, "Calls of utf_new (element found): %6d\n\n", count_utf_new_found);
        log_text(logtext);
+
+       sprintf(logtext, "Methods allocated by LSRA:         %6d", count_methods_allocated_by_lsra);
+       log_text(logtext);
+       sprintf(logtext, "Conflicts between local Variables: %6d", count_locals_conflicts);
+       log_text(logtext);
+       sprintf(logtext, "Local Variables held in Memory:    %6d", count_locals_spilled);
+       log_text(logtext);
+       sprintf(logtext, "Local Variables held in Registers: %6d", count_locals_register);
+       log_text(logtext);
+       sprintf(logtext, "Stackslots held in Memory:         %6d", count_ss_spilled);
+       log_text(logtext);
+       sprintf(logtext, "Stackslots held in Registers:      %6d",count_ss_register );
+       log_text(logtext);
+       sprintf(logtext, "Memory moves at BB Boundaries:     %6d\n\n",count_mem_move_bb );
+       log_text(logtext);
 }
 
 
index 672ba0360389efc606c260ca57f59dc829e87f15..a7882e684f6232667d48d6718f3495fdc26860e7 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: statistics.h 1751 2004-12-13 08:27:03Z twisti $
+   $Id: statistics.h 1953 2005-02-17 13:42:23Z christian $
 
 */
 
@@ -61,9 +61,18 @@ extern int count_utf_len;               /* size of utf hash                   */
 extern int count_utf_new;
 extern int count_utf_new_found;
 
+extern int count_locals_conflicts;
+extern int count_locals_spilled;
+extern int count_locals_register;
+extern int count_ss_spilled;
+extern int count_ss_register;
+extern int count_methods_allocated_by_lsra;
+extern int count_mem_move_bb;
+
 extern int count_jit_calls;
 extern int count_methods;
 extern int count_spills;
+extern int count_spills_read;
 extern int count_pcmd_activ;
 extern int count_pcmd_drop;
 extern int count_pcmd_zero;