Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: emit.c 4398 2006-01-31 23:43:08Z twisti $
-
*/
#include "vm/exceptions.h"
#include "vm/stringlocal.h" /* XXX for gen_resolvebranch */
+#include "vm/jit/abi.h"
#include "vm/jit/abi-asm.h"
#include "vm/jit/asmpart.h"
#include "vm/builtin.h"
#include "vmcore/options.h"
+#include "vm/jit/sparc64/solaris/macro_rename.h"
+
/* how to leaf optimization in the emitted stubs?? */
#define REG_PV REG_PV_CALLEE
cd = jd->cd;
if (src->flags & INMEMORY) {
- COUNT_SPILLS;
+ COUNT_READ_SPILLS(src)
- disp = JITSTACK + src->vv.regoff * 8;
+ disp = JITSTACK + src->vv.regoff;
switch(src->type)
{
cd = jd->cd;
if (dst->flags & INMEMORY) {
- COUNT_SPILLS;
+ COUNT_WRITE_SPILLS(dst)
- disp = JITSTACK + dst->vv.regoff * 8;
-
+ disp = JITSTACK + dst->vv.regoff;
+
switch(dst->type)
{
case TYPE_INT:
/* get required compiler data */
cd = jd->cd;
- rd = jd->rd;
/* get source and destination variables */
void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2)
{
if (INSTRUCTION_MUST_CHECK(iptr)) {
- M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));
+ M_ILD(REG_ITMP3, s1, OFFSET(java_array_t, size));
M_CMP(s2, REG_ITMP3);
M_XBULT(3);
M_NOP;
}
+/* emit_trap *******************************************************************
+
+ Emit a trap instruction and return the original machine code.
+
+*******************************************************************************/
+
+uint32_t emit_trap(codegendata *cd)
+{
+ uint32_t mcode;
+
+ /* Get machine code which is patched back in later. The
+ trap is 1 instruction word long. */
+
+ mcode = *((u4 *) cd->mcodeptr);
+
+ M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
+
+ return mcode;
+}
+
+
/* emit_patcher_stubs **********************************************************
Generates the code for the patcher stubs.
}
-/* emit_replacement_stubs ******************************************************
-
- Generates the code for the replacement stubs.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd)
-{
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
/* emit_verbosecall_enter ******************************************************
Generates the code for the call trace.
methoddesc *md;
s4 disp;
s4 i, t;
+ s4 stackslots;
/* get required compiler data */
M_NOP;
/* XXX jit-c-call */
- M_LDA(REG_SP, REG_SP, -(1 + FLT_ARG_CNT) * 8);
+ stackslots = 1 + FLT_ARG_CNT;
+ ALIGN_STACK_SLOTS(stackslots);
+
+ M_LDA(REG_SP, REG_SP, -(stackslots * 8));
/* save float argument registers */
for (i = 0; i < FLT_ARG_CNT; i++)
- M_DST(rd->argfltregs[i], REG_SP, JITSTACK + (1 + i) * 8);
+ M_DST(abi_registers_float_argument[i], REG_SP, JITSTACK + (1 + i) * 8);
/* save temporary registers for leaf methods */
/* XXX no leaf optimization yet
for (i = 0; i < md->paramcount && i < INT_NATARG_CNT; i++) {
t = md->paramtypes[i].type;
- /* using all available argument registers, this adds complexity */
+ /* all available argument registers used, which adds a little complexity */
if (IS_INT_LNG_TYPE(t)) {
if (i < INT_ARG_CNT) {
- M_INTMOVE(REG_WINDOW_TRANSPOSE(rd->argintregs[i]), rd->argintregs[i]);
+ M_INTMOVE(REG_WINDOW_TRANSPOSE(abi_registers_integer_argument[i]),
+ abi_registers_integer_argument[i]);
}
else {
assert(i == 5);
}
}
else {
- assert(i < 4); /* XXX only 4 float reg args right now! */
- if (IS_2_WORD_TYPE(t)) {
- M_DST(rd->argfltregs[i], REG_SP, JITSTACK);
- M_LDX(rd->argintregs[i], REG_SP, JITSTACK);
+ if (i < FLT_ARG_CNT) {
+
+ /* reg -> mem -> reg */
+
+ if (IS_2_WORD_TYPE(t)) {
+ M_DST(abi_registers_float_argument[i], REG_SP, JITSTACK);
+ M_LDX(abi_registers_integer_argument[i], REG_SP, JITSTACK);
+ }
+ else {
+ M_FST(abi_registers_float_argument[i], REG_SP, JITSTACK);
+ M_ILD(abi_registers_integer_argument[i], REG_SP, JITSTACK);
+ }
}
else {
- M_FST(rd->argfltregs[i], REG_SP, JITSTACK);
- M_ILD(rd->argintregs[i], REG_SP, JITSTACK);
+
+ /* mem -> reg */
+
+ assert(i == 5);
+ if (IS_2_WORD_TYPE(t)) {
+ M_LDX(REG_OUT5, REG_FP, JITSTACK);
+ }
+ else {
+ M_ILD(REG_OUT5, REG_FP, JITSTACK);
+ }
}
}
}
- /* method info pointer is passed in argument register 5 */
+ /* method info pointer is passed via stack */
disp = dseg_add_address(cd, m);
M_ALD(REG_ITMP1, REG_PV_CALLEE, disp);
M_AST(REG_ITMP1, REG_SP, CSTACK);
/* restore float argument registers */
for (i = 0; i < FLT_ARG_CNT; i++)
- M_DLD(rd->argfltregs[i], REG_SP, JITSTACK + (1 + i) * 8);
+ M_DLD(abi_registers_float_argument[i], REG_SP, JITSTACK + (1 + i) * 8);
/* restore temporary registers for leaf methods */
/* XXX no leaf optimization yet
M_DLD(rd->tmpfltregs[i], REG_SP, (2 + ARG_CNT + INT_TMP_CNT + i) * 8);
}
*/
- M_LDA(REG_SP, REG_SP, (1 + FLT_ARG_CNT) * 8);
+ M_LDA(REG_SP, REG_SP, stackslots * 8);
/* mark trace code */
M_NOP;
- /* XXX jit-c-call */
- M_LDA(REG_SP, REG_SP, -(1 * 8));
+ /* XXX jit-c-call (keep stack aligned)*/
+ M_LDA(REG_SP, REG_SP, -(2 * 8));
M_DST(REG_FRESULT, REG_SP, JITSTACK);
- M_MOV(REG_RESULT_CALLEE, rd->argintregs[0]);
+ M_MOV(REG_RESULT_CALLEE, REG_OUT0);
M_DMOV(REG_FRESULT, 1); /* logical dreg 1 => f2 */
M_FMOV(REG_FRESULT, 2); /* logical freg 2 => f5 */
disp = dseg_add_functionptr(cd, m);
- M_ALD(rd->argintregs[3], REG_PV_CALLEE, disp);
+ M_ALD(REG_OUT3, REG_PV_CALLEE, disp);
disp = dseg_add_functionptr(cd, builtin_verbosecall_exit);
M_ALD(REG_ITMP3, REG_PV_CALLEE, disp);
M_DLD(REG_FRESULT, REG_SP, JITSTACK);
- M_LDA(REG_SP, REG_SP, 1 * 8);
+ M_LDA(REG_SP, REG_SP, 2 * 8);
/* mark trace code */