Author: Andreas Krall EMAIL: cacao@complang.tuwien.ac.at
- Last Change: $Id: parse.c 383 2003-07-08 21:01:26Z carolyn $
+ Last Change: $Id: parse.c 553 2003-11-01 20:50:03Z twisti $
include Rapid Type Analysis parse - 5/2003 - carolyn
*******************************************************************************/
#include "math.h"
+#include "sets.h"
/* data about the currently parsed method */
static classinfo *rt_class; /* class the compiled method belongs to */
+(((u4)jcode[p+2])<<8)+jcode[p+3]))
+
+/*INLINING*/
+#include "inline.c"
+/*#define debug_writebranch printf("op: %s i: %d label_index[i]: %d\n",icmd_names[opcode], i, label_index[i]);*/
+#define debug_writebranch
+
/* functionc compiler_addinitclass *********************************************
add class into the list of classes to initialize
}
+/* function descriptor2typesL ***************************************************
+
+ decodes a already checked method descriptor. The parameter count, the
+ return type and the argument types are stored in the passed methodinfo.
+ gets and saves classptr for object ref.s
+
+*******************************************************************************/
+
+classSetNode * descriptor2typesL (methodinfo *m)
+{
+int debugInfo = 0;
+ int i;
+ u1 *types, *tptr;
+ int pcount, c;
+ char *utf_ptr;
+ classinfo** classtypes;
+ char *class;
+ char *desc;
+ classSetNode *p=NULL;
+if (debugInfo >= 1) {
+ printf("In descriptor2typesL >>>\t"); fflush(stdout);
+ utf_display(m->class->name); printf(".");
+ method_display(m);fflush(stdout);
+ }
+
+ pcount = 0;
+ desc = MNEW (char, 256);
+ types = DMNEW (u1, m->descriptor->blength);
+ classtypes = MNEW (classinfo*, m->descriptor->blength+1);
+ m->returnclass = NULL;
+ tptr = types;
+ if (!(m->flags & ACC_STATIC)) {
+ *tptr++ = TYPE_ADR;
+ if (debugInfo >= 1) {
+ printf("param #0 (this?) method class =");utf_display(m->class->name);printf("\n");
+ }
+ classtypes[pcount] = m->class;
+ p = addClassCone(p, m->class);
+ pcount++;
+ }
+
+ utf_ptr = m->descriptor->text + 1;
+ strcpy (desc,utf_ptr);
+
+ while ((c = *desc++) != ')') {
+ pcount++;
+ switch (c) {
+ case 'B':
+ case 'C':
+ case 'I':
+ case 'S':
+ case 'Z': *tptr++ = TYPE_INT;
+ break;
+ case 'J': *tptr++ = TYPE_LNG;
+ break;
+ case 'F': *tptr++ = TYPE_FLT;
+ break;
+ case 'D': *tptr++ = TYPE_DBL;
+ break;
+ case 'L': *tptr++ = TYPE_ADR;
+ /* get class string */
+ class = strtok(desc,";");
+ desc = strtok(NULL,"\0");
+ /* get/save classinfo ptr */
+ classtypes[pcount-1] = class_get(utf_new_char(class));
+ p = addClassCone(p, class_get(utf_new_char(class)));
+ if (debugInfo >= 1) {
+ printf("LParam#%i 's class type is: %s\n",pcount-1,class);fflush(stdout);
+ printf("Lclasstypes[%i]=",pcount-1);fflush(stdout);
+ utf_display(classtypes[pcount-1]->name);
+ }
+ break;
+ case '[': *tptr++ = TYPE_ADR;
+ while (c == '[')
+ c = *desc++;
+ /* get class string */
+ if (c == 'L') {
+ class = strtok(desc,";");
+ desc = strtok(NULL,"\0");
+ /* get/save classinfo ptr */
+ classtypes[pcount-1] = class_get(utf_new_char(class));
+ p= addClassCone(p, class_get(utf_new_char(class)));
+ if (debugInfo >= 1) {
+ printf("[Param#%i 's class type is: %s\n",pcount-1,class);
+ printf("[classtypes[%i]=",pcount-1);fflush(stdout);
+ utf_display(classtypes[pcount-1]->name);
+ printf("\n");
+ }
+ }
+ else
+ classtypes[pcount-1] = NULL;
+ break;
+ default:
+ panic("Ill formed methodtype-descriptor");
+ }
+ }
+
+ /* compute return type */
+ switch (*desc++) {
+ case 'B':
+ case 'C':
+ case 'I':
+ case 'S':
+ case 'Z': m->returntype = TYPE_INT;
+ break;
+ case 'J': m->returntype = TYPE_LNG;
+ break;
+ case 'F': m->returntype = TYPE_FLT;
+ break;
+ case 'D': m->returntype = TYPE_DBL;
+ break;
+ case '[':
+ m->returntype = TYPE_ADR;
+ c = *desc;
+ while (c == '[')
+ c = *desc++;
+ if (c != 'L') break;
+ *(desc++);
+
+ case 'L':
+ m->returntype = TYPE_ADR;
+
+ /* get class string */
+ class = strtok(desc,";");
+ m->returnclass = class_get(utf_new_char(class));
+ if (m->returnclass == NULL) {
+ printf("class=%s :\t",class);
+ panic ("return class not found");
+ }
+ break;
+ case 'V': m->returntype = TYPE_VOID;
+ break;
+
+ default: panic("Ill formed methodtype-descriptor-ReturnType");
+ }
+
+ m->paramcount = pcount;
+ m->paramtypes = types;
+ m->paramclass = classtypes;
+
+if (debugInfo >=1) {
+ if (pcount > 0) {
+ for (i=0; i< m->paramcount; i++) {
+ if ((m->paramtypes[i] == TYPE_ADR) && (m->paramclass[i] != NULL)) {
+ printf("Param #%i is:\t",i);
+ utf_display(m->paramclass[i]->name);
+ printf("\n");
+ }
+ }
+ }
+ if ((m->returntype == TYPE_ADR) && (m->returnclass != NULL)) {
+ printf("\tReturn Type is:\t"); fflush(stdout);
+ utf_display(m->returnclass->name);
+ printf("\n");
+ }
+
+ printf("params2types: START results in a set \n");
+ printf("param2types: A Set size=%i=\n",sizeOfSet(p));
+ printSet(p);
+ }
+
+return p;
+}
+
/* function descriptor2types ***************************************************
decodes a already checked method descriptor. The parameter count, the
}
-#ifdef OLD_COMPILER
-
-/* function allocate_literals **************************************************
-
- Scans the JavaVM code of a method and allocates string literals (in the
- same order as the old JIT). Needed to generate the same addresses as the
- old JIT compiler.
-
-*******************************************************************************/
-
-static void allocate_literals()
-{
- int p, nextp;
- int opcode, i;
- s4 num;
- utf *s;
-
- for (p = 0; p < jcodelength; p = nextp) {
-
- opcode = jcode[p];
- nextp = p + jcommandsize[opcode];
-
- switch (opcode) {
- case JAVA_WIDE:
- if (code_get_u1(p + 1) == JAVA_IINC)
- nextp = p + 6;
- else
- nextp = p + 4;
- break;
-
- case JAVA_LOOKUPSWITCH:
- nextp = ALIGN((p + 1), 4);
- num = code_get_u4(nextp + 4);
- nextp = nextp + 8 + 8 * num;
- break;
-
- case JAVA_TABLESWITCH:
- nextp = ALIGN ((p + 1),4);
- num = code_get_s4(nextp + 4);
- num = code_get_s4(nextp + 8) - num;
- nextp = nextp + 16 + 4 * num;
- break;
-
- case JAVA_LDC1:
- i = code_get_u1(p+1);
- goto pushconstantitem;
- case JAVA_LDC2:
- case JAVA_LDC2W:
- i = code_get_u2(p + 1);
- pushconstantitem:
- if (class_constanttype(class, i) == CONSTANT_String) {
- s = class_getconstant(class, i, CONSTANT_String);
- (void) literalstring_new(s);
- }
- break;
- } /* end switch */
- } /* end while */
-}
-#endif
-
-
/*******************************************************************************
function 'parse' scans the JavaVM code and generates intermediate code
#define block_insert(i) {if(!(block_index[i]&1))\
{b_count++;block_index[i] |= 1;}}
-#define bound_check(i) {if((i< 0) || (i>=jcodelength)) \
+#define bound_check(i) {if((i< 0) || (i>=cumjcodelength)) \
panic("branch target out of code-boundary");}
-#define bound_check1(i) {if((i< 0) || (i>jcodelength)) \
+#define bound_check1(i) {if((i< 0) || (i>cumjcodelength)) \
panic("branch target out of code-boundary");}
+/* FIXME really use cumjcodelength for the bound_checkers ? */
+static xtable* fillextable (xtable* extable, exceptiontable *raw_extable, int exceptiontablelength, int *label_index, int *block_count)
+{
+ int b_count, i, p;
+
+ if (exceptiontablelength == 0)
+ return extable;
+
+ b_count = *block_count;
+ for (i = 0; i < exceptiontablelength; i++) {
+
+ p = raw_extable[i].startpc;
+ if (label_index != NULL) p = label_index[p];
+ extable[i].startpc = p;
+ bound_check(p);
+ block_insert(p);
+
+ p = raw_extable[i].endpc;
+ if (label_index != NULL) p = label_index[p];
+ extable[i].endpc = p;
+ bound_check1(p);
+ if (p < cumjcodelength)
+ block_insert(p);
+
+ p = raw_extable[i].handlerpc;
+ if (label_index != NULL) p = label_index[p];
+ extable[i].handlerpc = p;
+ bound_check(p);
+ block_insert(p);
+
+ extable[i].catchtype = raw_extable[i].catchtype;
+
+ extable[i].next = NULL;
+ extable[i].down = &extable[i+1];
+ }
+ *block_count = b_count;
+ return &extable[i]; /* return the next free xtable* */
+}
static void parse()
{
bool blockend = false; /* true if basic block end has been reached */
bool iswide = false; /* true if last instruction was a wide */
instruction *iptr; /* current pointer into instruction array */
- static int xta1 = 0;
+ int gp; /* global java instruction counter */
+ /* inlining info for current method */
+ inlining_methodinfo *inlinfo = inlining_rootinfo, *tmpinlinf;
+ int nextgp = -1; /* start of next method to be inlined */
+ int *label_index = NULL; /* label redirection table */
+ int firstlocal = 0; /* first local variable of method */
+ xtable* nextex; /* points next free entry in extable */
+
+ bool useinltmp;
+
+/*INLINING*/
+ if (useinlining)
+ {
+ label_index = inlinfo->label_index;
+ maxstack = cummaxstack;
+ exceptiontablelength=cumextablelength;
+ }
+
+ useinltmp = useinlining; /*FIXME remove this after debugging */
+ /*useinlining = false;*/ /* and merge the if-statements */
+
+ if (!useinlining) {
+ cumjcodelength = jcodelength;
+ } else {
+ tmpinlinf = (inlining_methodinfo*) list_first(inlinfo->inlinedmethods);
+ if (tmpinlinf != NULL) nextgp = tmpinlinf->startgp;
+ }
- /*RTAprint*/ if ((opt_rt) && ((pOpcodes == 2) || (pOpcodes == 3)) )
+ /*RTAprint*/ if ( ((opt_rt) ||(opt_xta) || (opt_vta)) && ((pOpcodes == 2) || (pOpcodes == 3)) )
/*RTAprint*/ {printf("PARSE method name =");
/*RTAprint*/ utf_display(method->class->name);printf(".");
/*RTAprint*/ method_display(method); printf(">\n\n");fflush(stdout);}
- if (opt_rt) {
+ if ((opt_rt) || (opt_xta)) {
RT_jit_parse(method);
}
- else {
- if ((opt_xta) && (xta1 == 0)) {
- /*printf("XTA - not available yet\n"); */
- /*xta1++; */
- XTA_jit_parse(method);
- /*XTAprint*/ if (((pOpcodes == 1) || (pOpcodes == 3)) && opt_rt)
- /*XTAprint*/ {printf("XTA PARSE method name =");
- /*XTAprint*/ utf_display(rt_method->class->name);printf(".");
- /*XTAprint*/ method_display(rt_method); printf(">\n\n");fflush(stdout);}
-
- }
-
- }
-
-#ifdef OLD_COMPILER
- /* generate the same addresses as the old JIT compiler */
-
- if (runverbose)
- allocate_literals();
-#endif
+ else {
+ if (opt_vta)
+ printf("VTA requested, but not yet implemented\n");
+ }
+
/* allocate instruction array and block index table */
/* 1 additional for end ipc and 3 for loop unrolling */
- block_index = DMNEW(int, jcodelength + 4);
+ block_index = DMNEW(int, cumjcodelength + 4);
/* 1 additional for TRACEBUILTIN and 4 for MONITORENTER/EXIT */
/* additional MONITOREXITS are reached by branches which are 3 bytes */
- iptr = instr = DMNEW(instruction, jcodelength + 5);
+ iptr = instr = DMNEW(instruction, cumjcodelength + 5);
/* initialize block_index table (unrolled four times) */
{
int *ip;
- for (i = 0, ip = block_index; i <= jcodelength; i += 4, ip += 4) {
+ for (i = 0, ip = block_index; i <= cumjcodelength; i += 4, ip += 4) {
ip[0] = 0;
ip[1] = 0;
ip[2] = 0;
/* compute branch targets of exception table */
extable = DMNEW(xtable, exceptiontablelength + 1);
-
- for (i = 0; i < exceptiontablelength; i++) {
+ /*
+ for (i = 0; i < method->exceptiontablelength; i++) {
p = extable[i].startpc = raw_extable[i].startpc;
+ if (useinlining) p = label_index[p];
bound_check(p);
block_insert(p);
p = extable[i].endpc = raw_extable[i].endpc;
+ if (useinlining) p = label_index[p];
bound_check1(p);
- if (p < jcodelength)
+ if (p < cumjcodelength)
block_insert(p);
p = extable[i].handlerpc = raw_extable[i].handlerpc;
extable[i].next = NULL;
extable[i].down = &extable[i+1];
}
+ */
- if (exceptiontablelength > 0)
- extable[exceptiontablelength-1].down = NULL;
- else
- extable = NULL;
+ nextex = fillextable(extable, raw_extable, method->exceptiontablelength, label_index, &b_count);
s_count = 1 + exceptiontablelength; /* initialize stack element counter */
/* scan all java instructions */
- for (p = 0; p < jcodelength; p = nextp) {
-
- opcode = code_get_u1 (p); /* fetch op code */
-
- /*RTAprint*/ if ((opt_rt) && ((pOpcodes == 2) || (pOpcodes == 3)) )
- /*RTAprint*/ {printf("Parse<%i> p=%i<%i< opcode=<%i> %s\n",
- /*RTAprint*/ pOpcodes, p,jcodelength,opcode,opcode_names[opcode]);}
-
- block_index[p] |= (ipc << 1); /* store intermediate count */
-
- if (blockend) {
- block_insert(p); /* start new block */
- blockend = false;
- }
+ for (p = 0, gp = 0; p < jcodelength; gp += (nextp - p), p = nextp) {
+
+ /* DEBUG printf("p:%d gp:%d ",p,gp); */
+
+/*INLINING*/
+ if ((useinlining) && (gp == nextgp)) {
+ u1 *tptr;
+ bool *readonly = NULL;
+
+ opcode = code_get_u1 (p);
+ nextp = p += jcommandsize[opcode];
+ tmpinlinf = list_first(inlinfo->inlinedmethods);
+ firstlocal = tmpinlinf->firstlocal;
+ label_index = tmpinlinf->label_index;
+ readonly = tmpinlinf->readonly;
+ for (i=0, tptr=tmpinlinf->method->paramtypes + tmpinlinf->method->paramcount - 1 ; i<tmpinlinf->method->paramcount; i++, tptr--)
+ {
+ int op;
+
+ if ( (i==0) && inlineparamopt) {
+ OP1(ICMD_CLEAR_ARGREN, firstlocal);
+ }
+
+ if ( !inlineparamopt || !readonly[i] )
+ op = ICMD_ISTORE;
+ else op = ICMD_READONLY_ARG;
+
+ op += *tptr;
+ OP1(op, firstlocal + tmpinlinf->method->paramcount - 1 - i);
+
+ /* block_index[gp] |= (ipc << 1);*/ /*FIXME: necessary ? */
+ }
+ inlining_save_compiler_variables();
+ inlining_set_compiler_variables(tmpinlinf);
+ if (inlinfo->inlinedmethods == NULL) gp = -1;
+ else {
+ tmpinlinf = list_first(inlinfo->inlinedmethods);
+ nextgp = (tmpinlinf != NULL) ? tmpinlinf->startgp : -1;
+ }
+ if (method->exceptiontablelength > 0)
+ nextex = fillextable(nextex, method->exceptiontable, method->exceptiontablelength, label_index, &b_count);
+ continue;
+ }
+
+ opcode = code_get_u1 (p); /* fetch op code */
+
+
+ /*RTAprint*/ if ((opt_rt) && ((pOpcodes == 2) || (pOpcodes == 3)) )
+ /*RTAprint*/ {printf("Parse<%i> p=%i<%i< opcode=<%i> %s\n",
+ /*RTAprint*/ pOpcodes, p,rt_jcodelength,opcode,icmd_names[opcode]);}
+
+ block_index[gp] |= (ipc << 1); /* store intermediate count */
+
+ if (blockend) {
+ block_insert(gp); /* start new block */
+ blockend = false;
+ }
nextp = p + jcommandsize[opcode]; /* compute next instruction start */
s_count += stackreq[opcode]; /* compute stack element count */
i = code_get_u1(p+1);
else {
i = code_get_u2(p+1);
-//printf("WIDE ");
nextp = p+3;
iswide = false;
}
- OP1(opcode, i);
-// printf("I-ALOAD %s i=%i <%x>\n", opcode_names[opcode],i,jcode[p+1]);
+ OP1(opcode, i + firstlocal);
break;
case JAVA_ILOAD_0:
case JAVA_ILOAD_1:
case JAVA_ILOAD_2:
case JAVA_ILOAD_3:
- OP1(ICMD_ILOAD, opcode - JAVA_ILOAD_0);
+ OP1(ICMD_ILOAD, opcode - JAVA_ILOAD_0 + firstlocal);
break;
case JAVA_LLOAD_0:
case JAVA_LLOAD_1:
case JAVA_LLOAD_2:
case JAVA_LLOAD_3:
- OP1(ICMD_LLOAD, opcode - JAVA_LLOAD_0);
+ OP1(ICMD_LLOAD, opcode - JAVA_LLOAD_0 + firstlocal);
break;
case JAVA_FLOAD_0:
case JAVA_FLOAD_1:
case JAVA_FLOAD_2:
case JAVA_FLOAD_3:
- OP1(ICMD_FLOAD, opcode - JAVA_FLOAD_0);
+ OP1(ICMD_FLOAD, opcode - JAVA_FLOAD_0 + firstlocal);
break;
case JAVA_DLOAD_0:
case JAVA_DLOAD_1:
case JAVA_DLOAD_2:
case JAVA_DLOAD_3:
- OP1(ICMD_DLOAD, opcode - JAVA_DLOAD_0);
+ OP1(ICMD_DLOAD, opcode - JAVA_DLOAD_0 + firstlocal);
break;
case JAVA_ALOAD_0:
case JAVA_ALOAD_1:
case JAVA_ALOAD_2:
case JAVA_ALOAD_3:
- OP1(ICMD_ALOAD, opcode - JAVA_ALOAD_0);
+ OP1(ICMD_ALOAD, opcode - JAVA_ALOAD_0 + firstlocal);
break;
/* storing stack values into local variables */
i = code_get_u1(p+1);
else {
i = code_get_u2(p+1);
-//printf("WIDE ");
iswide=false;
nextp = p+3;
}
-//printf("I-ASTORE %s i=%i <%x>\n", opcode_names[opcode],i,jcode[p+1]);
- OP1(opcode, i);
+ OP1(opcode, i + firstlocal);
break;
case JAVA_ISTORE_0:
case JAVA_ISTORE_1:
case JAVA_ISTORE_2:
case JAVA_ISTORE_3:
- OP1(ICMD_ISTORE, opcode - JAVA_ISTORE_0);
+ OP1(ICMD_ISTORE, opcode - JAVA_ISTORE_0 + firstlocal);
break;
case JAVA_LSTORE_0:
case JAVA_LSTORE_1:
case JAVA_LSTORE_2:
case JAVA_LSTORE_3:
- OP1(ICMD_LSTORE, opcode - JAVA_LSTORE_0);
+ OP1(ICMD_LSTORE, opcode - JAVA_LSTORE_0 + firstlocal);
break;
case JAVA_FSTORE_0:
case JAVA_FSTORE_1:
case JAVA_FSTORE_2:
case JAVA_FSTORE_3:
- OP1(ICMD_FSTORE, opcode - JAVA_FSTORE_0);
+ OP1(ICMD_FSTORE, opcode - JAVA_FSTORE_0 + firstlocal);
break;
case JAVA_DSTORE_0:
case JAVA_DSTORE_1:
case JAVA_DSTORE_2:
case JAVA_DSTORE_3:
- OP1(ICMD_DSTORE, opcode - JAVA_DSTORE_0);
+ OP1(ICMD_DSTORE, opcode - JAVA_DSTORE_0 + firstlocal);
break;
case JAVA_ASTORE_0:
case JAVA_ASTORE_1:
case JAVA_ASTORE_2:
case JAVA_ASTORE_3:
- OP1(ICMD_ASTORE, opcode - JAVA_ASTORE_0);
+ OP1(ICMD_ASTORE, opcode - JAVA_ASTORE_0 + firstlocal);
break;
case JAVA_IINC:
iswide = false;
nextp = p+5;
}
- OP2I(opcode, i, v);
+ OP2I(opcode, i + firstlocal, v);
}
break;
s_count++;
LOADCONST_A(class_getconstant(class, i,
CONSTANT_Arraydescriptor));
-#ifdef __I386__
+#if defined(__I386__)
BUILTIN2((functionptr) asm_builtin_newarray_array, TYPE_ADR);
#else
BUILTIN2((functionptr)builtin_newarray_array, TYPE_ADR);
else {
LOADCONST_A(class_getconstant(class, i, CONSTANT_Class));
s_count++;
-#ifdef __I386__
+#if defined(__I386__)
BUILTIN2((functionptr) asm_builtin_anewarray, TYPE_ADR);
#else
BUILTIN2((functionptr)builtin_anewarray, TYPE_ADR);
case JAVA_GOTO:
case JAVA_JSR:
i = p + code_get_s2(p+1);
+ if (useinlining) {
+ debug_writebranch
+ i = label_index[i];
+ }
bound_check(i);
block_insert(i);
blockend = true;
case JAVA_GOTO_W:
case JAVA_JSR_W:
i = p + code_get_s4(p+1);
+ if (useinlining) {
+ debug_writebranch
+ i = label_index[i];
+ }
bound_check(i);
block_insert(i);
blockend = true;
iswide = false;
}
blockend = true;
- OP1(opcode, i);
+
+ /*
+ if (isinlinedmethod) {
+ OP1(ICMD_GOTO, inlinfo->stopgp);
+ break;
+ }*/
+
+ OP1(opcode, i + firstlocal);
break;
case JAVA_IRETURN:
case JAVA_DRETURN:
case JAVA_ARETURN:
case JAVA_RETURN:
+
+
+ if (isinlinedmethod) {
+/* if (p==jcodelength-1) {*/ /* return is at end of inlined method */
+/* OP(ICMD_NOP); */
+/* break; */
+/* } */
+ blockend = true;
+ OP1(ICMD_GOTO, inlinfo->stopgp);
+ break;
+ }
+
blockend = true;
OP(opcode);
break;
case JAVA_LOOKUPSWITCH:
{
s4 num, j;
+ s4 *tablep;
blockend = true;
nextp = ALIGN((p + 1), 4);
- OP2A(opcode, 0, jcode + nextp);
+ if (!useinlining) {
+ tablep = (s4*)(jcode + nextp);
+ }
+ else {
+ num = code_get_u4(nextp + 4);
+ tablep = DMNEW(s4, num * 2 + 2);
+ }
+
+ OP2A(opcode, 0, tablep);
/* default target */
j = p + code_get_s4(nextp);
- *((s4*)(jcode + nextp)) = j; /* restore for little endian */
+ if (useinlining) j = label_index[j];
+ *tablep = j; /* restore for little endian */
+ tablep++;
nextp += 4;
bound_check(j);
block_insert(j);
/* number of pairs */
num = code_get_u4(nextp);
- *((s4*)(jcode + nextp)) = num;
+ *tablep = num;
+ tablep++;
nextp += 4;
for (i = 0; i < num; i++) {
/* value */
j = code_get_s4(nextp);
- *((s4*)(jcode + nextp)) = j; /* restore for little endian */
+ *tablep = j; /* restore for little endian */
+ tablep++;
nextp += 4;
/* target */
j = p + code_get_s4(nextp);
- *((s4*)(jcode + nextp)) = j; /* restore for little endian */
+ if (useinlining) j = label_index[j];
+ *tablep = j; /* restore for little endian */
+ tablep++;
nextp += 4;
bound_check(j);
block_insert(j);
case JAVA_TABLESWITCH:
{
s4 num, j;
+ s4 *tablep;
blockend = true;
nextp = ALIGN((p + 1), 4);
- OP2A(opcode, 0, jcode + nextp);
+ if (!useinlining) {
+ tablep = (s4*)(jcode + nextp);
+ }
+ else {
+ num = code_get_u4(nextp + 8) - code_get_u4(nextp + 4);
+ tablep = DMNEW(s4, num + 1 + 3);
+ }
+
+ OP2A(opcode, 0, tablep);
/* default target */
j = p + code_get_s4(nextp);
- *((s4*)(jcode + nextp)) = j; /* restore for little endian */
+ if (useinlining) j = label_index[j];
+ *tablep = j; /* restore for little endian */
+ tablep++;
nextp += 4;
bound_check(j);
block_insert(j);
/* lower bound */
j = code_get_s4(nextp);
- *((s4*)(jcode + nextp)) = j; /* restore for little endian */
+ *tablep = j; /* restore for little endian */
+ tablep++;
nextp += 4;
/* upper bound */
num = code_get_s4(nextp);
- *((s4*)(jcode + nextp)) = num; /* restore for little endian */
+ *tablep = num; /* restore for little endian */
+ tablep++;
nextp += 4;
num -= j;
for (i = 0; i <= num; i++) {
j = p + code_get_s4(nextp);
- *((s4*)(jcode + nextp)) = j; /* restore for little endian */
+ if (useinlining) j = label_index[j];
+ *tablep = j; /* restore for little endian */
+ tablep++;
nextp += 4;
bound_check(j);
block_insert(j);
/* method invocation *****/
case JAVA_INVOKESTATIC:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1);
{
constant_FMIref *mr;
methodinfo *mi;
if (! (mi->flags & ACC_STATIC))
panic ("Static/Nonstatic mismatch calling static method");
descriptor2types(mi);
+
isleafmethod=false;
OP2A(opcode, mi->paramcount, mi);
}
if (class_constanttype (class, i) == CONSTANT_Arraydescriptor) {
LOADCONST_A(class_getconstant(class, i, CONSTANT_Arraydescriptor));
s_count++;
-#ifdef __I386__
+#if defined(__I386__)
BUILTIN2((functionptr) asm_builtin_arrayinstanceof, TYPE_INT);
#else
BUILTIN2((functionptr) builtin_arrayinstanceof, TYPE_INT);
case JAVA_MONITORENTER:
#ifdef USE_THREADS
if (checksync) {
-#ifdef SOFTNULLPTRCHECK
- if (checknull) {
- BUILTIN1((functionptr) asm_builtin_monitorenter, TYPE_VOID);
- }
- else {
-/* BUILTIN1((functionptr) builtin_monitorenter, TYPE_VOID); */
- BUILTIN1((functionptr) asm_builtin_monitorenter, TYPE_VOID);
- }
-#else
- BUILTIN1((functionptr) builtin_monitorenter, TYPE_VOID);
-#endif
- }
- else
+ BUILTIN1((functionptr) asm_builtin_monitorenter, TYPE_VOID);
+ } else
#endif
{
OP(ICMD_NULLCHECKPOP);
case JAVA_MONITOREXIT:
#ifdef USE_THREADS
if (checksync) {
- BUILTIN1((functionptr) builtin_monitorexit, TYPE_VOID);
+ BUILTIN1((functionptr) asm_builtin_monitorexit, TYPE_VOID);
}
else
#endif
break;
case JAVA_FREM:
-#ifdef __I386__
-/* BUILTIN2((functionptr) asm_builtin_frem, TYPE_FLOAT); */
+#if defined(__I386__)
OP(opcode);
#else
BUILTIN2((functionptr) builtin_frem, TYPE_FLOAT);
break;
case JAVA_DREM:
-#ifdef __I386__
+#if defined(__I386__)
OP(opcode);
#else
BUILTIN2((functionptr) builtin_drem, TYPE_DOUBLE);
break;
case JAVA_F2I:
- if (checkfloats) {
+#if defined(__ALPHA__)
+ if (!opt_noieee) {
BUILTIN1((functionptr) builtin_f2i, TYPE_INT);
- }
- else {
+ } else
+#endif
+ {
OP(opcode);
- }
+ }
break;
case JAVA_F2L:
- if (checkfloats) {
+#if defined(__ALPHA__)
+ if (!opt_noieee) {
BUILTIN1((functionptr) builtin_f2l, TYPE_LONG);
- }
- else {
+ } else
+#endif
+ {
OP(opcode);
- }
+ }
break;
case JAVA_D2I:
- if (checkfloats) {
+#if defined(__ALPHA__)
+ if (!opt_noieee) {
BUILTIN1((functionptr) builtin_d2i, TYPE_INT);
- }
- else {
+ } else
+#endif
+ {
OP(opcode);
- }
+ }
break;
case JAVA_D2L:
- if (checkfloats) {
+#if defined(__ALPHA__)
+ if (!opt_noieee) {
BUILTIN1((functionptr) builtin_d2l, TYPE_LONG);
- }
- else {
+ } else
+#endif
+ {
OP(opcode);
- }
+ }
break;
case JAVA_BREAKPOINT:
default:
OP(opcode);
break;
-
- } /* end switch */
+
+ } /* end switch */
+
+ /* INLINING */
+
+ if ((isinlinedmethod) && (p==jcodelength-1)) { /*end of an inlined method */
+ /* printf("setting gp from %d to %d\n",gp, inlinfo->stopgp); */
+ gp = inlinfo->stopgp;
+ inlining_restore_compiler_variables();
+ list_remove(inlinfo->inlinedmethods, list_first(inlinfo->inlinedmethods));
+ if (inlinfo->inlinedmethods == NULL) nextgp = -1;
+ else {
+ tmpinlinf = list_first(inlinfo->inlinedmethods);
+ nextgp = (tmpinlinf != NULL) ? tmpinlinf->startgp : -1;
+ }
+ /* printf("nextpgp: %d\n", nextgp); */
+ label_index=inlinfo->label_index;
+ firstlocal = inlinfo->firstlocal;
+ }
} /* end for */
-
if (p != jcodelength)
panic("Command-sequence crosses code-boundary");
/* allocate blocks */
- for (p = 0; p < jcodelength; p++)
+ for (p = 0; p < cumjcodelength; p++)
if (block_index[p] & 1) {
bptr->iinstr = instr + (block_index[p] >> 1);
last_block = bptr;
-
+ if (exceptiontablelength > 0)
+ extable[exceptiontablelength-1].down = NULL;
+ else
+ extable = NULL;
for (i = 0; i < exceptiontablelength; ++i) {
p = extable[i].startpc;
extable[i].handler = block + block_index[p];
}
}
+
+ if (useinlining) inlining_cleanup();
+ useinlining = useinltmp;
}
-
+#include "sets.c"
#include "parseRT.h"
-#include "parseXTA.h"
/*
* These are local overrides for various environment variables in Emacs.