add verification of PUT{STATIC,FIELD}CONST
[cacao.git] / src / vm / jit / jit.c
index 0481f7584a290c852026b0d3a16bd3d61db8bebc..23940b74c4f7b9d5a52cfbc8fc558ad6d6b49040 100644 (file)
@@ -1,4 +1,4 @@
-/* vm/jit/jit.c - calls the code generation functions
+/* src/vm/jit/jit.c - calls the code generation functions
 
    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
             Reinhard Grafl
 
    Changes: Edwin Steiner
+            Christian Thalinger
 
-   $Id: jit.c 1953 2005-02-17 13:42:23Z christian $
+   $Id: jit.c 2040 2005-03-20 13:39:51Z twisti $
 
 */
 
 
 #include <stdlib.h>
 
+#include "config.h"
 #include "codegen.h"
 #include "disass.h"
 #include "types.h"
@@ -694,9 +696,17 @@ int jcommandsize[256] = {
        1,
 #define ICMD_SASTORECONST     211
        1,
+#define ICMD_PUTSTATICCONST   212
+       1,
+#define ICMD_PUTFIELDCONST    213
+       1,
+#define ICMD_IMULPOW2         214
+       1,
+#define ICMD_LMULPOW2         215
+       1,
 
        /* unused */
-           1,1,1,1,1,1,1,1,
+                   1,1,1,1,
        1,1,1,1,1,1,1,1,1,1,
        1,1,1,1,1,1,1,1,1,1,
        1,1,1,1,1,1,1,1,1,1,
@@ -917,8 +927,11 @@ char *icmd_names[256] = {
        "BASTORECONST   ", /*             209 */
        "CASTORECONST   ", /*             210 */
        "SASTORECONST   ", /*             211 */
+       "PUTSTATICCONST ", /*             212 */
+       "PUTFIELDCONST  ", /*             213 */
+       "IMULPOW2       ", /*             214 */
+       "LMULPOW2       ", /*             215 */
 
-                   "UNDEF212", "UNDEF213", "UNDEF214", "UNDEF215",
        "UNDEF216", "UNDEF217", "UNDEF218", "UNDEF219", "UNDEF220",
        "UNDEF221", "UNDEF222", "UNDEF223", "UNDEF224", "UNDEF225",
        "UNDEF226", "UNDEF227", "UNDEF228", "UNDEF229", "UNDEF230",
@@ -1162,11 +1175,11 @@ stdopdescriptor builtintable[] = {
        { ICMD_LCMP,   TYPE_LONG, TYPE_LONG, TYPE_INT, ICMD_BUILTIN2,
          (functionptr) builtin_lcmp , SUPPORT_LONG && SUPPORT_LONG_CMP, false },
        { ICMD_LAND,   TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
-         (functionptr) builtin_land , SUPPORT_LONG && SUPPORT_LONG_LOG, false },
+         (functionptr) builtin_land , SUPPORT_LONG && SUPPORT_LONG_LOGICAL, false },
        { ICMD_LOR,    TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
-         (functionptr) builtin_lor , SUPPORT_LONG && SUPPORT_LONG_LOG, false },
+         (functionptr) builtin_lor , SUPPORT_LONG && SUPPORT_LONG_LOGICAL, false },
        { ICMD_LXOR,   TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
-         (functionptr) builtin_lxor , SUPPORT_LONG && SUPPORT_LONG_LOG, false },
+         (functionptr) builtin_lxor , SUPPORT_LONG && SUPPORT_LONG_LOGICAL, false },
        { ICMD_LSHL,   TYPE_LONG, TYPE_INT,  TYPE_LONG, ICMD_BUILTIN2,
          (functionptr) builtin_lshl , SUPPORT_LONG && SUPPORT_LONG_SHIFT, false },
        { ICMD_LSHR,   TYPE_LONG, TYPE_INT,  TYPE_LONG, ICMD_BUILTIN2,
@@ -1240,11 +1253,11 @@ builtin_descriptor builtin_desc[] = {
                     SUPPORT_LONG && SUPPORT_LONG_CMP,false,"lcmp"},
        
        {ICMD_LAND , BUILTIN_land ,ICMD_BUILTIN2,TYPE_LONG  ,TYPE_LONG  ,TYPE_VOID ,TYPE_LONG  ,
-                    SUPPORT_LONG && SUPPORT_LONG_LOG,false,"land"},
+                    SUPPORT_LONG && SUPPORT_LONG_LOGICAL,false,"land"},
        {ICMD_LOR  , BUILTIN_lor  ,ICMD_BUILTIN2,TYPE_LONG  ,TYPE_LONG  ,TYPE_VOID ,TYPE_LONG  ,
-                    SUPPORT_LONG && SUPPORT_LONG_LOG,false,"lor"},
+                    SUPPORT_LONG && SUPPORT_LONG_LOGICAL,false,"lor"},
        {ICMD_LXOR , BUILTIN_lxor ,ICMD_BUILTIN2,TYPE_LONG  ,TYPE_LONG  ,TYPE_VOID ,TYPE_LONG  ,
-                    SUPPORT_LONG && SUPPORT_LONG_LOG,false,"lxor"},
+                    SUPPORT_LONG && SUPPORT_LONG_LOGICAL,false,"lxor"},
        
        {ICMD_LSHL , BUILTIN_lshl ,ICMD_BUILTIN2,TYPE_LONG  ,TYPE_INT   ,TYPE_VOID ,TYPE_LONG  ,
                     SUPPORT_LONG && SUPPORT_LONG_SHIFT,false,"lshl"},
@@ -1374,8 +1387,10 @@ functionptr jit_compile(methodinfo *m)
        t_inlining_globals *id;
        s4                  dumpsize;
 
+#if defined(STATISTICS)
        if (opt_stat)
                count_jit_calls++;
+#endif
 
        /* this is the case if a native function is called by jni */
 
@@ -1398,8 +1413,10 @@ functionptr jit_compile(methodinfo *m)
                return m->entrypoint;
        }
 
+#if defined(STATISTICS)
        if (opt_stat)
                count_methods++;
+#endif
 
        /* if there is no javacode, print error message and return empty method   */
 
@@ -1412,10 +1429,12 @@ functionptr jit_compile(methodinfo *m)
                return m->entrypoint;    /* return empty method     */
        }
 
+#if defined(STATISTICS)
        /* measure time */
 
        if (getcompilingtime)
                compilingtime_start();
+#endif
 
        /* mark start of dump memory area */
 
@@ -1469,10 +1488,12 @@ functionptr jit_compile(methodinfo *m)
 
        dump_release(dumpsize);
 
+#if defined(STATISTICS)
        /* measure time */
 
        if (getcompilingtime)
                compilingtime_stop();
+#endif
 
        /* define in options.h; Used in main.c, jit.c & inline.c */
 #ifdef INAFTERMAIN
@@ -1510,14 +1531,7 @@ 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 */
 
@@ -1614,7 +1628,7 @@ static functionptr jit_compile_intern(methodinfo *m, codegendata *cd,
 #ifdef LSRA
        old_opt_lsra=opt_lsra;
        if (opt_lsra) {
-               if (!lsra(m, cd, rd, ld, id)) {
+               if (!lsra(m, cd, rd, id)) {
                        opt_lsra = false;
 /*                     log_message_method("Regalloc Fallback: ", m); */
                        regalloc( m, cd, rd );
@@ -1639,122 +1653,8 @@ static functionptr jit_compile_intern(methodinfo *m, codegendata *cd,
        }
 
 #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 */
-       }
+       if (opt_stat)
+               reg_make_statistics(m, cd, rd);
 #endif
 
        if (compileverbose) {