/* jit/inline.c - code inliner
+globals moved to structure and passed as parameter
+
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,
Authors: Dieter Thuernbeck
- $Id: inline.c 1236 2004-06-30 19:53:03Z twisti $
+ $Id: inline.c 1414 2004-10-04 12:55:33Z carolyn $
*/
#include "toolbox/logging.h"
#include "toolbox/memory.h"
+#define METHINFO(m) \
+ utf_display(m->class->name); printf("."); fflush(stdout); \
+ method_display(m); fflush(stdout); \
+
+#define IMETHINFO(m) \
+ utf_display(m->class->name); printf("."); fflush(stdout); \
+ method_display(m); fflush(stdout); \
+ printf("\tm->jcodelength=%i; ",m->jcodelength); fflush(stdout); \
+ printf("m->jcode=%p;\n",m->jcode); fflush(stdout); \
+ printf("\tm->maxlocals=%i; ",m->maxlocals); fflush(stdout); \
+ printf("m->maxstack=%i;\n",m->maxstack); fflush(stdout);
+bool DEBUGi = false;
// checked functions and macros: LOADCONST code_get OP1 BUILTIN block_insert bound_check ALIGN
// replace jcodelength loops with correct number after main for loop in parse()!
-static list *inlining_stack;
-//static list *inlining_patchlist;
-bool isinlinedmethod;
-int cumjcodelength; /* cumulative immediate intruction length */
-static int cumlocals;
-int cummaxstack;
-int cumextablelength;
-static int cummethods;
-inlining_methodinfo *inlining_rootinfo;
+/*-----------------------------------------------------------*/
+/* just initialize global structure for non-inlining */
+/*-----------------------------------------------------------*/
+t_inlining_globals *inlining_init0(methodinfo *m,
+ t_inlining_globals *inline_env)
+{
+ /* initialization for normal use in parse */
+ inlining_set_compiler_variables_fun(m, inline_env);
+ inline_env->isinlinedmethod = 0;
+ inline_env->cumjcodelength = m->jcodelength; /* for not inlining */
+ inline_env->cummaxstack = 0;
+ inline_env->cumextablelength = 0;
+ inline_env->cumlocals = m->maxlocals;
+ inline_env->cummethods = 0;//co not global or static-used only here?
+ inline_env->inlining_stack = NULL;
+ inline_env->inlining_rootinfo = NULL;
+return inline_env;
+}
+/*-----------------------------------------------------------*/
-void inlining_init(methodinfo *m)
+t_inlining_globals *inlining_init(methodinfo *m)
{
- inlining_stack = NULL;
- // inlining_patchlist = NULL;
- isinlinedmethod = 0;
- cumjcodelength = 0;
- cumlocals = 0;
- cumextablelength = 0;
- cummaxstack = 0;
- cummethods = 0;
-
- inlining_stack = NEW(list);
- list_init(inlining_stack, OFFSET(t_inlining_stacknode, linkage));
-
- inlining_rootinfo = inlining_analyse_method(m, 0, 0, 0, 0);
- m->maxlocals = cumlocals;
- m->maxstack = cummaxstack;
+ t_inlining_globals *inline_env = DNEW(t_inlining_globals);
+ inlining_init0(m,inline_env);
+if (useinlining)
+ {
+if (DEBUGi==true) {
+ printf("\n-------- Inlining init for: "); fflush(stdout);
+ IMETHINFO(m)
+ }
+ inline_env->cumjcodelength = 0;
+ inline_env->inlining_stack = NEW(list);
+ list_init(inline_env->inlining_stack,
+ OFFSET(t_inlining_stacknode, linkage));
+ /*------ analyze ------*/
+if (DEBUGi==true) {print_t_inlining_globals(inline_env);}
+ inline_env->inlining_rootinfo
+ = inlining_analyse_method(m, 0, 0, 0, 0, inline_env);
+if (DEBUGi==true) {print_t_inlining_globals(inline_env);}
+ /*---------------------*/
+ //if (inline_env->cummethods == 0) {
+ // inline_env = DNEW(t_inlining_globals);
+ // inlining_init0(m,inline_env);
+ // return inline_env;
+ // }
+if (DEBUGi==true) {
+ printf("(l,s) (%i,%i) was (%i,%i)\n",
+ m->maxlocals, inline_env->cumlocals,
+ m->maxstack, inline_env->cummaxstack); fflush(stdout);
+ }
+ m->maxlocals = inline_env->cumlocals; //orig not used
+ m->maxstack = inline_env->cummaxstack; //orig global maxstack var!!
+
+//panic("TEMP so can test just inline init\n");
+ }
+return inline_env;
}
-void inlining_cleanup()
+void inlining_cleanup(t_inlining_globals *inline_env)
{
- FREE(inlining_stack, t_inlining_stacknode);
+ FREE(inline_env->inlining_stack, t_inlining_stacknode);
}
-void inlining_push_compiler_variables(methodinfo *m, int i, int p, int nextp, int opcode, inlining_methodinfo *inlinfo)
+void inlining_push_compiler_variables(int i, int p, int nextp, int opcode, inlining_methodinfo *inlinfo, t_inlining_globals *inline_env)
{
t_inlining_stacknode *new = NEW(t_inlining_stacknode);
new->p = p;
new->nextp = nextp;
new->opcode = opcode;
- new->method = m;
- // new->patchlist = inlining_patchlist;
+ new->method = inline_env->method;
new->inlinfo = inlinfo;
- list_addfirst(inlining_stack, new);
- isinlinedmethod++;
+ list_addfirst(inline_env->inlining_stack, new);
+ inline_env->isinlinedmethod++;
}
-void inlining_pop_compiler_variables(methodinfo *m, int *i, int *p, int *nextp, int *opcode, inlining_methodinfo **inlinfo)
+void inlining_pop_compiler_variables(
+ int *i, int *p, int *nextp, int *opcode,
+ inlining_methodinfo **inlinfo,
+ t_inlining_globals *inline_env)
{
- t_inlining_stacknode *tmp = (t_inlining_stacknode *) list_first(inlining_stack);
+ t_inlining_stacknode *tmp
+ = (t_inlining_stacknode *) list_first(inline_env->inlining_stack);
- if (!isinlinedmethod) panic("Attempting to pop from inlining stack in toplevel method!\n");
+ if (!inline_env->isinlinedmethod) panic("Attempting to pop from inlining stack in toplevel method!\n");
*i = tmp->i;
*p = tmp->p;
*opcode = tmp->opcode;
*inlinfo = tmp->inlinfo;
- /* XXX TWISTI */
-/* method = tmp->method; */
-/* class = method->class; */
-/* jcodelength = method->jcodelength; */
-/* jcode = method->jcode; */
- // inlining_patchlist = tmp->patchlist;
-
- list_remove(inlining_stack, tmp);
- FREE(tmp, t_inlining_stacknode);
- isinlinedmethod--;
+ inline_env->method = tmp->method; /*co*/
+ inline_env->class = inline_env->method->class; /*co*/
+ inline_env->jcodelength = inline_env->method->jcodelength; /*co*/
+ inline_env->jcode = inline_env->method->jcode; /*co*/
+
+ list_remove(inline_env->inlining_stack, tmp);
+ FREE(tmp, t_inlining_stacknode);
+ inline_env->isinlinedmethod--;
}
-void inlining_set_compiler_variables_fun(methodinfo *m)
+void inlining_set_compiler_variables_fun(methodinfo *m,
+ t_inlining_globals *inline_env)
{
/* XXX TWISTI */
-/* method = m; */
-/* class = m->class; */
-/* jcodelength = m->jcodelength; */
-/* jcode = m->jcode; */
-
- // inlining_patchlist = DNEW(list);
- // list_init(inlining_patchlist, OFFSET(t_patchlistnode, linkage));
+ inline_env->method = m; /*co*/
+ inline_env->class = m->class; /*co*/
+ inline_env->jcode = m->jcode; /*co*/
+ inline_env->jcodelength = m->jcodelength; /*co*/
}
-/*void inlining_addpatch(instruction *iptr)
- {
- t_patchlistnode *patch = DNEW(t_patchlistnode);
- patch->iptr = iptr;
- list_addlast(inlining_patchlist, patch);
- }*/
-
-
classinfo *first_occurence(classinfo* class, utf* name, utf* desc)
{
classinfo *first = class;
return is_unique_rec(class, m, name, desc);
}
-
-inlining_methodinfo *inlining_analyse_method(methodinfo *m, int level, int gp, int firstlocal, int maxstackdepth)
+inlining_methodinfo *inlining_analyse_method(methodinfo *m,
+ int level, int gp,
+ int firstlocal, int maxstackdepth,
+ t_inlining_globals *inline_env)
{
inlining_methodinfo *newnode = DNEW(inlining_methodinfo);
- u1 *jcode = m->jcode;
+ /*u1 *jcode = m->jcode;*/
int jcodelength = m->jcodelength;
int p;
int nextp;
int opcode;
int i;
-/* int lastlabel = 0; */
bool iswide = false, oldiswide;
bool *readonly = NULL;
int *label_index = NULL;
readonly = NULL;
}
- label_index = DMNEW(int, jcodelength);
+ label_index = DMNEW(int, jcodelength+200);
newnode->inlinedmethods = DNEW(list);
list_init(newnode->inlinedmethods, OFFSET(inlining_methodinfo, linkage));
newnode->readonly = readonly;
newnode->label_index = label_index;
newnode->firstlocal = firstlocal;
- cumjcodelength += jcodelength + m->paramcount + 1 + 5;
+ inline_env->cumjcodelength += jcodelength + m->paramcount + 1 + 5;
- if ((firstlocal + m->maxlocals) > cumlocals) {
- cumlocals = firstlocal + m->maxlocals;
+ if ((firstlocal + m->maxlocals) > inline_env->cumlocals) {
+ inline_env->cumlocals = firstlocal + m->maxlocals;
}
- if ((maxstackdepth + m->maxstack) > cummaxstack) {
- cummaxstack = maxstackdepth + m->maxstack;
+ if ((maxstackdepth + m->maxstack) > inline_env->cummaxstack) {
+ inline_env->cummaxstack = maxstackdepth + m->maxstack;
}
- cumextablelength += m->exceptiontablelength;
+ inline_env->cumextablelength += m->exceptiontablelength;
for (p = 0; p < jcodelength; gp += (nextp - p), p = nextp) {
- opcode = code_get_u1 (p);
+ opcode = code_get_u1 (p,m);
nextp = p + jcommandsize[opcode];
oldiswide = iswide;
case JAVA_LOOKUPSWITCH:
nextp = ALIGN((p + 1), 4) + 4;
- nextp += code_get_u4(nextp) * 8 + 4;
+ nextp += code_get_u4(nextp,m) * 8 + 4;
break;
case JAVA_TABLESWITCH:
nextp = ALIGN((p + 1), 4) + 4;
- nextp += (code_get_u4(nextp+4) - code_get_u4(nextp) + 1) * 4 + 4;
+ nextp += (code_get_u4(nextp+4,m) - code_get_u4(nextp,m) + 1) * 4 + 4;
break;
}
case JAVA_DSTORE:
case JAVA_ASTORE:
if (!iswide) {
- i = code_get_u1(p + 1);
+ i = code_get_u1(p + 1,m);
} else {
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,m);
}
readonly[i] = false;
break;
case JAVA_IINC:
if (!iswide) {
- i = code_get_u1(p + 1);
+ i = code_get_u1(p + 1,m);
} else {
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,m);
}
readonly[i] = false;
break;
if (!inlinevirtuals)
break;
case JAVA_INVOKESTATIC:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,m);
{
constant_FMIref *imr;
methodinfo *imi;
break;
}
- if ((cummethods < INLINING_MAXMETHODS) &&
+ if ((inline_env->cummethods < INLINING_MAXMETHODS) &&
(!(imi->flags & ACC_NATIVE)) &&
(!inlineoutsiders || (m->class == imr->class)) &&
(imi->jcodelength < INLINING_MAXCODESIZE) &&
inlining_methodinfo *tmp;
descriptor2types(imi);
- cummethods++;
+ inline_env->cummethods++;
if (verbose) {
char logtext[MAXLOGTEXT];
log_text(logtext);
}
- tmp = inlining_analyse_method(imi, level + 1, gp, firstlocal + m->maxlocals, maxstackdepth + m->maxstack);
+ tmp =inlining_analyse_method(imi, level + 1, gp, firstlocal + m->maxlocals, maxstackdepth + m->maxstack, inline_env);
list_addlast(newnode->inlinedmethods, tmp);
gp = tmp->stopgp;
p = nextp;
newnode->stopgp = gp;
- /*
- sprintf (logtext, "Result of inlining analysis of: ");
- utf_sprint (logtext+strlen(logtext), m->class->name);
- strcpy (logtext+strlen(logtext), ".");
- utf_sprint (logtext+strlen(logtext), m->name);
- utf_sprint (logtext+strlen(logtext), m->descriptor);
- dolog ();
- sprintf (logtext, "label_index[0..%d]->", jcodelength);
- for (i=0; i<jcodelength; i++) sprintf (logtext, "%d:%d ", i, label_index[i]);
- sprintf(logtext,"stopgp : %d\n",newnode->stopgp); */
+ if (DEBUGi==true) {
+ printf ("\nResult of inlining analysis of: ");
+ IMETHINFO(m);
+ printf("was called by:\n"); fflush(stdout);
+ IMETHINFO(inline_env->method);
+ printf ("label_index[0..%d]->", jcodelength);
+ for (i=0;i<jcodelength; i++) printf ("%d:%d ", i, label_index[i]);
+ printf("stopgp : %d\n",newnode->stopgp);
+ }
return newnode;
}
+/* --------------------------------------------------------------------*/
+/* print_ functions: check inline structures contain what is expected */
+/* --------------------------------------------------------------------*/
+void print_t_inlining_globals (t_inlining_globals *g)
+{
+printf("\n------------\nt_inlining_globals struct for: \n\t");fflush(stdout);
+METHINFO(g->method);
+printf("\tclass=");fflush(stdout);
+ utf_display(g->class->name);printf("\n");fflush(stdout);
+
+printf("\tjcodelength=%i; jcode=%p;\n",g->jcodelength, g->jcode);
+
+if (g->isinlinedmethod==true) {
+ printf("\tisinlinedmethod=true ");fflush(stdout);
+ }
+else {
+ printf("\tisinlinedmethod=false");fflush(stdout);
+ }
+
+printf("\tcumjcodelength=%i ,cummaxstack=%i ,cumextablelength=%i ",
+ g->cumjcodelength, g->cummaxstack, g->cumextablelength);fflush(stdout);
+printf("\tcumlocals=%i ,cummethods=%i \n",
+ g->cumlocals, g->cummethods);fflush(stdout);
+
+printf("s>s>s> ");fflush(stdout);
+print_inlining_stack (g->inlining_stack);
+printf("i>i>i> "); fflush(stdout);
+print_inlining_methodinfo(g->inlining_rootinfo);
+printf("-------------------\n");fflush(stdout);
+}
+
+/* --------------------------------------------------------------------*/
+void print_inlining_stack ( list *s)
+{
+if (s==NULL) {
+ printf("\n\tinlining_stack: NULL\n");
+ return;
+ }
+
+ {/* print first element to see if get into stack */
+ t_inlining_stacknode *is;
+ printf("\n\tinlining_stack: NOT NULL\n");
+
+ is=list_first(s);
+ if (is==NULL) {
+ printf("\n\tinlining_stack = init'd but EMPTY\n");
+ fflush(stdout);
+ return;
+ }
+ }
+
+ {
+ t_inlining_stacknode *is;
+ printf("\n\tinlining_stack: NOT NULL\n");
+
+
+ for (is=list_first(s);
+ is!=NULL;
+ is=list_next(s,is)) {
+ printf("\n\ti>--->inlining_stack entry: \n"); fflush(stdout);
+ METHINFO(is->method);
+ printf("i=%i, p=%i, nextp=%i, opcode=%i;\n",
+ is->i,is->p,is->nextp,is->opcode);fflush(stdout);
+ print_inlining_methodinfo(is->inlinfo);
+ } /*end for */
+ }
+
+}
+
+/* --------------------------------------------------------------------*/
+void print_inlining_methodinfo( inlining_methodinfo *r) {
+if (r==NULL) {
+ printf("\n\tinlining_methodinfo: NULL\n");
+ return;
+ }
+
+if (r->method != NULL) {
+ utf_display(r->method->class->name); printf("."); fflush(stdout); \
+ method_display(r->method); fflush(stdout); \
+ }
+else {
+ printf("method is NULL!!!!!\n");fflush(stdout);
+ }
+
+printf("\n\tinlining_methodinfo for:"); fflush(stdout);
+if (r->readonly==NULL) {
+ printf("\treadonly==NULL ");fflush(stdout);
+ }
+else {
+ int i;
+ printf("\treadonly=");fflush(stdout);
+ for (i = 0; i < r->method->maxlocals; i++) {
+ if (r->readonly[i] == true)
+ printf("[i]=T;");
+ else
+ printf("[i]=F;");
+ fflush(stdout);
+ }
+ }
+
+
+printf("\tstartgp=%i; stopgp=%i; firstlocal=%i; label_index=%p;\n",
+ r->startgp, r->stopgp, r->firstlocal, r->label_index);
+{int i;
+printf ("label_index[0..%d]->", r->method->jcodelength);
+for (i=0; i<r->method->jcodelength; i++) printf ("%d:%d ", i, r->label_index[i]);
+}
+
+{
+inlining_methodinfo *im;
+for (im=list_first(r->inlinedmethods);
+ im!=NULL;
+ im=list_next(r->inlinedmethods,im)) {
+ }
+}
+}
+
/*
* These are local overrides for various environment variables in Emacs.
-/* jit/inline.c - code inliner
+/* jit/inline.h - code inliner
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
Authors: Dieter Thuernbeck
- $Id: inline.h 1203 2004-06-22 23:14:55Z twisti $
+ $Id: inline.h 1414 2004-10-04 12:55:33Z carolyn $
*/
//local variables used in parse()
- int i; /* temporary for different uses (counters) */
- int p; /* java instruction counter */
- int nextp; /* start of next java instruction */
- int opcode; /* java opcode */
+ int i; /* temporary for different uses (counters)*/
+ int p; /* java instruction counter */
+ int nextp; /* start of next java instruction */
+ int opcode; /* java opcode */
inlining_methodinfo *inlinfo;
- /* list *patchlist; */
} t_inlining_stacknode;
-
-/* extern variables */
-extern bool isinlinedmethod;
-extern int cumjcodelength;
-extern int cummaxstack;
-extern int cumextablelength;
-extern inlining_methodinfo *inlining_rootinfo;
-
+typedef struct t_inlining_globals { // try in parse.h with struct not include
+ bool isinlinedmethod;
+ int cumjcodelength; /* cumulative immediate intruction length */
+ int cummaxstack;
+ int cumextablelength;
+ int cumlocals; /* was static */
+ int cummethods; /* was static */
+ list *inlining_stack; /* was static */
+ inlining_methodinfo *inlining_rootinfo;
+ methodinfo *method;
+ classinfo *class;
+ int jcodelength;
+ u1 *jcode;
+} t_inlining_globals;
/* function prototypes*/
-void inlining_init(methodinfo *m);
-void inlining_cleanup();
-void inlining_push_compiler_variables(methodinfo *m,
- int i, int p, int nextp, int opcode,
- inlining_methodinfo* inlinfo);
-void inlining_pop_compiler_variables(methodinfo *m,
- int *i, int *p, int *nextp, int *opcode,
- inlining_methodinfo** inlinfo);
-void inlining_set_compiler_variables_fun(methodinfo *m);
+t_inlining_globals *inlining_init(methodinfo *m);
+void inlining_cleanup(t_inlining_globals *inline_env);
+void inlining_push_compiler_variables(
+ int i, int p, int nextp, int opcode,
+ inlining_methodinfo* inlinfo,
+ t_inlining_globals *inline_env);
+void inlining_pop_compiler_variables(
+ int *i, int *p, int *nextp, int *opcode,
+ inlining_methodinfo **inlinfo,
+ t_inlining_globals *inline_env);
+void inlining_set_compiler_variables_fun(methodinfo *m,
+ t_inlining_globals *inline_env);
classinfo *first_occurence(classinfo* class, utf* name, utf* desc);
bool is_unique_rec(classinfo *class, methodinfo *m, utf* name, utf* desc);
bool is_unique_method(classinfo *class, methodinfo *m, utf* name, utf* desc);
-inlining_methodinfo *inlining_analyse_method(methodinfo *m, int level, int gp,
- int firstlocal, int maxstackdepth);
+inlining_methodinfo *inlining_analyse_method(methodinfo *m,
+ int level, int gp,
+ int firstlocal, int maxstackdepth, t_inlining_globals *inline_env);
+void print_t_inlining_globals (t_inlining_globals *g);
+void print_inlining_stack ( list *s);
+void print_inlining_methodinfo( inlining_methodinfo *r);
#define inlining_save_compiler_variables() \
- inlining_push_compiler_variables(m, i, p, nextp, opcode, inlinfo)
+ inlining_push_compiler_variables(i,p,nextp,opcode,inlinfo,inline_env)
#define inlining_restore_compiler_variables() \
- inlining_pop_compiler_variables(m, &i, &p, &nextp, &opcode, &inlinfo)
+ inlining_pop_compiler_variables(&i, &p, &nextp, &opcode, &inlinfo, \
+ inline_env)
#define inlining_set_compiler_variables(i) \
do { \
p = nextp = 0; \
- inlining_set_compiler_variables_fun(i->method); \
+ inlining_set_compiler_variables_fun(i->method, inline_env); \
inlinfo = i; \
} while (0)
Changes: Edwin Steiner
- $Id: jit.c 1407 2004-08-17 12:42:34Z twisti $
+ $Id: jit.c 1414 2004-10-04 12:55:33Z carolyn $
*/
utf_display_classname(m->class->name);printf(".");utf_display(m->name);
printf("\n");
}
-
/* now the jit is running */
jitrunning = true;
static methodptr jit_compile_intern(methodinfo *m)
{
+t_inlining_globals *inline_env = NULL;
/* if there is no javacode, print error message and return empty method */
if (!m->jcode) {
reg_init(m);
/* must be called before reg_setup, because it can change maxlocals */
- if (useinlining)
- inlining_init(m);
+ /* init reqd to initialize for parse even in no inlining */
+ inline_env = inlining_init(m);
reg_setup(m);
if (compileverbose)
log_message_method("Parsing: ", m);
- if (!parse(m)) {
+ if (!parse(m, inline_env)) {
if (compileverbose)
log_message_method("Exception while parsing: ", m);
Changes: Carolyn Oates
Edwin Steiner
- $Id: parse.c 1373 2004-08-01 21:56:36Z stefan $
+ $Id: parse.c 1414 2004-10-04 12:55:33Z carolyn $
+Extra print is due backing changes that removed globals and merged variables that should not be merged... They will be removed... do not delete yet.
*/
#include "toolbox/memory.h"
#include "toolbox/logging.h"
+#define DEBUGMETH(mm) \
+if (DEBUG == true) \
+ { \
+ printf("PARSE method name ="); \
+ utf_display(mm->class->name); \
+ printf("."); \
+ method_display(mm); \
+ fflush(stdout); \
+ }
+
+bool DEBUG = false;
+bool DEBUG2 = false;
+bool DEBUG3 = false;
/* data about the currently parsed method */
/*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
+#define debug_writebranch if (DEBUG2==true) printf("op:: %s i: %d label_index[i]: %d label_index=%p\n",opcode_names[opcode], i, label_index[i],label_index);
+#define debug_writebranch1
/* function descriptor2typesL ***************************************************
*******************************************************************************/
-static exceptiontable* fillextable(methodinfo *m, exceptiontable* extable, exceptiontable *raw_extable, int exceptiontablelength, int *label_index, int *block_count)
+static exceptiontable* fillextable(methodinfo *m,
+ exceptiontable* extable, exceptiontable *raw_extable,
+ int exceptiontablelength,
+ int *label_index, int *block_count,
+ t_inlining_globals *inline_env)
{
int b_count, i, p;
if (exceptiontablelength == 0)
return extable;
+//if (m->exceptiontablelength > 0) {
+// DEBUGMETH(m);
+// printf("m->exceptiontablelength=%i\n",m->exceptiontablelength);
+// panic("exceptiontablelength > 0");
+// }
+
b_count = *block_count;
for (i = 0; i < exceptiontablelength; i++) {
if (label_index != NULL) p = label_index[p];
extable[i].startpc = p;
bound_check(p);
+if (DEBUG3==true) {printf("B1 EEE1 \t"); fflush(stdout);}
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 < m->jcodelength)
- block_insert(p);
+ if (p < m->jcodelength) {
+if (DEBUG3==true) {printf("B2 EEE2 \t"); fflush(stdout);}
+ block_insert(p); }
p = raw_extable[i].handlerpc;
if (label_index != NULL) p = label_index[p];
extable[i].handlerpc = p;
bound_check(p);
+if (DEBUG3==true) {printf("B3 EEE3 \t"); fflush(stdout);}
block_insert(p);
extable[i].catchtype = raw_extable[i].catchtype;
-methodinfo *parse(methodinfo *m)
+methodinfo *parse(methodinfo *m, t_inlining_globals *inline_env)
{
- int p; /* java instruction counter */
- int nextp; /* start of next java instruction */
- int opcode; /* java opcode */
- int i; /* temporary for different uses (counters) */
- int ipc = 0; /* intermediate instruction counter */
- int b_count = 0; /* basic block counter */
- int s_count = 0; /* stack element counter */
+ int p; /* java instruction counter */
+ int nextp; /* start of next java instruction */
+ int opcode; /* java opcode */
+ int i; /* temporary for different uses (ctrs)*/
+ int ipc = 0; /* intermediate instruction counter */
+ int b_count = 0; /* basic block counter */
+ int s_count = 0; /* stack element counter */
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 */
- int gp; /* global java instruction counter */
- /* inlining info for current method */
- inlining_methodinfo *inlinfo = inlining_rootinfo;
+ bool iswide = false; /* true if last instruction was a wide*/
+ instruction *iptr; /* current ptr into instruction array */
+ int gp; /* global java instruction counter */
+ /* inlining info for current method */
+
+ inlining_methodinfo *inlinfo = inline_env->inlining_rootinfo;
inlining_methodinfo *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 */
- exceptiontable* nextex; /* points next free entry in extable */
+ 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 */
+ exceptiontable* nextex; /* points next free entry in extable */
u1 *instructionstart; /* 1 for pcs which are valid instr. starts */
u2 lineindex=0;
u2 currentline=0;
u2 linepcchange=0;
- bool useinltmp;
+if (DEBUG==true) {printf("PARSING: "); fflush(stdout);
+DEBUGMETH(m);
+}
/* INLINING */
if (useinlining) {
label_index = inlinfo->label_index;
- m->maxstack = cummaxstack;
- m->exceptiontablelength = cumextablelength;
- }
-
- useinltmp = useinlining; /* FIXME remove this after debugging */
- /*useinlining = false;*/ /* and merge the if-statements */
-
- if (!useinlining) {
-/* cumjcodelength = m->jcodelength; */
-
- } else {
- tmpinlinf = (inlining_methodinfo*) list_first(inlinfo->inlinedmethods);
+ m->maxstack = inline_env->cummaxstack;
+ m->exceptiontablelength = inline_env->cumextablelength;
+ tmpinlinf = (inlining_methodinfo*)
+ list_first(inlinfo->inlinedmethods);
if (tmpinlinf != NULL) nextgp = tmpinlinf->startgp;
}
- if ((opt_rt || opt_xta || opt_vta) && (pOpcodes == 2 || pOpcodes == 3)) {
- printf("PARSE method name =");
- utf_display(m->class->name);
- printf(".");
- method_display(m);
- printf(">\n\n");
- fflush(stdout);
- }
-
- if (opt_rt || opt_xta) {
- RT_jit_parse(m);
-
- } else {
- if (opt_vta)
- printf("VTA requested, but not yet implemented\n");
- }
-
+/**** static analysis has to be called before inlining
+ which has to be called before reg_set
+ which has to be called before parse (or ???)
+ will check if method being parsed was analysed here
+ ****/
+ if (opt_rt) {
+ /**RT_jit_parse(m);**/
+ printf("RTA requested, not available\n");
+ }
+ if (opt_xta) {
+ /**RT_jit_parse(m);**/
+ printf("XTA requested, not available\n");
+ }
+ if (opt_vta)
+ printf("VTA requested, not yet implemented\n");
/* allocate instruction array and block index table */
- /* 1 additional for end ipc */
+ /* 1 additional for end ipc * # cum inline methods*/
- m->basicblockindex = DMNEW(s4, m->jcodelength + 1);
- memset(m->basicblockindex, 0, sizeof(s4) * (m->jcodelength + 1));
+ m->basicblockindex = DMNEW(s4, inline_env->cumjcodelength + inline_env->cummethods);
+ memset(m->basicblockindex, 0, sizeof(s4) * (inline_env->cumjcodelength + inline_env->cummethods));
- instructionstart = DMNEW(u1, m->jcodelength + 1);
- memset(instructionstart, 0, sizeof(u1) * (m->jcodelength + 1));
+ instructionstart = DMNEW(u1, inline_env->cumjcodelength + inline_env->cummethods);
+ memset(instructionstart, 0, sizeof(u1) * (inline_env->cumjcodelength + inline_env->cummethods));
/* 1 additional for TRACEBUILTIN and 4 for MONITORENTER/EXIT */
/* additional MONITOREXITS are reached by branches which are 3 bytes */
- iptr = m->instructions = DMNEW(instruction, m->jcodelength + 5);
+ iptr = m->instructions = DMNEW(instruction, inline_env->cumjcodelength + 5);
/* Zero the intermediate instructions array so we don't have any
* invalid pointers in it if we cannot finish analyse_stack(). */
- memset(iptr, 0, sizeof(instruction) * (m->jcodelength + 5));
+ memset(iptr, 0, sizeof(instruction) * (inline_env->cumjcodelength + 5));
/* compute branch targets of exception table */
-
-/* m->exceptiontable = DMNEW(exceptiontable, m->exceptiontablelength + 1); */
- /*
- for (i = 0; i < method->m->exceptiontablelength; i++) {
-
- p = m->exceptiontable[i].startpc = raw_extable[i].startpc;
- if (useinlining) p = label_index[p];
- bound_check(p);
- block_insert(p);
-
- p = m->exceptiontable[i].endpc = raw_extable[i].endpc;
- if (useinlining) p = label_index[p];
- bound_check1(p);
- if (p < cumjcodelength)
- block_insert(p);
-
- p = m->exceptiontable[i].handlerpc = raw_extable[i].handlerpc;
- bound_check(p);
- block_insert(p);
-
- m->exceptiontable[i].catchtype = raw_extable[i].catchtype;
-
- m->exceptiontable[i].next = NULL;
- m->exceptiontable[i].down = &m->exceptiontable[i+1];
- }
- */
-
- nextex = fillextable(m, m->exceptiontable, m->exceptiontable, m->exceptiontablelength, label_index, &b_count);
-
+//if (m->exceptiontable == NULL) {
+// printf("m->exceptiontable=NULL\n");fflush(stdout);
+// }
+//else {
+// printf("m->exceptiontable != NULL\n");fflush(stdout);
+// }
+//printf("m->exceptiontablelength=%i, inline_env->method->exceptiontablelength=%i,inline_env->cumextablelength=%i\n",
+//m->exceptiontablelength, inline_env->method->exceptiontablelength,inline_env->cumextablelength);
+
+//if (m->exceptiontablelength > 0)
+// m->exceptiontable = DMNEW(exceptiontable, m->exceptiontablelength + 1);
+
+ nextex = fillextable(m,
+ m->exceptiontable, m->exceptiontable, m->exceptiontablelength,
+ label_index, &b_count, inline_env);
s_count = 1 + m->exceptiontablelength; /* initialize stack element counter */
#ifdef USE_THREADS
linepcchange = m->linenumbers[0].start_pc;
}
- for (p = 0, gp = 0; p < m->jcodelength; gp += (nextp - p), p = nextp) {
+ for (p = 0, gp = 0; p < inline_env->method->jcodelength; gp += (nextp - p), p = nextp) {
- /* DEBUG */ /*printf("p:%d gp:%d ",p,gp);*/
+ /* DEBUG */ if (DEBUG==true) printf("----- p:%d gp:%d\n",p,gp);
/* mark this position as a valid instruction start */
if (!iswide) {
bool *readonly = NULL;
- opcode = code_get_u1(p);
+ opcode = code_get_u1(p,inline_env->method);
nextp = p += jcommandsize[opcode];
- if (nextp > m->jcodelength)
+ if (nextp > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
tmpinlinf = list_first(inlinfo->inlinedmethods);
firstlocal = tmpinlinf->firstlocal;
/* m->basicblockindex[gp] |= (ipc << 1);*/ /*FIXME: necessary ? */
}
-
+if (DEBUG==true) {
+printf("BEFORE SAVE: "); fflush(stdout);
+DEBUGMETH(inline_env->method);
+}
inlining_save_compiler_variables();
+if (DEBUG==true) {
+printf("AFTER SAVE: "); fflush(stdout);
+DEBUGMETH(inline_env->method);
+}
inlining_set_compiler_variables(tmpinlinf);
- if (compileverbose) {
- char logtext[MAXLOGTEXT];
- sprintf(logtext, "Parsing (inlined): ");
- utf_sprint(logtext+strlen(logtext), m->class->name);
- strcpy(logtext+strlen(logtext), ".");
- utf_sprint(logtext+strlen(logtext), m->name);
- utf_sprint(logtext+strlen(logtext), m->descriptor);
- log_text(logtext);
+if (DEBUG==true) {
+printf("AFTER SET :: "); fflush(stdout);
+DEBUGMETH(inline_env->method);
+}
+ if (DEBUG) {
+ printf("\n.......Parsing (inlined): ");
+ DEBUGMETH(m);
+ DEBUGMETH(inline_env->method);
}
+////label_index = inlinfo->label_index;
if (inlinfo->inlinedmethods == NULL) {
tmpinlinf = list_first(inlinfo->inlinedmethods);
nextgp = (tmpinlinf != NULL) ? tmpinlinf->startgp : -1;
}
- if (m->exceptiontablelength > 0)
- nextex = fillextable(m, nextex, m->exceptiontable, m->exceptiontablelength, label_index, &b_count);
+ if (inline_env->method->exceptiontablelength > 0)
+ nextex = fillextable(m, nextex,
+ inline_env->method->exceptiontable, inline_env->method->exceptiontablelength,
+ label_index, &b_count, inline_env);
continue;
}
- opcode = code_get_u1(p); /* fetch op code */
-
-
- if (opt_rt && (pOpcodes == 2 || pOpcodes == 3)) {
- printf("Parse<%i> p=%i<%i< opcode=<%i> %s\n",
- pOpcodes, p, rt_jcodelength, opcode, icmd_names[opcode]);
+ opcode = code_get_u1(p,inline_env->method); /* fetch op code */
+ if (DEBUG==true)
+ {
+ printf("Parse p=%i<%i< opcode=<%i> %s\n",
+ p, rt_jcodelength, opcode, opcode_names[opcode]);
}
- m->basicblockindex[gp] |= (ipc << 1); /* store intermediate count */
+//printf("basicblockindex[gp=%i]=%i=%p ipc=%i=%p shifted ipc=%i=%p\n",
+//gp,m->basicblockindex[gp],m->basicblockindex[gp],ipc,ipc,(ipc<<1),(ipc<<1));
+//fflush(stdout);
+ m->basicblockindex[gp] |= (ipc << 1); /*store intermed cnt*/
+//printf("basicblockindex[gp=%i]=%i=%p \n",
+//gp,m->basicblockindex[gp],m->basicblockindex[gp]);
+//fflush(stdout);
if (blockend) {
+//printf("B4 BEND\t"); fflush(stdout);
block_insert(gp); /* start new block */
blockend = false;
}
nextp = p + jcommandsize[opcode]; /* compute next instruction start */
- if (nextp > m->jcodelength)
+ if (nextp > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
s_count += stackreq[opcode]; /* compute stack element count */
/* pushing constants onto the stack p */
case JAVA_BIPUSH:
- LOADCONST_I(code_get_s1(p+1));
+ LOADCONST_I(code_get_s1(p+1,inline_env->method));
break;
case JAVA_SIPUSH:
- LOADCONST_I(code_get_s2(p+1));
+ LOADCONST_I(code_get_s2(p+1,inline_env->method));
break;
case JAVA_LDC1:
- i = code_get_u1(p+1);
+ i = code_get_u1(p+1,inline_env->method);
+
goto pushconstantitem;
case JAVA_LDC2:
case JAVA_LDC2W:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
pushconstantitem:
- if (i >= m->class->cpcount)
+ if (i >= inline_env->method->class->cpcount)
panic ("Attempt to access constant outside range");
- switch (m->class->cptags[i]) {
+ switch (inline_env->method->class->cptags[i]) {
case CONSTANT_Integer:
- LOADCONST_I(((constant_integer *) (m->class->cpinfos[i]))->value);
+ LOADCONST_I(((constant_integer *) (inline_env->method->class->cpinfos[i]))->value);
break;
case CONSTANT_Long:
- LOADCONST_L(((constant_long *) (m->class->cpinfos[i]))->value);
+ LOADCONST_L(((constant_long *) (inline_env->method->class->cpinfos[i]))->value);
break;
case CONSTANT_Float:
- LOADCONST_F(((constant_float *) (m->class->cpinfos[i]))->value);
+ LOADCONST_F(((constant_float *) (inline_env->method->class->cpinfos[i]))->value);
break;
case CONSTANT_Double:
- LOADCONST_D(((constant_double *) (m->class->cpinfos[i]))->value);
+ LOADCONST_D(((constant_double *) (inline_env->method->class->cpinfos[i]))->value);
break;
case CONSTANT_String:
- LOADCONST_A(literalstring_new((utf *) (m->class->cpinfos[i])));
+ LOADCONST_A(literalstring_new((utf *) (inline_env->method->class->cpinfos[i])));
break;
default: panic("Invalid constant type to push");
}
case JAVA_DLOAD:
case JAVA_ALOAD:
if (!iswide) {
- i = code_get_u1(p + 1);
+ i = code_get_u1(p + 1,inline_env->method);
} else {
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
nextp = p + 3;
iswide = false;
}
case JAVA_DSTORE:
case JAVA_ASTORE:
if (!iswide) {
- i = code_get_u1(p + 1);
+ i = code_get_u1(p + 1,inline_env->method);
} else {
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
iswide = false;
nextp = p + 3;
}
int v;
if (!iswide) {
- i = code_get_u1(p + 1);
- v = code_get_s1(p + 2);
+ i = code_get_u1(p + 1,inline_env->method);
+ v = code_get_s1(p + 2,inline_env->method);
} else {
- i = code_get_u2(p + 1);
- v = code_get_s2(p + 3);
+ i = code_get_u2(p + 1,inline_env->method);
+ v = code_get_s2(p + 3,inline_env->method);
iswide = false;
nextp = p + 5;
}
case JAVA_NEWARRAY:
OP(ICMD_CHECKASIZE);
- switch (code_get_s1(p + 1)) {
+ switch (code_get_s1(p + 1,inline_env->method)) {
case 4:
BUILTIN1(BUILTIN_newarray_boolean, TYPE_ADR,currentline);
break;
case JAVA_ANEWARRAY:
OP(ICMD_CHECKASIZE);
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
classinfo *component =
- (classinfo *) class_getconstant(m->class, i, CONSTANT_Class);
+ (classinfo *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
if (!class_load(component))
return NULL;
break;
case JAVA_MULTIANEWARRAY:
- m->isleafmethod = false;
- i = code_get_u2(p + 1);
+ inline_env->method->isleafmethod = false;
+ i = code_get_u2(p + 1,inline_env->method);
{
vftbl_t *arrayvftbl;
- s4 v = code_get_u1(p + 3);
+ s4 v = code_get_u1(p + 3,inline_env->method);
/* vftbl *arrayvftbl = */
classinfo *component =
- (classinfo *) class_getconstant(m->class, i, CONSTANT_Class);
+ (classinfo *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
if (!class_load(component))
return NULL;
case JAVA_IF_ACMPNE:
case JAVA_GOTO:
case JAVA_JSR:
- i = p + code_get_s2(p + 1);
+ i = p + code_get_s2(p + 1,inline_env->method);
if (useinlining) {
debug_writebranch;
i = label_index[i];
}
bound_check(i);
+if (DEBUG3==true) {
+printf("B5 IFs/GOTO\t"); fflush(stdout);}
block_insert(i);
blockend = true;
OP1(opcode, i);
break;
case JAVA_GOTO_W:
case JAVA_JSR_W:
- i = p + code_get_s4(p + 1);
+ i = p + code_get_s4(p + 1,inline_env->method);
if (useinlining) {
debug_writebranch;
i = label_index[i];
}
bound_check(i);
+//printf("B6 JSR_W\t"); fflush(stdout);
block_insert(i);
blockend = true;
OP1(opcode, i);
case JAVA_RET:
if (!iswide) {
- i = code_get_u1(p + 1);
+ i = code_get_u1(p + 1,inline_env->method);
} else {
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
nextp = p + 3;
iswide = false;
}
blockend = true;
/*
- if (isinlinedmethod) {
+ if (inline_env->isinlinedmethod) {
OP1(ICMD_GOTO, inlinfo->stopgp);
break;
}*/
case JAVA_DRETURN:
case JAVA_ARETURN:
case JAVA_RETURN:
- if (isinlinedmethod) {
+ if (inline_env->isinlinedmethod) {
/* if (p==m->jcodelength-1) {*/ /* return is at end of inlined method */
/* OP(ICMD_NOP); */
/* break; */
blockend = true;
nextp = ALIGN((p + 1), 4);
- if (nextp + 8 > m->jcodelength)
+ if (nextp + 8 > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
if (!useinlining) {
- tablep = (s4 *) (m->jcode + nextp);
+ tablep = (s4 *) (inline_env->method->jcode + nextp);
} else {
- num = code_get_u4(nextp + 4);
+ num = code_get_u4(nextp + 4,inline_env->method);
tablep = DMNEW(s4, num * 2 + 2);
}
/* default target */
- j = p + code_get_s4(nextp);
+ j = p + code_get_s4(nextp,inline_env->method);
if (useinlining)
j = label_index[j];
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
bound_check(j);
+//printf("B7 LOOKUP1\t"); fflush(stdout);
block_insert(j);
/* number of pairs */
- num = code_get_u4(nextp);
+ num = code_get_u4(nextp,inline_env->method);
*tablep = num;
tablep++;
nextp += 4;
- if (nextp + 8*(num) > m->jcodelength)
+ if (nextp + 8*(num) > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
for (i = 0; i < num; i++) {
/* value */
- j = code_get_s4(nextp);
+ j = code_get_s4(nextp,inline_env->method);
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
/* target */
- j = p + code_get_s4(nextp);
+ j = p + code_get_s4(nextp,inline_env->method);
if (useinlining)
j = label_index[j];
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
bound_check(j);
+//printf("B8 LOOKUP2\t"); fflush(stdout);
block_insert(j);
}
blockend = true;
nextp = ALIGN((p + 1), 4);
- if (nextp + 12 > m->jcodelength)
+ if (nextp + 12 > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
if (!useinlining) {
- tablep = (s4 *) (m->jcode + nextp);
+ tablep = (s4 *) (inline_env->method->jcode + nextp);
} else {
- num = code_get_u4(nextp + 8) - code_get_u4(nextp + 4);
+ num = code_get_u4(nextp + 8,inline_env->method) - code_get_u4(nextp + 4,inline_env->method);
tablep = DMNEW(s4, num + 1 + 3);
}
/* default target */
- j = p + code_get_s4(nextp);
+ j = p + code_get_s4(nextp,inline_env->method);
if (useinlining)
j = label_index[j];
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
bound_check(j);
+//printf("B9 TABLESWITCH1\t"); fflush(stdout);
block_insert(j);
/* lower bound */
- j = code_get_s4(nextp);
+ j = code_get_s4(nextp,inline_env->method);
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
/* upper bound */
- num = code_get_s4(nextp);
+ num = code_get_s4(nextp,inline_env->method);
*tablep = num; /* restore for little endian */
tablep++;
nextp += 4;
if (num < 0)
panic("invalid TABLESWITCH: upper bound < lower bound");
- if (nextp + 4*(num+1) > m->jcodelength)
+ if (nextp + 4*(num+1) > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
for (i = 0; i <= num; i++) {
- j = p + code_get_s4(nextp);
+ j = p + code_get_s4(nextp,inline_env->method);
if (useinlining)
j = label_index[j];
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
bound_check(j);
+//printf("B10 TABLESWITCH2\t"); fflush(stdout);
block_insert(j);
}
case JAVA_PUTSTATIC:
case JAVA_GETSTATIC:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
constant_FMIref *fr;
fieldinfo *fi;
- fr = class_getconstant(m->class, i, CONSTANT_Fieldref);
+ fr = class_getconstant(inline_env->method->class, i, CONSTANT_Fieldref);
if (!class_load(fr->class))
return NULL;
fi = class_resolvefield(fr->class,
fr->name,
fr->descriptor,
- m->class,
+ inline_env->method->class,
true);
if (!fi)
OP2A(opcode, fi->type, fi, currentline);
if (!fi->class->initialized) {
- m->isleafmethod = false;
+ inline_env->method->isleafmethod = false;
}
}
break;
case JAVA_PUTFIELD:
case JAVA_GETFIELD:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
constant_FMIref *fr;
fieldinfo *fi;
- fr = class_getconstant(m->class, i, CONSTANT_Fieldref);
+ fr = class_getconstant(inline_env->method->class, i, CONSTANT_Fieldref);
if (!class_load(fr->class))
return NULL;
fi = class_resolvefield(fr->class,
fr->name,
fr->descriptor,
- m->class,
+ inline_env->method->class,
true);
if (!fi)
/* method invocation *****/
case JAVA_INVOKESTATIC:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
constant_FMIref *mr;
methodinfo *mi;
- m->isleafmethod = false;
+ inline_env->method->isleafmethod = false;
- mr = class_getconstant(m->class, i, CONSTANT_Methodref);
+ mr = class_getconstant(inline_env->method->class, i, CONSTANT_Methodref);
if (!class_load(mr->class))
return NULL;
mi = class_resolveclassmethod(mr->class,
mr->name,
mr->descriptor,
- m->class,
+ inline_env->method->class,
true);
if (!mi)
return NULL;
- /*RTAprint*/ if (((pOpcodes == 2) || (pOpcodes == 3)) && opt_rt)
+ /*RTAprint*/// if (((pOpcodes == 2) || (pOpcodes == 3)) && opt_rt)
+if (DEBUG2==true)
/*RTAprint*/ {printf(" method name =");
/*RTAprint*/ utf_display(mi->class->name); printf(".");
/*RTAprint*/ utf_display(mi->name);printf("\tINVOKE STATIC\n");
case JAVA_INVOKESPECIAL:
case JAVA_INVOKEVIRTUAL:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
constant_FMIref *mr;
methodinfo *mi;
- m->isleafmethod = false;
+ inline_env->method->isleafmethod = false;
- mr = class_getconstant(m->class, i, CONSTANT_Methodref);
+ mr = class_getconstant(inline_env->method->class, i, CONSTANT_Methodref);
if (!class_load(mr->class))
return NULL;
mi = class_resolveclassmethod(mr->class,
mr->name,
mr->descriptor,
- m->class,
+ inline_env->method->class,
true);
if (!mi)
return NULL;
- /*RTAprint*/ if (((pOpcodes == 2) || (pOpcodes == 3)) && opt_rt)
+ /*RTAprint*/ // if (((pOpcodes == 2) || (pOpcodes == 3)) && opt_rt)
+if (DEBUG2==true)
/*RTAprint*/ {printf(" method name =");
method_display(mi);
/*RTAprint*/ utf_display(mi->class->name); printf(".");
break;
case JAVA_INVOKEINTERFACE:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
constant_FMIref *mr;
methodinfo *mi;
- m->isleafmethod = false;
+ inline_env->method->isleafmethod = false;
- mr = class_getconstant(m->class, i, CONSTANT_InterfaceMethodref);
+ mr = class_getconstant(inline_env->method->class, i, CONSTANT_InterfaceMethodref);
if (!class_load(mr->class))
return NULL;
mi = class_resolveinterfacemethod(mr->class,
mr->name,
mr->descriptor,
- m->class,
+ inline_env->method->class,
true);
if (!mi)
return NULL;
/* miscellaneous object operations *******/
case JAVA_NEW:
- i = code_get_u2(p + 1);
- LOADCONST_A_BUILTIN(class_getconstant(m->class, i, CONSTANT_Class));
+ i = code_get_u2(p + 1,inline_env->method);
+ LOADCONST_A_BUILTIN(class_getconstant(inline_env->method->class, i, CONSTANT_Class));
s_count++;
BUILTIN1(BUILTIN_new, TYPE_ADR, currentline);
OP(ICMD_CHECKEXCEPTION);
break;
case JAVA_CHECKCAST:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
classinfo *cls =
- (classinfo *) class_getconstant(m->class, i, CONSTANT_Class);
+ (classinfo *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
if (!cls->loaded)
if (!class_load(cls))
break;
case JAVA_INSTANCEOF:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
classinfo *cls =
- (classinfo *) class_getconstant(m->class, i, CONSTANT_Class);
+ (classinfo *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
if (!cls->loaded)
if (!class_load(cls))
/* INLINING */
- if (isinlinedmethod && p == m->jcodelength - 1) { /* end of an inlined method */
+ if (inline_env->isinlinedmethod && p == inline_env->method->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();
+//label_index = inlinfo->label_index;
+if (DEBUG==true) {
+printf("AFTER RESTORE : "); fflush(stdout);
+DEBUGMETH(inline_env->method);
+}
list_remove(inlinfo->inlinedmethods, list_first(inlinfo->inlinedmethods));
if (inlinfo->inlinedmethods == NULL) {
nextgp = -1;
firstlocal = inlinfo->firstlocal;
}
} /* end for */
+/*&&&&&&&&&&&&&&&&*/
+if (DEBUG==true) printf("&&&&&&&&&&&&&&&&\n");
+
if (p != m->jcodelength)
panic("Command-sequence crosses code-boundary");
/* allocate blocks */
-/* for (p = 0; p < cumjcodelength; p++) { */
- for (p = 0; p < m->jcodelength; p++) {
+/* for (p = 0; p < inline_env->cumjcodelength; p++) { */
+ for (p = 0; p < m->jcodelength; p++) {
if (m->basicblockindex[p] & 1) {
/* check if this block starts at the beginning of an instruction */
if (!instructionstart[p])
}
}
- if (useinlining) inlining_cleanup();
- useinlining = useinltmp;
+ if (useinlining) inlining_cleanup(inline_env);
/* just return methodinfo* to signal everything was ok */
Author: Christian Thalinger
- $Id: parse.h 1337 2004-07-21 16:00:33Z twisti $
+ $Id: parse.h 1414 2004-10-04 12:55:33Z carolyn $
*/
#define _PARSE_H
#include "global.h"
+#include "inline.h"
/* intermediate code generating macros */
/*iptr->op1=0;*/ \
iptr->val.i = (v); \
iptr->line = currentline; \
- iptr->method = m; \
+ 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=m;PINC
-#define LOADCONST_F(v) iptr->opc=ICMD_FCONST;/*iptr->op1=0*/;iptr->val.f=(v);iptr->line=currentline;iptr->method=m;PINC
-#define LOADCONST_D(v) iptr->opc=ICMD_DCONST;/*iptr->op1=0*/;iptr->val.d=(v);iptr->line=currentline;iptr->method=m;PINC
-#define LOADCONST_A(v) iptr->opc=ICMD_ACONST;/*iptr->op1=0*/;iptr->val.a=(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
/* 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=m;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=m;PINC
-#define OP1(o,o1) iptr->opc=(o);iptr->op1=(o1);/*iptr->val.l=(0)*/;iptr->line=currentline;iptr->method=m;PINC
-#define OP2I(o,o1,v) iptr->opc=(o);iptr->op1=(o1);iptr->val.i=(v);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 OP2A(o,o1,v,l) \
iptr->opc = (o); \
iptr->op1 = (o1); \
iptr->val.a = (v); \
iptr->line = l; \
- iptr->method = m; \
+ iptr->method = inline_env->method; \
PINC
#define BUILTIN1(v,t,l) \
- m->isleafmethod = false; \
+ inline_env->method->isleafmethod = false; \
iptr->opc = ICMD_BUILTIN1; \
iptr->val.a = (v); \
iptr->op1 = (t); \
iptr->line = (l); \
- iptr->method = m; \
+ iptr->method = inline_env->method; \
PINC
-#define BUILTIN2(v,t,l) m->isleafmethod=false;iptr->opc=ICMD_BUILTIN2;iptr->op1=t;\
- iptr->val.a=(v);iptr->line=l;iptr->method=m;PINC
-#define BUILTIN3(v,t,l) m->isleafmethod=false;iptr->opc=ICMD_BUILTIN3;iptr->op1=t;\
- iptr->val.a=(v);iptr->line=l;iptr->method=m;PINC
+#define BUILTIN2(v,t,l) inline_env->method->isleafmethod=false;iptr->opc=ICMD_BUILTIN2;iptr->op1=t;\
+ iptr->val.a=(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.a=(v);iptr->line=l;iptr->method=inline_env->method;PINC
/* We have to check local variables indices here because they are
#define INDEX_ONEWORD(num) \
do { \
- if ((num) < 0 || (num) >= m->maxlocals) { \
+ if ((num) < 0 || (num) >= inline_env->cumlocals) { \
*exceptionptr = \
- new_verifyerror(m, "Illegal local variable number"); \
+ new_verifyerror(inline_env->method, "Illegal local variable number"); \
return NULL; \
} \
} while (0)
#define INDEX_TWOWORD(num) \
do { \
- if ((num) < 0 || ((num) + 1) >= m->maxlocals) { \
+ if ((num) < 0 || ((num) + 1) >= inline_env->cumlocals) { \
*exceptionptr = \
- new_verifyerror(m, "Illegal local variable number"); \
+ new_verifyerror(inline_env->method, "Illegal local variable number"); \
return NULL; \
} \
} while (0)
if (!(m->basicblockindex[(i)] & 1)) { \
b_count++; \
m->basicblockindex[(i)] |= 1; \
+ if (DEBUG==true){printf("---------------------block_inserted:b_count=%i m->basicblockindex[(i=%i)]=%i=%p\n",b_count,i,m->basicblockindex[(i)],m->basicblockindex[(i)]); \
+ fflush(stdout); } \
} \
} while (0)
#define bound_check(i) \
do { \
-/* if (i < 0 || i >= cumjcodelength) { */\
- if (i < 0 || i >= m->jcodelength) { \
+ 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(m, "Illegal target of jump or branch"); \
+ 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) { */\
- if (i < 0 || i > m->jcodelength) { \
+ if (i < 0 || i > inline_env->cumjcodelength) { \
+/* if (i < 0 || i > m->jcodelength) { */ \
*exceptionptr = \
- new_verifyerror(m, "Illegal target of jump or branch"); \
+ new_verifyerror(inline_env->method, "Illegal target of jump or branch"); \
return NULL; \
} \
} while (0)
*******************************************************************************/
-#define code_get_u1(p) m->jcode[p]
-#define code_get_s1(p) ((s1)m->jcode[p])
-#define code_get_u2(p) ((((u2)m->jcode[p]) << 8) + m->jcode[p + 1])
-#define code_get_s2(p) ((s2)((((u2)m->jcode[p]) << 8) + m->jcode[p + 1]))
-#define code_get_u4(p) ((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
+#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) ((s4)((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
+#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]))
void compiler_addinitclass(classinfo *c);
classSetNode * descriptor2typesL(methodinfo *m);
void descriptor2types(methodinfo *m);
-methodinfo *parse(methodinfo *m);
+methodinfo *parse(methodinfo *m,t_inlining_globals *inline_env);
#endif /* _PARSE_H */
/* jit/inline.c - code inliner
+globals moved to structure and passed as parameter
+
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,
Authors: Dieter Thuernbeck
- $Id: inline.c 1236 2004-06-30 19:53:03Z twisti $
+ $Id: inline.c 1414 2004-10-04 12:55:33Z carolyn $
*/
#include "toolbox/logging.h"
#include "toolbox/memory.h"
+#define METHINFO(m) \
+ utf_display(m->class->name); printf("."); fflush(stdout); \
+ method_display(m); fflush(stdout); \
+
+#define IMETHINFO(m) \
+ utf_display(m->class->name); printf("."); fflush(stdout); \
+ method_display(m); fflush(stdout); \
+ printf("\tm->jcodelength=%i; ",m->jcodelength); fflush(stdout); \
+ printf("m->jcode=%p;\n",m->jcode); fflush(stdout); \
+ printf("\tm->maxlocals=%i; ",m->maxlocals); fflush(stdout); \
+ printf("m->maxstack=%i;\n",m->maxstack); fflush(stdout);
+bool DEBUGi = false;
// checked functions and macros: LOADCONST code_get OP1 BUILTIN block_insert bound_check ALIGN
// replace jcodelength loops with correct number after main for loop in parse()!
-static list *inlining_stack;
-//static list *inlining_patchlist;
-bool isinlinedmethod;
-int cumjcodelength; /* cumulative immediate intruction length */
-static int cumlocals;
-int cummaxstack;
-int cumextablelength;
-static int cummethods;
-inlining_methodinfo *inlining_rootinfo;
+/*-----------------------------------------------------------*/
+/* just initialize global structure for non-inlining */
+/*-----------------------------------------------------------*/
+t_inlining_globals *inlining_init0(methodinfo *m,
+ t_inlining_globals *inline_env)
+{
+ /* initialization for normal use in parse */
+ inlining_set_compiler_variables_fun(m, inline_env);
+ inline_env->isinlinedmethod = 0;
+ inline_env->cumjcodelength = m->jcodelength; /* for not inlining */
+ inline_env->cummaxstack = 0;
+ inline_env->cumextablelength = 0;
+ inline_env->cumlocals = m->maxlocals;
+ inline_env->cummethods = 0;//co not global or static-used only here?
+ inline_env->inlining_stack = NULL;
+ inline_env->inlining_rootinfo = NULL;
+return inline_env;
+}
+/*-----------------------------------------------------------*/
-void inlining_init(methodinfo *m)
+t_inlining_globals *inlining_init(methodinfo *m)
{
- inlining_stack = NULL;
- // inlining_patchlist = NULL;
- isinlinedmethod = 0;
- cumjcodelength = 0;
- cumlocals = 0;
- cumextablelength = 0;
- cummaxstack = 0;
- cummethods = 0;
-
- inlining_stack = NEW(list);
- list_init(inlining_stack, OFFSET(t_inlining_stacknode, linkage));
-
- inlining_rootinfo = inlining_analyse_method(m, 0, 0, 0, 0);
- m->maxlocals = cumlocals;
- m->maxstack = cummaxstack;
+ t_inlining_globals *inline_env = DNEW(t_inlining_globals);
+ inlining_init0(m,inline_env);
+if (useinlining)
+ {
+if (DEBUGi==true) {
+ printf("\n-------- Inlining init for: "); fflush(stdout);
+ IMETHINFO(m)
+ }
+ inline_env->cumjcodelength = 0;
+ inline_env->inlining_stack = NEW(list);
+ list_init(inline_env->inlining_stack,
+ OFFSET(t_inlining_stacknode, linkage));
+ /*------ analyze ------*/
+if (DEBUGi==true) {print_t_inlining_globals(inline_env);}
+ inline_env->inlining_rootinfo
+ = inlining_analyse_method(m, 0, 0, 0, 0, inline_env);
+if (DEBUGi==true) {print_t_inlining_globals(inline_env);}
+ /*---------------------*/
+ //if (inline_env->cummethods == 0) {
+ // inline_env = DNEW(t_inlining_globals);
+ // inlining_init0(m,inline_env);
+ // return inline_env;
+ // }
+if (DEBUGi==true) {
+ printf("(l,s) (%i,%i) was (%i,%i)\n",
+ m->maxlocals, inline_env->cumlocals,
+ m->maxstack, inline_env->cummaxstack); fflush(stdout);
+ }
+ m->maxlocals = inline_env->cumlocals; //orig not used
+ m->maxstack = inline_env->cummaxstack; //orig global maxstack var!!
+
+//panic("TEMP so can test just inline init\n");
+ }
+return inline_env;
}
-void inlining_cleanup()
+void inlining_cleanup(t_inlining_globals *inline_env)
{
- FREE(inlining_stack, t_inlining_stacknode);
+ FREE(inline_env->inlining_stack, t_inlining_stacknode);
}
-void inlining_push_compiler_variables(methodinfo *m, int i, int p, int nextp, int opcode, inlining_methodinfo *inlinfo)
+void inlining_push_compiler_variables(int i, int p, int nextp, int opcode, inlining_methodinfo *inlinfo, t_inlining_globals *inline_env)
{
t_inlining_stacknode *new = NEW(t_inlining_stacknode);
new->p = p;
new->nextp = nextp;
new->opcode = opcode;
- new->method = m;
- // new->patchlist = inlining_patchlist;
+ new->method = inline_env->method;
new->inlinfo = inlinfo;
- list_addfirst(inlining_stack, new);
- isinlinedmethod++;
+ list_addfirst(inline_env->inlining_stack, new);
+ inline_env->isinlinedmethod++;
}
-void inlining_pop_compiler_variables(methodinfo *m, int *i, int *p, int *nextp, int *opcode, inlining_methodinfo **inlinfo)
+void inlining_pop_compiler_variables(
+ int *i, int *p, int *nextp, int *opcode,
+ inlining_methodinfo **inlinfo,
+ t_inlining_globals *inline_env)
{
- t_inlining_stacknode *tmp = (t_inlining_stacknode *) list_first(inlining_stack);
+ t_inlining_stacknode *tmp
+ = (t_inlining_stacknode *) list_first(inline_env->inlining_stack);
- if (!isinlinedmethod) panic("Attempting to pop from inlining stack in toplevel method!\n");
+ if (!inline_env->isinlinedmethod) panic("Attempting to pop from inlining stack in toplevel method!\n");
*i = tmp->i;
*p = tmp->p;
*opcode = tmp->opcode;
*inlinfo = tmp->inlinfo;
- /* XXX TWISTI */
-/* method = tmp->method; */
-/* class = method->class; */
-/* jcodelength = method->jcodelength; */
-/* jcode = method->jcode; */
- // inlining_patchlist = tmp->patchlist;
-
- list_remove(inlining_stack, tmp);
- FREE(tmp, t_inlining_stacknode);
- isinlinedmethod--;
+ inline_env->method = tmp->method; /*co*/
+ inline_env->class = inline_env->method->class; /*co*/
+ inline_env->jcodelength = inline_env->method->jcodelength; /*co*/
+ inline_env->jcode = inline_env->method->jcode; /*co*/
+
+ list_remove(inline_env->inlining_stack, tmp);
+ FREE(tmp, t_inlining_stacknode);
+ inline_env->isinlinedmethod--;
}
-void inlining_set_compiler_variables_fun(methodinfo *m)
+void inlining_set_compiler_variables_fun(methodinfo *m,
+ t_inlining_globals *inline_env)
{
/* XXX TWISTI */
-/* method = m; */
-/* class = m->class; */
-/* jcodelength = m->jcodelength; */
-/* jcode = m->jcode; */
-
- // inlining_patchlist = DNEW(list);
- // list_init(inlining_patchlist, OFFSET(t_patchlistnode, linkage));
+ inline_env->method = m; /*co*/
+ inline_env->class = m->class; /*co*/
+ inline_env->jcode = m->jcode; /*co*/
+ inline_env->jcodelength = m->jcodelength; /*co*/
}
-/*void inlining_addpatch(instruction *iptr)
- {
- t_patchlistnode *patch = DNEW(t_patchlistnode);
- patch->iptr = iptr;
- list_addlast(inlining_patchlist, patch);
- }*/
-
-
classinfo *first_occurence(classinfo* class, utf* name, utf* desc)
{
classinfo *first = class;
return is_unique_rec(class, m, name, desc);
}
-
-inlining_methodinfo *inlining_analyse_method(methodinfo *m, int level, int gp, int firstlocal, int maxstackdepth)
+inlining_methodinfo *inlining_analyse_method(methodinfo *m,
+ int level, int gp,
+ int firstlocal, int maxstackdepth,
+ t_inlining_globals *inline_env)
{
inlining_methodinfo *newnode = DNEW(inlining_methodinfo);
- u1 *jcode = m->jcode;
+ /*u1 *jcode = m->jcode;*/
int jcodelength = m->jcodelength;
int p;
int nextp;
int opcode;
int i;
-/* int lastlabel = 0; */
bool iswide = false, oldiswide;
bool *readonly = NULL;
int *label_index = NULL;
readonly = NULL;
}
- label_index = DMNEW(int, jcodelength);
+ label_index = DMNEW(int, jcodelength+200);
newnode->inlinedmethods = DNEW(list);
list_init(newnode->inlinedmethods, OFFSET(inlining_methodinfo, linkage));
newnode->readonly = readonly;
newnode->label_index = label_index;
newnode->firstlocal = firstlocal;
- cumjcodelength += jcodelength + m->paramcount + 1 + 5;
+ inline_env->cumjcodelength += jcodelength + m->paramcount + 1 + 5;
- if ((firstlocal + m->maxlocals) > cumlocals) {
- cumlocals = firstlocal + m->maxlocals;
+ if ((firstlocal + m->maxlocals) > inline_env->cumlocals) {
+ inline_env->cumlocals = firstlocal + m->maxlocals;
}
- if ((maxstackdepth + m->maxstack) > cummaxstack) {
- cummaxstack = maxstackdepth + m->maxstack;
+ if ((maxstackdepth + m->maxstack) > inline_env->cummaxstack) {
+ inline_env->cummaxstack = maxstackdepth + m->maxstack;
}
- cumextablelength += m->exceptiontablelength;
+ inline_env->cumextablelength += m->exceptiontablelength;
for (p = 0; p < jcodelength; gp += (nextp - p), p = nextp) {
- opcode = code_get_u1 (p);
+ opcode = code_get_u1 (p,m);
nextp = p + jcommandsize[opcode];
oldiswide = iswide;
case JAVA_LOOKUPSWITCH:
nextp = ALIGN((p + 1), 4) + 4;
- nextp += code_get_u4(nextp) * 8 + 4;
+ nextp += code_get_u4(nextp,m) * 8 + 4;
break;
case JAVA_TABLESWITCH:
nextp = ALIGN((p + 1), 4) + 4;
- nextp += (code_get_u4(nextp+4) - code_get_u4(nextp) + 1) * 4 + 4;
+ nextp += (code_get_u4(nextp+4,m) - code_get_u4(nextp,m) + 1) * 4 + 4;
break;
}
case JAVA_DSTORE:
case JAVA_ASTORE:
if (!iswide) {
- i = code_get_u1(p + 1);
+ i = code_get_u1(p + 1,m);
} else {
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,m);
}
readonly[i] = false;
break;
case JAVA_IINC:
if (!iswide) {
- i = code_get_u1(p + 1);
+ i = code_get_u1(p + 1,m);
} else {
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,m);
}
readonly[i] = false;
break;
if (!inlinevirtuals)
break;
case JAVA_INVOKESTATIC:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,m);
{
constant_FMIref *imr;
methodinfo *imi;
break;
}
- if ((cummethods < INLINING_MAXMETHODS) &&
+ if ((inline_env->cummethods < INLINING_MAXMETHODS) &&
(!(imi->flags & ACC_NATIVE)) &&
(!inlineoutsiders || (m->class == imr->class)) &&
(imi->jcodelength < INLINING_MAXCODESIZE) &&
inlining_methodinfo *tmp;
descriptor2types(imi);
- cummethods++;
+ inline_env->cummethods++;
if (verbose) {
char logtext[MAXLOGTEXT];
log_text(logtext);
}
- tmp = inlining_analyse_method(imi, level + 1, gp, firstlocal + m->maxlocals, maxstackdepth + m->maxstack);
+ tmp =inlining_analyse_method(imi, level + 1, gp, firstlocal + m->maxlocals, maxstackdepth + m->maxstack, inline_env);
list_addlast(newnode->inlinedmethods, tmp);
gp = tmp->stopgp;
p = nextp;
newnode->stopgp = gp;
- /*
- sprintf (logtext, "Result of inlining analysis of: ");
- utf_sprint (logtext+strlen(logtext), m->class->name);
- strcpy (logtext+strlen(logtext), ".");
- utf_sprint (logtext+strlen(logtext), m->name);
- utf_sprint (logtext+strlen(logtext), m->descriptor);
- dolog ();
- sprintf (logtext, "label_index[0..%d]->", jcodelength);
- for (i=0; i<jcodelength; i++) sprintf (logtext, "%d:%d ", i, label_index[i]);
- sprintf(logtext,"stopgp : %d\n",newnode->stopgp); */
+ if (DEBUGi==true) {
+ printf ("\nResult of inlining analysis of: ");
+ IMETHINFO(m);
+ printf("was called by:\n"); fflush(stdout);
+ IMETHINFO(inline_env->method);
+ printf ("label_index[0..%d]->", jcodelength);
+ for (i=0;i<jcodelength; i++) printf ("%d:%d ", i, label_index[i]);
+ printf("stopgp : %d\n",newnode->stopgp);
+ }
return newnode;
}
+/* --------------------------------------------------------------------*/
+/* print_ functions: check inline structures contain what is expected */
+/* --------------------------------------------------------------------*/
+void print_t_inlining_globals (t_inlining_globals *g)
+{
+printf("\n------------\nt_inlining_globals struct for: \n\t");fflush(stdout);
+METHINFO(g->method);
+printf("\tclass=");fflush(stdout);
+ utf_display(g->class->name);printf("\n");fflush(stdout);
+
+printf("\tjcodelength=%i; jcode=%p;\n",g->jcodelength, g->jcode);
+
+if (g->isinlinedmethod==true) {
+ printf("\tisinlinedmethod=true ");fflush(stdout);
+ }
+else {
+ printf("\tisinlinedmethod=false");fflush(stdout);
+ }
+
+printf("\tcumjcodelength=%i ,cummaxstack=%i ,cumextablelength=%i ",
+ g->cumjcodelength, g->cummaxstack, g->cumextablelength);fflush(stdout);
+printf("\tcumlocals=%i ,cummethods=%i \n",
+ g->cumlocals, g->cummethods);fflush(stdout);
+
+printf("s>s>s> ");fflush(stdout);
+print_inlining_stack (g->inlining_stack);
+printf("i>i>i> "); fflush(stdout);
+print_inlining_methodinfo(g->inlining_rootinfo);
+printf("-------------------\n");fflush(stdout);
+}
+
+/* --------------------------------------------------------------------*/
+void print_inlining_stack ( list *s)
+{
+if (s==NULL) {
+ printf("\n\tinlining_stack: NULL\n");
+ return;
+ }
+
+ {/* print first element to see if get into stack */
+ t_inlining_stacknode *is;
+ printf("\n\tinlining_stack: NOT NULL\n");
+
+ is=list_first(s);
+ if (is==NULL) {
+ printf("\n\tinlining_stack = init'd but EMPTY\n");
+ fflush(stdout);
+ return;
+ }
+ }
+
+ {
+ t_inlining_stacknode *is;
+ printf("\n\tinlining_stack: NOT NULL\n");
+
+
+ for (is=list_first(s);
+ is!=NULL;
+ is=list_next(s,is)) {
+ printf("\n\ti>--->inlining_stack entry: \n"); fflush(stdout);
+ METHINFO(is->method);
+ printf("i=%i, p=%i, nextp=%i, opcode=%i;\n",
+ is->i,is->p,is->nextp,is->opcode);fflush(stdout);
+ print_inlining_methodinfo(is->inlinfo);
+ } /*end for */
+ }
+
+}
+
+/* --------------------------------------------------------------------*/
+void print_inlining_methodinfo( inlining_methodinfo *r) {
+if (r==NULL) {
+ printf("\n\tinlining_methodinfo: NULL\n");
+ return;
+ }
+
+if (r->method != NULL) {
+ utf_display(r->method->class->name); printf("."); fflush(stdout); \
+ method_display(r->method); fflush(stdout); \
+ }
+else {
+ printf("method is NULL!!!!!\n");fflush(stdout);
+ }
+
+printf("\n\tinlining_methodinfo for:"); fflush(stdout);
+if (r->readonly==NULL) {
+ printf("\treadonly==NULL ");fflush(stdout);
+ }
+else {
+ int i;
+ printf("\treadonly=");fflush(stdout);
+ for (i = 0; i < r->method->maxlocals; i++) {
+ if (r->readonly[i] == true)
+ printf("[i]=T;");
+ else
+ printf("[i]=F;");
+ fflush(stdout);
+ }
+ }
+
+
+printf("\tstartgp=%i; stopgp=%i; firstlocal=%i; label_index=%p;\n",
+ r->startgp, r->stopgp, r->firstlocal, r->label_index);
+{int i;
+printf ("label_index[0..%d]->", r->method->jcodelength);
+for (i=0; i<r->method->jcodelength; i++) printf ("%d:%d ", i, r->label_index[i]);
+}
+
+{
+inlining_methodinfo *im;
+for (im=list_first(r->inlinedmethods);
+ im!=NULL;
+ im=list_next(r->inlinedmethods,im)) {
+ }
+}
+}
+
/*
* These are local overrides for various environment variables in Emacs.
-/* jit/inline.c - code inliner
+/* jit/inline.h - code inliner
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
Authors: Dieter Thuernbeck
- $Id: inline.h 1203 2004-06-22 23:14:55Z twisti $
+ $Id: inline.h 1414 2004-10-04 12:55:33Z carolyn $
*/
//local variables used in parse()
- int i; /* temporary for different uses (counters) */
- int p; /* java instruction counter */
- int nextp; /* start of next java instruction */
- int opcode; /* java opcode */
+ int i; /* temporary for different uses (counters)*/
+ int p; /* java instruction counter */
+ int nextp; /* start of next java instruction */
+ int opcode; /* java opcode */
inlining_methodinfo *inlinfo;
- /* list *patchlist; */
} t_inlining_stacknode;
-
-/* extern variables */
-extern bool isinlinedmethod;
-extern int cumjcodelength;
-extern int cummaxstack;
-extern int cumextablelength;
-extern inlining_methodinfo *inlining_rootinfo;
-
+typedef struct t_inlining_globals { // try in parse.h with struct not include
+ bool isinlinedmethod;
+ int cumjcodelength; /* cumulative immediate intruction length */
+ int cummaxstack;
+ int cumextablelength;
+ int cumlocals; /* was static */
+ int cummethods; /* was static */
+ list *inlining_stack; /* was static */
+ inlining_methodinfo *inlining_rootinfo;
+ methodinfo *method;
+ classinfo *class;
+ int jcodelength;
+ u1 *jcode;
+} t_inlining_globals;
/* function prototypes*/
-void inlining_init(methodinfo *m);
-void inlining_cleanup();
-void inlining_push_compiler_variables(methodinfo *m,
- int i, int p, int nextp, int opcode,
- inlining_methodinfo* inlinfo);
-void inlining_pop_compiler_variables(methodinfo *m,
- int *i, int *p, int *nextp, int *opcode,
- inlining_methodinfo** inlinfo);
-void inlining_set_compiler_variables_fun(methodinfo *m);
+t_inlining_globals *inlining_init(methodinfo *m);
+void inlining_cleanup(t_inlining_globals *inline_env);
+void inlining_push_compiler_variables(
+ int i, int p, int nextp, int opcode,
+ inlining_methodinfo* inlinfo,
+ t_inlining_globals *inline_env);
+void inlining_pop_compiler_variables(
+ int *i, int *p, int *nextp, int *opcode,
+ inlining_methodinfo **inlinfo,
+ t_inlining_globals *inline_env);
+void inlining_set_compiler_variables_fun(methodinfo *m,
+ t_inlining_globals *inline_env);
classinfo *first_occurence(classinfo* class, utf* name, utf* desc);
bool is_unique_rec(classinfo *class, methodinfo *m, utf* name, utf* desc);
bool is_unique_method(classinfo *class, methodinfo *m, utf* name, utf* desc);
-inlining_methodinfo *inlining_analyse_method(methodinfo *m, int level, int gp,
- int firstlocal, int maxstackdepth);
+inlining_methodinfo *inlining_analyse_method(methodinfo *m,
+ int level, int gp,
+ int firstlocal, int maxstackdepth, t_inlining_globals *inline_env);
+void print_t_inlining_globals (t_inlining_globals *g);
+void print_inlining_stack ( list *s);
+void print_inlining_methodinfo( inlining_methodinfo *r);
#define inlining_save_compiler_variables() \
- inlining_push_compiler_variables(m, i, p, nextp, opcode, inlinfo)
+ inlining_push_compiler_variables(i,p,nextp,opcode,inlinfo,inline_env)
#define inlining_restore_compiler_variables() \
- inlining_pop_compiler_variables(m, &i, &p, &nextp, &opcode, &inlinfo)
+ inlining_pop_compiler_variables(&i, &p, &nextp, &opcode, &inlinfo, \
+ inline_env)
#define inlining_set_compiler_variables(i) \
do { \
p = nextp = 0; \
- inlining_set_compiler_variables_fun(i->method); \
+ inlining_set_compiler_variables_fun(i->method, inline_env); \
inlinfo = i; \
} while (0)
Changes: Edwin Steiner
- $Id: jit.c 1407 2004-08-17 12:42:34Z twisti $
+ $Id: jit.c 1414 2004-10-04 12:55:33Z carolyn $
*/
utf_display_classname(m->class->name);printf(".");utf_display(m->name);
printf("\n");
}
-
/* now the jit is running */
jitrunning = true;
static methodptr jit_compile_intern(methodinfo *m)
{
+t_inlining_globals *inline_env = NULL;
/* if there is no javacode, print error message and return empty method */
if (!m->jcode) {
reg_init(m);
/* must be called before reg_setup, because it can change maxlocals */
- if (useinlining)
- inlining_init(m);
+ /* init reqd to initialize for parse even in no inlining */
+ inline_env = inlining_init(m);
reg_setup(m);
if (compileverbose)
log_message_method("Parsing: ", m);
- if (!parse(m)) {
+ if (!parse(m, inline_env)) {
if (compileverbose)
log_message_method("Exception while parsing: ", m);
Changes: Carolyn Oates
Edwin Steiner
- $Id: parse.c 1373 2004-08-01 21:56:36Z stefan $
+ $Id: parse.c 1414 2004-10-04 12:55:33Z carolyn $
+Extra print is due backing changes that removed globals and merged variables that should not be merged... They will be removed... do not delete yet.
*/
#include "toolbox/memory.h"
#include "toolbox/logging.h"
+#define DEBUGMETH(mm) \
+if (DEBUG == true) \
+ { \
+ printf("PARSE method name ="); \
+ utf_display(mm->class->name); \
+ printf("."); \
+ method_display(mm); \
+ fflush(stdout); \
+ }
+
+bool DEBUG = false;
+bool DEBUG2 = false;
+bool DEBUG3 = false;
/* data about the currently parsed method */
/*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
+#define debug_writebranch if (DEBUG2==true) printf("op:: %s i: %d label_index[i]: %d label_index=%p\n",opcode_names[opcode], i, label_index[i],label_index);
+#define debug_writebranch1
/* function descriptor2typesL ***************************************************
*******************************************************************************/
-static exceptiontable* fillextable(methodinfo *m, exceptiontable* extable, exceptiontable *raw_extable, int exceptiontablelength, int *label_index, int *block_count)
+static exceptiontable* fillextable(methodinfo *m,
+ exceptiontable* extable, exceptiontable *raw_extable,
+ int exceptiontablelength,
+ int *label_index, int *block_count,
+ t_inlining_globals *inline_env)
{
int b_count, i, p;
if (exceptiontablelength == 0)
return extable;
+//if (m->exceptiontablelength > 0) {
+// DEBUGMETH(m);
+// printf("m->exceptiontablelength=%i\n",m->exceptiontablelength);
+// panic("exceptiontablelength > 0");
+// }
+
b_count = *block_count;
for (i = 0; i < exceptiontablelength; i++) {
if (label_index != NULL) p = label_index[p];
extable[i].startpc = p;
bound_check(p);
+if (DEBUG3==true) {printf("B1 EEE1 \t"); fflush(stdout);}
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 < m->jcodelength)
- block_insert(p);
+ if (p < m->jcodelength) {
+if (DEBUG3==true) {printf("B2 EEE2 \t"); fflush(stdout);}
+ block_insert(p); }
p = raw_extable[i].handlerpc;
if (label_index != NULL) p = label_index[p];
extable[i].handlerpc = p;
bound_check(p);
+if (DEBUG3==true) {printf("B3 EEE3 \t"); fflush(stdout);}
block_insert(p);
extable[i].catchtype = raw_extable[i].catchtype;
-methodinfo *parse(methodinfo *m)
+methodinfo *parse(methodinfo *m, t_inlining_globals *inline_env)
{
- int p; /* java instruction counter */
- int nextp; /* start of next java instruction */
- int opcode; /* java opcode */
- int i; /* temporary for different uses (counters) */
- int ipc = 0; /* intermediate instruction counter */
- int b_count = 0; /* basic block counter */
- int s_count = 0; /* stack element counter */
+ int p; /* java instruction counter */
+ int nextp; /* start of next java instruction */
+ int opcode; /* java opcode */
+ int i; /* temporary for different uses (ctrs)*/
+ int ipc = 0; /* intermediate instruction counter */
+ int b_count = 0; /* basic block counter */
+ int s_count = 0; /* stack element counter */
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 */
- int gp; /* global java instruction counter */
- /* inlining info for current method */
- inlining_methodinfo *inlinfo = inlining_rootinfo;
+ bool iswide = false; /* true if last instruction was a wide*/
+ instruction *iptr; /* current ptr into instruction array */
+ int gp; /* global java instruction counter */
+ /* inlining info for current method */
+
+ inlining_methodinfo *inlinfo = inline_env->inlining_rootinfo;
inlining_methodinfo *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 */
- exceptiontable* nextex; /* points next free entry in extable */
+ 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 */
+ exceptiontable* nextex; /* points next free entry in extable */
u1 *instructionstart; /* 1 for pcs which are valid instr. starts */
u2 lineindex=0;
u2 currentline=0;
u2 linepcchange=0;
- bool useinltmp;
+if (DEBUG==true) {printf("PARSING: "); fflush(stdout);
+DEBUGMETH(m);
+}
/* INLINING */
if (useinlining) {
label_index = inlinfo->label_index;
- m->maxstack = cummaxstack;
- m->exceptiontablelength = cumextablelength;
- }
-
- useinltmp = useinlining; /* FIXME remove this after debugging */
- /*useinlining = false;*/ /* and merge the if-statements */
-
- if (!useinlining) {
-/* cumjcodelength = m->jcodelength; */
-
- } else {
- tmpinlinf = (inlining_methodinfo*) list_first(inlinfo->inlinedmethods);
+ m->maxstack = inline_env->cummaxstack;
+ m->exceptiontablelength = inline_env->cumextablelength;
+ tmpinlinf = (inlining_methodinfo*)
+ list_first(inlinfo->inlinedmethods);
if (tmpinlinf != NULL) nextgp = tmpinlinf->startgp;
}
- if ((opt_rt || opt_xta || opt_vta) && (pOpcodes == 2 || pOpcodes == 3)) {
- printf("PARSE method name =");
- utf_display(m->class->name);
- printf(".");
- method_display(m);
- printf(">\n\n");
- fflush(stdout);
- }
-
- if (opt_rt || opt_xta) {
- RT_jit_parse(m);
-
- } else {
- if (opt_vta)
- printf("VTA requested, but not yet implemented\n");
- }
-
+/**** static analysis has to be called before inlining
+ which has to be called before reg_set
+ which has to be called before parse (or ???)
+ will check if method being parsed was analysed here
+ ****/
+ if (opt_rt) {
+ /**RT_jit_parse(m);**/
+ printf("RTA requested, not available\n");
+ }
+ if (opt_xta) {
+ /**RT_jit_parse(m);**/
+ printf("XTA requested, not available\n");
+ }
+ if (opt_vta)
+ printf("VTA requested, not yet implemented\n");
/* allocate instruction array and block index table */
- /* 1 additional for end ipc */
+ /* 1 additional for end ipc * # cum inline methods*/
- m->basicblockindex = DMNEW(s4, m->jcodelength + 1);
- memset(m->basicblockindex, 0, sizeof(s4) * (m->jcodelength + 1));
+ m->basicblockindex = DMNEW(s4, inline_env->cumjcodelength + inline_env->cummethods);
+ memset(m->basicblockindex, 0, sizeof(s4) * (inline_env->cumjcodelength + inline_env->cummethods));
- instructionstart = DMNEW(u1, m->jcodelength + 1);
- memset(instructionstart, 0, sizeof(u1) * (m->jcodelength + 1));
+ instructionstart = DMNEW(u1, inline_env->cumjcodelength + inline_env->cummethods);
+ memset(instructionstart, 0, sizeof(u1) * (inline_env->cumjcodelength + inline_env->cummethods));
/* 1 additional for TRACEBUILTIN and 4 for MONITORENTER/EXIT */
/* additional MONITOREXITS are reached by branches which are 3 bytes */
- iptr = m->instructions = DMNEW(instruction, m->jcodelength + 5);
+ iptr = m->instructions = DMNEW(instruction, inline_env->cumjcodelength + 5);
/* Zero the intermediate instructions array so we don't have any
* invalid pointers in it if we cannot finish analyse_stack(). */
- memset(iptr, 0, sizeof(instruction) * (m->jcodelength + 5));
+ memset(iptr, 0, sizeof(instruction) * (inline_env->cumjcodelength + 5));
/* compute branch targets of exception table */
-
-/* m->exceptiontable = DMNEW(exceptiontable, m->exceptiontablelength + 1); */
- /*
- for (i = 0; i < method->m->exceptiontablelength; i++) {
-
- p = m->exceptiontable[i].startpc = raw_extable[i].startpc;
- if (useinlining) p = label_index[p];
- bound_check(p);
- block_insert(p);
-
- p = m->exceptiontable[i].endpc = raw_extable[i].endpc;
- if (useinlining) p = label_index[p];
- bound_check1(p);
- if (p < cumjcodelength)
- block_insert(p);
-
- p = m->exceptiontable[i].handlerpc = raw_extable[i].handlerpc;
- bound_check(p);
- block_insert(p);
-
- m->exceptiontable[i].catchtype = raw_extable[i].catchtype;
-
- m->exceptiontable[i].next = NULL;
- m->exceptiontable[i].down = &m->exceptiontable[i+1];
- }
- */
-
- nextex = fillextable(m, m->exceptiontable, m->exceptiontable, m->exceptiontablelength, label_index, &b_count);
-
+//if (m->exceptiontable == NULL) {
+// printf("m->exceptiontable=NULL\n");fflush(stdout);
+// }
+//else {
+// printf("m->exceptiontable != NULL\n");fflush(stdout);
+// }
+//printf("m->exceptiontablelength=%i, inline_env->method->exceptiontablelength=%i,inline_env->cumextablelength=%i\n",
+//m->exceptiontablelength, inline_env->method->exceptiontablelength,inline_env->cumextablelength);
+
+//if (m->exceptiontablelength > 0)
+// m->exceptiontable = DMNEW(exceptiontable, m->exceptiontablelength + 1);
+
+ nextex = fillextable(m,
+ m->exceptiontable, m->exceptiontable, m->exceptiontablelength,
+ label_index, &b_count, inline_env);
s_count = 1 + m->exceptiontablelength; /* initialize stack element counter */
#ifdef USE_THREADS
linepcchange = m->linenumbers[0].start_pc;
}
- for (p = 0, gp = 0; p < m->jcodelength; gp += (nextp - p), p = nextp) {
+ for (p = 0, gp = 0; p < inline_env->method->jcodelength; gp += (nextp - p), p = nextp) {
- /* DEBUG */ /*printf("p:%d gp:%d ",p,gp);*/
+ /* DEBUG */ if (DEBUG==true) printf("----- p:%d gp:%d\n",p,gp);
/* mark this position as a valid instruction start */
if (!iswide) {
bool *readonly = NULL;
- opcode = code_get_u1(p);
+ opcode = code_get_u1(p,inline_env->method);
nextp = p += jcommandsize[opcode];
- if (nextp > m->jcodelength)
+ if (nextp > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
tmpinlinf = list_first(inlinfo->inlinedmethods);
firstlocal = tmpinlinf->firstlocal;
/* m->basicblockindex[gp] |= (ipc << 1);*/ /*FIXME: necessary ? */
}
-
+if (DEBUG==true) {
+printf("BEFORE SAVE: "); fflush(stdout);
+DEBUGMETH(inline_env->method);
+}
inlining_save_compiler_variables();
+if (DEBUG==true) {
+printf("AFTER SAVE: "); fflush(stdout);
+DEBUGMETH(inline_env->method);
+}
inlining_set_compiler_variables(tmpinlinf);
- if (compileverbose) {
- char logtext[MAXLOGTEXT];
- sprintf(logtext, "Parsing (inlined): ");
- utf_sprint(logtext+strlen(logtext), m->class->name);
- strcpy(logtext+strlen(logtext), ".");
- utf_sprint(logtext+strlen(logtext), m->name);
- utf_sprint(logtext+strlen(logtext), m->descriptor);
- log_text(logtext);
+if (DEBUG==true) {
+printf("AFTER SET :: "); fflush(stdout);
+DEBUGMETH(inline_env->method);
+}
+ if (DEBUG) {
+ printf("\n.......Parsing (inlined): ");
+ DEBUGMETH(m);
+ DEBUGMETH(inline_env->method);
}
+////label_index = inlinfo->label_index;
if (inlinfo->inlinedmethods == NULL) {
tmpinlinf = list_first(inlinfo->inlinedmethods);
nextgp = (tmpinlinf != NULL) ? tmpinlinf->startgp : -1;
}
- if (m->exceptiontablelength > 0)
- nextex = fillextable(m, nextex, m->exceptiontable, m->exceptiontablelength, label_index, &b_count);
+ if (inline_env->method->exceptiontablelength > 0)
+ nextex = fillextable(m, nextex,
+ inline_env->method->exceptiontable, inline_env->method->exceptiontablelength,
+ label_index, &b_count, inline_env);
continue;
}
- opcode = code_get_u1(p); /* fetch op code */
-
-
- if (opt_rt && (pOpcodes == 2 || pOpcodes == 3)) {
- printf("Parse<%i> p=%i<%i< opcode=<%i> %s\n",
- pOpcodes, p, rt_jcodelength, opcode, icmd_names[opcode]);
+ opcode = code_get_u1(p,inline_env->method); /* fetch op code */
+ if (DEBUG==true)
+ {
+ printf("Parse p=%i<%i< opcode=<%i> %s\n",
+ p, rt_jcodelength, opcode, opcode_names[opcode]);
}
- m->basicblockindex[gp] |= (ipc << 1); /* store intermediate count */
+//printf("basicblockindex[gp=%i]=%i=%p ipc=%i=%p shifted ipc=%i=%p\n",
+//gp,m->basicblockindex[gp],m->basicblockindex[gp],ipc,ipc,(ipc<<1),(ipc<<1));
+//fflush(stdout);
+ m->basicblockindex[gp] |= (ipc << 1); /*store intermed cnt*/
+//printf("basicblockindex[gp=%i]=%i=%p \n",
+//gp,m->basicblockindex[gp],m->basicblockindex[gp]);
+//fflush(stdout);
if (blockend) {
+//printf("B4 BEND\t"); fflush(stdout);
block_insert(gp); /* start new block */
blockend = false;
}
nextp = p + jcommandsize[opcode]; /* compute next instruction start */
- if (nextp > m->jcodelength)
+ if (nextp > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
s_count += stackreq[opcode]; /* compute stack element count */
/* pushing constants onto the stack p */
case JAVA_BIPUSH:
- LOADCONST_I(code_get_s1(p+1));
+ LOADCONST_I(code_get_s1(p+1,inline_env->method));
break;
case JAVA_SIPUSH:
- LOADCONST_I(code_get_s2(p+1));
+ LOADCONST_I(code_get_s2(p+1,inline_env->method));
break;
case JAVA_LDC1:
- i = code_get_u1(p+1);
+ i = code_get_u1(p+1,inline_env->method);
+
goto pushconstantitem;
case JAVA_LDC2:
case JAVA_LDC2W:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
pushconstantitem:
- if (i >= m->class->cpcount)
+ if (i >= inline_env->method->class->cpcount)
panic ("Attempt to access constant outside range");
- switch (m->class->cptags[i]) {
+ switch (inline_env->method->class->cptags[i]) {
case CONSTANT_Integer:
- LOADCONST_I(((constant_integer *) (m->class->cpinfos[i]))->value);
+ LOADCONST_I(((constant_integer *) (inline_env->method->class->cpinfos[i]))->value);
break;
case CONSTANT_Long:
- LOADCONST_L(((constant_long *) (m->class->cpinfos[i]))->value);
+ LOADCONST_L(((constant_long *) (inline_env->method->class->cpinfos[i]))->value);
break;
case CONSTANT_Float:
- LOADCONST_F(((constant_float *) (m->class->cpinfos[i]))->value);
+ LOADCONST_F(((constant_float *) (inline_env->method->class->cpinfos[i]))->value);
break;
case CONSTANT_Double:
- LOADCONST_D(((constant_double *) (m->class->cpinfos[i]))->value);
+ LOADCONST_D(((constant_double *) (inline_env->method->class->cpinfos[i]))->value);
break;
case CONSTANT_String:
- LOADCONST_A(literalstring_new((utf *) (m->class->cpinfos[i])));
+ LOADCONST_A(literalstring_new((utf *) (inline_env->method->class->cpinfos[i])));
break;
default: panic("Invalid constant type to push");
}
case JAVA_DLOAD:
case JAVA_ALOAD:
if (!iswide) {
- i = code_get_u1(p + 1);
+ i = code_get_u1(p + 1,inline_env->method);
} else {
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
nextp = p + 3;
iswide = false;
}
case JAVA_DSTORE:
case JAVA_ASTORE:
if (!iswide) {
- i = code_get_u1(p + 1);
+ i = code_get_u1(p + 1,inline_env->method);
} else {
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
iswide = false;
nextp = p + 3;
}
int v;
if (!iswide) {
- i = code_get_u1(p + 1);
- v = code_get_s1(p + 2);
+ i = code_get_u1(p + 1,inline_env->method);
+ v = code_get_s1(p + 2,inline_env->method);
} else {
- i = code_get_u2(p + 1);
- v = code_get_s2(p + 3);
+ i = code_get_u2(p + 1,inline_env->method);
+ v = code_get_s2(p + 3,inline_env->method);
iswide = false;
nextp = p + 5;
}
case JAVA_NEWARRAY:
OP(ICMD_CHECKASIZE);
- switch (code_get_s1(p + 1)) {
+ switch (code_get_s1(p + 1,inline_env->method)) {
case 4:
BUILTIN1(BUILTIN_newarray_boolean, TYPE_ADR,currentline);
break;
case JAVA_ANEWARRAY:
OP(ICMD_CHECKASIZE);
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
classinfo *component =
- (classinfo *) class_getconstant(m->class, i, CONSTANT_Class);
+ (classinfo *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
if (!class_load(component))
return NULL;
break;
case JAVA_MULTIANEWARRAY:
- m->isleafmethod = false;
- i = code_get_u2(p + 1);
+ inline_env->method->isleafmethod = false;
+ i = code_get_u2(p + 1,inline_env->method);
{
vftbl_t *arrayvftbl;
- s4 v = code_get_u1(p + 3);
+ s4 v = code_get_u1(p + 3,inline_env->method);
/* vftbl *arrayvftbl = */
classinfo *component =
- (classinfo *) class_getconstant(m->class, i, CONSTANT_Class);
+ (classinfo *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
if (!class_load(component))
return NULL;
case JAVA_IF_ACMPNE:
case JAVA_GOTO:
case JAVA_JSR:
- i = p + code_get_s2(p + 1);
+ i = p + code_get_s2(p + 1,inline_env->method);
if (useinlining) {
debug_writebranch;
i = label_index[i];
}
bound_check(i);
+if (DEBUG3==true) {
+printf("B5 IFs/GOTO\t"); fflush(stdout);}
block_insert(i);
blockend = true;
OP1(opcode, i);
break;
case JAVA_GOTO_W:
case JAVA_JSR_W:
- i = p + code_get_s4(p + 1);
+ i = p + code_get_s4(p + 1,inline_env->method);
if (useinlining) {
debug_writebranch;
i = label_index[i];
}
bound_check(i);
+//printf("B6 JSR_W\t"); fflush(stdout);
block_insert(i);
blockend = true;
OP1(opcode, i);
case JAVA_RET:
if (!iswide) {
- i = code_get_u1(p + 1);
+ i = code_get_u1(p + 1,inline_env->method);
} else {
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
nextp = p + 3;
iswide = false;
}
blockend = true;
/*
- if (isinlinedmethod) {
+ if (inline_env->isinlinedmethod) {
OP1(ICMD_GOTO, inlinfo->stopgp);
break;
}*/
case JAVA_DRETURN:
case JAVA_ARETURN:
case JAVA_RETURN:
- if (isinlinedmethod) {
+ if (inline_env->isinlinedmethod) {
/* if (p==m->jcodelength-1) {*/ /* return is at end of inlined method */
/* OP(ICMD_NOP); */
/* break; */
blockend = true;
nextp = ALIGN((p + 1), 4);
- if (nextp + 8 > m->jcodelength)
+ if (nextp + 8 > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
if (!useinlining) {
- tablep = (s4 *) (m->jcode + nextp);
+ tablep = (s4 *) (inline_env->method->jcode + nextp);
} else {
- num = code_get_u4(nextp + 4);
+ num = code_get_u4(nextp + 4,inline_env->method);
tablep = DMNEW(s4, num * 2 + 2);
}
/* default target */
- j = p + code_get_s4(nextp);
+ j = p + code_get_s4(nextp,inline_env->method);
if (useinlining)
j = label_index[j];
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
bound_check(j);
+//printf("B7 LOOKUP1\t"); fflush(stdout);
block_insert(j);
/* number of pairs */
- num = code_get_u4(nextp);
+ num = code_get_u4(nextp,inline_env->method);
*tablep = num;
tablep++;
nextp += 4;
- if (nextp + 8*(num) > m->jcodelength)
+ if (nextp + 8*(num) > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
for (i = 0; i < num; i++) {
/* value */
- j = code_get_s4(nextp);
+ j = code_get_s4(nextp,inline_env->method);
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
/* target */
- j = p + code_get_s4(nextp);
+ j = p + code_get_s4(nextp,inline_env->method);
if (useinlining)
j = label_index[j];
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
bound_check(j);
+//printf("B8 LOOKUP2\t"); fflush(stdout);
block_insert(j);
}
blockend = true;
nextp = ALIGN((p + 1), 4);
- if (nextp + 12 > m->jcodelength)
+ if (nextp + 12 > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
if (!useinlining) {
- tablep = (s4 *) (m->jcode + nextp);
+ tablep = (s4 *) (inline_env->method->jcode + nextp);
} else {
- num = code_get_u4(nextp + 8) - code_get_u4(nextp + 4);
+ num = code_get_u4(nextp + 8,inline_env->method) - code_get_u4(nextp + 4,inline_env->method);
tablep = DMNEW(s4, num + 1 + 3);
}
/* default target */
- j = p + code_get_s4(nextp);
+ j = p + code_get_s4(nextp,inline_env->method);
if (useinlining)
j = label_index[j];
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
bound_check(j);
+//printf("B9 TABLESWITCH1\t"); fflush(stdout);
block_insert(j);
/* lower bound */
- j = code_get_s4(nextp);
+ j = code_get_s4(nextp,inline_env->method);
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
/* upper bound */
- num = code_get_s4(nextp);
+ num = code_get_s4(nextp,inline_env->method);
*tablep = num; /* restore for little endian */
tablep++;
nextp += 4;
if (num < 0)
panic("invalid TABLESWITCH: upper bound < lower bound");
- if (nextp + 4*(num+1) > m->jcodelength)
+ if (nextp + 4*(num+1) > inline_env->method->jcodelength)
panic("Unexpected end of bytecode");
for (i = 0; i <= num; i++) {
- j = p + code_get_s4(nextp);
+ j = p + code_get_s4(nextp,inline_env->method);
if (useinlining)
j = label_index[j];
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
bound_check(j);
+//printf("B10 TABLESWITCH2\t"); fflush(stdout);
block_insert(j);
}
case JAVA_PUTSTATIC:
case JAVA_GETSTATIC:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
constant_FMIref *fr;
fieldinfo *fi;
- fr = class_getconstant(m->class, i, CONSTANT_Fieldref);
+ fr = class_getconstant(inline_env->method->class, i, CONSTANT_Fieldref);
if (!class_load(fr->class))
return NULL;
fi = class_resolvefield(fr->class,
fr->name,
fr->descriptor,
- m->class,
+ inline_env->method->class,
true);
if (!fi)
OP2A(opcode, fi->type, fi, currentline);
if (!fi->class->initialized) {
- m->isleafmethod = false;
+ inline_env->method->isleafmethod = false;
}
}
break;
case JAVA_PUTFIELD:
case JAVA_GETFIELD:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
constant_FMIref *fr;
fieldinfo *fi;
- fr = class_getconstant(m->class, i, CONSTANT_Fieldref);
+ fr = class_getconstant(inline_env->method->class, i, CONSTANT_Fieldref);
if (!class_load(fr->class))
return NULL;
fi = class_resolvefield(fr->class,
fr->name,
fr->descriptor,
- m->class,
+ inline_env->method->class,
true);
if (!fi)
/* method invocation *****/
case JAVA_INVOKESTATIC:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
constant_FMIref *mr;
methodinfo *mi;
- m->isleafmethod = false;
+ inline_env->method->isleafmethod = false;
- mr = class_getconstant(m->class, i, CONSTANT_Methodref);
+ mr = class_getconstant(inline_env->method->class, i, CONSTANT_Methodref);
if (!class_load(mr->class))
return NULL;
mi = class_resolveclassmethod(mr->class,
mr->name,
mr->descriptor,
- m->class,
+ inline_env->method->class,
true);
if (!mi)
return NULL;
- /*RTAprint*/ if (((pOpcodes == 2) || (pOpcodes == 3)) && opt_rt)
+ /*RTAprint*/// if (((pOpcodes == 2) || (pOpcodes == 3)) && opt_rt)
+if (DEBUG2==true)
/*RTAprint*/ {printf(" method name =");
/*RTAprint*/ utf_display(mi->class->name); printf(".");
/*RTAprint*/ utf_display(mi->name);printf("\tINVOKE STATIC\n");
case JAVA_INVOKESPECIAL:
case JAVA_INVOKEVIRTUAL:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
constant_FMIref *mr;
methodinfo *mi;
- m->isleafmethod = false;
+ inline_env->method->isleafmethod = false;
- mr = class_getconstant(m->class, i, CONSTANT_Methodref);
+ mr = class_getconstant(inline_env->method->class, i, CONSTANT_Methodref);
if (!class_load(mr->class))
return NULL;
mi = class_resolveclassmethod(mr->class,
mr->name,
mr->descriptor,
- m->class,
+ inline_env->method->class,
true);
if (!mi)
return NULL;
- /*RTAprint*/ if (((pOpcodes == 2) || (pOpcodes == 3)) && opt_rt)
+ /*RTAprint*/ // if (((pOpcodes == 2) || (pOpcodes == 3)) && opt_rt)
+if (DEBUG2==true)
/*RTAprint*/ {printf(" method name =");
method_display(mi);
/*RTAprint*/ utf_display(mi->class->name); printf(".");
break;
case JAVA_INVOKEINTERFACE:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
constant_FMIref *mr;
methodinfo *mi;
- m->isleafmethod = false;
+ inline_env->method->isleafmethod = false;
- mr = class_getconstant(m->class, i, CONSTANT_InterfaceMethodref);
+ mr = class_getconstant(inline_env->method->class, i, CONSTANT_InterfaceMethodref);
if (!class_load(mr->class))
return NULL;
mi = class_resolveinterfacemethod(mr->class,
mr->name,
mr->descriptor,
- m->class,
+ inline_env->method->class,
true);
if (!mi)
return NULL;
/* miscellaneous object operations *******/
case JAVA_NEW:
- i = code_get_u2(p + 1);
- LOADCONST_A_BUILTIN(class_getconstant(m->class, i, CONSTANT_Class));
+ i = code_get_u2(p + 1,inline_env->method);
+ LOADCONST_A_BUILTIN(class_getconstant(inline_env->method->class, i, CONSTANT_Class));
s_count++;
BUILTIN1(BUILTIN_new, TYPE_ADR, currentline);
OP(ICMD_CHECKEXCEPTION);
break;
case JAVA_CHECKCAST:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
classinfo *cls =
- (classinfo *) class_getconstant(m->class, i, CONSTANT_Class);
+ (classinfo *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
if (!cls->loaded)
if (!class_load(cls))
break;
case JAVA_INSTANCEOF:
- i = code_get_u2(p + 1);
+ i = code_get_u2(p + 1,inline_env->method);
{
classinfo *cls =
- (classinfo *) class_getconstant(m->class, i, CONSTANT_Class);
+ (classinfo *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
if (!cls->loaded)
if (!class_load(cls))
/* INLINING */
- if (isinlinedmethod && p == m->jcodelength - 1) { /* end of an inlined method */
+ if (inline_env->isinlinedmethod && p == inline_env->method->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();
+//label_index = inlinfo->label_index;
+if (DEBUG==true) {
+printf("AFTER RESTORE : "); fflush(stdout);
+DEBUGMETH(inline_env->method);
+}
list_remove(inlinfo->inlinedmethods, list_first(inlinfo->inlinedmethods));
if (inlinfo->inlinedmethods == NULL) {
nextgp = -1;
firstlocal = inlinfo->firstlocal;
}
} /* end for */
+/*&&&&&&&&&&&&&&&&*/
+if (DEBUG==true) printf("&&&&&&&&&&&&&&&&\n");
+
if (p != m->jcodelength)
panic("Command-sequence crosses code-boundary");
/* allocate blocks */
-/* for (p = 0; p < cumjcodelength; p++) { */
- for (p = 0; p < m->jcodelength; p++) {
+/* for (p = 0; p < inline_env->cumjcodelength; p++) { */
+ for (p = 0; p < m->jcodelength; p++) {
if (m->basicblockindex[p] & 1) {
/* check if this block starts at the beginning of an instruction */
if (!instructionstart[p])
}
}
- if (useinlining) inlining_cleanup();
- useinlining = useinltmp;
+ if (useinlining) inlining_cleanup(inline_env);
/* just return methodinfo* to signal everything was ok */
Author: Christian Thalinger
- $Id: parse.h 1337 2004-07-21 16:00:33Z twisti $
+ $Id: parse.h 1414 2004-10-04 12:55:33Z carolyn $
*/
#define _PARSE_H
#include "global.h"
+#include "inline.h"
/* intermediate code generating macros */
/*iptr->op1=0;*/ \
iptr->val.i = (v); \
iptr->line = currentline; \
- iptr->method = m; \
+ 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=m;PINC
-#define LOADCONST_F(v) iptr->opc=ICMD_FCONST;/*iptr->op1=0*/;iptr->val.f=(v);iptr->line=currentline;iptr->method=m;PINC
-#define LOADCONST_D(v) iptr->opc=ICMD_DCONST;/*iptr->op1=0*/;iptr->val.d=(v);iptr->line=currentline;iptr->method=m;PINC
-#define LOADCONST_A(v) iptr->opc=ICMD_ACONST;/*iptr->op1=0*/;iptr->val.a=(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
/* 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=m;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=m;PINC
-#define OP1(o,o1) iptr->opc=(o);iptr->op1=(o1);/*iptr->val.l=(0)*/;iptr->line=currentline;iptr->method=m;PINC
-#define OP2I(o,o1,v) iptr->opc=(o);iptr->op1=(o1);iptr->val.i=(v);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 OP2A(o,o1,v,l) \
iptr->opc = (o); \
iptr->op1 = (o1); \
iptr->val.a = (v); \
iptr->line = l; \
- iptr->method = m; \
+ iptr->method = inline_env->method; \
PINC
#define BUILTIN1(v,t,l) \
- m->isleafmethod = false; \
+ inline_env->method->isleafmethod = false; \
iptr->opc = ICMD_BUILTIN1; \
iptr->val.a = (v); \
iptr->op1 = (t); \
iptr->line = (l); \
- iptr->method = m; \
+ iptr->method = inline_env->method; \
PINC
-#define BUILTIN2(v,t,l) m->isleafmethod=false;iptr->opc=ICMD_BUILTIN2;iptr->op1=t;\
- iptr->val.a=(v);iptr->line=l;iptr->method=m;PINC
-#define BUILTIN3(v,t,l) m->isleafmethod=false;iptr->opc=ICMD_BUILTIN3;iptr->op1=t;\
- iptr->val.a=(v);iptr->line=l;iptr->method=m;PINC
+#define BUILTIN2(v,t,l) inline_env->method->isleafmethod=false;iptr->opc=ICMD_BUILTIN2;iptr->op1=t;\
+ iptr->val.a=(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.a=(v);iptr->line=l;iptr->method=inline_env->method;PINC
/* We have to check local variables indices here because they are
#define INDEX_ONEWORD(num) \
do { \
- if ((num) < 0 || (num) >= m->maxlocals) { \
+ if ((num) < 0 || (num) >= inline_env->cumlocals) { \
*exceptionptr = \
- new_verifyerror(m, "Illegal local variable number"); \
+ new_verifyerror(inline_env->method, "Illegal local variable number"); \
return NULL; \
} \
} while (0)
#define INDEX_TWOWORD(num) \
do { \
- if ((num) < 0 || ((num) + 1) >= m->maxlocals) { \
+ if ((num) < 0 || ((num) + 1) >= inline_env->cumlocals) { \
*exceptionptr = \
- new_verifyerror(m, "Illegal local variable number"); \
+ new_verifyerror(inline_env->method, "Illegal local variable number"); \
return NULL; \
} \
} while (0)
if (!(m->basicblockindex[(i)] & 1)) { \
b_count++; \
m->basicblockindex[(i)] |= 1; \
+ if (DEBUG==true){printf("---------------------block_inserted:b_count=%i m->basicblockindex[(i=%i)]=%i=%p\n",b_count,i,m->basicblockindex[(i)],m->basicblockindex[(i)]); \
+ fflush(stdout); } \
} \
} while (0)
#define bound_check(i) \
do { \
-/* if (i < 0 || i >= cumjcodelength) { */\
- if (i < 0 || i >= m->jcodelength) { \
+ 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(m, "Illegal target of jump or branch"); \
+ 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) { */\
- if (i < 0 || i > m->jcodelength) { \
+ if (i < 0 || i > inline_env->cumjcodelength) { \
+/* if (i < 0 || i > m->jcodelength) { */ \
*exceptionptr = \
- new_verifyerror(m, "Illegal target of jump or branch"); \
+ new_verifyerror(inline_env->method, "Illegal target of jump or branch"); \
return NULL; \
} \
} while (0)
*******************************************************************************/
-#define code_get_u1(p) m->jcode[p]
-#define code_get_s1(p) ((s1)m->jcode[p])
-#define code_get_u2(p) ((((u2)m->jcode[p]) << 8) + m->jcode[p + 1])
-#define code_get_s2(p) ((s2)((((u2)m->jcode[p]) << 8) + m->jcode[p + 1]))
-#define code_get_u4(p) ((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
+#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) ((s4)((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
+#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]))
void compiler_addinitclass(classinfo *c);
classSetNode * descriptor2typesL(methodinfo *m);
void descriptor2types(methodinfo *m);
-methodinfo *parse(methodinfo *m);
+methodinfo *parse(methodinfo *m,t_inlining_globals *inline_env);
#endif /* _PARSE_H */