* src/vm/jit/stack.h (COPY): Prevent setting varkind to STACKVAR for stackslots copie...
[cacao.git] / src / vm / jit / jit.h
index 38887504f3ba5d365e7028ee6788b24ceb1d9e66..95bdbe1812cb72ab458b6e564dc6d664ab6c0524 100644 (file)
@@ -1,9 +1,9 @@
 /* src/vm/jit/jit.h - code generation header
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
+   Contact: cacao@cacaojvm.org
 
    Authors: Andreas Krall
             Reinhard Grafl
 
    Changes: Christian Thalinger
+                       Edwin Steiner
 
-   $Id: jit.h 2135 2005-03-30 09:55:26Z twisti $
+   $Id: jit.h 4524 2006-02-16 19:39:36Z christian $
 
 */
 
@@ -46,15 +47,28 @@ typedef struct instruction instruction;
 typedef struct subroutineinfo subroutineinfo;
 
 
+#include "config.h"
+#include "vm/types.h"
+
 #include "toolbox/chain.h"
-#include "vm/class.h"
 #include "vm/global.h"
 #include "vm/method.h"
-#include "vm/jit/codegen.inc.h"
+#include "vm/references.h"
+#include "vm/statistics.h"
+#include "vm/jit/codegen-common.h"
 #include "vm/jit/verify/typeinfo.h"
 
 
-/**************************** resolve typedef-cycles **************************/
+/* common jit/codegen macros **************************************************/
+
+#if defined(ENABLE_STATISTICS)
+# define COUNT(x)        (x)++
+# define COUNT_SPILLS    count_spills++
+#else
+# define COUNT(x)        /* nothing */
+# define COUNT_SPILLS    /* nothing */
+#endif
+
 
 /************************** stack element structure ***************************/
 
@@ -80,6 +94,9 @@ typedef struct subroutineinfo subroutineinfo;
 #define SAVEDVAR   1            /* variable has to survive method invocations */
 #define INMEMORY   2            /* variable stored in memory                  */
 #define SAVEDTMP   4            /* temporary variable using a saved register  */
+#define TMPARG     8            /* temporary variable using a arg register    */
+#define STCOPY    16            /* there is another stackslot alive           */
+                                /* using the same register/memory location    */
 
 /* variable kinds */
 
@@ -93,7 +110,7 @@ typedef struct subroutineinfo subroutineinfo;
 struct stackelement {
        stackptr prev;              /* pointer to next element towards bottom     */
        s4       type;              /* slot type of stack element                 */
-#ifdef CACAO_TYPECHECK
+#ifdef ENABLE_VERIFIER
        typeinfo typeinfo;          /* info on reference types                    */
 #endif
        s4       flags;             /* flags (SAVED, INMEMORY)                    */
@@ -129,44 +146,49 @@ struct instruction {
 #define INSTRUCTION_PUTCONST_FIELDINFO(iptr) \
        ((fieldinfo *)((iptr)[1].val.a))
 
+#define INSTRUCTION_PUTCONST_FIELDINFO_PTR(iptr) \
+       ((fieldinfo **) &((iptr)[1].val.a))
+
 #define INSTRUCTION_PUTCONST_FIELDREF(iptr) \
-       ((constant_FMIref *)((iptr)[1].val.a))
+       ((unresolved_field *)((iptr)[1].target))
 
 
-/**************************** basic block structure ***************************/
+/* basicblock *****************************************************************/
  
-/*                    flags                                                   */
+/* flags */
+
+#define BBDELETED            -2
+#define BBUNDEF              -1
+#define BBREACHED            0
+#define BBFINISHED           1
 
-#define BBDELETED     -2
-#define BBUNDEF       -1
-#define BBREACHED     0
-#define BBFINISHED    1
 #define BBTYPECHECK_UNDEF    2
 #define BBTYPECHECK_REACHED  3
 
-#define BBTYPE_STD 0            /* standard basic block type                  */
-#define BBTYPE_EXH 1            /* exception handler basic block type         */
-#define BBTYPE_SBR 2            /* subroutine basic block type                */
+#define BBTYPE_STD           0  /* standard basic block type                  */
+#define BBTYPE_EXH           1  /* exception handler basic block type         */
+#define BBTYPE_SBR           2  /* subroutine basic block type                */
 
 
 struct basicblock {
-       int          flags;         /* used during stack analysis, init with -1   */
-       int          type;          /* basic block type (std, xhandler, subroutine*/
+       s4           debug_nr;      /* basic block number                         */
+       s4           flags;         /* used during stack analysis, init with -1   */
+       s4           type;          /* basic block type (std, xhandler, subroutine*/
        instruction *iinstr;        /* pointer to intermediate code instructions  */
-       int          icount;        /* number of intermediate code instructions   */
-       int          mpc;           /* machine code pc at start of block          */
+       s4           icount;        /* number of intermediate code instructions   */
+       s4           mpc;           /* machine code pc at start of block          */
        stackptr     instack;       /* stack at begin of basic block              */
        stackptr     outstack;      /* stack at end of basic block                */
-       int          indepth;       /* stack depth at begin of basic block        */
-       int          outdepth;      /* stack depth end of basic block             */
-       int          pre_count;     /* count of predecessor basic blocks          */
-       struct branchref *branchrefs; /* list of branches to be patched           */
+       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          */
+       branchref   *branchrefs;    /* list of branches to be patched             */
 
        basicblock  *next;          /* used to build a BB list (instead of array) */
-       int          lflags;        /* used during loop copying, init with 0      */
+       s4           lflags;        /* used during loop copying, init with 0      */
        basicblock  *copied_to;     /* points to the copy of this basic block     */
                                 /* when loop nodes are copied                 */
-       int debug_nr;
+       stackptr     stack;         /* start of stack array for this block        */
 };
 
 
@@ -188,7 +210,7 @@ extern int jcommandsize[256];
 #define ICMD_ACONST            1        /* val.a = constant                   */
 
 #define JAVA_ICONST_M1         2
-#define ICMD_NULLCHECKPOP      2
+#define ICMD_CHECKNULL         2
 
 #define JAVA_ICONST_0          3
 #define ICMD_ICONST            3        /* val.i = constant                   */
@@ -731,7 +753,7 @@ extern int jcommandsize[256];
 #define JAVA_INVOKEINTERFACE  185
 #define ICMD_INVOKEINTERFACE  185       /* val.a = method info pointer        */
 
-#define ICMD_CHECKASIZE       186       /*                                    */
+/* UNDEF186 */
 
 #define JAVA_NEW              187
 #define ICMD_NEW              187       /* op1 = 1, val.a = class pointer     */
@@ -777,7 +799,7 @@ extern int jcommandsize[256];
 
 #define JAVA_BREAKPOINT       202
 
-#define ICMD_CHECKEXCEPTION   203       /* check for an exception             */
+/* UNDEF203 */
 
 #define ICMD_IASTORECONST     204
 
@@ -803,11 +825,12 @@ extern int jcommandsize[256];
 
 #define ICMD_LMULPOW2         215
 
-#define ICMD_INLINE_START     251       /* before the first instruction of an inlined method */
-#define ICMD_INLINE_END       252       /* after the last instruction of an inlined method */
-#define ICMD_BUILTIN3         253       /* internal opcode */
-#define ICMD_BUILTIN2         254       /* internal opcode */
-#define ICMD_BUILTIN1         255       /* internal opcode */
+#define ICMD_INLINE_START     251       /* instruction before inlined method  */
+#define ICMD_INLINE_END       252       /* instruction after inlined method   */
+#define ICMD_INLINE_GOTO      253       /* jump to caller of inlined method   */
+
+#define ICMD_BUILTIN          255       /* internal opcode                    */
+
 #define ICMD_READONLY_ARG     1024      /* used for inlining, opcodes 1024-1028 are used */
 #define ICMD_CLEAR_ARGREN     1029      /* indicates the start of a new inlined method argument renaming must be reset */
 
@@ -838,12 +861,23 @@ extern int stackreq[256];
 
 /* function prototypes ********************************************************/
 
-functionptr jit_compile(methodinfo *m); /* compile a method with jit compiler */
+/* compiler initialisation */
+void jit_init(void);
+
+/* compiler finalisation */
+void jit_close(void);
 
-void jit_init();                        /* compiler initialisation            */
-void jit_close();                       /* compiler finalisation              */
+/* compile a method with jit compiler */
+u1 *jit_compile(methodinfo *m);
 
-void compile_all_class_methods(classinfo *c);
+/* machine dependent initialization */
+#if defined(ENABLE_JIT)
+void md_init(void);
+#endif
+
+#if defined(ENABLE_INTRP)
+void intrp_md_init(void);
+#endif
 
 #endif /* _JIT_H */
 
@@ -859,4 +893,5 @@ void compile_all_class_methods(classinfo *c);
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */