* Updated header: Added 2006. Changed address of FSF. Changed email
[cacao.git] / src / vm / jit / jit.h
index 8c128be32b7b34654e3bed8f18c75d2c49b707f1..18aeb6067bb1cffe9727feec599cd722eb29446f 100644 (file)
@@ -1,9 +1,9 @@
-/* jit/jit.h - code generation header
+/* src/vm/jit/jit.h - code generation header
 
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-   R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
-   M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
-   P. Tomsich, J. Wenninger
+   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
 
-   $Id: jit.h 1494 2004-11-12 13:34:26Z twisti $
+   $Id: jit.h 4357 2006-01-22 23:33:38Z twisti $
 
 */
 
 #ifndef _JIT_H
 #define _JIT_H
 
-#include "global.h"
-#include "builtin.h"
-#include "typeinfo.h"
-#include "jit/codegen.inc.h"
-#include "toolbox/chain.h"
-
-
-/**************************** resolve typedef-cycles **************************/
+/* resolve typedef cycles *****************************************************/
 
 typedef struct stackelement stackelement;
 typedef stackelement *stackptr;
@@ -53,6 +46,29 @@ typedef struct instruction instruction;
 typedef struct subroutineinfo subroutineinfo;
 
 
+#include "config.h"
+#include "vm/types.h"
+
+#include "toolbox/chain.h"
+#include "vm/global.h"
+#include "vm/method.h"
+#include "vm/references.h"
+#include "vm/statistics.h"
+#include "vm/jit/codegen-common.h"
+#include "vm/jit/verify/typeinfo.h"
+
+
+/* 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 ***************************/
 
 /* slot types */
@@ -66,9 +82,10 @@ typedef struct subroutineinfo subroutineinfo;
 #define TYPE_DBL   TYPE_DOUBLE  /*3*/  /* integer, long, float, double, address      */
 #define TYPE_ADR   TYPE_ADDRESS /*4*/
 
-#define IS_INT_LNG_TYPE(a)      (!((a)&TYPE_FLT))
-#define IS_FLT_DBL_TYPE(a)      ((a)&TYPE_FLT)
-#define IS_2_WORD_TYPE(a)       ((a)&TYPE_LNG)
+#define IS_INT_LNG_TYPE(a)      (!((a) & TYPE_FLT))
+#define IS_FLT_DBL_TYPE(a)      ((a) & TYPE_FLT)
+#define IS_2_WORD_TYPE(a)       ((a) & TYPE_LNG)
+#define IS_ADR_TYPE(a)          ((a) & TYPE_ADR)
 
 
 /* flags */
@@ -76,6 +93,7 @@ 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 argument register  */
 
 /* variable kinds */
 
@@ -89,7 +107,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)                    */
@@ -112,19 +130,33 @@ struct instruction {
        u2          line;           /* line number in source file                 */
        methodinfo *method;         /* needed for inlining. can't be done on      */
                                    /* basic block level, since an inlined        */
-                                   /* function doesn't start necessarily start   */
+                                   /* function doesn't necessarily start         */
                                    /* a new block                                */
 };
 
+#define INSTRUCTION_PUTCONST_TYPE(iptr) \
+       ((iptr)[0].op1)
+
+#define INSTRUCTION_PUTCONST_VALUE_ADR(iptr) \
+       ((iptr)[0].val.a)
+
+#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) \
+       ((unresolved_field *)((iptr)[1].target))
 
 /**************************** basic block structure ***************************/
  
 /*                    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
 
@@ -172,7 +204,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                   */
@@ -715,7 +747,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     */
@@ -761,7 +793,7 @@ extern int jcommandsize[256];
 
 #define JAVA_BREAKPOINT       202
 
-#define ICMD_CHECKEXCEPTION   203       /* check for an exception             */
+/* UNDEF203 */
 
 #define ICMD_IASTORECONST     204
 
@@ -779,20 +811,25 @@ extern int jcommandsize[256];
 
 #define ICMD_SASTORECONST     211
 
-#define ICMD_BUILTIN3         253       /* internal opcode */
-#define ICMD_BUILTIN2         254       /* internal opcode */
-#define ICMD_BUILTIN1         255       /* internal opcode */
+#define ICMD_PUTSTATICCONST   212
+
+#define ICMD_PUTFIELDCONST    213
+
+#define ICMD_IMULPOW2         214
+
+#define ICMD_LMULPOW2         215
+
+#define ICMD_INLINE_START     251       /* instruction before inlined method  */
+#define ICMD_INLINE_END       252       /* instruction after 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 */
 
 
 /******************* description of JavaVM instructions ***********************/
 
-#if defined(USEBUILTINTABLE)
-
-builtin_descriptor *find_builtin(int opcode);
-
-#endif /* USEBUILTINTABLE */
 
 
 /***************************** register types *********************************/
@@ -815,26 +852,25 @@ builtin_descriptor *find_builtin(int opcode);
 extern int stackreq[256];
 
 
-#if defined(__I386__)
-extern bool method_uses_ecx;
-extern bool method_uses_edx;
-#endif
-
-
-/* function prototypes */
+/* function prototypes ********************************************************/
 
-functionptr jit_compile(methodinfo *m); /* compile a method with jit compiler */
+/* compiler initialisation */
+void jit_init(void);
 
-void jit_init();                        /* compiler initialisation            */
-void jit_close();                       /* compiler finalisation              */
+/* compiler finalisation */
+void jit_close(void);
 
-void compile_all_class_methods(classinfo *c);
+/* compile a method with jit compiler */
+u1 *jit_compile(methodinfo *m);
 
-u1 *createcompilerstub(methodinfo *m);
-u1 *createnativestub(functionptr f, methodinfo *m);
+/* machine dependent initialization */
+#if defined(ENABLE_JIT)
+void md_init(void);
+#endif
 
-void removecompilerstub(u1 *stub);
-void removenativestub(u1 *stub);
+#if defined(ENABLE_INTRP)
+void intrp_md_init(void);
+#endif
 
 #endif /* _JIT_H */