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 $
*/
}
break;
}
-
+#ifdef STATISTICS
+ if (opt_stat)
+ count_spills_read++;
+#endif
v->flags |= INMEMORY;
return tempregnum;
}
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 $
*/
#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 */
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);
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 $
*/
/* 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);
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>
#include "vm/jit/reg.h"
#include "vm/jit/loop/graph.h"
#include "vm/jit/loop/loop.h"
+#include "vm/statistics.h"
/* #include "string.h" */
{
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];
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);
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
bool drop;
struct depthElement *de;
- instruction *ip;
-
int *stack;
int *visited;
int stack_top;
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)
}
#endif
-
-
-
-
-
-
-
-
/* BBDELETED Blöcke aus loopdata->c_dTable rausschmeissen! */
/* Exceptionhandler in loopdata->c_dTable hinzufügen */
#ifdef LSRA_DEBUG
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;
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 $
*/
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;
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);
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);
}
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 $
*/
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;