* src/vm/jit/i386/codegen.c (codegen): Implemented inlining of synchronized
[cacao.git] / src / vm / jit / parse.h
index d9e8c96ba36eddd99df2e8fbe3be0573f7de7a06..c8fd6ea5db1859de04ce76f21df6a1c4a8927e20 100644 (file)
@@ -1,9 +1,9 @@
-/* jit/parse.h - parser header
+/* src/vm/jit/parse.h - parser 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
 
    Author: Christian Thalinger
 
-   $Id: parse.h 1735 2004-12-07 14:33:27Z twisti $
+   Changes:
+
+   $Id: parse.h 4699 2006-03-28 14:52:32Z twisti $
 
 */
 
 #ifndef _PARSE_H
 #define _PARSE_H
 
+#include "config.h"
+#include "vm/types.h"
+
 #include "vm/global.h"
-#include "vm/jit/codegen.inc.h"
-#include "vm/jit/inline/inline.h"
+#include "vm/jit/codegen-common.h"
 
 
-/* intermediate code generating macros */
+/* intermediate code generating macros ****************************************/
 
 #define PINC           iptr++;ipc++
 
 #define LOADCONST_I(v) \
-    iptr->opc = ICMD_ICONST; \
-    /*iptr->op1=0;*/ \
-    iptr->val.i = (v); \
-    iptr->line = currentline; \
-    iptr->method = inline_env->method; \
+    iptr->opc    = ICMD_ICONST; \
+    iptr->val.i  = (v); \
+    iptr->line   = currentline; \
+    iptr->method = m; \
+    PINC
+
+#define LOADCONST_L(v) \
+    iptr->opc    = ICMD_LCONST; \
+    iptr->val.l  = (v); \
+    iptr->line   = currentline; \
+    iptr->method = m; \
     PINC
 
-#define LOADCONST_L(v) iptr->opc=ICMD_LCONST;/*iptr->op1=0*/;iptr->val.l=(v);iptr->line=currentline;iptr->method=inline_env->method;PINC
-#define LOADCONST_F(v) iptr->opc=ICMD_FCONST;/*iptr->op1=0*/;iptr->val.f=(v);iptr->line=currentline;iptr->method=inline_env->method;PINC
-#define LOADCONST_D(v) iptr->opc=ICMD_DCONST;/*iptr->op1=0*/;iptr->val.d=(v);iptr->line=currentline;iptr->method=inline_env->method;PINC
-#define LOADCONST_A(v) iptr->opc=ICMD_ACONST;/*iptr->op1=0*/;iptr->val.a=(v);iptr->line=currentline;iptr->method=inline_env->method;PINC
+#define LOADCONST_F(v) \
+    iptr->opc    = ICMD_FCONST; \
+    iptr->val.f  = (v); \
+    iptr->line   = currentline; \
+    iptr->method = m; \
+    PINC
+
+#define LOADCONST_D(v) \
+    iptr->opc    = ICMD_DCONST; \
+    iptr->val.d  = (v); \
+    iptr->line   = currentline; \
+    iptr->method = m; \
+    PINC
+
+#define LOADCONST_A(v) \
+    iptr->opc    = ICMD_ACONST; \
+    iptr->val.a  = (v); \
+    iptr->line   = currentline; \
+    iptr->method = m; \
+    PINC
+
+#define LOADCONST_A_CLASS(v,t) \
+    iptr->opc    = ICMD_ACONST; \
+    iptr->val.a  = (v); \
+    iptr->target = (t); \
+    iptr->line   = currentline; \
+    iptr->method = m; \
+    PINC
 
 /* ACONST instructions generated as arguments for builtin functions
  * have op1 set to non-zero. This is used for stack overflow checking
  * in stack.c. */
-#define LOADCONST_A_BUILTIN(v) \
-                       iptr->opc=ICMD_ACONST;iptr->op1=1;iptr->val.a=(v);iptr->line=currentline;iptr->method=inline_env->method;PINC
+#define LOADCONST_A_BUILTIN(v,t) \
+    iptr->opc    = ICMD_ACONST; \
+    iptr->op1    = 1; \
+    iptr->val.a  = (v); \
+    iptr->target = (t); \
+    iptr->line   = currentline; \
+    iptr->method = m; \
+    PINC
 
-#define OP(o)          iptr->opc=(o);/*iptr->op1=0*/;/*iptr->val.l=0*/;iptr->line=currentline;iptr->method=inline_env->method;PINC
-#define OP1(o,o1)      iptr->opc=(o);iptr->op1=(o1);/*iptr->val.l=(0)*/;iptr->line=currentline;iptr->method=inline_env->method;PINC
-#define OP2I(o,o1,v)   iptr->opc=(o);iptr->op1=(o1);iptr->val.i=(v);iptr->line=currentline;iptr->method=inline_env->method;PINC
+#define OP(o) \
+    iptr->opc    = (o); \
+    iptr->line   = currentline; \
+    iptr->method = m; \
+    PINC
 
-#define OP2A(o,o1,v,l) \
-    iptr->opc = (o); \
-    iptr->op1 = (o1); \
-    iptr->val.a = (v); \
-    iptr->line = (l); \
-    iptr->method = inline_env->method; \
+#define OP1(o,o1) \
+    iptr->opc    = (o); \
+    iptr->op1    = (o1); \
+    iptr->line   = currentline; \
+    iptr->method = m; \
     PINC
 
-#define BUILTIN1(v,t,l) \
-    inline_env->method->isleafmethod = false; \
-    iptr->opc = ICMD_BUILTIN1; \
-    iptr->op1 = (t); \
-    iptr->val.fp = (v); \
-    iptr->line = (l); \
-    iptr->method = inline_env->method; \
+#define OP2I(o,o1,v) \
+    iptr->opc    = (o); \
+    iptr->op1    = (o1); \
+    iptr->val.i  = (v); \
+    iptr->line   = currentline; \
+    iptr->method = m; \
     PINC
 
-#define BUILTIN2(v,t,l) \
-    inline_env->method->isleafmethod = false; \
-    iptr->opc = ICMD_BUILTIN2; \
-    iptr->op1 = (t);\
-    iptr->val.fp = (v); \
-    iptr->line = (l); \
-    iptr->method = inline_env->method; \
+#define OP2A_NOINC(o,o1,v,l) \
+    iptr->opc    = (o); \
+    iptr->op1    = (o1); \
+    iptr->val.a  = (v); \
+    iptr->line   = (l); \
+    iptr->method = m
+
+#define OP2A(o,o1,v,l) \
+    OP2A_NOINC(o,o1,v,l); \
+    PINC
+
+#define OP2AT(o,o1,v,t,l) \
+    OP2A_NOINC(o,o1,v,l); \
+    iptr->target = (t); \
     PINC
 
-#define BUILTIN3(v,t,l) \
-    inline_env->method->isleafmethod = false; \
-    iptr->opc = ICMD_BUILTIN3; \
-    iptr->op1 = (t);\
-    iptr->val.fp = (v); \
-    iptr->line = (l); \
-    iptr->method = inline_env->method; \
+#define BUILTIN(v,o1,t,l) \
+    m->isleafmethod = false; \
+    iptr->opc    = ICMD_BUILTIN; \
+    iptr->op1    = (o1); \
+    iptr->val.a  = (v); \
+    iptr->target = (t); \
+    iptr->line   = (l); \
+    iptr->method = m; \
     PINC
 
 
 
 #define INDEX_ONEWORD(num) \
     do { \
-        if ((num) < 0 || (num) >= inline_env->cumlocals) { \
-            *exceptionptr = \
-                new_verifyerror(inline_env->method, "Illegal local variable number"); \
-            return NULL; \
-        } \
+        if (((num) < 0) || ((num) >= m->maxlocals)) \
+            goto throw_illegal_local_variable_number; \
     } while (0)
 
 #define INDEX_TWOWORD(num) \
     do { \
-        if ((num) < 0 || ((num) + 1) >= inline_env->cumlocals) { \
-            *exceptionptr = \
-                new_verifyerror(inline_env->method, "Illegal local variable number"); \
-            return NULL; \
-        } \
+        if (((num) < 0) || (((num) + 1) >= m->maxlocals)) \
+            goto throw_illegal_local_variable_number; \
     } while (0)
 
-#define OP1LOAD(o,o1)                                                  \
-       do {if (o == ICMD_LLOAD || o == ICMD_DLOAD)     \
-                       INDEX_TWOWORD(o1);                                      \
-               else                                                                    \
-                       INDEX_ONEWORD(o1);                                      \
-               OP1(o,o1);} while(0)
+#define OP1LOAD(o,o1) \
+    do { \
+        if (((o) == ICMD_LLOAD) || ((o) == ICMD_DLOAD)) \
+            INDEX_TWOWORD(o1); \
+        else \
+            INDEX_ONEWORD(o1); \
+        OP1(o,o1); \
+    } while (0)
 
-#define OP1STORE(o,o1)                                                         \
-       do {if (o == ICMD_LSTORE || o == ICMD_DSTORE)   \
-                       INDEX_TWOWORD(o1);                                              \
-               else                                                                            \
-                       INDEX_ONEWORD(o1);                                              \
-               OP1(o,o1);} while(0)
+#define OP1STORE(o,o1) \
+    do { \
+        if (((o) == ICMD_LSTORE) || ((o) == ICMD_DSTORE)) \
+            INDEX_TWOWORD(o1); \
+        else \
+            INDEX_ONEWORD(o1); \
+        OP1(o,o1); \
+    } while (0)
 
 /* block generating and checking macros */
 
     } while (0)
 
 
-/* FIXME really use cumjcodelength for the bound_checkers ? */
+#if defined(ENABLE_VERIFIER)
 
-#define bound_check(i) \
+#define CHECK_BYTECODE_INDEX(i) \
     do { \
-        if (i < 0 || i >= inline_env->cumjcodelength) { \
- printf("bound_check i=%i >= %i=cum\n",i,inline_env->cumjcodelength); \
- fflush(stdout); \
-       /*  if (i < 0 || i >= m->jcodelength) { */ \
-            *exceptionptr = \
-                new_verifyerror(inline_env->method, "Illegal target of jump or branch"); \
-            return NULL; \
-        } \
+        if (((i) < 0) || ((i) >= m->jcodelength)) \
+                       goto throw_invalid_bytecode_index; \
     } while (0)
 
-/* bound_check1 is used for the inclusive ends of exception handler ranges */
-#define bound_check1(i) \
+/* CHECK_BYTECODE_INDEX_EXCLUSIVE is used for the exclusive ends */ 
+/* of exception handler ranges                                   */
+#define CHECK_BYTECODE_INDEX_EXCLUSIVE(i) \
     do { \
-        if (i < 0 || i > inline_env->cumjcodelength) { \
-/*        if (i < 0 || i > m->jcodelength) { */ \
-            *exceptionptr = \
-                new_verifyerror(inline_env->method, "Illegal target of jump or branch"); \
-            return NULL; \
-        } \
+        if ((i) < 0 || (i) > m->jcodelength) \
+                       goto throw_invalid_bytecode_index; \
     } while (0)
 
+#else /* !ENABLE_VERIFIER */
+
+#define CHECK_BYTECODE_INDEX(i)
+#define CHECK_BYTECODE_INDEX_EXCLUSIVE(i)
+
+#endif
 
 /* macros for byte code fetching ***********************************************
 
 #define code_get_s4(p,m)  ((s4)((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
                              +(((u4)m->jcode[p + 2]) << 8) + m->jcode[p + 3]))
 
-/* function prototypes */
 
-void compiler_addinitclass(classinfo *c);
-classSetNode * descriptor2typesL(methodinfo *m);
-void descriptor2types(methodinfo *m);
-methodinfo *parse(methodinfo *m, codegendata *cd, t_inlining_globals *inline_env);
+/* function prototypes ********************************************************/
+
+bool parse(jitdata *jd);
 
 #endif /* _PARSE_H */
 
@@ -210,6 +251,7 @@ methodinfo *parse(methodinfo *m, codegendata *cd, t_inlining_globals *inline_env
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */