Authors: Andreas Krall
Reinhard Grafl
- $Id: asmpart.S 1127 2004-06-03 22:15:22Z twisti $
+ $Id: asmpart.S 1218 2004-06-29 14:11:16Z twisti $
*/
/*************************** imported functions *******************************/
.globl jit_compile
- .globl _exceptionptr
.globl builtin_monitorexit
.globl builtin_throw_exception
.globl builtin_trace_exception
Authors: Andreas Krall
Reinhard Grafl
- $Id: codegen.c 1162 2004-06-12 13:29:07Z stefan $
+ $Id: codegen.c 1218 2004-06-29 14:11:16Z twisti $
*/
*******************************************************************************/
-void codegen()
+void codegen(methodinfo *m)
{
int len, s1, s2, s3, d;
s4 a;
varinfo *var;
basicblock *bptr;
instruction *iptr;
- xtable *ex;
+ exceptiontable *ex;
{
int p, pa, t, l, r;
- savedregs_num = (isleafmethod) ? 0 : 1; /* space to save the RA */
+ savedregs_num = (m->isleafmethod) ? 0 : 1; /* space to save the RA */
/* space to save used callee saved registers */
#if defined(USE_THREADS) /* space to save argument of monitor_enter */
- if (checksync && (method->flags & ACC_SYNCHRONIZED))
+ if (checksync && (m->flags & ACC_SYNCHRONIZED))
parentargs_base++;
#endif
/* create method header */
- (void) dseg_addaddress(method); /* MethodPointer */
+ (void) dseg_addaddress(m); /* MethodPointer */
(void) dseg_adds4(parentargs_base * 8); /* FrameSize */
#if defined(USE_THREADS)
offset by one.
*/
- if (checksync && (method->flags & ACC_SYNCHRONIZED))
+ if (checksync && (m->flags & ACC_SYNCHRONIZED))
(void) dseg_adds4((maxmemuse + 1) * 8); /* IsSync */
else
(void) dseg_adds4(0); /* IsSync */
- (void) dseg_adds4(isleafmethod); /* IsLeaf */
+ (void) dseg_adds4(m->isleafmethod); /* IsLeaf */
(void) dseg_adds4(savintregcnt - maxsavintreguse); /* IntSave */
(void) dseg_adds4(savfltregcnt - maxsavfltreguse); /* FltSave */
dseg_addlinenumbertablesize();
- (void) dseg_adds4(exceptiontablelength); /* ExTableSize */
+ (void) dseg_adds4(m->exceptiontablelength); /* ExTableSize */
/* create exception table */
- for (ex = extable; ex != NULL; ex = ex->down) {
+ for (ex = m->exceptiontable; ex != NULL; ex = ex->down) {
dseg_addtarget(ex->start);
dseg_addtarget(ex->end);
dseg_addtarget(ex->handler);
mcodeptr = (s4*) mcodebase;
mcodeend = (s4*) (mcodebase + mcodesize);
- MCODECHECK(128 + mparamcount);
+ MCODECHECK(128 + m->paramcount);
/* create stack frame (if necessary) */
/* save return address and used callee saved registers */
p = parentargs_base;
- if (!isleafmethod)
- {p--; M_AST (REG_RA, REG_SP, 8*p);}
+ if (!m->isleafmethod)
+ {p--; M_AST (REG_RA, REG_SP, 8*p);}
for (r = savintregcnt - 1; r >= maxsavintreguse; r--)
{p--; M_LST (savintregs[r], REG_SP, 8 * p);}
for (r = savfltregcnt - 1; r >= maxsavfltreguse; r--)
/* save monitorenter argument */
#if defined(USE_THREADS)
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
- if (method->flags & ACC_STATIC) {
- p = dseg_addaddress(class);
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+ if (m->flags & ACC_STATIC) {
+ p = dseg_addaddress(m->class);
M_ALD(REG_ITMP1, REG_PV, p);
M_AST(REG_ITMP1, REG_SP, maxmemuse * 8);
/* save and copy float arguments into integer registers */
for (p = 0; /* p < mparamcount && */ p < FLT_ARG_CNT; p++) {
- t = mparamtypes[p];
+ t = m->paramtypes[p];
if (IS_FLT_DBL_TYPE(t)) {
if (IS_2_WORD_TYPE(t)) {
}
}
- p = dseg_addaddress(method);
+ p = dseg_addaddress(m);
M_ALD(REG_ITMP1, REG_PV, p);
M_AST(REG_ITMP1, REG_SP, 0 * 8);
p = dseg_addaddress((void *) builtin_trace_args);
}
for (p = 0; /* p < mparamcount && */ p < FLT_ARG_CNT; p++) {
- t = mparamtypes[p];
+ t = m->paramtypes[p];
if (IS_FLT_DBL_TYPE(t)) {
if (IS_2_WORD_TYPE(t)) {
/* take arguments out of register or stack frame */
- for (p = 0, l = 0; p < mparamcount; p++) {
- t = mparamtypes[p];
+ for (p = 0, l = 0; p < m->paramcount; p++) {
+ t = m->paramtypes[p];
var = &(locals[l][t]);
l++;
if (IS_2_WORD_TYPE(t)) /* increment local counter for 2 word types */
/* call monitorenter function */
#if defined(USE_THREADS)
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
- int disp;
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+ s4 disp;
p = dseg_addaddress((void*) (builtin_monitorenter));
M_ALD(REG_PV, REG_PV, p);
M_ALD(argintregs[0], REG_SP, maxmemuse * 8);
M_JSR(REG_RA, REG_PV);
- disp = -(int)((u1*) mcodeptr - mcodebase);
+ disp = -(s4) ((u1 *) mcodeptr - mcodebase);
M_LDA(REG_PV, REG_RA, disp);
}
#endif
/* end of header generation */
/* walk through all basic blocks */
- for (bptr = block; bptr != NULL; bptr = bptr->next) {
+ for (bptr = m->basicblocks; bptr != NULL; bptr = bptr->next) {
- bptr->mpc = (int)((u1*) mcodeptr - mcodebase);
+ bptr->mpc = (s4) ((u1 *) mcodeptr - mcodebase);
if (bptr->flags >= BBREACHED) {
M_INTMOVE(s1, REG_RESULT);
#if defined(USE_THREADS)
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
s4 disp;
a = dseg_addaddress((void *) (builtin_monitorexit));
M_ALD(REG_PV, REG_PV, a);
M_FLTMOVE(s1, REG_FRESULT);
#if defined(USE_THREADS)
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
s4 disp;
a = dseg_addaddress((void *) (builtin_monitorexit));
M_ALD(REG_PV, REG_PV, a);
case ICMD_RETURN: /* ... ==> ... */
#if defined(USE_THREADS)
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
s4 disp;
a = dseg_addaddress((void *) (builtin_monitorexit));
M_ALD(REG_PV, REG_PV, a);
/* restore return address */
- if (!isleafmethod)
- {p--; M_LLD (REG_RA, REG_SP, 8 * p);}
+ if (!m->isleafmethod)
+ {p--; M_LLD(REG_RA, REG_SP, 8 * p);}
/* restore saved registers */
for (r = savintregcnt - 1; r >= maxsavintreguse; r--)
- {p--; M_LLD(savintregs[r], REG_SP, 8 * p);}
+ {p--; M_LLD(savintregs[r], REG_SP, 8 * p);}
for (r = savfltregcnt - 1; r >= maxsavfltreguse; r--)
- {p--; M_DLD(savfltregs[r], REG_SP, 8 * p);}
+ {p--; M_DLD(savfltregs[r], REG_SP, 8 * p);}
/* deallocate stack */
M_AST(REG_RA, REG_SP, 0 * 8);
M_LST(REG_RESULT, REG_SP, 1 * 8);
M_DST(REG_FRESULT, REG_SP, 2 * 8);
- a = dseg_addaddress(method);
+ a = dseg_addaddress(m);
M_ALD(argintregs[0], REG_PV, a);
M_MOV(REG_RESULT, argintregs[1]);
M_FLTMOVE(REG_FRESULT, argfltregs[2]);
xcodeptr = NULL;
for (; xcheckarefs != NULL; xcheckarefs = xcheckarefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ if ((m->exceptiontablelength == 0) && (xcodeptr != NULL)) {
gen_resolvebranch((u1*) mcodebase + xcheckarefs->branchpos,
xcheckarefs->branchpos,
(u1*) xcodeptr - (u1*) mcodebase - 4);
xcodeptr = NULL;
for (; xcastrefs != NULL; xcastrefs = xcastrefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ if ((m->exceptiontablelength == 0) && (xcodeptr != NULL)) {
gen_resolvebranch((u1*) mcodebase + xcastrefs->branchpos,
xcastrefs->branchpos,
(u1*) xcodeptr - (u1*) mcodebase - 4);
xcodeptr = NULL;
for (; xexceptionrefs != NULL; xexceptionrefs = xexceptionrefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ if ((m->exceptiontablelength == 0) && (xcodeptr != NULL)) {
gen_resolvebranch((u1*) mcodebase + xexceptionrefs->branchpos,
xexceptionrefs->branchpos,
(u1*) xcodeptr - (u1*) mcodebase - 4);
xcodeptr = NULL;
for (; xnullrefs != NULL; xnullrefs = xnullrefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ if ((m->exceptiontablelength == 0) && (xcodeptr != NULL)) {
gen_resolvebranch((u1*) mcodebase + xnullrefs->branchpos,
xnullrefs->branchpos,
(u1*) xcodeptr - (u1*) mcodebase - 4);
}
}
- codegen_finish((int)((u1*) mcodeptr - mcodebase));
+ codegen_finish(m, (s4) ((u1 *) mcodeptr - mcodebase));
}
Authors: Andreas Krall
Reinhard Grafl
- $Id: codegen.h 1146 2004-06-06 12:48:10Z twisti $
+ $Id: codegen.h 1218 2004-06-29 14:11:16Z twisti $
*/
void codegen_init();
void init_exceptions();
-void codegen();
+void codegen(methodinfo *m);
void codegen_close();
void dseg_display(s4 *s4ptr);
void thread_restartcriticalsection(ucontext_t*);
Authors: Andreas Krall
Reinhard Grafl
- $Id: asmpart.S 1127 2004-06-03 22:15:22Z twisti $
+ $Id: asmpart.S 1218 2004-06-29 14:11:16Z twisti $
*/
/*************************** imported functions *******************************/
.globl jit_compile
- .globl _exceptionptr
.globl builtin_monitorexit
.globl builtin_throw_exception
.globl builtin_trace_exception
Authors: Andreas Krall
Reinhard Grafl
- $Id: codegen.c 1162 2004-06-12 13:29:07Z stefan $
+ $Id: codegen.c 1218 2004-06-29 14:11:16Z twisti $
*/
*******************************************************************************/
-void codegen()
+void codegen(methodinfo *m)
{
int len, s1, s2, s3, d;
s4 a;
varinfo *var;
basicblock *bptr;
instruction *iptr;
- xtable *ex;
+ exceptiontable *ex;
{
int p, pa, t, l, r;
- savedregs_num = (isleafmethod) ? 0 : 1; /* space to save the RA */
+ savedregs_num = (m->isleafmethod) ? 0 : 1; /* space to save the RA */
/* space to save used callee saved registers */
#if defined(USE_THREADS) /* space to save argument of monitor_enter */
- if (checksync && (method->flags & ACC_SYNCHRONIZED))
+ if (checksync && (m->flags & ACC_SYNCHRONIZED))
parentargs_base++;
#endif
/* create method header */
- (void) dseg_addaddress(method); /* MethodPointer */
+ (void) dseg_addaddress(m); /* MethodPointer */
(void) dseg_adds4(parentargs_base * 8); /* FrameSize */
#if defined(USE_THREADS)
offset by one.
*/
- if (checksync && (method->flags & ACC_SYNCHRONIZED))
+ if (checksync && (m->flags & ACC_SYNCHRONIZED))
(void) dseg_adds4((maxmemuse + 1) * 8); /* IsSync */
else
(void) dseg_adds4(0); /* IsSync */
- (void) dseg_adds4(isleafmethod); /* IsLeaf */
+ (void) dseg_adds4(m->isleafmethod); /* IsLeaf */
(void) dseg_adds4(savintregcnt - maxsavintreguse); /* IntSave */
(void) dseg_adds4(savfltregcnt - maxsavfltreguse); /* FltSave */
dseg_addlinenumbertablesize();
- (void) dseg_adds4(exceptiontablelength); /* ExTableSize */
+ (void) dseg_adds4(m->exceptiontablelength); /* ExTableSize */
/* create exception table */
- for (ex = extable; ex != NULL; ex = ex->down) {
+ for (ex = m->exceptiontable; ex != NULL; ex = ex->down) {
dseg_addtarget(ex->start);
dseg_addtarget(ex->end);
dseg_addtarget(ex->handler);
mcodeptr = (s4*) mcodebase;
mcodeend = (s4*) (mcodebase + mcodesize);
- MCODECHECK(128 + mparamcount);
+ MCODECHECK(128 + m->paramcount);
/* create stack frame (if necessary) */
/* save return address and used callee saved registers */
p = parentargs_base;
- if (!isleafmethod)
- {p--; M_AST (REG_RA, REG_SP, 8*p);}
+ if (!m->isleafmethod)
+ {p--; M_AST (REG_RA, REG_SP, 8*p);}
for (r = savintregcnt - 1; r >= maxsavintreguse; r--)
{p--; M_LST (savintregs[r], REG_SP, 8 * p);}
for (r = savfltregcnt - 1; r >= maxsavfltreguse; r--)
/* save monitorenter argument */
#if defined(USE_THREADS)
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
- if (method->flags & ACC_STATIC) {
- p = dseg_addaddress(class);
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+ if (m->flags & ACC_STATIC) {
+ p = dseg_addaddress(m->class);
M_ALD(REG_ITMP1, REG_PV, p);
M_AST(REG_ITMP1, REG_SP, maxmemuse * 8);
/* save and copy float arguments into integer registers */
for (p = 0; /* p < mparamcount && */ p < FLT_ARG_CNT; p++) {
- t = mparamtypes[p];
+ t = m->paramtypes[p];
if (IS_FLT_DBL_TYPE(t)) {
if (IS_2_WORD_TYPE(t)) {
}
}
- p = dseg_addaddress(method);
+ p = dseg_addaddress(m);
M_ALD(REG_ITMP1, REG_PV, p);
M_AST(REG_ITMP1, REG_SP, 0 * 8);
p = dseg_addaddress((void *) builtin_trace_args);
}
for (p = 0; /* p < mparamcount && */ p < FLT_ARG_CNT; p++) {
- t = mparamtypes[p];
+ t = m->paramtypes[p];
if (IS_FLT_DBL_TYPE(t)) {
if (IS_2_WORD_TYPE(t)) {
/* take arguments out of register or stack frame */
- for (p = 0, l = 0; p < mparamcount; p++) {
- t = mparamtypes[p];
+ for (p = 0, l = 0; p < m->paramcount; p++) {
+ t = m->paramtypes[p];
var = &(locals[l][t]);
l++;
if (IS_2_WORD_TYPE(t)) /* increment local counter for 2 word types */
/* call monitorenter function */
#if defined(USE_THREADS)
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
- int disp;
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+ s4 disp;
p = dseg_addaddress((void*) (builtin_monitorenter));
M_ALD(REG_PV, REG_PV, p);
M_ALD(argintregs[0], REG_SP, maxmemuse * 8);
M_JSR(REG_RA, REG_PV);
- disp = -(int)((u1*) mcodeptr - mcodebase);
+ disp = -(s4) ((u1 *) mcodeptr - mcodebase);
M_LDA(REG_PV, REG_RA, disp);
}
#endif
/* end of header generation */
/* walk through all basic blocks */
- for (bptr = block; bptr != NULL; bptr = bptr->next) {
+ for (bptr = m->basicblocks; bptr != NULL; bptr = bptr->next) {
- bptr->mpc = (int)((u1*) mcodeptr - mcodebase);
+ bptr->mpc = (s4) ((u1 *) mcodeptr - mcodebase);
if (bptr->flags >= BBREACHED) {
M_INTMOVE(s1, REG_RESULT);
#if defined(USE_THREADS)
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
s4 disp;
a = dseg_addaddress((void *) (builtin_monitorexit));
M_ALD(REG_PV, REG_PV, a);
M_FLTMOVE(s1, REG_FRESULT);
#if defined(USE_THREADS)
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
s4 disp;
a = dseg_addaddress((void *) (builtin_monitorexit));
M_ALD(REG_PV, REG_PV, a);
case ICMD_RETURN: /* ... ==> ... */
#if defined(USE_THREADS)
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
s4 disp;
a = dseg_addaddress((void *) (builtin_monitorexit));
M_ALD(REG_PV, REG_PV, a);
/* restore return address */
- if (!isleafmethod)
- {p--; M_LLD (REG_RA, REG_SP, 8 * p);}
+ if (!m->isleafmethod)
+ {p--; M_LLD(REG_RA, REG_SP, 8 * p);}
/* restore saved registers */
for (r = savintregcnt - 1; r >= maxsavintreguse; r--)
- {p--; M_LLD(savintregs[r], REG_SP, 8 * p);}
+ {p--; M_LLD(savintregs[r], REG_SP, 8 * p);}
for (r = savfltregcnt - 1; r >= maxsavfltreguse; r--)
- {p--; M_DLD(savfltregs[r], REG_SP, 8 * p);}
+ {p--; M_DLD(savfltregs[r], REG_SP, 8 * p);}
/* deallocate stack */
M_AST(REG_RA, REG_SP, 0 * 8);
M_LST(REG_RESULT, REG_SP, 1 * 8);
M_DST(REG_FRESULT, REG_SP, 2 * 8);
- a = dseg_addaddress(method);
+ a = dseg_addaddress(m);
M_ALD(argintregs[0], REG_PV, a);
M_MOV(REG_RESULT, argintregs[1]);
M_FLTMOVE(REG_FRESULT, argfltregs[2]);
xcodeptr = NULL;
for (; xcheckarefs != NULL; xcheckarefs = xcheckarefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ if ((m->exceptiontablelength == 0) && (xcodeptr != NULL)) {
gen_resolvebranch((u1*) mcodebase + xcheckarefs->branchpos,
xcheckarefs->branchpos,
(u1*) xcodeptr - (u1*) mcodebase - 4);
xcodeptr = NULL;
for (; xcastrefs != NULL; xcastrefs = xcastrefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ if ((m->exceptiontablelength == 0) && (xcodeptr != NULL)) {
gen_resolvebranch((u1*) mcodebase + xcastrefs->branchpos,
xcastrefs->branchpos,
(u1*) xcodeptr - (u1*) mcodebase - 4);
xcodeptr = NULL;
for (; xexceptionrefs != NULL; xexceptionrefs = xexceptionrefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ if ((m->exceptiontablelength == 0) && (xcodeptr != NULL)) {
gen_resolvebranch((u1*) mcodebase + xexceptionrefs->branchpos,
xexceptionrefs->branchpos,
(u1*) xcodeptr - (u1*) mcodebase - 4);
xcodeptr = NULL;
for (; xnullrefs != NULL; xnullrefs = xnullrefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ if ((m->exceptiontablelength == 0) && (xcodeptr != NULL)) {
gen_resolvebranch((u1*) mcodebase + xnullrefs->branchpos,
xnullrefs->branchpos,
(u1*) xcodeptr - (u1*) mcodebase - 4);
}
}
- codegen_finish((int)((u1*) mcodeptr - mcodebase));
+ codegen_finish(m, (s4) ((u1 *) mcodeptr - mcodebase));
}
Authors: Andreas Krall
Reinhard Grafl
- $Id: codegen.h 1146 2004-06-06 12:48:10Z twisti $
+ $Id: codegen.h 1218 2004-06-29 14:11:16Z twisti $
*/
void codegen_init();
void init_exceptions();
-void codegen();
+void codegen(methodinfo *m);
void codegen_close();
void dseg_display(s4 *s4ptr);
void thread_restartcriticalsection(ucontext_t*);