X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fjit%2Fparse.h;h=d73328ed49a0577300001c956551168cf0d04479;hb=dd22a9f8f3c18ff57cda3527ba27809f8b0402c9;hp=67a753aeb2152900d1671f77e04b80c0985ad8fa;hpb=752864ea39b63b6dd8e3170e416c48bf05208573;p=cacao.git diff --git a/src/vm/jit/parse.h b/src/vm/jit/parse.h index 67a753aeb..d73328ed4 100644 --- a/src/vm/jit/parse.h +++ b/src/vm/jit/parse.h @@ -1,9 +1,9 @@ /* jit/parse.h - parser 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 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. @@ -26,7 +26,7 @@ Author: Christian Thalinger - $Id: parse.h 1092 2004-05-27 15:46:59Z twisti $ + $Id: parse.h 2262 2005-04-11 09:55:44Z twisti $ */ @@ -34,52 +34,107 @@ #ifndef _PARSE_H #define _PARSE_H -#include "global.h" +#include "vm/global.h" +#include "vm/jit/codegen.inc.h" +#include "vm/jit/inline/inline.h" /* 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=method;PINC -#define LOADCONST_L(v) iptr->opc=ICMD_LCONST;/*iptr->op1=0*/;iptr->val.l=(v);iptr->line=currentline;iptr->method=method;PINC -#define LOADCONST_F(v) iptr->opc=ICMD_FCONST;/*iptr->op1=0*/;iptr->val.f=(v);iptr->line=currentline;iptr->method=method;PINC -#define LOADCONST_D(v) iptr->opc=ICMD_DCONST;/*iptr->op1=0*/;iptr->val.d=(v);iptr->line=currentline;iptr->method=method;PINC -#define LOADCONST_A(v) iptr->opc=ICMD_ACONST;/*iptr->op1=0*/;iptr->val.a=(v);iptr->line=currentline;iptr->method=method;PINC + +#define LOADCONST_I(v) \ + iptr->opc = ICMD_ICONST; \ + /*iptr->op1=0;*/ \ + iptr->val.i = (v); \ + iptr->line = currentline; \ + iptr->method = inline_env->method; \ + 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 /* 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=method;PINC + iptr->opc = ICMD_ACONST; \ + iptr->op1 = 1; \ + iptr->val.a = (v); \ + iptr->line = currentline; \ + iptr->method = inline_env->method; \ + PINC -#define OP(o) iptr->opc=(o);/*iptr->op1=0*/;/*iptr->val.l=0*/;iptr->line=currentline;iptr->method=method;PINC -#define OP1(o,o1) iptr->opc=(o);iptr->op1=(o1);/*iptr->val.l=(0)*/;iptr->line=currentline;iptr->method=method;PINC -#define OP2I(o,o1,v) iptr->opc=(o);iptr->op1=(o1);iptr->val.i=(v);iptr->line=currentline;iptr->method=method;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 OP2A(o,o1,v,l) \ +#define OP2A_NOINC(o,o1,v,l) \ iptr->opc = (o); \ iptr->op1 = (o1); \ iptr->val.a = (v); \ - iptr->line = l; \ - iptr->method = method; \ + iptr->line = (l); \ + iptr->method = inline_env->method + +#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 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; \ + 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; \ + 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; \ PINC -#define BUILTIN1(v,t,l) isleafmethod=false;iptr->opc=ICMD_BUILTIN1;iptr->op1=t;\ - iptr->val.a=(v);iptr->line=l;iptr->method=method;PINC -#define BUILTIN2(v,t,l) isleafmethod=false;iptr->opc=ICMD_BUILTIN2;iptr->op1=t;\ - iptr->val.a=(v);iptr->line=l;iptr->method=method;PINC -#define BUILTIN3(v,t,l) isleafmethod=false;iptr->opc=ICMD_BUILTIN3;iptr->op1=t;\ - iptr->val.a=(v);iptr->line=l;iptr->method=method;PINC /* We have to check local variables indices here because they are * used in stack.c to index the locals array. */ -#define INDEX_ONEWORD(num) \ - do { if((num)<0 || (num)>=maxlocals) \ - panic("Invalid local variable index"); } while (0) -#define INDEX_TWOWORD(num) \ - do { if((num)<0 || ((num)+1)>=maxlocals) \ - panic("Invalid local variable index"); } while (0) +#define INDEX_ONEWORD(num) \ + do { \ + if ((num) < 0 || (num) >= inline_env->cumlocals) { \ + *exceptionptr = \ + new_verifyerror(inline_env->method, "Illegal local variable number"); \ + return NULL; \ + } \ + } 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; \ + } \ + } while (0) #define OP1LOAD(o,o1) \ do {if (o == ICMD_LLOAD || o == ICMD_DLOAD) \ @@ -99,9 +154,9 @@ #define block_insert(i) \ do { \ - if (!(block_index[(i)] & 1)) { \ + if (!(m->basicblockindex[(i)] & 1)) { \ b_count++; \ - block_index[(i)] |= 1; \ + m->basicblockindex[(i)] |= 1; \ } \ } while (0) @@ -110,16 +165,24 @@ #define bound_check(i) \ do { \ - if (i < 0 || i >= cumjcodelength) { \ - panic("branch target out of code-boundary"); \ + 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; \ } \ } while (0) /* bound_check1 is used for the inclusive ends of exception handler ranges */ #define bound_check1(i) \ do { \ - if (i < 0 || i > cumjcodelength) { \ - panic("branch target out of code-boundary"); \ + 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; \ } \ } while (0) @@ -130,29 +193,19 @@ *******************************************************************************/ -#define code_get_u1(p) jcode[p] -#define code_get_s1(p) ((s1)jcode[p]) -#define code_get_u2(p) ((((u2)jcode[p]) << 8) + jcode[p + 1]) -#define code_get_s2(p) ((s2)((((u2)jcode[p]) << 8) + jcode[p + 1])) -#define code_get_u4(p) ((((u4)jcode[p]) << 24) + (((u4)jcode[p + 1]) << 16) \ - +(((u4)jcode[p + 2]) << 8) + jcode[p + 3]) -#define code_get_s4(p) ((s4)((((u4)jcode[p]) << 24) + (((u4)jcode[p + 1]) << 16) \ - +(((u4)jcode[p + 2]) << 8) + jcode[p + 3])) - - -extern classinfo *rt_class; -extern methodinfo *rt_method; -extern utf *rt_descriptor; -extern int rt_jcodelength; -extern u1 *rt_jcode; - +#define code_get_u1(p,m) m->jcode[p] +#define code_get_s1(p,m) ((s1)m->jcode[p]) +#define code_get_u2(p,m) ((((u2)m->jcode[p]) << 8) + m->jcode[p + 1]) +#define code_get_s2(p,m) ((s2)((((u2)m->jcode[p]) << 8) + m->jcode[p + 1])) +#define code_get_u4(p,m) ((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \ + +(((u4)m->jcode[p + 2]) << 8) + m->jcode[p + 3]) +#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); +methodinfo *parse(methodinfo *m, codegendata *cd, t_inlining_globals *inline_env); #endif /* _PARSE_H */