add verification of PUT{STATIC,FIELD}CONST
[cacao.git] / src / vm / jit / jit.c
index d2f25fc381708ca5cacf04abc321a17a12b2ca24..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 1944 2005-02-15 16:30:41Z 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
@@ -1511,6 +1532,7 @@ static functionptr jit_compile_intern(methodinfo *m, codegendata *cd,
        bool old_opt_lsra;
 #endif
 
+
        /* print log message for compiled method */
 
        if (compileverbose)
@@ -1606,15 +1628,34 @@ 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 );
-               } /* 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)
+               reg_make_statistics(m, cd, rd);
+#endif
 
        if (compileverbose) {
                log_message_method("Allocating registers done: ", m);