Changes: Edwin Steiner
- $Id: jit.c 1420 2004-10-27 16:05:14Z twisti $
+ $Id: jit.c 1506 2004-11-14 14:48:49Z jowenn $
*/
"UNDEF236","UNDEF237","UNDEF238","UNDEF239","UNDEF240",
"UNDEF","UNDEF","UNDEF","UNDEF","UNDEF",
"UNDEF246","UNDEF247","UNDEF248","UNDEF249","UNDEF250",
- "UNDEF251","UNDEF252",
+
+ "INLINE_START", /* 251 */
+ "INLINE_END", /* 252"*/
"BUILTIN3 ", /* 253 */
"BUILTIN2 ", /* 254 */
"UNDEF236","UNDEF237","UNDEF238","UNDEF239","UNDEF240",
"UNDEF","UNDEF","UNDEF","UNDEF","UNDEF",
"UNDEF246","UNDEF247","UNDEF248","UNDEF249","UNDEF250",
- "UNDEF251","UNDEF252",
+ "INLINE_START", /* 251 */
+ "INLINE_END", /* 252 */
"BUILTIN3 ", /* 253 */
"BUILTIN2 ", /* 254 */
"BUILTIN1 " /* 255 */
/* jit_compile *****************************************************************
- jit_compile, new version of compiler, translates one method to machine code
+ jit_compile, new version of compiler, translates one method to machine code
*******************************************************************************/
-static methodptr jit_compile_intern(methodinfo *m);
+static functionptr jit_compile_intern(methodinfo *m, codegendata *cd,
+ registerdata *rd, loopdata *ld,
+ t_inlining_globals *id);
-methodptr jit_compile(methodinfo *m)
+functionptr jit_compile(methodinfo *m)
{
static bool jitrunning;
- methodptr r;
+ functionptr r;
s4 dumpsize;
+ codegendata *cd;
+ registerdata *rd;
+ loopdata *ld;
+ t_inlining_globals *id;
if (opt_stat)
count_jit_calls++;
/* if method has been already compiled return immediately */
if (m->entrypoint) {
- builtin_monitorexit((java_objectheader *) m );
+ builtin_monitorexit((java_objectheader *) m);
return m->entrypoint;
}
if (opt_stat)
count_methods++;
+ /* if there is no javacode, print error message and return empty method */
+
+ if (!m->jcode) {
+ if (compileverbose)
+ log_message_method("No code given for: ", m);
+
+ /*m->entrypoint = (methodptr) do_nothing_function;*/
+ m->entrypoint = (functionptr) do_nothing_function;
+
+ return m->entrypoint; /* return empty method */
+ }
+
+#if 0
if (jitrunning) {
printf("JITRUNNING!!! new method=");
utf_display_classname(m->class->name);printf(".");utf_display(m->name);
printf("\n");
}
+
/* now the jit is running */
jitrunning = true;
+#endif
+
+ /* measure time */
+
+ if (getcompilingtime)
+ compilingtime_start();
/* mark start of dump memory area */
dumpsize = dump_size();
- /* measure time */
+ /* allocate memory */
- if (getcompilingtime)
- compilingtime_start();
+ cd = DNEW(codegendata);
+ rd = DNEW(registerdata);
+ ld = DNEW(loopdata);
+ id = DNEW(t_inlining_globals);
+
+ /* RTA static analysis must be called before inlining */
+ if (opt_rt)
+ RT_jit_parse(m); /* will be called just once */
+ /* return value ignored for now */
+
+ /* must be called before reg_setup, because it can change maxlocals */
+ /* init reqd to initialize for parse even in no inlining */
+ inlining_setup(m, id);
+
+ /* initialize the register allocator */
+ reg_setup(m, rd, id);
+
+ /* setup the codegendata memory */
+ codegen_setup(m, cd, id);
/* now call internal compile function */
- r = jit_compile_intern(m);
+ r = jit_compile_intern(m, cd, rd, ld, id);
- if (r) {
- if (compileverbose)
- log_message_method("Running: ", m);
- }
+ /* free some memory */
+
+ reg_free(m, rd);
+ codegen_free(m, cd);
/* clear pointers to dump memory area */
jitrunning = false;
+ /* define in options.h; Used in main.c, jit.c & inline.c */
+ #ifdef INAFTERMAIN
+ if ((utf_new_char("main") == m->name) && (useinliningm))
+ useinlining = false;
+ #endif
+
/* leave the monitor */
builtin_monitorexit((java_objectheader *) m );
+ if (r) {
+ if (compileverbose)
+ log_message_method("Running: ", m);
+ }
+
/* return pointer to the methods entry point */
return r;
}
-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 */
+/* jit_compile_intern **********************************************************
- if (!m->jcode) {
- if (compileverbose)
- log_message_method("No code given for: ", m);
+ Static internal function which does the actual compilation.
- return (methodptr) do_nothing_function; /* return empty method */
- }
+*******************************************************************************/
+static functionptr jit_compile_intern(methodinfo *m, codegendata *cd,
+ registerdata *rd, loopdata *ld,
+ t_inlining_globals *id)
+{
/* print log message for compiled method */
if (compileverbose)
/* call the compiler passes ***********************************************/
- EXTABLEN
- /* first of all initialize the register allocator */
- reg_init(m);
-
- /* RTA static analysis must be called before inlining */
- if (opt_rt) RT_jit_parse(m); // will be called just once
- /* return value ignored for now */
-
- /* must be called before reg_setup, because it can change maxlocals */
- /* init reqd to initialize for parse even in no inlining */
- inline_env = inlining_init(m);
-
- EXTABLEN
-
- reg_setup(m);
-
- /* setup the codegendata memory */
- codegen_setup(m,inline_env);
-
- EXTABLEN
-
if (compileverbose)
log_message_method("Parsing: ", m);
- if (!parse(m, inline_env)) {
+ /* call parse pass */
+ if (!parse(m, cd, id)) {
if (compileverbose)
log_message_method("Exception while parsing: ", m);
log_message_method("Analysing: ", m);
}
-
- if (!analyse_stack(m->codegendata)) {
+ /* call stack analysis pass */
+ if (!analyse_stack(m, cd, rd)) {
if (compileverbose)
log_message_method("Exception while analysing: ", m);
if (compileverbose)
log_message_method("Typechecking: ", m);
- if (!typecheck(m->codegendata)) {
+ /* call typecheck pass */
+ if (!typecheck(m, cd, rd)) {
if (compileverbose)
log_message_method("Exception while typechecking: ", m);
log_message_method("Typechecking done: ", m);
}
#endif
+
if (opt_loops) {
- depthFirst(m);
- analyseGraph(m);
- optimize_loops(m);
+ depthFirst(m, ld);
+ analyseGraph(m, ld);
+ optimize_loops(m, ld);
}
#ifdef SPECIALMEMUSE
- preregpass(m);
+ preregpass(m, rd);
#endif
if (compileverbose)
log_message_method("Allocating registers: ", m);
- regalloc(m);
+ /* allocate registers */
+ regalloc(m, cd, rd);
if (compileverbose) {
log_message_method("Allocating registers done: ", m);
}
/* now generate the machine code */
- codegen(m);
+ codegen(m, cd, rd);
if (compileverbose)
log_message_method("Generating code done: ", m);
/* intermediate and assembly code listings */
if (showintermediate) {
- show_icmd_method(m);
+ show_icmd_method(m, cd, rd);
} else if (showdisassemble) {
- disassemble((void *) (m->mcode + m->codegendata->dseglen),
- m->mcodelength - m->codegendata->dseglen);
+ disassemble((void *) ((long) m->mcode + cd->dseglen),
+ m->mcodelength - cd->dseglen);
}
if (showddatasegment)
- dseg_display(m);
-
- /* free some memory */
-
- reg_close(m);
- codegen_close(m);
+ dseg_display(m, cd);
if (compileverbose)
log_message_method("Compiling done: ", m);