Authors: Andreas Krall
Reinhard Grafl
- $Id: jit.c 727 2003-12-11 10:52:40Z edwin $
+ Changes: Edwin Steiner
+
+ $Id: jit.c 789 2003-12-16 14:46:55Z edwin $
*/
/* global switches ************************************************************/
-bool compileverbose = false;
-bool showstack = false;
-bool showdisassemble = false;
-bool showddatasegment = false;
-bool showintermediate = false;
-int optimizelevel = 0;
-
-bool useinlining = false;
-bool inlinevirtuals = false;
-bool inlineexceptions = false;
-bool inlineparamopt = false;
-bool inlineoutsiders = false;
-
-bool checkbounds = true;
-bool checknull = true;
-bool opt_noieee = false;
-bool checksync = true;
-bool opt_loops = false;
bool getcompilingtime = false;
long compilingtime = 0;
chain *uninitializedclasses;
int stackreq[256];
+
+#if defined(__I386__)
+/* these define if a method has ICMDs which use %edx or %ecx */
+bool method_uses_ecx;
+bool method_uses_edx;
+#endif
+
int jcommandsize[256] = {
};
#endif
-int builtintablelen; /* XXX make static again? */
+
+static int builtintablelen;
#endif /* USEBUILTINTABLE */
The first part of the table (up to the 255-marker) lists the
opcodes which are automatically replaced in stack.c.
- The second part lists the builtin functions which are used for
- BUILTIN* opcodes in parse.c and stack.c.
+ The second part lists the builtin functions which are "manually"
+ used for BUILTIN* opcodes in parse.c and stack.c.
*****************************************************************************/
builtin_descriptor builtin_desc[] = {
+#if defined(USEBUILTINTABLE)
{ICMD_LCMP , BUILTIN_lcmp ,ICMD_BUILTIN2,TYPE_LONG ,TYPE_LONG ,TYPE_VOID ,TYPE_INT ,
SUPPORT_LONG && SUPPORT_LONG_CMP,false,"lcmp"},
SUPPORT_FLOAT && SUPPORT_FICVT,true ,"f2i"},
{ICMD_D2I , BUILTIN_d2i ,ICMD_BUILTIN1,TYPE_DOUBLE,TYPE_VOID ,TYPE_VOID ,TYPE_INT ,
SUPPORT_DOUBLE && SUPPORT_FICVT,true ,"d2i"},
+#endif
/* this record marks the end of the automatically replaced opcodes */
{255 , NULL ,0 ,0 ,0 ,0 ,0 ,
true ,false,"<INVALID>"},
+#if defined(__ALPHA__)
+ {255, BUILTIN_f2l ,ICMD_BUILTIN1,TYPE_FLOAT ,TYPE_VOID ,TYPE_VOID ,TYPE_LONG ,0,0,"f2l"},
+ {255, BUILTIN_d2l ,ICMD_BUILTIN1,TYPE_DOUBLE,TYPE_VOID ,TYPE_VOID ,TYPE_LONG ,0,0,"d2l"},
+ {255, BUILTIN_f2i ,ICMD_BUILTIN1,TYPE_FLOAT ,TYPE_VOID ,TYPE_VOID ,TYPE_INT ,0,0,"f2i"},
+ {255, BUILTIN_d2i ,ICMD_BUILTIN1,TYPE_DOUBLE,TYPE_VOID ,TYPE_VOID ,TYPE_INT ,0,0,"d2i"},
+#endif
+
/* the following functions are not replaced automatically */
{255,BUILTIN_instanceof ,ICMD_BUILTIN2,TYPE_ADR ,TYPE_ADR ,TYPE_VOID ,TYPE_INT ,0,0,"instanceof"},
{255,BUILTIN_arrayinstanceof ,ICMD_BUILTIN2,TYPE_ADR ,TYPE_ADR ,TYPE_VOID ,TYPE_INT ,0,0,"arrayinstanceof"},
count_methods++;
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ pthread_mutex_lock(&compiler_mutex);
+#endif
+
intsDisable(); /* disable interrupts */
regs_ok = false;
strcpy(logtext+strlen(logtext), ".");
utf_sprint(logtext+strlen(logtext), m->name);
utf_sprint(logtext+strlen(logtext), m->descriptor);
- dolog(logtext);
+ log_text(logtext);
intsRestore(); /* enable interrupts again */
return (methodptr) do_nothing_function; /* return empty method */
}
strcpy(logtext+strlen(logtext), ".");
utf_sprint(logtext+strlen(logtext), m->name);
utf_sprint(logtext+strlen(logtext), m->descriptor);
- dolog(logtext);
+ log_text(logtext);
}
/* initialize class list with class the compiled method belongs to */
- uninitializedclasses = chain_new();
+ uninitializedclasses = chain_new();
compiler_addinitclass(m->class);
+#if defined(__I386__)
+ method_uses_ecx = true;
+ method_uses_edx = false;
+#endif
+
/* call the compiler passes ***********************************************/
- /* must be call before reg_init, because it can change maxlocals */
+ /* must be called before reg_init, because it can change maxlocals */
if (useinlining)
inlining_init(m);
- reg_init(m);
+ reg_setup();
codegen_init();
strcpy(logtext+strlen(logtext), ".");
utf_sprint(logtext+strlen(logtext), m->name);
utf_sprint(logtext+strlen(logtext), m->descriptor);
- dolog(logtext);
+ log_text(logtext);
}
typecheck();
if (getcompilingtime) {
stoptime = getcputime();
- compilingtime += (stoptime-starttime);
+ compilingtime += (stoptime - starttime);
}
/* initialize all used classes */
intsRestore(); /* enable interrupts again */
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ pthread_mutex_unlock(&compiler_mutex);
+#endif
+
/* return pointer to the methods entry point */
return m->entrypoint;
stackreq[JAVA_DUP_X2] = 4;
stackreq[JAVA_DUP2_X1] = 3;
stackreq[JAVA_DUP2_X2] = 4;
-
+
+ reg_init();
init_exceptions();
}