-/* jit/alpha/codegen.c - machine code generator for alpha
+/* vm/jit/alpha/codegen.c - machine code generator for alpha
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
- Institut f. Computersprachen, TU Wien
- R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Probst,
- S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich,
- J. Wenninger
+ Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+ R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
+ C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+ Institut f. Computersprachen - TU Wien
This file is part of CACAO.
Authors: Andreas Krall
Reinhard Grafl
- $Id: codegen.c 964 2004-03-15 14:52:43Z jowenn $
+ Changes: Joseph Wenninger
+
+ $Id: codegen.c 1735 2004-12-07 14:33:27Z twisti $
*/
#include <stdio.h>
#include <signal.h>
-#include "types.h"
-#include "main.h"
-#include "codegen.h"
-#include "jit.h"
-#include "parse.h"
-#include "reg.h"
-#include "builtin.h"
-#include "asmpart.h"
-#include "jni.h"
-#include "loader.h"
-#include "tables.h"
-#include "native.h"
-#include "main.h"
-
-/* include independent code generation stuff */
-#include "codegen.inc"
-#include "reg.inc"
+
+#include "vm/jit/alpha/arch.h"
+#include "native/native.h"
+#include "vm/builtin.h"
+#include "vm/global.h"
+#include "vm/loader.h"
+#include "vm/tables.h"
+#include "vm/jit/asmpart.h"
+#include "vm/jit/jit.h"
+#ifdef LSRA
+#include "vm/jit/lsra.h"
+#endif
+#include "vm/jit/parse.h"
+#include "vm/jit/reg.h"
+#include "vm/jit/alpha/codegen.h"
+#include "vm/jit/alpha/types.h"
+#include "vm/jit/alpha/asmoffsets.h"
/* *****************************************************************************
REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES,
REG_END };
-/* for use of reserved registers, see comment above */
-
-
-/* parameter allocation mode */
-
-int nreg_parammode = PARAMMODE_NUMBERED;
-
- /* parameter-registers will be allocated by assigning the
- 1. parameter: int/float-reg 16
- 2. parameter: int/float-reg 17
- 3. parameter: int/float-reg 18 ....
- */
+/* Include independent code generation stuff -- include after register */
+/* descriptions to avoid extern definitions. */
-/* stackframe-infos ***********************************************************/
-
-int parentargs_base; /* offset in stackframe for the parameter from the caller*/
-
-/* -> see file 'calling.doc' */
-
-
-/* additional functions and macros to generate code ***************************/
-
-/* #define BlockPtrOfPC(pc) block+block_index[pc] */
-#define BlockPtrOfPC(pc) ((basicblock *) iptr->target)
-
-
-#ifdef STATISTICS
-#define COUNT_SPILLS count_spills++
-#else
-#define COUNT_SPILLS
+#include "vm/jit/codegen.inc"
+#include "vm/jit/reg.inc"
+#ifdef LSRA
+#include "vm/jit/lsra.inc"
#endif
-/* gen_nullptr_check(objreg) */
-
-#define gen_nullptr_check(objreg) \
- if (checknull) { \
- M_BEQZ((objreg), 0); \
- codegen_addxnullrefs(mcodeptr); \
- }
-
-
-/* MCODECHECK(icnt) */
-
-#define MCODECHECK(icnt) \
- if((mcodeptr + (icnt)) > mcodeend) mcodeptr = codegen_increase((u1*) mcodeptr)
-
-/* M_INTMOVE:
- generates an integer-move from register a to b.
- if a and b are the same int-register, no code will be generated.
-*/
-
-#define M_INTMOVE(a,b) if (a != b) { M_MOV(a, b); }
-
-
-/* M_FLTMOVE:
- generates a floating-point-move from register a to b.
- if a and b are the same float-register, no code will be generated
-*/
-
-#define M_FLTMOVE(a,b) if (a != b) { M_FMOV(a, b); }
-
-
-/* var_to_reg_xxx:
- this function generates code to fetch data from a pseudo-register
- into a real register.
- If the pseudo-register has actually been assigned to a real
- register, no code will be emitted, since following operations
- can use this register directly.
-
- v: pseudoregister to be fetched from
- tempregnum: temporary register to be used if v is actually spilled to ram
-
- return: the register number, where the operand can be found after
- fetching (this wil be either tempregnum or the register
- number allready given to v)
-*/
-
-#define var_to_reg_int(regnr,v,tempnr) { \
- if ((v)->flags & INMEMORY) \
- {COUNT_SPILLS;M_LLD(tempnr,REG_SP,8*(v)->regoff);regnr=tempnr;} \
- else regnr=(v)->regoff; \
-}
-
-
-#define var_to_reg_flt(regnr,v,tempnr) { \
- if ((v)->flags & INMEMORY) \
- {COUNT_SPILLS;M_DLD(tempnr,REG_SP,8*(v)->regoff);regnr=tempnr;} \
- else regnr=(v)->regoff; \
-}
-
-
-/* reg_of_var:
- This function determines a register, to which the result of an operation
- should go, when it is ultimatively intended to store the result in
- pseudoregister v.
- If v is assigned to an actual register, this register will be returned.
- Otherwise (when v is spilled) this function returns tempregnum.
- If not already done, regoff and flags are set in the stack location.
-*/
-
-static int reg_of_var(stackptr v, int tempregnum)
-{
- varinfo *var;
-
- switch (v->varkind) {
- case TEMPVAR:
- if (!(v->flags & INMEMORY))
- return(v->regoff);
- break;
- case STACKVAR:
- var = &(interfaces[v->varnum][v->type]);
- v->regoff = var->regoff;
- if (!(var->flags & INMEMORY))
- return(var->regoff);
- break;
- case LOCALVAR:
- var = &(locals[v->varnum][v->type]);
- v->regoff = var->regoff;
- if (!(var->flags & INMEMORY))
- return(var->regoff);
- break;
- case ARGVAR:
- v->regoff = v->varnum;
- if (IS_FLT_DBL_TYPE(v->type)) {
- if (v->varnum < fltreg_argnum) {
- v->regoff = argfltregs[v->varnum];
- return(argfltregs[v->varnum]);
- }
- }
- else
- if (v->varnum < intreg_argnum) {
- v->regoff = argintregs[v->varnum];
- return(argintregs[v->varnum]);
- }
- v->regoff -= intreg_argnum;
- break;
- }
- v->flags |= INMEMORY;
- return tempregnum;
-}
-
-
-/* store_reg_to_var_xxx:
- This function generates the code to store the result of an operation
- back into a spilled pseudo-variable.
- If the pseudo-variable has not been spilled in the first place, this
- function will generate nothing.
-
- v ............ Pseudovariable
- tempregnum ... Number of the temporary registers as returned by
- reg_of_var.
-*/
-
-#define store_reg_to_var_int(sptr, tempregnum) { \
- if ((sptr)->flags & INMEMORY) { \
- COUNT_SPILLS; \
- M_LST(tempregnum, REG_SP, 8 * (sptr)->regoff); \
- } \
- }
-
-#define store_reg_to_var_flt(sptr, tempregnum) { \
- if ((sptr)->flags & INMEMORY) { \
- COUNT_SPILLS; \
- M_DST(tempregnum, REG_SP, 8 * (sptr)->regoff); \
- } \
- }
-
-
/* NullPointerException handlers and exception handling initialisation */
typedef struct sigctx_struct {
-
long sc_onstack; /* sigstack state to restore */
long sc_mask; /* signal mask to restore */
long sc_pc; /* pc at time of signal */
} sigctx_struct;
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+void thread_restartcriticalsection(ucontext_t *uc)
+{
+ void *critical;
+ if ((critical = thread_checkcritical((void*) uc->uc_mcontext.sc_pc)) != NULL)
+ uc->uc_mcontext.sc_pc = (u8) critical;
+}
+#endif
+
/* NullPointerException signal handler for hardware null pointer check */
void catch_NullPointerException(int sig, int code, sigctx_struct *sigctx)
sigset_t nsig;
int instr;
long faultaddr;
+ java_objectheader *xptr;
/* Reset signal handler - necessary for SysV, does no harm for BSD */
faultaddr = sigctx->sc_regs[(instr >> 16) & 0x1f];
if (faultaddr == 0) {
- signal(sig, (void*) catch_NullPointerException); /* reinstall handler */
+ /* reinstall handler */
+ signal(sig, (functionptr) catch_NullPointerException);
sigemptyset(&nsig);
sigaddset(&nsig, sig);
sigprocmask(SIG_UNBLOCK, &nsig, NULL); /* unblock signal */
- if (!proto_java_lang_NullPointerException) {
- proto_java_lang_NullPointerException =
- new_exception(string_java_lang_NullPointerException);
- }
+ /*xptr = new_nullpointerexception();
+ sigctx->sc_regs[REG_ITMP1_XPTR] = (u8) xptr;*/
- sigctx->sc_regs[REG_ITMP1_XPTR] =
- (long) proto_java_lang_NullPointerException;
+ sigctx->sc_regs[REG_ITMP1_XPTR]=string_java_lang_NullPointerException;
sigctx->sc_regs[REG_ITMP2_XPC] = sigctx->sc_pc;
- sigctx->sc_pc = (long) asm_handle_exception;
+ /*sigctx->sc_pc = (u8) asm_handle_exception;*/
+ sigctx->sc_pc = (u8) asm_throw_and_handle_exception;
return;
} else {
faultaddr += (long) ((instr << 16) >> 16);
- fprintf(stderr, "faulting address: 0x%16lx\n", faultaddr);
+ fprintf(stderr, "faulting address: 0x%016lx\n", faultaddr);
panic("Stack overflow");
}
}
if (!checknull) {
#if defined(SIGSEGV)
- signal(SIGSEGV, (void*) catch_NullPointerException);
+ signal(SIGSEGV, (functionptr) catch_NullPointerException);
#endif
#if defined(SIGBUS)
- signal(SIGBUS, (void*) catch_NullPointerException);
+ signal(SIGBUS, (functionptr) catch_NullPointerException);
#endif
}
}
*******************************************************************************/
-void codegen()
+void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
{
- int len, s1, s2, s3, d;
- s4 a;
- s4 *mcodeptr;
- stackptr src;
- varinfo *var;
- basicblock *bptr;
- instruction *iptr;
- xtable *ex;
-
+ s4 len, s1, s2, s3, d;
+ s4 a;
+ s4 parentargs_base;
+ s4 *mcodeptr;
+ stackptr src;
+ varinfo *var;
+ basicblock *bptr;
+ instruction *iptr;
+ exceptiontable *ex;
+ u2 currentline=0;
{
- int p, pa, t, l, r;
+ s4 i, p, pa, t, l;
+ s4 savedregs_num;
- 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 */
- savedregs_num += (savintregcnt - maxsavintreguse);
- savedregs_num += (savfltregcnt - maxsavfltreguse);
+ savedregs_num += (rd->savintregcnt - rd->maxsavintreguse);
+ savedregs_num += (rd->savfltregcnt - rd->maxsavfltreguse);
- parentargs_base = maxmemuse + savedregs_num;
+ parentargs_base = rd->maxmemuse + savedregs_num;
-#ifdef USE_THREADS /* space to save argument of monitor_enter */
+#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_adds4(parentargs_base * 8); /* FrameSize */
+ (void) dseg_addaddress(cd, m); /* MethodPointer */
+ (void) dseg_adds4(cd, parentargs_base * 8); /* FrameSize */
-#ifdef USE_THREADS
+#if defined(USE_THREADS)
/* IsSync contains the offset relative to the stack pointer for the
argument of monitor_exit used in the exception handler. Since the
offset by one.
*/
- if (checksync && (method->flags & ACC_SYNCHRONIZED))
- (void) dseg_adds4((maxmemuse + 1) * 8); /* IsSync */
+ if (checksync && (m->flags & ACC_SYNCHRONIZED))
+ (void) dseg_adds4(cd, (rd->maxmemuse + 1) * 8); /* IsSync */
else
#endif
- (void) dseg_adds4(0); /* IsSync */
+ (void) dseg_adds4(cd, 0); /* IsSync */
- (void) dseg_adds4(isleafmethod); /* IsLeaf */
- (void) dseg_adds4(savintregcnt - maxsavintreguse); /* IntSave */
- (void) dseg_adds4(savfltregcnt - maxsavfltreguse); /* FltSave */
- (void) dseg_adds4(exceptiontablelength); /* ExTableSize */
-
- /* create exception table */
-
- for (ex = extable; ex != NULL; ex = ex->down) {
+ (void) dseg_adds4(cd, m->isleafmethod); /* IsLeaf */
+ (void) dseg_adds4(cd, rd->savintregcnt - rd->maxsavintreguse);/* IntSave */
+ (void) dseg_adds4(cd, rd->savfltregcnt - rd->maxsavfltreguse);/* FltSave */
-#ifdef LOOP_DEBUG
- if (ex->start != NULL)
- printf("adding start - %d - ", ex->start->debug_nr);
- else {
- printf("PANIC - start is NULL");
- exit(-1);
- }
-#endif
-
- dseg_addtarget(ex->start);
-
-#ifdef LOOP_DEBUG
- if (ex->end != NULL)
- printf("adding end - %d - ", ex->end->debug_nr);
- else {
- printf("PANIC - end is NULL");
- exit(-1);
- }
-#endif
+ dseg_addlinenumbertablesize(cd);
- dseg_addtarget(ex->end);
+ (void) dseg_adds4(cd, cd->exceptiontablelength); /* ExTableSize */
-#ifdef LOOP_DEBUG
- if (ex->handler != NULL)
- printf("adding handler - %d\n", ex->handler->debug_nr);
- else {
- printf("PANIC - handler is NULL");
- exit(-1);
- }
-#endif
+ /* create exception table */
- dseg_addtarget(ex->handler);
-
- (void) dseg_addaddress(ex->catchtype);
- }
+ for (ex = cd->exceptiontable; ex != NULL; ex = ex->down) {
+ dseg_addtarget(cd, ex->start);
+ dseg_addtarget(cd, ex->end);
+ dseg_addtarget(cd, ex->handler);
+ (void) dseg_addaddress(cd, ex->catchtype);
+ }
/* initialize mcode variables */
- mcodeptr = (s4*) mcodebase;
- mcodeend = (s4*) (mcodebase + mcodesize);
- MCODECHECK(128 + mparamcount);
+ mcodeptr = (s4 *) cd->mcodebase;
+ cd->mcodeend = (s4 *) (cd->mcodebase + cd->mcodesize);
+ MCODECHECK(128 + m->paramcount);
/* create stack frame (if necessary) */
- if (parentargs_base)
- {M_LDA (REG_SP, REG_SP, -parentargs_base * 8);}
+ if (parentargs_base) {
+ M_LDA(REG_SP, REG_SP, -parentargs_base * 8);
+ }
/* save return address and used callee saved registers */
p = parentargs_base;
- if (!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--)
- {p--; M_DST (savfltregs[r], REG_SP, 8 * p);}
+ if (!m->isleafmethod) {
+ p--; M_AST(REG_RA, REG_SP, p * 8);
+ }
+ for (i = rd->savintregcnt - 1; i >= rd->maxsavintreguse; i--) {
+ p--; M_LST(rd->savintregs[i], REG_SP, p * 8);
+ }
+ for (i = rd->savfltregcnt - 1; i >= rd->maxsavfltreguse; i--) {
+ p--; M_DST(rd->savfltregs[i], REG_SP, p * 8);
+ }
/* save monitorenter argument */
-#ifdef USE_THREADS
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
- if (method->flags & ACC_STATIC) {
- p = dseg_addaddress (class);
+#if defined(USE_THREADS)
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+ if (m->flags & ACC_STATIC) {
+ p = dseg_addaddress(cd, m->class);
M_ALD(REG_ITMP1, REG_PV, p);
- M_AST(REG_ITMP1, REG_SP, 8 * maxmemuse);
- }
- else {
- M_AST (argintregs[0], REG_SP, 8 * maxmemuse);
- }
- }
+ M_AST(REG_ITMP1, REG_SP, rd->maxmemuse * 8);
+
+ } else {
+ M_AST(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
+ }
+ }
#endif
/* copy argument registers to stack and call trace function with pointer
*/
if (runverbose) {
- int disp;
- M_LDA(REG_SP, REG_SP, -(14 * 8));
+ s4 disp;
+ M_LDA(REG_SP, REG_SP, -((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8));
M_AST(REG_RA, REG_SP, 1 * 8);
/* save integer argument registers */
- for (p = 0; p < mparamcount && p < INT_ARG_CNT; p++) {
- M_LST(argintregs[p], REG_SP, (2 + p) * 8);
+ for (p = 0; /* p < m->paramcount && */ p < INT_ARG_CNT; p++) {
+ M_LST(rd->argintregs[p], REG_SP, (2 + p) * 8);
}
/* save and copy float arguments into integer registers */
- for (p = 0; p < mparamcount && p < FLT_ARG_CNT; p++) {
- t = mparamtypes[p];
+ for (p = 0; /* p < m->paramcount && */ p < FLT_ARG_CNT; p++) {
+ t = m->paramtypes[p];
if (IS_FLT_DBL_TYPE(t)) {
if (IS_2_WORD_TYPE(t)) {
- M_DST(argfltregs[p], REG_SP, (8 + p) * 8);
+ M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+
} else {
- M_FST(argfltregs[p], REG_SP, (8 + p) * 8);
+ M_FST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
}
- M_LLD(argintregs[p], REG_SP, (8 + p) * 8);
+ M_LLD(rd->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
} else {
- M_DST(argfltregs[p], REG_SP, (8 + p) * 8);
+ M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
}
}
- p = dseg_addaddress(method);
+ p = dseg_addaddress(cd, m);
M_ALD(REG_ITMP1, REG_PV, p);
- M_AST(REG_ITMP1, REG_SP, 0);
- p = dseg_addaddress((void *) builtin_trace_args);
+ M_AST(REG_ITMP1, REG_SP, 0 * 8);
+ p = dseg_addaddress(cd, (void *) builtin_trace_args);
M_ALD(REG_PV, REG_PV, p);
M_JSR(REG_RA, REG_PV);
- disp = -(int)((u1 *) mcodeptr - mcodebase);
+ disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
M_LDA(REG_PV, REG_RA, disp);
M_ALD(REG_RA, REG_SP, 1 * 8);
- for (p = 0; p < mparamcount && p < INT_ARG_CNT; p++) {
- M_LLD(argintregs[p], REG_SP, (2 + p) * 8);
+ for (p = 0; /* p < mparamcount && */ p < INT_ARG_CNT; p++) {
+ M_LLD(rd->argintregs[p], REG_SP, (2 + p) * 8);
}
- for (p = 0; p < mparamcount && p < FLT_ARG_CNT; p++) {
- t = mparamtypes[p];
+ for (p = 0; /* p < mparamcount && */ p < FLT_ARG_CNT; p++) {
+ t = m->paramtypes[p];
if (IS_FLT_DBL_TYPE(t)) {
if (IS_2_WORD_TYPE(t)) {
- M_DLD(argfltregs[p], REG_SP, (8 + p) * 8);
+ M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+
} else {
- M_FLD(argfltregs[p], REG_SP, (8 + p) * 8);
+ M_FLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
}
+
} else {
- M_DLD(argfltregs[p], REG_SP, (8 + p) * 8);
+ M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
}
}
- M_LDA (REG_SP, REG_SP, 14 * 8);
+ M_LDA(REG_SP, REG_SP, (INT_ARG_CNT + FLT_ARG_CNT + 2) * 8);
}
/* take arguments out of register or stack frame */
- for (p = 0, l = 0; p < mparamcount; p++) {
- t = mparamtypes[p];
- var = &(locals[l][t]);
+ for (p = 0, l = 0; p < m->paramcount; p++) {
+ t = m->paramtypes[p];
+ var = &(rd->locals[l][t]);
l++;
if (IS_2_WORD_TYPE(t)) /* increment local counter for 2 word types */
l++;
if (var->type < 0)
continue;
- r = var->regoff;
if (IS_INT_LNG_TYPE(t)) { /* integer args */
if (p < INT_ARG_CNT) { /* register arguments */
- if (!(var->flags & INMEMORY)) /* reg arg -> register */
- {M_INTMOVE (argintregs[p], r);}
- else /* reg arg -> spilled */
- M_LST (argintregs[p], REG_SP, 8 * r);
+ if (!(var->flags & INMEMORY)) { /* reg arg -> register */
+ M_INTMOVE(rd->argintregs[p], var->regoff);
+ } else { /* reg arg -> spilled */
+ M_LST(rd->argintregs[p], REG_SP, 8 * var->regoff);
}
- else { /* stack arguments */
+
+ } else { /* stack arguments */
pa = p - INT_ARG_CNT;
- if (!(var->flags & INMEMORY)) /* stack arg -> register */
- M_LLD (r, REG_SP, 8 * (parentargs_base + pa));
- else { /* stack arg -> spilled */
- M_LLD (REG_ITMP1, REG_SP, 8 * (parentargs_base + pa));
- M_LST (REG_ITMP1, REG_SP, 8 * r);
- }
- }
- }
- else { /* floating args */
+ if (!(var->flags & INMEMORY)) { /* stack arg -> register */
+ M_LLD(var->regoff, REG_SP, 8 * (parentargs_base + pa));
+
+ } else { /* stack arg -> spilled */
+ M_LLD(REG_ITMP1, REG_SP, 8 * (parentargs_base + pa));
+ M_LST(REG_ITMP1, REG_SP, 8 * var->regoff);
+ }
+ }
+
+ } else { /* floating args */
if (p < FLT_ARG_CNT) { /* register arguments */
- if (!(var->flags & INMEMORY)) /* reg arg -> register */
- {M_FLTMOVE (argfltregs[p], r);}
- else /* reg arg -> spilled */
- M_DST (argfltregs[p], REG_SP, 8 * r);
- }
- else { /* stack arguments */
- pa = p - FLT_ARG_CNT;
- if (!(var->flags & INMEMORY)) /* stack-arg -> register */
- M_DLD (r, REG_SP, 8 * (parentargs_base + pa) );
- else { /* stack-arg -> spilled */
- M_DLD (REG_FTMP1, REG_SP, 8 * (parentargs_base + pa));
- M_DST (REG_FTMP1, REG_SP, 8 * r);
- }
+ if (!(var->flags & INMEMORY)) { /* reg arg -> register */
+ M_FLTMOVE(rd->argfltregs[p], var->regoff);
+
+ } else { /* reg arg -> spilled */
+ M_DST(rd->argfltregs[p], REG_SP, 8 * var->regoff);
}
- }
- } /* end for */
- /* call trace function */
+ } else { /* stack arguments */
+ pa = p - FLT_ARG_CNT;
+ if (!(var->flags & INMEMORY)) { /* stack-arg -> register */
+ M_DLD(var->regoff, REG_SP, 8 * (parentargs_base + pa) );
-#if 0
- if (runverbose && !isleafmethod) {
- M_LDA (REG_SP, REG_SP, -8);
- p = dseg_addaddress (method);
- M_ALD(REG_ITMP1, REG_PV, p);
- M_AST(REG_ITMP1, REG_SP, 0);
- p = dseg_addaddress ((void*) (builtin_trace_args));
- M_ALD(REG_PV, REG_PV, p);
- M_JSR(REG_RA, REG_PV);
- M_LDA(REG_PV, REG_RA, -(int)((u1*) mcodeptr - mcodebase));
- M_LDA(REG_SP, REG_SP, 8);
+ } else { /* stack-arg -> spilled */
+ M_DLD(REG_FTMP1, REG_SP, 8 * (parentargs_base + pa));
+ M_DST(REG_FTMP1, REG_SP, 8 * var->regoff);
+ }
+ }
}
-#endif
+ } /* end for */
/* call monitorenter function */
-#ifdef USE_THREADS
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
- int disp;
- p = dseg_addaddress ((void*) (builtin_monitorenter));
+#if defined(USE_THREADS)
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+ s4 disp;
+ s8 func_enter = (m->flags & ACC_STATIC) ?
+ (s8) builtin_staticmonitorenter : (s8) builtin_monitorenter;
+ p = dseg_addaddress(cd, (void*) func_enter);
M_ALD(REG_PV, REG_PV, p);
- M_ALD(argintregs[0], REG_SP, 8 * maxmemuse);
+ M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
M_JSR(REG_RA, REG_PV);
- disp = -(int)((u1*) mcodeptr - mcodebase);
+ disp = -(s4) ((u1 *) mcodeptr - cd->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 - cd->mcodebase);
if (bptr->flags >= BBREACHED) {
{
branchref *brefs;
for (brefs = bptr->branchrefs; brefs != NULL; brefs = brefs->next) {
- gen_resolvebranch((u1*) mcodebase + brefs->branchpos,
+ gen_resolvebranch((u1*) cd->mcodebase + brefs->branchpos,
brefs->branchpos, bptr->mpc);
}
}
src = bptr->instack;
len = bptr->indepth;
MCODECHECK(64+len);
+#ifdef LSRA
+ if (opt_lsra) {
while (src != NULL) {
len--;
if ((len == 0) && (bptr->type != BBTYPE_STD)) {
- d = reg_of_var(src, REG_ITMP1);
+ /* d = reg_of_var(m, src, REG_ITMP1); */
+ if (!(src->flags & INMEMORY))
+ d= src->regoff;
+ else
+ d=REG_ITMP1;
+ M_INTMOVE(REG_ITMP1, d);
+ store_reg_to_var_int(src, d);
+ }
+ src = src->prev;
+ }
+ } else {
+#endif
+ while (src != NULL) {
+ len--;
+ if ((len == 0) && (bptr->type != BBTYPE_STD)) {
+ d = reg_of_var(rd, src, REG_ITMP1);
M_INTMOVE(REG_ITMP1, d);
store_reg_to_var_int(src, d);
}
else {
- d = reg_of_var(src, REG_IFTMP);
+ d = reg_of_var(rd, src, REG_IFTMP);
if ((src->varkind != STACKVAR)) {
s2 = src->type;
if (IS_FLT_DBL_TYPE(s2)) {
- if (!(interfaces[len][s2].flags & INMEMORY)) {
- s1 = interfaces[len][s2].regoff;
+ if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+ s1 = rd->interfaces[len][s2].regoff;
M_FLTMOVE(s1,d);
}
else {
- M_DLD(d, REG_SP, 8 * interfaces[len][s2].regoff);
+ M_DLD(d, REG_SP, 8 * rd->interfaces[len][s2].regoff);
}
store_reg_to_var_flt(src, d);
}
else {
- if (!(interfaces[len][s2].flags & INMEMORY)) {
- s1 = interfaces[len][s2].regoff;
+ if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+ s1 = rd->interfaces[len][s2].regoff;
M_INTMOVE(s1,d);
}
else {
- M_LLD(d, REG_SP, 8 * interfaces[len][s2].regoff);
+ M_LLD(d, REG_SP, 8 * rd->interfaces[len][s2].regoff);
}
store_reg_to_var_int(src, d);
}
}
src = src->prev;
}
+#ifdef LSRA
+ }
+#endif
/* walk through all instructions */
len > 0;
src = iptr->dst, len--, iptr++) {
+ if (iptr->line!=currentline) {
+ dseg_addlinenumber(cd,iptr->line,mcodeptr);
+ currentline=iptr->line;
+ }
+
MCODECHECK(64); /* an instruction usually needs < 64 words */
switch (iptr->opc) {
var_to_reg_int(s1, src, REG_ITMP1);
M_BEQZ(s1, 0);
- codegen_addxnullrefs(mcodeptr);
+ codegen_addxnullrefs(cd, mcodeptr);
break;
/* constant operations ************************************************/
-#define ICONST(r,c) if(((c)>=-32768)&&((c)<= 32767)){M_LDA(r,REG_ZERO,c);} \
- else{a=dseg_adds4(c);M_ILD(r,REG_PV,a);}
-
-#define LCONST(r,c) if(((c)>=-32768)&&((c)<= 32767)){M_LDA(r,REG_ZERO,c);} \
- else{a=dseg_adds8(c);M_LLD(r,REG_PV,a);}
-
case ICMD_ICONST: /* ... ==> ..., constant */
/* op1 = 0, val.i = constant */
- d = reg_of_var(iptr->dst, REG_ITMP1);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP1);
ICONST(d, iptr->val.i);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_LCONST: /* ... ==> ..., constant */
/* op1 = 0, val.l = constant */
- d = reg_of_var(iptr->dst, REG_ITMP1);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP1);
LCONST(d, iptr->val.l);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_FCONST: /* ... ==> ..., constant */
/* op1 = 0, val.f = constant */
- d = reg_of_var(iptr->dst, REG_FTMP1);
- a = dseg_addfloat(iptr->val.f);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ a = dseg_addfloat(cd, iptr->val.f);
M_FLD(d, REG_PV, a);
store_reg_to_var_flt(iptr->dst, d);
break;
case ICMD_DCONST: /* ... ==> ..., constant */
/* op1 = 0, val.d = constant */
- d = reg_of_var(iptr->dst, REG_FTMP1);
- a = dseg_adddouble(iptr->val.d);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ a = dseg_adddouble(cd, iptr->val.d);
M_DLD(d, REG_PV, a);
store_reg_to_var_flt(iptr->dst, d);
break;
case ICMD_ACONST: /* ... ==> ..., constant */
/* op1 = 0, val.a = constant */
- d = reg_of_var(iptr->dst, REG_ITMP1);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP1);
if (iptr->val.a) {
- a = dseg_addaddress (iptr->val.a);
+ a = dseg_addaddress(cd, iptr->val.a);
M_ALD(d, REG_PV, a);
- }
- else {
+ } else {
M_INTMOVE(REG_ZERO, d);
- }
+ }
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_LLOAD: /* op1 = local variable */
case ICMD_ALOAD:
- d = reg_of_var(iptr->dst, REG_ITMP1);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP1);
if ((iptr->dst->varkind == LOCALVAR) &&
(iptr->dst->varnum == iptr->op1))
break;
- var = &(locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
+ var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
if (var->flags & INMEMORY)
M_LLD(d, REG_SP, 8 * var->regoff);
else
case ICMD_FLOAD: /* ... ==> ..., content of local variable */
case ICMD_DLOAD: /* op1 = local variable */
- d = reg_of_var(iptr->dst, REG_FTMP1);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP1);
if ((iptr->dst->varkind == LOCALVAR) &&
(iptr->dst->varnum == iptr->op1))
break;
- var = &(locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
+ var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
if (var->flags & INMEMORY)
M_DLD(d, REG_SP, 8 * var->regoff);
else
if ((src->varkind == LOCALVAR) &&
(src->varnum == iptr->op1))
break;
- var = &(locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
+ var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
if (var->flags & INMEMORY) {
var_to_reg_int(s1, src, REG_ITMP1);
M_LST(s1, REG_SP, 8 * var->regoff);
if ((src->varkind == LOCALVAR) &&
(src->varnum == iptr->op1))
break;
- var = &(locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
+ var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
if (var->flags & INMEMORY) {
var_to_reg_flt(s1, src, REG_FTMP1);
M_DST(s1, REG_SP, 8 * var->regoff);
case ICMD_POP2: /* ..., value, value ==> ... */
break;
-#define M_COPY(from,to) \
- d = reg_of_var(to, REG_IFTMP); \
- if ((from->regoff != to->regoff) || \
- ((from->flags ^ to->flags) & INMEMORY)) { \
- if (IS_FLT_DBL_TYPE(from->type)) { \
- var_to_reg_flt(s1, from, d); \
- M_FLTMOVE(s1,d); \
- store_reg_to_var_flt(to, d); \
- }\
- else { \
- var_to_reg_int(s1, from, d); \
- M_INTMOVE(s1,d); \
- store_reg_to_var_int(to, d); \
- }\
- }
-
case ICMD_DUP: /* ..., a ==> ..., a, a */
M_COPY(src, iptr->dst);
break;
case ICMD_DUP_X1: /* ..., a, b ==> ..., b, a, b */
- M_COPY(src, iptr->dst->prev->prev);
+ M_COPY(src, iptr->dst);
+ M_COPY(src->prev, iptr->dst->prev);
+ M_COPY(iptr->dst, iptr->dst->prev->prev);
+ break;
+
+ case ICMD_DUP_X2: /* ..., a, b, c ==> ..., c, a, b, c */
+
+ M_COPY(src, iptr->dst);
+ M_COPY(src->prev, iptr->dst->prev);
+ M_COPY(src->prev->prev, iptr->dst->prev->prev);
+ M_COPY(iptr->dst, iptr->dst->prev->prev->prev);
+ break;
case ICMD_DUP2: /* ..., a, b ==> ..., a, b, a, b */
case ICMD_DUP2_X1: /* ..., a, b, c ==> ..., b, c, a, b, c */
- M_COPY(src->prev, iptr->dst->prev->prev->prev);
-
- case ICMD_DUP_X2: /* ..., a, b, c ==> ..., c, a, b, c */
-
M_COPY(src, iptr->dst);
M_COPY(src->prev, iptr->dst->prev);
M_COPY(src->prev->prev, iptr->dst->prev->prev);
- M_COPY(src, iptr->dst->prev->prev->prev);
+ M_COPY(iptr->dst, iptr->dst->prev->prev->prev);
+ M_COPY(iptr->dst->prev, iptr->dst->prev->prev->prev->prev);
break;
case ICMD_DUP2_X2: /* ..., a, b, c, d ==> ..., c, d, a, b, c, d */
M_COPY(src->prev, iptr->dst->prev);
M_COPY(src->prev->prev, iptr->dst->prev->prev);
M_COPY(src->prev->prev->prev, iptr->dst->prev->prev->prev);
- M_COPY(src, iptr->dst->prev->prev->prev->prev);
- M_COPY(src->prev, iptr->dst->prev->prev->prev->prev->prev);
+ M_COPY(iptr->dst, iptr->dst->prev->prev->prev->prev);
+ M_COPY(iptr->dst->prev, iptr->dst->prev->prev->prev->prev->prev);
break;
case ICMD_SWAP: /* ..., a, b ==> ..., b, a */
- M_COPY(src, iptr->dst->prev);
+ M_COPY(src, iptr->dst->prev);
M_COPY(src->prev, iptr->dst);
break;
case ICMD_INEG: /* ..., value ==> ..., - value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_ISUB(REG_ZERO, s1, d);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_LNEG: /* ..., value ==> ..., - value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_LSUB(REG_ZERO, s1, d);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_I2L: /* ..., value ==> ..., value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_INTMOVE(s1, d);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_L2I: /* ..., value ==> ..., value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_IADD(s1, REG_ZERO, d );
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_INT2BYTE: /* ..., value ==> ..., value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (has_ext_instr_set) {
M_BSEXT(s1, d);
}
case ICMD_INT2CHAR: /* ..., value ==> ..., value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_CZEXT(s1, d);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_INT2SHORT: /* ..., value ==> ..., value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (has_ext_instr_set) {
M_SSEXT(s1, d);
}
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_IADD(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
M_IADD_IMM(s1, iptr->val.i, d);
}
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_LADD(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
M_LADD_IMM(s1, iptr->val.l, d);
}
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_ISUB(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
M_ISUB_IMM(s1, iptr->val.i, d);
}
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_LSUB(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
M_LSUB_IMM(s1, iptr->val.l, d);
}
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_IMUL(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
M_IMUL_IMM(s1, iptr->val.i, d);
}
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_LMUL (s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
M_LMUL_IMM(s1, iptr->val.l, d);
}
case ICMD_LDIVPOW2: /* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (iptr->val.i <= 15) {
M_LDA(REG_ITMP2, s1, (1 << iptr->val.i) -1);
M_CMOVGE(s1, s1, REG_ITMP2);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_AND_IMM(s2, 0x1f, REG_ITMP3);
M_SLL(s1, REG_ITMP3, d);
M_IADD(d, REG_ZERO, d);
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_SLL_IMM(s1, iptr->val.i & 0x1f, d);
M_IADD(d, REG_ZERO, d);
store_reg_to_var_int(iptr->dst, d);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_AND_IMM(s2, 0x1f, REG_ITMP3);
M_SRA(s1, REG_ITMP3, d);
store_reg_to_var_int(iptr->dst, d);
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_SRA_IMM(s1, iptr->val.i & 0x1f, d);
store_reg_to_var_int(iptr->dst, d);
break;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_AND_IMM(s2, 0x1f, REG_ITMP2);
M_IZEXT(s1, d);
M_SRL(d, REG_ITMP2, d);
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_IZEXT(s1, d);
M_SRL_IMM(d, iptr->val.i & 0x1f, d);
M_IADD(d, REG_ZERO, d);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_SLL(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_SLL_IMM(s1, iptr->val.i & 0x3f, d);
store_reg_to_var_int(iptr->dst, d);
break;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_SRA(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_SRA_IMM(s1, iptr->val.i & 0x3f, d);
store_reg_to_var_int(iptr->dst, d);
break;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_SRL(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_SRL_IMM(s1, iptr->val.i & 0x3f, d);
store_reg_to_var_int(iptr->dst, d);
break;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_AND(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
M_AND_IMM(s1, iptr->val.i, d);
}
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (s1 == d) {
M_MOV(s1, REG_ITMP1);
s1 = REG_ITMP1;
store_reg_to_var_int(iptr->dst, d);
break;
- case ICMD_IREM0X10001: /* ..., value ==> ..., value % 0x100001 */
-
-/* b = value & 0xffff;
- a = value >> 16;
- a = ((b - a) & 0xffff) + (b < a);
-*/
- var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
- if (s1 == d) {
- M_MOV(s1, REG_ITMP3);
- s1 = REG_ITMP3;
- }
- M_BLTZ(s1, 7);
- M_CZEXT(s1, REG_ITMP2);
- M_SRA_IMM(s1, 16, d);
- M_CMPLT(REG_ITMP2, d, REG_ITMP1);
- M_ISUB(REG_ITMP2, d, d);
- M_CZEXT(d, d);
- M_IADD(d, REG_ITMP1, d);
- M_BR(11 + (s1 == REG_ITMP1));
- M_ISUB(REG_ZERO, s1, REG_ITMP1);
- M_CZEXT(REG_ITMP1, REG_ITMP2);
- M_SRA_IMM(REG_ITMP1, 16, d);
- M_CMPLT(REG_ITMP2, d, REG_ITMP1);
- M_ISUB(REG_ITMP2, d, d);
- M_CZEXT(d, d);
- M_IADD(d, REG_ITMP1, d);
- M_ISUB(REG_ZERO, d, d);
- if (s1 == REG_ITMP1) {
- var_to_reg_int(s1, src, REG_ITMP1);
- }
- M_SLL_IMM(s1, 33, REG_ITMP2);
- M_CMPEQ(REG_ITMP2, REG_ZERO, REG_ITMP2);
- M_ISUB(d, REG_ITMP2, d);
- store_reg_to_var_int(iptr->dst, d);
- break;
-
case ICMD_LANDCONST: /* ..., value ==> ..., value & constant */
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
M_AND_IMM(s1, iptr->val.l, d);
}
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (s1 == d) {
M_MOV(s1, REG_ITMP1);
s1 = REG_ITMP1;
store_reg_to_var_int(iptr->dst, d);
break;
- case ICMD_LREM0X10001:/* ..., value ==> ..., value % 0x10001 */
-
- var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
- if (s1 == d) {
- M_MOV(s1, REG_ITMP3);
- s1 = REG_ITMP3;
- }
- M_CZEXT(s1, REG_ITMP2);
- M_SRA_IMM(s1, 16, d);
- M_CMPLT(REG_ITMP2, d, REG_ITMP1);
- M_LSUB(REG_ITMP2, d, d);
- M_CZEXT(d, d);
- M_LADD(d, REG_ITMP1, d);
- M_LDA(REG_ITMP2, REG_ZERO, -1);
- M_SRL_IMM(REG_ITMP2, 33, REG_ITMP2);
- if (s1 == REG_ITMP1) {
- var_to_reg_int(s1, src, REG_ITMP1);
- }
- M_CMPULT(s1, REG_ITMP2, REG_ITMP2);
- M_BNEZ(REG_ITMP2, 11);
- M_LDA(d, REG_ZERO, -257);
- M_ZAPNOT_IMM(d, 0xcd, d);
- M_LSUB(REG_ZERO, s1, REG_ITMP2);
- M_CMOVGE(s1, s1, REG_ITMP2);
- M_UMULH(REG_ITMP2, d, REG_ITMP2);
- M_SRL_IMM(REG_ITMP2, 16, REG_ITMP2);
- M_LSUB(REG_ZERO, REG_ITMP2, d);
- M_CMOVGE(s1, REG_ITMP2, d);
- M_SLL_IMM(d, 16, REG_ITMP2);
- M_LADD(d, REG_ITMP2, d);
- M_LSUB(s1, d, d);
- store_reg_to_var_int(iptr->dst, d);
- break;
-
case ICMD_IOR: /* ..., val1, val2 ==> ..., val1 | val2 */
case ICMD_LOR:
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_OR( s1,s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
M_OR_IMM(s1, iptr->val.i, d);
}
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
M_OR_IMM(s1, iptr->val.l, d);
}
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_XOR(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
M_XOR_IMM(s1, iptr->val.i, d);
}
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
M_XOR_IMM(s1, iptr->val.l, d);
}
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_CMPLT(s1, s2, REG_ITMP3);
M_CMPLT(s2, s1, REG_ITMP1);
M_LSUB (REG_ITMP1, REG_ITMP3, d);
case ICMD_IINC: /* ..., value ==> ..., value + constant */
/* op1 = variable, val.i = constant */
- var = &(locals[iptr->op1][TYPE_INT]);
+ var = &(rd->locals[iptr->op1][TYPE_INT]);
if (var->flags & INMEMORY) {
s1 = REG_ITMP1;
M_LLD(s1, REG_SP, 8 * var->regoff);
case ICMD_FNEG: /* ..., value ==> ..., - value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
M_FMOVN(s1, d);
store_reg_to_var_flt(iptr->dst, d);
break;
case ICMD_DNEG: /* ..., value ==> ..., - value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
M_FMOVN(s1, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (opt_noieee) {
M_FADD(s1, s2, d);
}
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (opt_noieee) {
M_DADD(s1, s2, d);
}
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (opt_noieee) {
M_FSUB(s1, s2, d);
}
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (opt_noieee) {
M_DSUB(s1, s2, d);
}
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (opt_noieee) {
M_FMUL(s1, s2, d);
}
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (opt_noieee) {
M_DMUL(s1, s2, d);
}
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (opt_noieee) {
M_FDIV(s1, s2, d);
}
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (opt_noieee) {
M_DDIV(s1, s2, d);
}
case ICMD_I2F: /* ..., value ==> ..., (float) value */
case ICMD_L2F:
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_FTMP3);
- a = dseg_adddouble(0.0);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
+ a = dseg_adddouble(cd, 0.0);
M_LST (s1, REG_PV, a);
M_DLD (d, REG_PV, a);
M_CVTLF(d, d);
case ICMD_I2D: /* ..., value ==> ..., (double) value */
case ICMD_L2D:
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_FTMP3);
- a = dseg_adddouble(0.0);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
+ a = dseg_adddouble(cd, 0.0);
M_LST (s1, REG_PV, a);
M_DLD (d, REG_PV, a);
M_CVTLD(d, d);
case ICMD_F2I: /* ..., value ==> ..., (int) value */
case ICMD_D2I:
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
- a = dseg_adddouble(0.0);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
+ a = dseg_adddouble(cd, 0.0);
M_CVTDL_C(s1, REG_FTMP2);
M_CVTLI(REG_FTMP2, REG_FTMP3);
M_DST (REG_FTMP3, REG_PV, a);
case ICMD_F2L: /* ..., value ==> ..., (long) value */
case ICMD_D2L:
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
- a = dseg_adddouble(0.0);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
+ a = dseg_adddouble(cd, 0.0);
M_CVTDL_C(s1, REG_FTMP2);
M_DST (REG_FTMP2, REG_PV, a);
M_LLD (d, REG_PV, a);
case ICMD_F2D: /* ..., value ==> ..., (double) value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
M_CVTFDS(s1, d);
M_TRAPB;
store_reg_to_var_flt(iptr->dst, d);
case ICMD_D2F: /* ..., value ==> ..., (float) value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (opt_noieee) {
M_CVTDF(s1, d);
}
case ICMD_DCMPL:
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (opt_noieee) {
M_LSUB_IMM(REG_ZERO, 1, d);
M_FCMPEQ(s1, s2, REG_FTMP3);
case ICMD_DCMPG:
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (opt_noieee) {
M_LADD_IMM(REG_ZERO, 1, d);
M_FCMPEQ(s1, s2, REG_FTMP3);
/* memory operations **************************************************/
- /* #define gen_bound_check \
- if (checkbounds) {\
- M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
- M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\
- M_BEQZ(REG_ITMP3, 0);\
- codegen_addxboundrefs(mcodeptr);\
- }
- */
-
-#define gen_bound_check \
- if (checkbounds) { \
- M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
- M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\
- M_BEQZ(REG_ITMP3, 0);\
- codegen_addxboundrefs(mcodeptr, s2); \
- }
-
case ICMD_ARRAYLENGTH: /* ..., arrayref ==> ..., length */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
gen_nullptr_check(s1);
M_ILD(d, s1, OFFSET(java_arrayheader, size));
store_reg_to_var_int(iptr->dst, d);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_FTMP3);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP3);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
break;
+ case ICMD_IASTORECONST: /* ..., arrayref, index ==> ... */
+
+ var_to_reg_int(s1, src->prev, REG_ITMP1);
+ var_to_reg_int(s2, src, REG_ITMP2);
+ if (iptr->op1 == 0) {
+ gen_nullptr_check(s1);
+ gen_bound_check;
+ }
+ M_S4ADDQ(s2, s1, REG_ITMP1);
+ M_IST(REG_ZERO, REG_ITMP1, OFFSET(java_intarray, data[0]));
+ break;
+
+ case ICMD_LASTORECONST: /* ..., arrayref, index ==> ... */
+
+ var_to_reg_int(s1, src->prev, REG_ITMP1);
+ var_to_reg_int(s2, src, REG_ITMP2);
+ if (iptr->op1 == 0) {
+ gen_nullptr_check(s1);
+ gen_bound_check;
+ }
+ M_S8ADDQ(s2, s1, REG_ITMP1);
+ M_LST(REG_ZERO, REG_ITMP1, OFFSET(java_longarray, data[0]));
+ break;
+
+ case ICMD_AASTORECONST: /* ..., arrayref, index ==> ... */
+
+ var_to_reg_int(s1, src->prev, REG_ITMP1);
+ var_to_reg_int(s2, src, REG_ITMP2);
+ if (iptr->op1 == 0) {
+ gen_nullptr_check(s1);
+ gen_bound_check;
+ }
+ M_SAADDQ(s2, s1, REG_ITMP1);
+ M_AST(REG_ZERO, REG_ITMP1, OFFSET(java_objectarray, data[0]));
+ break;
+
+ case ICMD_BASTORECONST: /* ..., arrayref, index ==> ... */
+
+ var_to_reg_int(s1, src->prev, REG_ITMP1);
+ var_to_reg_int(s2, src, REG_ITMP2);
+ if (iptr->op1 == 0) {
+ gen_nullptr_check(s1);
+ gen_bound_check;
+ }
+ if (has_ext_instr_set) {
+ M_LADD(s2, s1, REG_ITMP1);
+ M_BST(REG_ZERO, REG_ITMP1, OFFSET(java_bytearray, data[0]));
+
+ } else {
+ M_LADD(s2, s1, REG_ITMP1);
+ M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_bytearray, data[0]));
+ M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_bytearray, data[0]));
+ M_INSBL(REG_ZERO, REG_ITMP1, REG_ITMP3);
+ M_MSKBL(REG_ITMP2, REG_ITMP1, REG_ITMP2);
+ M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2);
+ M_LST_U(REG_ITMP2, REG_ITMP1, 0);
+ }
+ break;
+
+ case ICMD_CASTORECONST: /* ..., arrayref, index ==> ... */
+
+ var_to_reg_int(s1, src->prev, REG_ITMP1);
+ var_to_reg_int(s2, src, REG_ITMP2);
+ if (iptr->op1 == 0) {
+ gen_nullptr_check(s1);
+ gen_bound_check;
+ }
+ if (has_ext_instr_set) {
+ M_LADD(s2, s1, REG_ITMP1);
+ M_LADD(s2, REG_ITMP1, REG_ITMP1);
+ M_SST(REG_ZERO, REG_ITMP1, OFFSET(java_chararray, data[0]));
+
+ } else {
+ M_LADD(s2, s1, REG_ITMP1);
+ M_LADD(s2, REG_ITMP1, REG_ITMP1);
+ M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_chararray, data[0]));
+ M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_chararray, data[0]));
+ M_INSWL(REG_ZERO, REG_ITMP1, REG_ITMP3);
+ M_MSKWL(REG_ITMP2, REG_ITMP1, REG_ITMP2);
+ M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2);
+ M_LST_U(REG_ITMP2, REG_ITMP1, 0);
+ }
+ break;
+
+ case ICMD_SASTORECONST: /* ..., arrayref, index ==> ... */
+
+ var_to_reg_int(s1, src->prev, REG_ITMP1);
+ var_to_reg_int(s2, src, REG_ITMP2);
+ if (iptr->op1 == 0) {
+ gen_nullptr_check(s1);
+ gen_bound_check;
+ }
+ if (has_ext_instr_set) {
+ M_LADD(s2, s1, REG_ITMP1);
+ M_LADD(s2, REG_ITMP1, REG_ITMP1);
+ M_SST(REG_ZERO, REG_ITMP1, OFFSET(java_shortarray, data[0]));
+
+ } else {
+ M_LADD(s2, s1, REG_ITMP1);
+ M_LADD(s2, REG_ITMP1, REG_ITMP1);
+ M_LLD_U(REG_ITMP2, REG_ITMP1, OFFSET(java_shortarray, data[0]));
+ M_LDA(REG_ITMP1, REG_ITMP1, OFFSET(java_shortarray, data[0]));
+ M_INSWL(REG_ZERO, REG_ITMP1, REG_ITMP3);
+ M_MSKWL(REG_ITMP2, REG_ITMP1, REG_ITMP2);
+ M_OR(REG_ITMP2, REG_ITMP3, REG_ITMP2);
+ M_LST_U(REG_ITMP2, REG_ITMP1, 0);
+ }
+ break;
+
+
case ICMD_PUTSTATIC: /* ..., value ==> ... */
/* op1 = type, val.a = field address */
- /* if class isn't yet initialized, do it */
+ /* If the static fields' class is not yet initialized, we do it */
+ /* now. The call code is generated later. */
if (!((fieldinfo *) iptr->val.a)->class->initialized) {
- /* call helper function which patches this code */
- a = dseg_addaddress(((fieldinfo *) iptr->val.a)->class);
- M_ALD(REG_ITMP1, REG_PV, a);
- a = dseg_addaddress(asm_check_clinit);
- M_ALD(REG_PV, REG_PV, a);
- M_JSR(REG_RA, REG_PV);
+ codegen_addclinitref(cd, mcodeptr, ((fieldinfo *) iptr->val.a)->class);
- /* recompute pv */
- s1 = (int) ((u1*) mcodeptr - mcodebase);
- if (s1 <= 32768) {
- M_LDA(REG_PV, REG_RA, -s1);
+ /* This is just for debugging purposes. Is very difficult to */
+ /* read patched code. Here we patch the following 2 nop's */
+ /* so that the real code keeps untouched. */
+ if (showdisassemble) {
M_NOP;
-
- } else {
- s4 ml = -s1, mh = 0;
- while (ml < -32768) { ml += 65536; mh--; }
- M_LDA(REG_PV, REG_RA, ml);
- M_LDAH(REG_PV, REG_PV, mh);
}
}
- a = dseg_addaddress(&(((fieldinfo *)(iptr->val.a))->value));
+ a = dseg_addaddress(cd, &(((fieldinfo *)(iptr->val.a))->value));
M_ALD(REG_ITMP1, REG_PV, a);
switch (iptr->op1) {
case TYPE_INT:
/* if class isn't yet initialized, do it */
if (!((fieldinfo *) iptr->val.a)->class->initialized) {
- /* call helper function which patches this code */
- a = dseg_addaddress(((fieldinfo *) iptr->val.a)->class);
- M_ALD(REG_ITMP1, REG_PV, a);
- a = dseg_addaddress(asm_check_clinit);
- M_ALD(REG_PV, REG_PV, a);
- M_JSR(REG_RA, REG_PV);
+ codegen_addclinitref(cd, mcodeptr, ((fieldinfo *) iptr->val.a)->class);
- /* recompute pv */
- s1 = (int) ((u1*) mcodeptr - mcodebase);
- if (s1 <= 32768) {
- M_LDA(REG_PV, REG_RA, -s1);
+ /* This is just for debugging purposes. Is very difficult to */
+ /* read patched code. Here we patch the following 2 nop's */
+ /* so that the real code keeps untouched. */
+ if (showdisassemble) {
M_NOP;
-
- } else {
- s4 ml = -s1, mh = 0;
- while (ml < -32768) { ml += 65536; mh--; }
- M_LDA(REG_PV, REG_RA, ml);
- M_LDAH(REG_PV, REG_PV, mh);
}
}
- a = dseg_addaddress (&(((fieldinfo *)(iptr->val.a))->value));
+ a = dseg_addaddress(cd, &(((fieldinfo *) iptr->val.a)->value));
M_ALD(REG_ITMP1, REG_PV, a);
switch (iptr->op1) {
case TYPE_INT:
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_ILD(d, REG_ITMP1, 0);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_LNG:
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_LLD(d, REG_ITMP1, 0);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_ADR:
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
M_ALD(d, REG_ITMP1, 0);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_FLT:
- d = reg_of_var(iptr->dst, REG_FTMP1);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP1);
M_FLD(d, REG_ITMP1, 0);
store_reg_to_var_flt(iptr->dst, d);
break;
case TYPE_DBL:
- d = reg_of_var(iptr->dst, REG_FTMP1);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP1);
M_DLD(d, REG_ITMP1, 0);
store_reg_to_var_flt(iptr->dst, d);
break;
case ICMD_PUTFIELD: /* ..., value ==> ... */
/* op1 = type, val.i = field offset */
- a = ((fieldinfo *)(iptr->val.a))->offset;
+ a = ((fieldinfo *) iptr->val.a)->offset;
switch (iptr->op1) {
case TYPE_INT:
var_to_reg_int(s1, src->prev, REG_ITMP1);
switch (iptr->op1) {
case TYPE_INT:
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
gen_nullptr_check(s1);
M_ILD(d, s1, a);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_LNG:
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
gen_nullptr_check(s1);
M_LLD(d, s1, a);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_ADR:
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
gen_nullptr_check(s1);
M_ALD(d, s1, a);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_FLT:
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_FTMP1);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP1);
gen_nullptr_check(s1);
M_FLD(d, s1, a);
store_reg_to_var_flt(iptr->dst, d);
break;
case TYPE_DBL:
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_FTMP1);
+ d = reg_of_var(rd, iptr->dst, REG_FTMP1);
gen_nullptr_check(s1);
M_DLD(d, s1, a);
store_reg_to_var_flt(iptr->dst, d);
var_to_reg_int(s1, src, REG_ITMP1);
M_INTMOVE(s1, REG_ITMP1_XPTR);
- a = dseg_addaddress(asm_handle_exception);
+ a = dseg_addaddress(cd, asm_handle_exception);
M_ALD(REG_ITMP2, REG_PV, a);
M_JMP(REG_ITMP2_XPC, REG_ITMP2);
M_NOP; /* nop ensures that XPC is less than the end */
case ICMD_GOTO: /* ... ==> ... */
/* op1 = target JavaVM pc */
M_BR(0);
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
ALIGNCODENOP;
break;
/* op1 = target JavaVM pc */
M_BSR(REG_ITMP1, 0);
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_RET: /* ... ==> ... */
/* op1 = local variable */
- var = &(locals[iptr->op1][TYPE_ADR]);
+ var = &(rd->locals[iptr->op1][TYPE_ADR]);
if (var->flags & INMEMORY) {
M_ALD(REG_ITMP1, REG_SP, 8 * var->regoff);
M_RET(REG_ZERO, REG_ITMP1);
var_to_reg_int(s1, src, REG_ITMP1);
M_BEQZ(s1, 0);
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IFNONNULL: /* ..., value ==> ... */
var_to_reg_int(s1, src, REG_ITMP1);
M_BNEZ(s1, 0);
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IFEQ: /* ..., value ==> ... */
}
M_BNEZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IFLT: /* ..., value ==> ... */
}
M_BNEZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IFLE: /* ..., value ==> ... */
}
M_BNEZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IFNE: /* ..., value ==> ... */
}
M_BEQZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IFGT: /* ..., value ==> ... */
}
M_BEQZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IFGE: /* ..., value ==> ... */
}
M_BEQZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_LEQ: /* ..., value ==> ... */
}
M_BNEZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_LLT: /* ..., value ==> ... */
}
M_BNEZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_LLE: /* ..., value ==> ... */
}
M_BNEZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_LNE: /* ..., value ==> ... */
}
M_BEQZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_LGT: /* ..., value ==> ... */
}
M_BEQZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_LGE: /* ..., value ==> ... */
}
M_BEQZ(REG_ITMP1, 0);
}
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_ICMPEQ: /* ..., value, value ==> ... */
var_to_reg_int(s2, src, REG_ITMP2);
M_CMPEQ(s1, s2, REG_ITMP1);
M_BNEZ(REG_ITMP1, 0);
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_ICMPNE: /* ..., value, value ==> ... */
var_to_reg_int(s2, src, REG_ITMP2);
M_CMPEQ(s1, s2, REG_ITMP1);
M_BEQZ(REG_ITMP1, 0);
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_ICMPLT: /* ..., value, value ==> ... */
var_to_reg_int(s2, src, REG_ITMP2);
M_CMPLT(s1, s2, REG_ITMP1);
M_BNEZ(REG_ITMP1, 0);
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_ICMPGT: /* ..., value, value ==> ... */
var_to_reg_int(s2, src, REG_ITMP2);
M_CMPLE(s1, s2, REG_ITMP1);
M_BEQZ(REG_ITMP1, 0);
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_ICMPLE: /* ..., value, value ==> ... */
var_to_reg_int(s2, src, REG_ITMP2);
M_CMPLE(s1, s2, REG_ITMP1);
M_BNEZ(REG_ITMP1, 0);
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
case ICMD_IF_ICMPGE: /* ..., value, value ==> ... */
var_to_reg_int(s2, src, REG_ITMP2);
M_CMPLT(s1, s2, REG_ITMP1);
M_BEQZ(REG_ITMP1, 0);
- codegen_addreference(BlockPtrOfPC(iptr->op1), mcodeptr);
+ codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
break;
/* (value xx 0) ? IFxx_ICONST : ELSE_ICONST */
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
s3 = iptr->val.i;
if (iptr[1].opc == ICMD_ELSE_ICONST) {
if ((s3 == 1) && (iptr[1].val.i == 0)) {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
s3 = iptr->val.i;
if (iptr[1].opc == ICMD_ELSE_ICONST) {
if ((s3 == 0) && (iptr[1].val.i == 1)) {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
s3 = iptr->val.i;
if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
if ((s3 == 1) && (iptr[1].val.i == 0)) {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
s3 = iptr->val.i;
if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
if ((s3 == 1) && (iptr[1].val.i == 0)) {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
s3 = iptr->val.i;
if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
if ((s3 == 1) && (iptr[1].val.i == 0)) {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
s3 = iptr->val.i;
if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
if ((s3 == 1) && (iptr[1].val.i == 0)) {
case ICMD_LRETURN:
case ICMD_ARETURN:
-#ifdef USE_THREADS
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
- int disp;
- a = dseg_addaddress ((void*) (builtin_monitorexit));
+ var_to_reg_int(s1, src, REG_RESULT);
+ M_INTMOVE(s1, REG_RESULT);
+
+#if defined(USE_THREADS)
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+ s4 disp;
+ a = dseg_addaddress(cd, (void *) (builtin_monitorexit));
M_ALD(REG_PV, REG_PV, a);
- M_ALD(argintregs[0], REG_SP, 8 * maxmemuse);
+ M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
+ M_LST(REG_RESULT, REG_SP, rd->maxmemuse * 8);
M_JSR(REG_RA, REG_PV);
- disp = -(int)((u1*) mcodeptr - mcodebase);
+ disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
M_LDA(REG_PV, REG_RA, disp);
- }
+ M_LLD(REG_RESULT, REG_SP, rd->maxmemuse * 8);
+ }
#endif
- var_to_reg_int(s1, src, REG_RESULT);
- M_INTMOVE(s1, REG_RESULT);
+
goto nowperformreturn;
case ICMD_FRETURN: /* ..., retvalue ==> ... */
case ICMD_DRETURN:
-#ifdef USE_THREADS
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
- int disp;
- a = dseg_addaddress ((void*) (builtin_monitorexit));
+ var_to_reg_flt(s1, src, REG_FRESULT);
+ M_FLTMOVE(s1, REG_FRESULT);
+
+#if defined(USE_THREADS)
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+ s4 disp;
+ a = dseg_addaddress(cd, (void *) (builtin_monitorexit));
M_ALD(REG_PV, REG_PV, a);
- M_ALD(argintregs[0], REG_SP, 8 * maxmemuse);
+ M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
+ M_DST(REG_FRESULT, REG_SP, rd->maxmemuse * 8);
M_JSR(REG_RA, REG_PV);
- disp = -(int)((u1*) mcodeptr - mcodebase);
+ disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
M_LDA(REG_PV, REG_RA, disp);
- }
+ M_DLD(REG_FRESULT, REG_SP, rd->maxmemuse * 8);
+ }
#endif
- var_to_reg_flt(s1, src, REG_FRESULT);
- M_FLTMOVE(s1, REG_FRESULT);
+
goto nowperformreturn;
case ICMD_RETURN: /* ... ==> ... */
-#ifdef USE_THREADS
- if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
- int disp;
- a = dseg_addaddress ((void*) (builtin_monitorexit));
+#if defined(USE_THREADS)
+ if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+ s4 disp;
+ a = dseg_addaddress(cd, (void *) (builtin_monitorexit));
M_ALD(REG_PV, REG_PV, a);
- M_ALD(argintregs[0], REG_SP, 8 * maxmemuse);
+ M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
M_JSR(REG_RA, REG_PV);
- disp = -(int)((u1*) mcodeptr - mcodebase);
+ disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
M_LDA(REG_PV, REG_RA, disp);
- }
+ }
#endif
nowperformreturn:
{
- int r, p;
+ s4 i, p;
p = parentargs_base;
/* restore return address */
- if (!isleafmethod)
- {p--; M_LLD (REG_RA, REG_SP, 8 * p);}
+ if (!m->isleafmethod) {
+ p--; M_LLD(REG_RA, REG_SP, p * 8);
+ }
/* restore saved registers */
- for (r = savintregcnt - 1; r >= maxsavintreguse; r--)
- {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);}
+ for (i = rd->savintregcnt - 1; i >= rd->maxsavintreguse; i--) {
+ p--; M_LLD(rd->savintregs[i], REG_SP, p * 8);
+ }
+ for (i = rd->savfltregcnt - 1; i >= rd->maxsavfltreguse; i--) {
+ p--; M_DLD(rd->savfltregs[i], REG_SP, p * 8);
+ }
/* deallocate stack */
- if (parentargs_base)
- {M_LDA(REG_SP, REG_SP, parentargs_base*8);}
+ if (parentargs_base) {
+ M_LDA(REG_SP, REG_SP, parentargs_base * 8);
+ }
/* call trace function */
if (runverbose) {
- M_LDA (REG_SP, REG_SP, -24);
- M_AST(REG_RA, REG_SP, 0);
- M_LST(REG_RESULT, REG_SP, 8);
- M_DST(REG_FRESULT, REG_SP,16);
- a = dseg_addaddress(method);
- M_ALD(argintregs[0], REG_PV, a);
- M_MOV(REG_RESULT, argintregs[1]);
- M_FLTMOVE(REG_FRESULT, argfltregs[2]);
- M_FLTMOVE(REG_FRESULT, argfltregs[3]);
- a = dseg_addaddress((void *) builtin_displaymethodstop);
+ M_LDA(REG_SP, REG_SP, -3 * 8);
+ 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(cd, m);
+ M_ALD(rd->argintregs[0], REG_PV, a);
+ M_MOV(REG_RESULT, rd->argintregs[1]);
+ M_FLTMOVE(REG_FRESULT, rd->argfltregs[2]);
+ M_FLTMOVE(REG_FRESULT, rd->argfltregs[3]);
+ a = dseg_addaddress(cd, (void *) builtin_displaymethodstop);
M_ALD(REG_PV, REG_PV, a);
- M_JSR (REG_RA, REG_PV);
- s1 = (int)((u1*) mcodeptr - mcodebase);
- if (s1<=32768) M_LDA (REG_PV, REG_RA, -s1);
+ M_JSR(REG_RA, REG_PV);
+ s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
else {
- s4 ml=-s1, mh=0;
- while (ml<-32768) { ml+=65536; mh--; }
- M_LDA (REG_PV, REG_RA, ml );
- M_LDAH (REG_PV, REG_PV, mh );
- }
- M_DLD(REG_FRESULT, REG_SP,16);
- M_LLD(REG_RESULT, REG_SP, 8);
- M_ALD(REG_RA, REG_SP, 0);
- M_LDA (REG_SP, REG_SP, 24);
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
}
+ M_DLD(REG_FRESULT, REG_SP, 2 * 8);
+ M_LLD(REG_RESULT, REG_SP, 1 * 8);
+ M_ALD(REG_RA, REG_SP, 0 * 8);
+ M_LDA(REG_SP, REG_SP, 3 * 8);
+ }
M_RET(REG_ZERO, REG_RA);
ALIGNCODENOP;
M_BEQZ(REG_ITMP2, 0);
- /* codegen_addreference(BlockPtrOfPC(s4ptr[0]), mcodeptr); */
- codegen_addreference((basicblock *) tptr[0], mcodeptr);
+ /* codegen_addreference(cd, BlockPtrOfPC(s4ptr[0]), mcodeptr); */
+ codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr);
/* build jump table top down and use address of lowest entry */
tptr += i;
while (--i >= 0) {
- /* dseg_addtarget(BlockPtrOfPC(*--s4ptr)); */
- dseg_addtarget((basicblock *) tptr[0]);
+ /* dseg_addtarget(cd, BlockPtrOfPC(*--s4ptr)); */
+ dseg_addtarget(cd, (basicblock *) tptr[0]);
--tptr;
}
}
/* length of dataseg after last dseg_addtarget is used by load */
M_SAADDQ(REG_ITMP1, REG_PV, REG_ITMP2);
- M_ALD(REG_ITMP2, REG_ITMP2, -dseglen);
+ M_ALD(REG_ITMP2, REG_ITMP2, -(cd->dseglen));
M_JMP(REG_ZERO, REG_ITMP2);
ALIGNCODENOP;
break;
M_LDA(REG_ITMP2, REG_ZERO, val);
}
else {
- a = dseg_adds4 (val);
+ a = dseg_adds4(cd, val);
M_ILD(REG_ITMP2, REG_PV, a);
}
M_CMPEQ(s1, REG_ITMP2, REG_ITMP2);
}
M_BNEZ(REG_ITMP2, 0);
- /* codegen_addreference(BlockPtrOfPC(s4ptr[1]), mcodeptr); */
- codegen_addreference((basicblock *) tptr[0], mcodeptr);
+ /* codegen_addreference(cd, BlockPtrOfPC(s4ptr[1]), mcodeptr); */
+ codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr);
}
M_BR(0);
- /* codegen_addreference(BlockPtrOfPC(l), mcodeptr); */
+ /* codegen_addreference(cd, BlockPtrOfPC(l), mcodeptr); */
tptr = (void **) iptr->target;
- codegen_addreference((basicblock *) tptr[0], mcodeptr);
+ codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr);
ALIGNCODENOP;
break;
s3 = iptr->op1;
gen_method: {
- methodinfo *m;
- classinfo *ci;
+ methodinfo *lm;
MCODECHECK((s3 << 1) + 64);
continue;
if (IS_INT_LNG_TYPE(src->type)) {
if (s3 < INT_ARG_CNT) {
- s1 = argintregs[s3];
+ s1 = rd->argintregs[s3];
var_to_reg_int(d, src, s1);
M_INTMOVE(d, s1);
- }
- else {
+
+ } else {
var_to_reg_int(d, src, REG_ITMP1);
M_LST(d, REG_SP, 8 * (s3 - INT_ARG_CNT));
- }
}
- else
+
+ } else {
if (s3 < FLT_ARG_CNT) {
- s1 = argfltregs[s3];
+ s1 = rd->argfltregs[s3];
var_to_reg_flt(d, src, s1);
M_FLTMOVE(d, s1);
- }
- else {
+
+ } else {
var_to_reg_flt(d, src, REG_FTMP1);
M_DST(d, REG_SP, 8 * (s3 - FLT_ARG_CNT));
- }
- } /* end of for */
+ }
+ }
+ } /* end of for */
- m = iptr->val.a;
+ lm = iptr->val.a;
switch (iptr->opc) {
- case ICMD_BUILTIN3:
- case ICMD_BUILTIN2:
- case ICMD_BUILTIN1:
- a = dseg_addaddress ((void*) (m));
-
- M_ALD(REG_PV, REG_PV, a); /* Pointer to built-in-function */
- d = iptr->op1;
- goto makeactualcall;
+ case ICMD_BUILTIN3:
+ case ICMD_BUILTIN2:
+ case ICMD_BUILTIN1:
+ a = dseg_addaddress(cd, (void *) lm);
+ d = iptr->op1;
- case ICMD_INVOKESTATIC:
- case ICMD_INVOKESPECIAL:
- a = dseg_addaddress (m->stubroutine);
-
- M_ALD(REG_PV, REG_PV, a ); /* method pointer in r27 */
+ M_ALD(REG_PV, REG_PV, a); /* Pointer to built-in-function */
+ break;
- d = m->returntype;
- goto makeactualcall;
+ case ICMD_INVOKESTATIC:
+ case ICMD_INVOKESPECIAL:
+ a = dseg_addaddress(cd, lm->stubroutine);
+ d = lm->returntype;
- case ICMD_INVOKEVIRTUAL:
+ M_ALD(REG_PV, REG_PV, a); /* method pointer in r27 */
+ break;
- gen_nullptr_check(argintregs[0]);
- M_ALD(REG_METHODPTR, argintregs[0],
- OFFSET(java_objectheader, vftbl));
- M_ALD(REG_PV, REG_METHODPTR, OFFSET(vftbl, table[0]) +
- sizeof(methodptr) * m->vftblindex);
+ case ICMD_INVOKEVIRTUAL:
+ d = lm->returntype;
- d = m->returntype;
- goto makeactualcall;
+ gen_nullptr_check(rd->argintregs[0]);
+ M_ALD(REG_METHODPTR, rd->argintregs[0],
+ OFFSET(java_objectheader, vftbl));
+ M_ALD(REG_PV, REG_METHODPTR, OFFSET(vftbl_t, table[0]) +
+ sizeof(methodptr) * lm->vftblindex);
+ break;
- case ICMD_INVOKEINTERFACE:
- ci = m->class;
+ case ICMD_INVOKEINTERFACE:
+ d = lm->returntype;
- gen_nullptr_check(argintregs[0]);
- M_ALD(REG_METHODPTR, argintregs[0],
- OFFSET(java_objectheader, vftbl));
- M_ALD(REG_METHODPTR, REG_METHODPTR,
- OFFSET(vftbl, interfacetable[0]) -
- sizeof(methodptr*) * ci->index);
- M_ALD(REG_PV, REG_METHODPTR,
- sizeof(methodptr) * (m - ci->methods));
-
- d = m->returntype;
- goto makeactualcall;
-
- default:
- d = 0;
- error ("Unkown ICMD-Command: %d", iptr->opc);
- }
-
-makeactualcall:
+ gen_nullptr_check(rd->argintregs[0]);
+ M_ALD(REG_METHODPTR, rd->argintregs[0],
+ OFFSET(java_objectheader, vftbl));
+ M_ALD(REG_METHODPTR, REG_METHODPTR,
+ OFFSET(vftbl_t, interfacetable[0]) -
+ sizeof(methodptr*) * lm->class->index);
+ M_ALD(REG_PV, REG_METHODPTR,
+ sizeof(methodptr) * (lm - lm->class->methods));
+ break;
+ }
- M_JSR (REG_RA, REG_PV);
+ M_JSR(REG_RA, REG_PV);
/* recompute pv */
- s1 = (int)((u1*) mcodeptr - mcodebase);
- if (s1<=32768) M_LDA (REG_PV, REG_RA, -s1);
+ s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
else {
- s4 ml=-s1, mh=0;
- while (ml<-32768) { ml+=65536; mh--; }
- M_LDA (REG_PV, REG_RA, ml );
- M_LDAH (REG_PV, REG_PV, mh );
- }
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
/* d contains return type */
if (d != TYPE_VOID) {
if (IS_INT_LNG_TYPE(iptr->dst->type)) {
- s1 = reg_of_var(iptr->dst, REG_RESULT);
+ s1 = reg_of_var(rd, iptr->dst, REG_RESULT);
M_INTMOVE(REG_RESULT, s1);
store_reg_to_var_int(iptr->dst, s1);
- }
- else {
- s1 = reg_of_var(iptr->dst, REG_FRESULT);
+
+ } else {
+ s1 = reg_of_var(rd, iptr->dst, REG_FRESULT);
M_FLTMOVE(REG_FRESULT, s1);
store_reg_to_var_flt(iptr->dst, s1);
- }
}
}
+ }
break;
{
classinfo *super = (classinfo*) iptr->val.a;
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ codegen_threadcritrestart(cd, (u1 *) mcodeptr - cd->mcodebase);
+#endif
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(iptr->dst, REG_ITMP3);
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
if (s1 == d) {
M_MOV(s1, REG_ITMP1);
s1 = REG_ITMP1;
if (super->flags & ACC_INTERFACE) { /* interface */
M_BEQZ(s1, 6);
M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
- M_ILD(REG_ITMP2, REG_ITMP1, OFFSET(vftbl, interfacetablelength));
+ M_ILD(REG_ITMP2, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength));
M_LDA(REG_ITMP2, REG_ITMP2, - super->index);
M_BLEZ(REG_ITMP2, 2);
M_ALD(REG_ITMP1, REG_ITMP1,
- OFFSET(vftbl, interfacetable[0]) -
+ OFFSET(vftbl_t, interfacetable[0]) -
super->index * sizeof(methodptr*));
M_CMPULT(REG_ZERO, REG_ITMP1, d); /* REG_ITMP1 != 0 */
}
s2 = super->vftbl->diffval;
M_BEQZ(s1, 4 + (s2 > 255));
M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
- M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl, baseval));
+ M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
M_LDA(REG_ITMP1, REG_ITMP1, - super->vftbl->baseval);
if (s2 <= 255)
M_CMPULE_IMM(REG_ITMP1, s2, d);
*/
M_BEQZ(s1, 7);
M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
- a = dseg_addaddress ((void*) super->vftbl);
+ a = dseg_addaddress(cd, (void*) super->vftbl);
M_ALD(REG_ITMP2, REG_PV, a);
- M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl, baseval));
- M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl, baseval));
- M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl, diffval));
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ codegen_threadcritstart(cd, (u1 *) mcodeptr - cd->mcodebase);
+#endif
+ M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
+ M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
+ M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase);
+#endif
M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
M_CMPULE(REG_ITMP1, REG_ITMP2, d);
}
*/
{
- classinfo *super = (classinfo*) iptr->val.a;
+ classinfo *super = (classinfo *) iptr->val.a;
- d = reg_of_var(iptr->dst, REG_ITMP3);
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ codegen_threadcritrestart(cd, (u1 *) mcodeptr - cd->mcodebase);
+#endif
+ d = reg_of_var(rd, iptr->dst, REG_ITMP3);
var_to_reg_int(s1, src, d);
if (iptr->op1) { /* class/interface */
if (super->flags & ACC_INTERFACE) { /* interface */
M_BEQZ(s1, 6);
M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
- M_ILD(REG_ITMP2, REG_ITMP1, OFFSET(vftbl, interfacetablelength));
+ M_ILD(REG_ITMP2, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength));
M_LDA(REG_ITMP2, REG_ITMP2, - super->index);
M_BLEZ(REG_ITMP2, 0);
- codegen_addxcastrefs(mcodeptr);
+ codegen_addxcastrefs(cd, mcodeptr);
M_ALD(REG_ITMP2, REG_ITMP1,
- OFFSET(vftbl, interfacetable[0]) -
+ OFFSET(vftbl_t, interfacetable[0]) -
super->index * sizeof(methodptr*));
M_BEQZ(REG_ITMP2, 0);
- codegen_addxcastrefs(mcodeptr);
+ codegen_addxcastrefs(cd, mcodeptr);
}
else { /* class */
/*
s2 = super->vftbl->diffval;
M_BEQZ(s1, 4 + (s2 != 0) + (s2 > 255));
M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
- M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl, baseval));
+ M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
M_LDA(REG_ITMP1, REG_ITMP1, - super->vftbl->baseval);
if (s2 == 0) {
M_BNEZ(REG_ITMP1, 0);
*/
M_BEQZ(s1, 8 + (d == REG_ITMP3));
M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
- a = dseg_addaddress ((void*) super->vftbl);
+ a = dseg_addaddress(cd, (void *) super->vftbl);
M_ALD(REG_ITMP2, REG_PV, a);
- M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl, baseval));
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ codegen_threadcritstart(cd, (u1 *) mcodeptr - cd->mcodebase);
+#endif
+ M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
if (d != REG_ITMP3) {
- M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl, baseval));
- M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl, diffval));
+ M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
+ M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase);
+#endif
M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
}
else {
- M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl, baseval));
+ M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
M_ISUB(REG_ITMP1, REG_ITMP2, REG_ITMP1);
M_ALD(REG_ITMP2, REG_PV, a);
- M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl, diffval));
+ M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase);
+#endif
}
M_CMPULE(REG_ITMP1, REG_ITMP2, REG_ITMP2);
M_BEQZ(REG_ITMP2, 0);
- codegen_addxcastrefs(mcodeptr);
+ codegen_addxcastrefs(cd, mcodeptr);
}
}
else
var_to_reg_int(s1, src, REG_ITMP1);
M_BLTZ(s1, 0);
- codegen_addxcheckarefs(mcodeptr);
+ codegen_addxcheckarefs(cd, mcodeptr);
+ break;
+
+ case ICMD_CHECKEXCEPTION: /* ... ==> ... */
+
+ M_BEQZ(REG_RESULT, 0);
+ codegen_addxexceptionrefs(cd, mcodeptr);
break;
case ICMD_MULTIANEWARRAY:/* ..., cnt1, [cnt2, ...] ==> ..., arrayref */
for (s1 = iptr->op1; --s1 >= 0; src = src->prev) {
var_to_reg_int(s2, src, REG_ITMP1);
M_BLTZ(s2, 0);
- codegen_addxcheckarefs(mcodeptr);
+ codegen_addxcheckarefs(cd, mcodeptr);
/* copy sizes to stack (argument numbers >= INT_ARG_CNT) */
if (src->varkind != ARGVAR) {
M_LST(s2, REG_SP, 8 * (s1 + INT_ARG_CNT));
- }
}
+ }
/* a0 = dimension count */
- ICONST(argintregs[0], iptr->op1);
+ ICONST(rd->argintregs[0], iptr->op1);
/* a1 = arraydescriptor */
- a = dseg_addaddress(iptr->val.a);
- M_ALD(argintregs[1], REG_PV, a);
+ a = dseg_addaddress(cd, iptr->val.a);
+ M_ALD(rd->argintregs[1], REG_PV, a);
/* a2 = pointer to dimensions = stack pointer */
- M_INTMOVE(REG_SP, argintregs[2]);
+ M_INTMOVE(REG_SP, rd->argintregs[2]);
- a = dseg_addaddress((void*) (builtin_nmultianewarray));
+ a = dseg_addaddress(cd, (void *) builtin_nmultianewarray);
M_ALD(REG_PV, REG_PV, a);
M_JSR(REG_RA, REG_PV);
- s1 = (int)((u1*) mcodeptr - mcodebase);
+ s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
if (s1 <= 32768)
- M_LDA (REG_PV, REG_RA, -s1);
+ M_LDA(REG_PV, REG_RA, -s1);
else {
s4 ml = -s1, mh = 0;
- while (ml < -32768) {ml += 65536; mh--;}
+ while (ml < -32768) { ml += 65536; mh--; }
M_LDA(REG_PV, REG_RA, ml);
M_LDAH(REG_PV, REG_PV, mh);
- }
- s1 = reg_of_var(iptr->dst, REG_RESULT);
+ }
+ s1 = reg_of_var(rd, iptr->dst, REG_RESULT);
M_INTMOVE(REG_RESULT, s1);
store_reg_to_var_int(iptr->dst, s1);
break;
+ case ICMD_INLINE_START:
+ case ICMD_INLINE_END:
+ break;
default: error ("Unknown pseudo command: %d", iptr->opc);
src = bptr->outstack;
len = bptr->outdepth;
MCODECHECK(64+len);
+#ifdef LSRA
+ if (!opt_lsra)
+#endif
while (src) {
len--;
if ((src->varkind != STACKVAR)) {
s2 = src->type;
if (IS_FLT_DBL_TYPE(s2)) {
var_to_reg_flt(s1, src, REG_FTMP1);
- if (!(interfaces[len][s2].flags & INMEMORY)) {
- M_FLTMOVE(s1,interfaces[len][s2].regoff);
+ if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+ M_FLTMOVE(s1,rd->interfaces[len][s2].regoff);
}
else {
- M_DST(s1, REG_SP, 8 * interfaces[len][s2].regoff);
+ M_DST(s1, REG_SP, 8 * rd->interfaces[len][s2].regoff);
}
}
else {
var_to_reg_int(s1, src, REG_ITMP1);
- if (!(interfaces[len][s2].flags & INMEMORY)) {
- M_INTMOVE(s1,interfaces[len][s2].regoff);
+ if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+ M_INTMOVE(s1,rd->interfaces[len][s2].regoff);
}
else {
- M_LST(s1, REG_SP, 8 * interfaces[len][s2].regoff);
+ M_LST(s1, REG_SP, 8 * rd->interfaces[len][s2].regoff);
}
}
}
} /* if (bptr -> flags >= BBREACHED) */
} /* for basic block */
- /* bptr -> mpc = (int)((u1*) mcodeptr - mcodebase); */
+ codegen_createlinenumbertable(cd);
{
/* generate bound check stubs */
s4 *xcodeptr = NULL;
+ branchref *bref;
+
+ for (bref = cd->xboundrefs; bref != NULL; bref = bref->next) {
+ gen_resolvebranch((u1*) cd->mcodebase + bref->branchpos,
+ bref->branchpos,
+ (u1*) mcodeptr - cd->mcodebase);
+
+ MCODECHECK(8);
+
+ /* move index register into REG_ITMP1 */
+ M_MOV(bref->reg, REG_ITMP1);
+ M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4);
+
+ if (xcodeptr != NULL) {
+ M_BR(xcodeptr - mcodeptr - 1);
+
+ } else {
+ xcodeptr = mcodeptr;
+
+ a = dseg_addaddress(cd, asm_throw_and_handle_arrayindexoutofbounds_exception);
+ M_ALD(REG_PV, REG_PV, a);
+
+ M_JSR(REG_RA, REG_PV);
+
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
+ }
+ }
+
+ /* generate negative array size check stubs */
+
+ xcodeptr = NULL;
- for (; xboundrefs != NULL; xboundrefs = xboundrefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
- gen_resolvebranch((u1*) mcodebase + xboundrefs->branchpos,
- xboundrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - (4 + 4));
+ for (bref = cd->xcheckarefs; bref != NULL; bref = bref->next) {
+ if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
+ bref->branchpos,
+ (u1 *) xcodeptr - (u1 *) cd->mcodebase - 4);
continue;
}
-
- gen_resolvebranch((u1*) mcodebase + xboundrefs->branchpos,
- xboundrefs->branchpos, (u1*) mcodeptr - mcodebase);
+ gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
+ bref->branchpos,
+ (u1 *) mcodeptr - cd->mcodebase);
MCODECHECK(8);
- M_MOV(xboundrefs->reg, REG_ITMP1);
- M_LDA(REG_ITMP2_XPC, REG_PV, xboundrefs->branchpos - 4);
+ M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4);
if (xcodeptr != NULL) {
M_BR(xcodeptr - mcodeptr - 1);
} else {
xcodeptr = mcodeptr;
- M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
- M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
- a = dseg_addaddress(string_java_lang_ArrayIndexOutOfBoundsException);
- M_ALD(argintregs[0], REG_PV, a);
- M_MOV(REG_ITMP1, argintregs[1]);
+
+ a = dseg_addaddress(cd, string_java_lang_NegativeArraySizeException);
+ M_ALD(REG_ITMP1_XPTR,REG_PV,a);
- a = dseg_addaddress(new_exception_int);
+ a = dseg_addaddress(cd, asm_throw_and_handle_nat_exception);
M_ALD(REG_PV, REG_PV, a);
- M_JSR(REG_RA, REG_PV);
+ M_JSR(REG_RA, REG_PV);
+
/* recompute pv */
- s1 = (s4) ((u1 *) mcodeptr - mcodebase);
+ s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
else {
s4 ml = -s1, mh = 0;
M_LDAH(REG_PV, REG_PV, mh);
}
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
- M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
- M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
-
- a = dseg_addaddress(asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JMP(REG_ZERO, REG_ITMP3);
}
}
- /* generate negative array size check stubs */
+ /* generate cast check stubs */
xcodeptr = NULL;
- for (; xcheckarefs != NULL; xcheckarefs = xcheckarefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
- gen_resolvebranch((u1*) mcodebase + xcheckarefs->branchpos,
- xcheckarefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
+ for (bref = cd->xcastrefs; bref != NULL; bref = bref->next) {
+ if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
+ bref->branchpos,
+ (u1 *) xcodeptr - (u1 *) cd->mcodebase - 4);
continue;
}
- gen_resolvebranch((u1*) mcodebase + xcheckarefs->branchpos,
- xcheckarefs->branchpos, (u1*) mcodeptr - mcodebase);
+ gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
+ bref->branchpos,
+ (u1 *) mcodeptr - cd->mcodebase);
MCODECHECK(8);
- M_LDA(REG_ITMP2_XPC, REG_PV, xcheckarefs->branchpos - 4);
+ M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4);
if (xcodeptr != NULL) {
M_BR(xcodeptr - mcodeptr - 1);
} else {
xcodeptr = mcodeptr;
- M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
- M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
- a = dseg_addaddress(string_java_lang_NegativeArraySizeException);
- M_ALD(argintregs[0], REG_PV, a);
-
- a = dseg_addaddress(new_exception);
- M_ALD(REG_PV, REG_PV, a);
- M_JSR(REG_RA, REG_PV);
-
- /* recompute pv */
- s1 = (s4) ((u1 *) mcodeptr - mcodebase);
- if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
- else {
- s4 ml = -s1, mh = 0;
- while (ml < -32768) { ml += 65536; mh--; }
- M_LDA(REG_PV, REG_RA, ml);
- M_LDAH(REG_PV, REG_PV, mh);
- }
+ a = dseg_addaddress(cd, string_java_lang_ClassCastException);
+ M_ALD(REG_ITMP1_XPTR,REG_PV,a);
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+ a = dseg_addaddress(cd, asm_throw_and_handle_nat_exception);
+ M_ALD(REG_PV, REG_PV, a);
- M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
- M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
+ M_JSR(REG_RA, REG_PV);
- a = dseg_addaddress(asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, a);
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
- M_JMP(REG_ZERO, REG_ITMP3);
}
}
- /* generate cast check stubs */
+ /* generate exception check stubs */
xcodeptr = NULL;
-
- for (; xcastrefs != NULL; xcastrefs = xcastrefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
- gen_resolvebranch((u1*) mcodebase + xcastrefs->branchpos,
- xcastrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
+
+ for (bref = cd->xexceptionrefs; bref != NULL; bref = bref->next) {
+ if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
+ bref->branchpos,
+ (u1 *) xcodeptr - (u1 *) cd->mcodebase - 4);
continue;
}
- gen_resolvebranch((u1*) mcodebase + xcastrefs->branchpos,
- xcastrefs->branchpos, (u1*) mcodeptr - mcodebase);
+ gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
+ bref->branchpos,
+ (u1 *) mcodeptr - cd->mcodebase);
MCODECHECK(8);
- M_LDA(REG_ITMP2_XPC, REG_PV, xcastrefs->branchpos - 4);
+ M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4);
if (xcodeptr != NULL) {
M_BR(xcodeptr - mcodeptr - 1);
} else {
xcodeptr = mcodeptr;
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
- a = dseg_addaddress(string_java_lang_ClassCastException);
- M_ALD(argintregs[0], REG_PV, a);
-
- a = dseg_addaddress(new_exception);
+ a = dseg_addaddress(cd, &builtin_get_exceptionptrptr);
M_ALD(REG_PV, REG_PV, a);
M_JSR(REG_RA, REG_PV);
/* recompute pv */
- s1 = (s4) ((u1 *) mcodeptr - mcodebase);
+ s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
else {
s4 ml = -s1, mh = 0;
M_LDAH(REG_PV, REG_PV, mh);
}
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+ M_ALD(REG_ITMP1_XPTR, REG_RESULT, 0);
+ M_AST(REG_ZERO, REG_RESULT, 0);
M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
-
- a = dseg_addaddress(asm_handle_exception);
+#else
+ a = dseg_addaddress(cd, &_exceptionptr);
M_ALD(REG_ITMP3, REG_PV, a);
+ M_ALD(REG_ITMP1_XPTR, REG_ITMP3, 0);
+ M_AST(REG_ZERO, REG_ITMP3, 0);
+#endif
+
+ a = dseg_addaddress(cd, asm_refillin_and_handle_exception);
+ M_ALD(REG_PV, REG_PV, a);
+
+ M_JMP(REG_RA, REG_PV);
+
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
- M_JMP(REG_ZERO, REG_ITMP3);
}
}
xcodeptr = NULL;
- for (; xnullrefs != NULL; xnullrefs = xnullrefs->next) {
- if ((exceptiontablelength == 0) && (xcodeptr != NULL)) {
- gen_resolvebranch((u1*) mcodebase + xnullrefs->branchpos,
- xnullrefs->branchpos, (u1*) xcodeptr - (u1*) mcodebase - 4);
+ for (bref = cd->xnullrefs; bref != NULL; bref = bref->next) {
+ if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) {
+ gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
+ bref->branchpos,
+ (u1 *) xcodeptr - (u1 *) cd->mcodebase - 4);
continue;
}
- gen_resolvebranch((u1*) mcodebase + xnullrefs->branchpos,
- xnullrefs->branchpos, (u1*) mcodeptr - mcodebase);
+ gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
+ bref->branchpos,
+ (u1 *) mcodeptr - cd->mcodebase);
MCODECHECK(8);
- M_LDA(REG_ITMP2_XPC, REG_PV, xnullrefs->branchpos - 4);
+ M_LDA(REG_ITMP2_XPC, REG_PV, bref->branchpos - 4);
if (xcodeptr != NULL) {
M_BR(xcodeptr - mcodeptr - 1);
} else {
xcodeptr = mcodeptr;
- M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
- M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+ a = dseg_addaddress(cd, string_java_lang_NullPointerException);
+ M_ALD(REG_ITMP1_XPTR,REG_PV,a);
- a = dseg_addaddress(string_java_lang_NullPointerException);
- M_ALD(argintregs[0], REG_PV, a);
+ a = dseg_addaddress(cd, asm_throw_and_handle_nat_exception);
+ M_ALD(REG_PV, REG_PV, a);
- a = dseg_addaddress(new_exception);
- M_ALD(REG_PV, REG_PV, a);
- M_JSR(REG_RA, REG_PV);
+ M_JSR(REG_RA, REG_PV);
- /* recompute pv */
- s1 = (s4) ((u1 *) mcodeptr - mcodebase);
- if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
- else {
- s4 ml = -s1, mh = 0;
- while (ml < -32768) { ml += 65536; mh--; }
- M_LDA(REG_PV, REG_RA, ml);
- M_LDAH(REG_PV, REG_PV, mh);
- }
+ /* recompute pv */
+ s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
+ if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+ else {
+ s4 ml = -s1, mh = 0;
+ while (ml < -32768) { ml += 65536; mh--; }
+ M_LDA(REG_PV, REG_RA, ml);
+ M_LDAH(REG_PV, REG_PV, mh);
+ }
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+ }
+ }
- M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
- M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
+ /* generate put/getstatic stub call code */
- a = dseg_addaddress(asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, a);
+ {
+ clinitref *cref;
+ u4 mcode;
+ s4 *tmpmcodeptr;
- M_JMP(REG_ZERO, REG_ITMP3);
+ for (cref = cd->clinitrefs; cref != NULL; cref = cref->next) {
+ /* Get machine code which is patched back in later. The call is */
+ /* 1 instruction word long. */
+ xcodeptr = (s4 *) (cd->mcodebase + cref->branchpos);
+ mcode = *xcodeptr;
+
+ /* patch in the call to call the following code (done at compile */
+ /* time) */
+
+ tmpmcodeptr = mcodeptr; /* save current mcodeptr */
+ mcodeptr = xcodeptr; /* set mcodeptr to patch position */
+
+ M_BSR(REG_RA, tmpmcodeptr - (xcodeptr + 1));
+
+ mcodeptr = tmpmcodeptr; /* restore the current mcodeptr */
+
+ MCODECHECK(6);
+
+ /* move class pointer into REG_ITMP2 */
+ a = dseg_addaddress(cd, cref->class);
+ M_ALD(REG_ITMP1, REG_PV, a);
+
+ /* move machine code onto stack */
+ a = dseg_adds4(cd, mcode);
+ M_ILD(REG_ITMP3, REG_PV, a);
+ M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
+ M_IST(REG_ITMP3, REG_SP, 0);
+
+ a = dseg_addaddress(cd, asm_check_clinit);
+ M_ALD(REG_ITMP2, REG_PV, a);
+ M_JMP(REG_ZERO, REG_ITMP2);
}
}
}
- codegen_finish((int)((u1*) mcodeptr - mcodebase));
+ codegen_finish(m, cd, (s4) ((u1 *) mcodeptr - cd->mcodebase));
}
s[1] = (u8) m; /* literals to be adressed */
s[2] = (u8) asm_call_jit_compiler; /* jump directly via PV from above */
-#ifdef STATISTICS
- count_cstub_len += COMPSTUBSIZE * 8;
+#if defined(STATISTICS)
+ if (opt_stat)
+ count_cstub_len += COMPSTUBSIZE * 8;
#endif
return (u1 *) s;
*******************************************************************************/
-#define NATIVESTUBSIZE 44
-#define NATIVEVERBOSESIZE 39 + 13
-#define NATIVESTUBOFFSET 8
+
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#define NATIVESTUB_STACK 8/*ra,native result, oldThreadspecificHeadValue, addressOfThreadspecificHead, method, 0,0,ra*/
+#define NATIVESTUB_THREAD_EXTRA (6 + 20) /*20 for additional frame creation*/
+#define NATIVESTUB_STACKTRACE_OFFSET 1
+#else
+#define NATIVESTUB_STACK 7/*ra,oldThreadspecificHeadValue, addressOfThreadspecificHead, method, 0,0,ra*/
+#define NATIVESTUB_THREAD_EXTRA (1 + 20) /*20 for additional frame creation*/
+#define NATIVESTUB_STACKTRACE_OFFSET 0
+#endif
+
+#define NATIVESTUB_SIZE (44 + NATIVESTUB_THREAD_EXTRA - 1)
+#define NATIVESTUB_STATIC_SIZE 5
+#define NATIVESTUB_VERBOSE_SIZE (39 + 13)
+#define NATIVESTUB_OFFSET 11
+
+#if 0
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#define NATIVESTUB_STACK 2
+#define NATIVESTUB_THREAD_EXTRA 6
+#else
+#define NATIVESTUB_STACK 1
+#define NATIVESTUB_THREAD_EXTRA 1
+#endif
+
+#define NATIVESTUB_SIZE (44 + NATIVESTUB_THREAD_EXTRA - 1)
+#define NATIVESTUB_STATIC_SIZE 4
+#define NATIVESTUB_VERBOSE_SIZE (39 + 13)
+#define NATIVESTUB_OFFSET 10
+#endif
u1 *createnativestub(functionptr f, methodinfo *m)
{
u8 *s; /* memory pointer to hold the stub */
u8 *cs;
s4 *mcodeptr; /* code generation pointer */
- int stackframesize = 0; /* size of stackframe if needed */
- int disp;
- int stubsize;
+ s4 stackframesize = 0; /* size of stackframe if needed */
+ s4 disp;
+ s4 stubsize;
+ codegendata *cd;
+ registerdata *rd;
+ t_inlining_globals *id;
+ s4 dumpsize;
+
+ /* mark start of dump memory area */
+
+ dumpsize = dump_size();
+
+ /* setup registers before using it */
+
+ cd = DNEW(codegendata);
+ rd = DNEW(registerdata);
+ id = DNEW(t_inlining_globals);
+
+ inlining_setup(m, id);
+ reg_setup(m, rd, id);
- reg_init();
descriptor2types(m); /* set paramcount and paramtypes */
- stubsize = runverbose ? NATIVESTUBSIZE + NATIVEVERBOSESIZE : NATIVESTUBSIZE;
+ stubsize = NATIVESTUB_SIZE; /* calculate nativestub size */
+
+ if ((m->flags & ACC_STATIC) && !m->class->initialized)
+ stubsize += NATIVESTUB_STATIC_SIZE;
+
+ if (runverbose)
+ stubsize += NATIVESTUB_VERBOSE_SIZE;
+
s = CNEW(u8, stubsize); /* memory to hold the stub */
- cs = s + NATIVESTUBOFFSET;
- mcodeptr = (s4 *) (cs); /* code generation pointer */
-
- *(cs-1) = (u8) f; /* address of native method */
- *(cs-2) = (u8) (&_exceptionptr); /* address of exceptionptr */
- *(cs-3) = (u8) asm_handle_nat_exception; /* addr of asm exception handler */
- *(cs-4) = (u8) (&env); /* addr of jni_environement */
- *(cs-5) = (u8) builtin_trace_args;
- *(cs-6) = (u8) m;
- *(cs-7) = (u8) builtin_displaymethodstop;
- *(cs-8) = (u8) m->class;
-
- M_LDA(REG_SP, REG_SP, -8); /* build up stackframe */
- M_AST(REG_RA, REG_SP, 0); /* store return address */
-
- /* max. 39 instructions */
- if (runverbose) {
- int p;
- int t;
- M_LDA(REG_SP, REG_SP, -(14 * 8));
+ cs = s + NATIVESTUB_OFFSET;
+ mcodeptr = (s4 *) cs; /* code generation pointer */
+
+ /* set some required varibles which are normally set by codegen_setup */
+ cd->mcodebase = (u1 *) mcodeptr;
+ cd->clinitrefs = NULL;
+
+ *(cs-1) = (u8) f; /* address of native method */
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ *(cs-2) = (u8) &builtin_get_exceptionptrptr;
+#else
+ *(cs-2) = (u8) (&_exceptionptr); /* address of exceptionptr */
+#endif
+ *(cs-3) = (u8) asm_handle_nat_exception; /* addr of asm exception handler*/
+ *(cs-4) = (u8) (&env); /* addr of jni_environement */
+ *(cs-5) = (u8) builtin_trace_args;
+ *(cs-6) = (u8) m;
+ *(cs-7) = (u8) builtin_displaymethodstop;
+ *(cs-8) = (u8) m->class;
+ *(cs-9) = (u8) asm_check_clinit;
+ *(cs-10) = (u8) &builtin_asm_get_stackframeinfo;
+ *(cs-11) = (u8) NULL; /* filled with machine code */
+
+ M_LDA(REG_SP, REG_SP, -NATIVESTUB_STACK * 8); /* build up stackframe */
+ M_AST(REG_RA, REG_SP, 0 * 8); /* store return address */
+
+ M_AST(REG_RA, REG_SP, (6+NATIVESTUB_STACKTRACE_OFFSET) * 8); /* store return address in stackinfo helper*/
+
+ /* if function is static, check for initialized */
+
+ if (m->flags & ACC_STATIC) {
+ /* if class isn't yet initialized, do it */
+ if (!m->class->initialized) {
+ codegen_addclinitref(cd, mcodeptr, m->class);
+ }
+ }
+
+ /* max. 39 +9 instructions */
+ {
+ s4 p;
+ s4 t;
+ M_LDA(REG_SP, REG_SP, -((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8));
M_AST(REG_RA, REG_SP, 1 * 8);
/* save integer argument registers */
for (p = 0; p < m->paramcount && p < INT_ARG_CNT; p++) {
- M_LST(argintregs[p], REG_SP, (2 + p) * 8);
+ M_LST(rd->argintregs[p], REG_SP, (2 + p) * 8);
}
/* save and copy float arguments into integer registers */
if (IS_FLT_DBL_TYPE(t)) {
if (IS_2_WORD_TYPE(t)) {
- M_DST(argfltregs[p], REG_SP, (8 + p) * 8);
- M_LLD(argintregs[p], REG_SP, (8 + p) * 8);
+ M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+ M_LLD(rd->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
} else {
- M_FST(argfltregs[p], REG_SP, (8 + p) * 8);
- M_ILD(argintregs[p], REG_SP, (8 + p) * 8);
+ M_FST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+ M_ILD(rd->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
}
} else {
- M_DST(argfltregs[p], REG_SP, (8 + p) * 8);
+ M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
}
}
- M_ALD(REG_ITMP1, REG_PV, -6 * 8);
- M_AST(REG_ITMP1, REG_SP, 0);
- M_ALD(REG_PV, REG_PV, -5 * 8);
- M_JSR(REG_RA, REG_PV);
- disp = -(int) (mcodeptr - (s4*) cs) * 4;
- M_LDA(REG_PV, REG_RA, disp);
+ if (runverbose) {
+ M_ALD(REG_ITMP1, REG_PV, -6 * 8);
+ M_AST(REG_ITMP1, REG_SP, 0 * 8);
+ M_ALD(REG_PV, REG_PV, -5 * 8);
+ M_JSR(REG_RA, REG_PV);
+ disp = -(s4) (mcodeptr - (s4 *) cs) * 4;
+ M_LDA(REG_PV, REG_RA, disp);
+ }
+
+
+/*stack info */
+ M_ALD(REG_PV, REG_PV, -10 * 8); /* builtin_asm_get_stackframeinfo */
+ M_JSR(REG_RA, REG_PV);
+ disp = -(s4) (mcodeptr - (s4 *) cs) * 4;
+ M_LDA(REG_PV, REG_RA, disp);
+
+#if 0
+ M_MOV(REG_RESULT,REG_ITMP3);
+ M_LST(REG_RESULT,REG_ITMP3,0);
+#endif
+ M_LST(REG_RESULT,REG_SP, ((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8)+(2+NATIVESTUB_STACKTRACE_OFFSET)*8);/*save adress of pointer*/
+ M_LLD(REG_ITMP3,REG_RESULT,0); /* get pointer*/
+ M_LST(REG_ITMP3,REG_SP,(1+NATIVESTUB_STACKTRACE_OFFSET)*8+((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8)); /*save old value*/
+ M_LDA(REG_ITMP3,REG_SP,(1+NATIVESTUB_STACKTRACE_OFFSET)*8+((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8)); /*calculate new value*/
+ M_LLD(REG_ITMP2,REG_ITMP3,8);
+ M_LST(REG_ITMP3,REG_ITMP2,0); /*store new value*/
+ M_LLD(REG_ITMP2,REG_PV,-6*8);
+ M_LST(REG_ITMP2,REG_SP,(3+NATIVESTUB_STACKTRACE_OFFSET)*8+((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8));
+ M_LST(REG_ZERO,REG_SP,(4+NATIVESTUB_STACKTRACE_OFFSET)*8+((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8));
+ M_LST(REG_ZERO,REG_SP,(5+NATIVESTUB_STACKTRACE_OFFSET)*8+((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8));
+/*stack info -end */
+
for (p = 0; p < m->paramcount && p < INT_ARG_CNT; p++) {
- M_LLD(argintregs[p], REG_SP, (2 + p) * 8);
+ M_LLD(rd->argintregs[p], REG_SP, (2 + p) * 8);
}
for (p = 0; p < m->paramcount && p < FLT_ARG_CNT; p++) {
if (IS_FLT_DBL_TYPE(t)) {
if (IS_2_WORD_TYPE(t)) {
- M_DLD(argfltregs[p], REG_SP, (8 + p) * 8);
+ M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
} else {
- M_FLD(argfltregs[p], REG_SP, (8 + p) * 8);
+ M_FLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
}
} else {
- M_DLD(argfltregs[p], REG_SP, (8 + p) * 8);
+ M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
}
}
M_ALD(REG_RA, REG_SP, 1 * 8);
- M_LDA(REG_SP, REG_SP, 14 * 8);
+ M_LDA(REG_SP, REG_SP, (INT_ARG_CNT + FLT_ARG_CNT + 2) * 8);
}
/* save argument registers on stack -- if we have to */
if ((m->flags & ACC_STATIC && m->paramcount > (INT_ARG_CNT - 2)) || m->paramcount > (INT_ARG_CNT - 1)) {
- int i;
- int paramshiftcnt = (m->flags & ACC_STATIC) ? 2 : 1;
- int stackparamcnt = (m->paramcount > INT_ARG_CNT) ? m->paramcount - INT_ARG_CNT : 0;
+ s4 i;
+ s4 paramshiftcnt = (m->flags & ACC_STATIC) ? 2 : 1;
+ s4 stackparamcnt = (m->paramcount > INT_ARG_CNT) ? m->paramcount - INT_ARG_CNT : 0;
stackframesize = stackparamcnt + paramshiftcnt;
if (m->flags & ACC_STATIC) {
if (IS_FLT_DBL_TYPE(m->paramtypes[5])) {
- M_DST(argfltregs[5], REG_SP, 1 * 8);
+ M_DST(rd->argfltregs[5], REG_SP, 1 * 8);
} else {
- M_LST(argintregs[5], REG_SP, 1 * 8);
+ M_LST(rd->argintregs[5], REG_SP, 1 * 8);
}
if (IS_FLT_DBL_TYPE(m->paramtypes[4])) {
- M_DST(argfltregs[4], REG_SP, 0 * 8);
+ M_DST(rd->argfltregs[4], REG_SP, 0 * 8);
} else {
- M_LST(argintregs[4], REG_SP, 0 * 8);
+ M_LST(rd->argintregs[4], REG_SP, 0 * 8);
}
} else {
if (IS_FLT_DBL_TYPE(m->paramtypes[5])) {
- M_DST(argfltregs[5], REG_SP, 0 * 8);
+ M_DST(rd->argfltregs[5], REG_SP, 0 * 8);
} else {
- M_LST(argintregs[5], REG_SP, 0 * 8);
+ M_LST(rd->argintregs[5], REG_SP, 0 * 8);
}
}
}
if (m->flags & ACC_STATIC) {
- M_MOV(argintregs[3], argintregs[5]);
- M_MOV(argintregs[2], argintregs[4]);
- M_MOV(argintregs[1], argintregs[3]);
- M_MOV(argintregs[0], argintregs[2]);
- M_FMOV(argfltregs[3], argfltregs[5]);
- M_FMOV(argfltregs[2], argfltregs[4]);
- M_FMOV(argfltregs[1], argfltregs[3]);
- M_FMOV(argfltregs[0], argfltregs[2]);
+ M_MOV(rd->argintregs[3], rd->argintregs[5]);
+ M_MOV(rd->argintregs[2], rd->argintregs[4]);
+ M_MOV(rd->argintregs[1], rd->argintregs[3]);
+ M_MOV(rd->argintregs[0], rd->argintregs[2]);
+ M_FMOV(rd->argfltregs[3], rd->argfltregs[5]);
+ M_FMOV(rd->argfltregs[2], rd->argfltregs[4]);
+ M_FMOV(rd->argfltregs[1], rd->argfltregs[3]);
+ M_FMOV(rd->argfltregs[0], rd->argfltregs[2]);
/* put class into second argument register */
- M_ALD(argintregs[1], REG_PV, -8 * 8);
+ M_ALD(rd->argintregs[1], REG_PV, -8 * 8);
} else {
- M_MOV(argintregs[4], argintregs[5]);
- M_MOV(argintregs[3], argintregs[4]);
- M_MOV(argintregs[2], argintregs[3]);
- M_MOV(argintregs[1], argintregs[2]);
- M_MOV(argintregs[0], argintregs[1]);
- M_FMOV(argfltregs[4], argfltregs[5]);
- M_FMOV(argfltregs[3], argfltregs[4]);
- M_FMOV(argfltregs[2], argfltregs[3]);
- M_FMOV(argfltregs[1], argfltregs[2]);
- M_FMOV(argfltregs[0], argfltregs[1]);
+ M_MOV(rd->argintregs[4], rd->argintregs[5]);
+ M_MOV(rd->argintregs[3], rd->argintregs[4]);
+ M_MOV(rd->argintregs[2], rd->argintregs[3]);
+ M_MOV(rd->argintregs[1], rd->argintregs[2]);
+ M_MOV(rd->argintregs[0], rd->argintregs[1]);
+ M_FMOV(rd->argfltregs[4], rd->argfltregs[5]);
+ M_FMOV(rd->argfltregs[3], rd->argfltregs[4]);
+ M_FMOV(rd->argfltregs[2], rd->argfltregs[3]);
+ M_FMOV(rd->argfltregs[1], rd->argfltregs[2]);
+ M_FMOV(rd->argfltregs[0], rd->argfltregs[1]);
}
/* put env into first argument register */
- M_ALD(argintregs[0], REG_PV, -4 * 8);
+ M_ALD(rd->argintregs[0], REG_PV, -4 * 8);
M_ALD(REG_PV, REG_PV, -1 * 8); /* load adress of native method */
M_JSR(REG_RA, REG_PV); /* call native method */
- disp = -(int) (mcodeptr - (s4*) cs) * 4;
+ disp = -(s4) (mcodeptr - (s4 *) cs) * 4;
M_LDA(REG_PV, REG_RA, disp); /* recompute pv from ra */
/* remove stackframe if there is one */
/* 13 instructions */
if (runverbose) {
- M_LDA(REG_SP, REG_SP, -(2 * 8));
- M_ALD(argintregs[0], REG_PV, -6 * 8); /* load method adress */
+ M_LDA(REG_SP, REG_SP, -2 * 8);
+ M_ALD(rd->argintregs[0], REG_PV, -6 * 8); /* load method adress */
M_LST(REG_RESULT, REG_SP, 0 * 8);
M_DST(REG_FRESULT, REG_SP, 1 * 8);
- M_MOV(REG_RESULT, argintregs[1]);
- M_FMOV(REG_FRESULT, argfltregs[2]);
- M_FMOV(REG_FRESULT, argfltregs[3]);
+ M_MOV(REG_RESULT, rd->argintregs[1]);
+ M_FMOV(REG_FRESULT, rd->argfltregs[2]);
+ M_FMOV(REG_FRESULT, rd->argfltregs[3]);
M_ALD(REG_PV, REG_PV, -7 * 8); /* builtin_displaymethodstop */
M_JSR(REG_RA, REG_PV);
- disp = -(int) (mcodeptr - (s4*) cs) * 4;
+ disp = -(s4) (mcodeptr - (s4 *) cs) * 4;
M_LDA(REG_PV, REG_RA, disp);
M_LLD(REG_RESULT, REG_SP, 0 * 8);
M_DLD(REG_FRESULT, REG_SP, 1 * 8);
M_LDA(REG_SP, REG_SP, 2 * 8);
}
+ M_LLD(REG_ITMP3,REG_SP,(2+NATIVESTUB_STACKTRACE_OFFSET)*8); /*get address of stacktrace helper pointer*/
+ M_LLD(REG_ITMP1,REG_SP,(1+NATIVESTUB_STACKTRACE_OFFSET)*8); /*get old value*/
+ M_LST(REG_ITMP1,REG_ITMP3,0); /*set old value*/
+
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+ if (IS_FLT_DBL_TYPE(m->returntype))
+ M_DST(REG_FRESULT, REG_SP, 1 * 8);
+ else
+ M_AST(REG_RESULT, REG_SP, 1 * 8);
+ M_ALD(REG_PV, REG_PV, -2 * 8); /* builtin_get_exceptionptrptr */
+ M_JSR(REG_RA, REG_PV);
+ disp = -(s4) (mcodeptr - (s4 *) cs) * 4;
+ M_LDA(REG_PV, REG_RA, disp);
+ M_MOV(REG_RESULT, REG_ITMP3);
+ if (IS_FLT_DBL_TYPE(m->returntype))
+ M_DLD(REG_FRESULT, REG_SP, 1 * 8);
+ else
+ M_ALD(REG_RESULT, REG_SP, 1 * 8);
+#else
M_ALD(REG_ITMP3, REG_PV, -2 * 8); /* get address of exceptionptr */
+#endif
M_ALD(REG_ITMP1, REG_ITMP3, 0); /* load exception into reg. itmp1 */
M_BNEZ(REG_ITMP1, 3); /* if no exception then return */
- M_ALD(REG_RA, REG_SP, 0); /* load return address */
- M_LDA(REG_SP, REG_SP, 8); /* remove stackframe */
+ M_ALD(REG_RA, REG_SP, 0 * 8); /* load return address */
+ M_LDA(REG_SP, REG_SP, NATIVESTUB_STACK * 8); /* remove stackframe */
M_RET(REG_ZERO, REG_RA); /* return to caller */
M_AST(REG_ZERO, REG_ITMP3, 0); /* store NULL into exceptionptr */
- M_ALD(REG_RA, REG_SP, 0); /* load return address */
- M_LDA(REG_SP, REG_SP, 8); /* remove stackframe */
+ M_ALD(REG_RA, REG_SP, 0 * 8); /* load return address */
+ M_LDA(REG_SP, REG_SP, NATIVESTUB_STACK * 8); /* remove stackframe */
M_LDA(REG_ITMP2, REG_RA, -4); /* move fault address into reg. itmp2 */
M_ALD(REG_ITMP3, REG_PV, -3 * 8); /* load asm exception handler address */
M_JMP(REG_ZERO, REG_ITMP3); /* jump to asm exception handler */
+ /* generate put/getstatic stub call code */
+
+ {
+ s4 *xcodeptr;
+ clinitref *cref;
+ s4 *tmpmcodeptr;
+
+ /* there can only be one clinit ref entry */
+ cref = cd->clinitrefs;
+
+ if (cref) {
+ /* Get machine code which is patched back in later. The call is */
+ /* 1 instruction word long. */
+ xcodeptr = (s4 *) (cd->mcodebase + cref->branchpos);
+ *(cs-11) = (u4) *xcodeptr;
+
+ /* patch in the call to call the following code (done at compile */
+ /* time) */
+
+ tmpmcodeptr = mcodeptr; /* save current mcodeptr */
+ mcodeptr = xcodeptr; /* set mcodeptr to patch position */
+
+ M_BSR(REG_RA, tmpmcodeptr - (xcodeptr + 1));
+
+ mcodeptr = tmpmcodeptr; /* restore the current mcodeptr */
+
+ /* move class pointer into REG_ITMP2 */
+ M_ALD(REG_ITMP1, REG_PV, -8 * 8); /* class */
+
+ /* move machine code into REG_ITMP3 */
+ M_ILD(REG_ITMP3, REG_PV, -11 * 8); /* machine code */
+ M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
+ M_IST(REG_ITMP3, REG_SP, 0);
+
+ M_ALD(REG_ITMP2, REG_PV, -9 * 8); /* asm_check_clinit */
+ M_JMP(REG_ZERO, REG_ITMP2);
+ }
+ }
+
#if 0
dolog_plain("stubsize: %d (for %d params)\n", (int) (mcodeptr - (s4*) s), m->paramcount);
#endif
-#ifdef STATISTICS
- count_nstub_len += NATIVESTUBSIZE * 8;
+#if defined(STATISTICS)
+ if (opt_stat)
+ count_nstub_len += NATIVESTUB_SIZE * 8;
#endif
- return (u1*) (s + NATIVESTUBOFFSET);
+ /* release dump area */
+
+ dump_release(dumpsize);
+
+ return (u1 *) (s + NATIVESTUB_OFFSET);
}
void removenativestub(u1 *stub)
{
- CFREE((u8*) stub - NATIVESTUBOFFSET, NATIVESTUBSIZE * 8);
+ CFREE((u8 *) stub - NATIVESTUBOFFSET, NATIVESTUBSIZE * 8);
}