#include "vm/jit/dseg.h"
#include "vm/jit/emit-common.h"
#include "vm/jit/jit.h"
+#include "vm/jit/linenumbertable.h"
#include "vm/jit/methodheader.h"
#include "vm/jit/parse.h"
#include "vm/jit/patcher-common.h"
* purpose registers.
*/
+/*
static void do__log(u4 *regs) {
- /* insert stuff here */
}
+*/
#define DO__LOG \
N_AHI(REG_SP, -200); \
N_LM(R0, R15, 96, REG_SP); \
N_AHI(REG_SP, 200);
-#define SUPPORT_HERCULES 1
+/* If the following macro is defined, workaround code for hercules quirks
+ * is generated
+ */
+
+/* #define SUPPORT_HERCULES 1 */
/* codegen *********************************************************************
registerdata *rd;
s4 len, s1, s2, s3, d, dd, disp;
u2 currentline;
- ptrint a;
- varinfo *var, *var1, *var2, *dst;
+ varinfo *var;
basicblock *bptr;
instruction *iptr;
- exception_entry *ex;
constant_classref *cr;
unresolved_class *uc;
methodinfo *lm; /* local methodinfo for ICMD_INVOKE* */
(void) dseg_add_unique_address(cd, code); /* CodeinfoPointer */
(void) dseg_add_unique_s4(cd, cd->stackframesize * 8); /* FrameSize */
- /* IsSync contains the offset relative to the stack pointer for the
- argument of monitor_exit used in the exception handler. Since the
- offset could be zero and give a wrong meaning of the flag it is
- offset by one.
- */
- /* XXX Remove this "offset by one". */
-
- code->synchronizedoffset = (rd->memuse + 1) * 8;
+ code->synchronizedoffset = rd->memuse * 8;
/* REMOVEME: We still need it for exception handling in assembler. */
(void) dseg_add_unique_s4(cd, INT_SAV_CNT - rd->savintreguse); /* IntSave */
(void) dseg_add_unique_s4(cd, FLT_SAV_CNT - rd->savfltreguse); /* FltSave */
- (void) dseg_addlinenumbertablesize(cd);
-
- (void) dseg_add_unique_s4(cd, jd->exceptiontablelength); /* ExTableSize */
-
- /* create exception table */
-
- for (ex = jd->exceptiontable; ex != NULL; ex = ex->down) {
- dseg_add_target(cd, ex->start);
- dseg_add_target(cd, ex->end);
- dseg_add_target(cd, ex->handler);
- (void) dseg_add_unique_address(cd, ex->catchtype.any);
- }
-
/* Offset PV */
M_AADD_IMM(N_PV_OFFSET, REG_PV);
for (iptr = bptr->iinstr; len > 0; len--, iptr++) {
if (iptr->line != currentline) {
- dseg_addlinenumber(cd, iptr->line);
+ linenumbertable_list_entry_add(cd, iptr->line);
currentline = iptr->line;
}
case ICMD_INLINE_BODY:
REPLACEMENT_POINT_INLINE_BODY(cd, iptr);
- dseg_addlinenumber_inline_start(cd, iptr);
- dseg_addlinenumber(cd, iptr->line);
+ linenumbertable_list_entry_add_inline_start(cd, iptr);
+ linenumbertable_list_entry_add(cd, iptr->line);
break;
case ICMD_INLINE_END:
- dseg_addlinenumber_inline_end(cd, iptr);
- dseg_addlinenumber(cd, iptr->line);
+ linenumbertable_list_entry_add_inline_end(cd, iptr);
+ linenumbertable_list_entry_add(cd, iptr->line);
break;
case ICMD_CHECKNULL: /* ..., objectref ==> ..., objectref */
case ICMD_F2D: /* ..., value ==> ..., (double) value */
{
+#ifdef SUPPORT_HERCULES
u1 *ref;
+#endif
s1 = emit_load_s1(jd, iptr, REG_FTMP1);
d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
#ifdef SUPPORT_HERCULES
} /* if (bptr -> flags >= BBREACHED) */
} /* for basic block */
- dseg_createlinenumbertable(cd);
-
/* generate stubs */
emit_patcher_traps(jd);
return true;
}
-
-/* codegen_emit_stub_compiler **************************************************
-
- Emits a stub routine which calls the compiler.
-
-*******************************************************************************/
-
-void codegen_emit_stub_compiler(jitdata *jd)
-{
- methodinfo *m;
- codegendata *cd;
-
- /* get required compiler data */
-
- m = jd->m;
- cd = jd->cd;
-
- /* code for the stub */
-
- /* don't touch ITMP2 as it cointains the return address */
-
- M_AADD_IMM(N_PV_OFFSET, REG_PV); /* suppress negative displacements */
-
- /* REG_METHODPTR (REG_ITMP1) already used */
- M_ILD_DSEG(REG_ITMP3, -2 * SIZEOF_VOID_P); /* methodinfo */
- M_ILD_DSEG(REG_PV, -3 * SIZEOF_VOID_P); /* compiler pointer */
- N_BR(REG_PV);
-}
-
-
/* codegen_emit_stub_native ****************************************************
Emits a stub routine which calls a native method.
codeinfo *code;
codegendata *cd;
methoddesc *md;
- s4 i, j; /* count variables */
- s4 t;
- s4 s1, s2, disp;
- s4 funcdisp;
+ int i, j;
+ int t;
+ int s1, s2;
+ int disp;
/* get required compiler data */
(void) dseg_add_unique_address(cd, code); /* CodeinfoPointer */
(void) dseg_add_unique_s4(cd, cd->stackframesize * 8); /* FrameSize */
- (void) dseg_add_unique_s4(cd, 0); /* IsSync */
(void) dseg_add_unique_s4(cd, 0); /* IsLeaf */
(void) dseg_add_unique_s4(cd, 0); /* IntSave */
(void) dseg_add_unique_s4(cd, 0); /* FltSave */
- (void) dseg_addlinenumbertablesize(cd);
- (void) dseg_add_unique_s4(cd, 0); /* ExTableSize */
/* generate code */
M_AST(REG_RA, REG_SP, (cd->stackframesize - 1) * 8);
- /* get function address (this must happen before the stackframeinfo) */
-
- funcdisp = dseg_add_functionptr(cd, f);
-
- if (f == NULL)
- patcher_add_patch_ref(jd, PATCHER_resolve_native_function, m, funcdisp);
-
#if defined(ENABLE_GC_CACAO)
/* Save callee saved integer registers in stackframeinfo (GC may
need to recover them during a collection). */
M_ALD_DSEG(REG_A0, disp);
}
- /* generate the actual native call */
+ /* Call native function. */
- M_ALD_DSEG(REG_ITMP2, funcdisp);
+ disp = dseg_add_functionptr(cd, f);
+ M_ALD_DSEG(REG_ITMP2, disp);
M_CALL(REG_ITMP2);
/* save return value */
/* handle exception */
M_MOV(REG_RA, REG_ITMP1_XPC);
+ M_ASUB_IMM(2, REG_ITMP1_XPC);
disp = dseg_add_functionptr(cd, asm_handle_nat_exception);
M_ALD_DSEG(REG_ITMP2, disp);
M_JMP(RN, REG_ITMP2);
-
- /* generate patcher traps */
-
- emit_patcher_traps(jd);
}
/*