X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fjit%2Fparse.h;h=c7d561dbb8ebfafcd6dd7633d46d46918ca5317a;hb=ff4083aaec535fb7a937e3221a42782959586644;hp=b54af4dca39c093dc6ecef228d7ff6d10dc82343;hpb=674a23dcf15f46dbd0b5de887d4d0b6ee98d67bb;p=cacao.git diff --git a/src/vm/jit/parse.h b/src/vm/jit/parse.h index b54af4dca..c7d561dbb 100644 --- a/src/vm/jit/parse.h +++ b/src/vm/jit/parse.h @@ -25,10 +25,9 @@ Contact: cacao@cacaojvm.org Author: Christian Thalinger + Edwin Steiner - Changes: Edwin Steiner - - $Id: parse.h 5418 2006-09-08 12:10:39Z edwin $ + $Id: parse.h 5959 2006-11-12 13:31:14Z edwin $ */ @@ -79,29 +78,29 @@ goto throw_invalid_bytecode_index; \ } while (0) -#else /* !define(ENABLE_VERIFIER) */ +#else /* !defined(ENABLE_VERIFIER) */ #define INDEX_ONEWORD(num) #define INDEX_TWOWORD(num) #define CHECK_BYTECODE_INDEX(i) #define CHECK_BYTECODE_INDEX_EXCLUSIVE(i) -#endif /* define(ENABLE_VERIFIER) */ +#endif /* defined(ENABLE_VERIFIER) */ /* basic block generating macro ***********************************************/ -#define MARK_BASICBLOCK(i) \ - do { \ - if (!(jd->new_basicblockindex[(i)] & 1)) { \ - b_count++; \ - jd->new_basicblockindex[(i)] |= 1; \ - } \ +#define MARK_BASICBLOCK(i) \ + do { \ + if (!(jd->basicblockindex[(i)] & 1)) { \ + b_count++; \ + jd->basicblockindex[(i)] |= 1; \ + } \ } while (0) -#define INSTRUCTIONS_CHECK(i) \ - if ((ipc + (i)) > pd.instructionslength) \ - iptr = parse_check_instructions(&pd, ipc) +#define INSTRUCTIONS_CHECK(i) \ + if ((ipc + (i)) > pd.instructionslength) \ + iptr = parse_realloc_instructions(&pd, ipc, (i)) /* intermediate code generating macros ****************************************/ @@ -119,169 +118,172 @@ /* The _PREPARE macros omit the PINC, so you can set additional fields */ /* afterwards. */ -/* CAUTION: Some of the _PREPARE macros don't set iptr->flags! */ -#define PINC \ +#define PINC \ iptr++; ipc++ -/* CAUTION: You must set iptr->flags yourself when using this! */ -#define OP_PREPARE(o) \ - iptr->opc = (o); \ - iptr->line = currentline; +#define OP_PREPARE_FLAGS(o, f) \ + iptr->opc = (o); \ + iptr->line = currentline; \ + iptr->flags.bits = (f) | (ipc << INS_FLAG_ID_SHIFT); -#define OP_PREPARE_FLAGS(o, f) \ - iptr->opc = (o); \ - iptr->line = currentline; \ - iptr->flags.bits = (f); +#define OP_PREPARE_ZEROFLAGS(o) \ + OP_PREPARE_FLAGS(o, 0) -#define OP_PREPARE_ZEROFLAGS(o) \ - OP_PREPARE_FLAGS(o, 0) +#define OP_PREPARE(o) \ + OP_PREPARE_ZEROFLAGS(o) -#define OP(o) \ - OP_PREPARE_ZEROFLAGS(o); \ +#define OP(o) \ + OP_PREPARE_ZEROFLAGS(o); \ PINC -#define OP_LOADCONST_I(v) \ - OP_PREPARE_ZEROFLAGS(ICMD_ICONST); \ - iptr->sx.val.i = (v); \ +#define OP_LOADCONST_I(v) \ + OP_PREPARE_ZEROFLAGS(ICMD_ICONST); \ + iptr->sx.val.i = (v); \ PINC -#define OP_LOADCONST_L(v) \ - OP_PREPARE_ZEROFLAGS(ICMD_LCONST); \ - iptr->sx.val.l = (v); \ +#define OP_LOADCONST_L(v) \ + OP_PREPARE_ZEROFLAGS(ICMD_LCONST); \ + iptr->sx.val.l = (v); \ PINC -#define OP_LOADCONST_F(v) \ - OP_PREPARE_ZEROFLAGS(ICMD_FCONST); \ - iptr->sx.val.f = (v); \ +#define OP_LOADCONST_F(v) \ + OP_PREPARE_ZEROFLAGS(ICMD_FCONST); \ + iptr->sx.val.f = (v); \ PINC -#define OP_LOADCONST_D(v) \ - OP_PREPARE_ZEROFLAGS(ICMD_DCONST); \ - iptr->sx.val.d = (v); \ +#define OP_LOADCONST_D(v) \ + OP_PREPARE_ZEROFLAGS(ICMD_DCONST); \ + iptr->sx.val.d = (v); \ PINC -#define OP_LOADCONST_NULL() \ - OP_PREPARE_FLAGS(ICMD_ACONST, INS_FLAG_CHECK); \ - iptr->sx.val.anyptr = NULL; \ +#define OP_LOADCONST_NULL() \ + OP_PREPARE_FLAGS(ICMD_ACONST, INS_FLAG_CHECK); \ + iptr->sx.val.anyptr = NULL; \ PINC -#define OP_LOADCONST_STRING(v) \ - OP_PREPARE_FLAGS(ICMD_ACONST, INS_FLAG_CHECK); \ - iptr->sx.val.stringconst = (v); \ +#define OP_LOADCONST_STRING(v) \ + OP_PREPARE_FLAGS(ICMD_ACONST, INS_FLAG_CHECK); \ + iptr->sx.val.stringconst = (v); \ PINC -#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS(cl, cr, extraflags) \ - OP_PREPARE(ICMD_ACONST); \ - if (cl) { \ - iptr->sx.val.c.cls = (cl); \ - iptr->flags.bits = INS_FLAG_CLASS | (extraflags); \ - } \ - else { \ - iptr->sx.val.c.ref = (cr); \ - iptr->flags.bits = INS_FLAG_CLASS | INS_FLAG_UNRESOLVED \ - | (extraflags); \ - } \ +#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS(cl, cr, extraflags) \ + OP_PREPARE(ICMD_ACONST); \ + if (cl) { \ + iptr->sx.val.c.cls = (cl); \ + iptr->flags.bits |= INS_FLAG_CLASS | (extraflags); \ + } \ + else { \ + iptr->sx.val.c.ref = (cr); \ + iptr->flags.bits |= INS_FLAG_CLASS | INS_FLAG_UNRESOLVED \ + | (extraflags); \ + } \ PINC -#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_CHECK(c, cr) \ - OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS((c), (cr), INS_FLAG_CHECK) - -#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr) \ - OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS((c), (cr), 0) - -#define OP_S3_CLASSINFO_OR_CLASSREF(o, c, cr, extraflags) \ - OP_PREPARE(o); \ - if (c) { \ - iptr->sx.s23.s3.c.cls= (c); \ - iptr->flags.bits = (extraflags); \ - } \ - else { \ - iptr->sx.s23.s3.c.ref= (cr); \ - iptr->flags.bits = INS_FLAG_UNRESOLVED | (extraflags); \ - } \ +#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_CHECK(c, cr) \ + OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS((c), (cr), INS_FLAG_CHECK) + +#define OP_LOADCONST_CLASSINFO_OR_CLASSREF_NOCHECK(c, cr) \ + OP_LOADCONST_CLASSINFO_OR_CLASSREF_FLAGS((c), (cr), 0) + +#define OP_S3_CLASSINFO_OR_CLASSREF(o, c, cr, extraflags) \ + OP_PREPARE(o); \ + if (c) { \ + iptr->sx.s23.s3.c.cls= (c); \ + iptr->flags.bits |= (extraflags); \ + } \ + else { \ + iptr->sx.s23.s3.c.ref= (cr); \ + iptr->flags.bits |= INS_FLAG_UNRESOLVED | (extraflags); \ + } \ PINC -#define OP_INSINDEX(o, iindex) \ - OP_PREPARE_ZEROFLAGS(o); \ - iptr->dst.insindex = (iindex); \ +#define OP_INSINDEX(o, iindex) \ + OP_PREPARE_ZEROFLAGS(o); \ + iptr->dst.insindex = (iindex); \ PINC -# define OP_LOCALINDEX(o,index) \ - OP_PREPARE_ZEROFLAGS(o); \ +# define OP_LOCALINDEX(o,index) \ + OP_PREPARE_ZEROFLAGS(o); \ iptr->s1.varindex = (index); \ PINC -# define OP_LOCALINDEX_I(o,index,v) \ - OP_PREPARE_ZEROFLAGS(o); \ - iptr->s1.varindex = (index); \ - iptr->sx.val.i = (v); \ +# define OP_LOCALINDEX_I(o,index,v) \ + OP_PREPARE_ZEROFLAGS(o); \ + iptr->s1.varindex = (index); \ + iptr->sx.val.i = (v); \ PINC -# define LOCALTYPE_USED(index,type) \ - do { \ - local_map[(index) * 5 + (type)] = 1; \ - } while (0) +# define LOCALTYPE_USED(index,type) \ + do { \ + local_map[(index) * 5 + (type)] = 1; \ + } while (0) + +#define OP_LOAD_ONEWORD(o,index,type) \ + do { \ + INDEX_ONEWORD(index); \ + OP_LOCALINDEX(o,index); \ + LOCALTYPE_USED(index,type); \ + } while (0) -#define OP_LOAD_ONEWORD(o,index,type) \ - do { \ - INDEX_ONEWORD(index); \ - OP_LOCALINDEX(o,index); \ - LOCALTYPE_USED(index,type); \ +#define OP_LOAD_TWOWORD(o,index,type) \ + do { \ + INDEX_TWOWORD(index); \ + OP_LOCALINDEX(o,index); \ + LOCALTYPE_USED(index,type); \ } while (0) -#define OP_LOAD_TWOWORD(o,index,type) \ - do { \ - INDEX_TWOWORD(index); \ - OP_LOCALINDEX(o,index); \ - LOCALTYPE_USED(index,type); \ - } while (0) - -# define OP_STORE_ONEWORD(o,index,type) \ - do { \ - INDEX_ONEWORD(index); \ - OP_PREPARE_ZEROFLAGS(o); \ - iptr->dst.varindex = (index); \ - LOCALTYPE_USED(index,type); \ - PINC; \ +# define OP_STORE_ONEWORD(o,index,type) \ + do { \ + INDEX_ONEWORD(index); \ + OP_PREPARE_ZEROFLAGS(o); \ + iptr->dst.varindex = (index); \ + LOCALTYPE_USED(index,type); \ + PINC; \ } while (0) -# define OP_STORE_TWOWORD(o,index,type) \ - do { \ - INDEX_TWOWORD(index); \ - OP_PREPARE_ZEROFLAGS(o); \ - iptr->dst.varindex = (index); \ - LOCALTYPE_USED(index,type); \ - PINC; \ +# define OP_STORE_TWOWORD(o,index,type) \ + do { \ + INDEX_TWOWORD(index); \ + OP_PREPARE_ZEROFLAGS(o); \ + iptr->dst.varindex = (index); \ + LOCALTYPE_USED(index,type); \ + PINC; \ } while (0) -#define OP_BUILTIN_CHECK_EXCEPTION(bte) \ - jd->isleafmethod = false; \ - OP_PREPARE_FLAGS(ICMD_BUILTIN, INS_FLAG_CHECK); \ - iptr->sx.s23.s3.bte = (bte); \ +#define OP_BUILTIN_CHECK_EXCEPTION(bte) \ + jd->isleafmethod = false; \ + OP_PREPARE_FLAGS(ICMD_BUILTIN, INS_FLAG_CHECK); \ + iptr->sx.s23.s3.bte = (bte); \ PINC -#define OP_BUILTIN_NO_EXCEPTION(bte) \ - jd->isleafmethod = false; \ - OP_PREPARE_ZEROFLAGS(ICMD_BUILTIN); \ - iptr->sx.s23.s3.bte = (bte); \ +#define OP_BUILTIN_NO_EXCEPTION(bte) \ + jd->isleafmethod = false; \ + OP_PREPARE_ZEROFLAGS(ICMD_BUILTIN); \ + iptr->sx.s23.s3.bte = (bte); \ PINC -#define OP_BUILTIN_ARITHMETIC(opcode, bte) \ - jd->isleafmethod = false; \ - OP_PREPARE_FLAGS(opcode, INS_FLAG_CHECK); \ - iptr->sx.s23.s3.bte = (bte); \ +#define OP_BUILTIN_ARITHMETIC(opcode, bte) \ + jd->isleafmethod = false; \ + OP_PREPARE_FLAGS(opcode, INS_FLAG_CHECK); \ + iptr->sx.s23.s3.bte = (bte); \ PINC /* CAUTION: You must set iptr->flags yourself when using this! */ -#define OP_FMIREF_PREPARE(o, fmiref) \ - OP_PREPARE(o); \ +#define OP_FMIREF_PREPARE(o, fmiref) \ + OP_PREPARE(o); \ iptr->sx.s23.s3.fmiref = (fmiref); +/* external macros ************************************************************/ + +#define BLOCK_OF(index) \ + (jd->basicblocks + jd->basicblockindex[index]) + + /* function prototypes ********************************************************/ -bool new_parse(jitdata *jd); +bool parse(jitdata *jd); #endif /* _PARSE_H */