/* remove native stackframe info */
- M_LDA(REG_A0, REG_SP, cd->stackframesize * 8 - SIZEOF_VOID_P);
+ M_MOV(REG_SP, REG_A0);
+ M_MOV(REG_PV, REG_A1);
disp = dseg_add_functionptr(cd, codegen_finish_native_call);
M_ALD(REG_PV, REG_PV, disp);
M_JSR(REG_RA, REG_PV);
M_STMFD(BITMASK_RESULT, REG_SP);
- M_ADD_IMM(REG_A0, REG_SP, 2*4 + cd->stackframesize - SIZEOF_VOID_P);
+ M_ADD_IMM(REG_A0, REG_SP, 2*4);
+ M_MOV(REG_A1, REG_PV);
disp = dseg_add_functionptr(cd, codegen_finish_native_call);
M_DSEG_BRANCH(disp);
s1 = (s4) (cd->mcodeptr - cd->mcodebase);
code = *((codeinfo **) (pv + CodeinfoPointer));
framesize = *((int32_t *) (pv + FrameSize));
-
assert(code);
assert(framesize > sizeof(stackframeinfo) + sizeof(localref_table));
/* get the methodinfo */
m = code->m;
-
assert(m);
/* calculate needed values */
*******************************************************************************/
-java_object_t *codegen_finish_native_call(u1 *datasp)
+java_object_t *codegen_finish_native_call(u1 *currentsp, u1 *pv)
{
stackframeinfo *sfi;
java_handle_t *e;
java_object_t *o;
+ codeinfo *code;
+ methodinfo *m;
+ int32_t framesize;
+
+ uint8_t *datasp;
+ uint64_t *ret_regs;
+
+ /* get information from method header */
+
+ code = *((codeinfo **) (pv + CodeinfoPointer));
+ framesize = *((int32_t *) (pv + FrameSize));
+ assert(code);
+
+ /* get the methodinfo */
+
+ m = code->m;
+ assert(m);
+
+ /* calculate needed values */
+
+#if defined(__ALPHA__) || defined(__ARM__)
+ datasp = currentsp + framesize - SIZEOF_VOID_P;
+ ret_regs = (uint64_t *) currentsp;
+#elif defined(__MIPS__) || defined(__S390__)
+ /* MIPS and S390 always uses 8 bytes to store the RA */
+ datasp = currentsp + framesize - 8;
+#elif defined(__I386__)
+ datasp = currentsp + framesize;
+ ret_regs = (uint64_t *) (currentsp + 2 * SIZEOF_VOID_P);
+#elif defined (__M68K__) || defined (__X86_64__)
+ datasp = currentsp + framesize;
+ ret_regs = (uint64_t *) currentsp;
+#elif defined(__POWERPC__) || defined(__POWERPC64__)
+ datasp = currentsp + framesize;
+ ret_regs = (uint64_t *) (currentsp + LA_SIZE + 2 * SIZEOF_VOID_P);
+#else
+ vm_abort("codegen_finish_native_call: unsupported architecture");
+#endif
+
+
+#if !defined(NDEBUG)
+# if defined(__POWERPC__)
+ /* print the call-trace if necesarry */
+
+ if (opt_TraceJavaCalls)
+ trace_java_call_exit(m, ret_regs);
+# endif
+#endif
/* get data structures from stack */
stacktrace_remove_stackframeinfo(sfi);
+ /* XXX unfill lrt here!!! */
+
/* get and unwrap the exception */
/* ATTENTION: do the this _after_ the stackframeinfo was
removed but _before_ the localref_table gets removed! */
void codegen_stub_builtin_exit(u1 *datasp);
java_handle_t *codegen_start_native_call(u1 *currentsp, u1 *pv);
-java_object_t *codegen_finish_native_call(u1 *datasp);
+java_object_t *codegen_finish_native_call(u1 *currentsp, u1 *pv);
s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum);
s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum);
/* remove native stackframe info */
M_MOV(REG_SP, REG_ITMP1);
- M_AADD_IMM(cd->stackframesize * 8, REG_ITMP1);
-
M_AST(REG_ITMP1, REG_SP, 0 * 4);
+ M_IST_IMM(0, REG_SP, 1 * 4);
+ dseg_adddata(cd);
+
M_MOV_IMM(codegen_finish_native_call, REG_ITMP1);
M_CALL(REG_ITMP1);
M_MOV(REG_RESULT, REG_ITMP2); /* REG_ITMP3 == REG_RESULT2 */
case TYPE_FLT:
case TYPE_INT:
case TYPE_ADR:
- M_IST(REG_D0, REG_SP, 1 * 4);
+ M_IST(REG_D0, REG_SP, 2 * 4);
break;
default: assert(0);
/* remove native stackframe info */
/* therefore we call: java_objectheader *codegen_finish_native_call(u1 *datasp) */
- M_AMOV(REG_SP, REG_ATMP3);
- M_AADD_IMM(cd->stackframesize * 4, REG_ATMP3);
- M_AST(REG_ATMP3, REG_SP, 0 * 4); /* datasp */
+ M_AMOV(REG_SP, REG_ATMP1);
+ M_AST(REG_ATMP1, REG_SP, 0 * 4); /* currentsp */
+
+ M_AMOV_IMM(0, REG_ATMP2); /* 0 needs to patched */
+ dseg_adddata(cd); /* this patches it */
+
+ M_AST(REG_ATMP2, REG_SP, 1 * 4); /* pv */
+
M_JSR_IMM(codegen_finish_native_call);
M_INT2ADRMOVE(REG_RESULT, REG_ATMP1);
case TYPE_FLT:
case TYPE_INT:
case TYPE_ADR:
- M_ILD(REG_D0, REG_SP, 1 * 4);
+ M_ILD(REG_D0, REG_SP, 2 * 4);
break;
default: assert(0);
* as cacao jit code expects them there */
switch (md->returntype.type) {
case TYPE_FLT:
- M_FLD(REG_D0, REG_SP, 1 * 4);
+ M_FLD(REG_D0, REG_SP, 2 * 4);
break;
case TYPE_DBL:
- M_DLD(REG_D0, REG_SP, 1 * 4);
+ M_DLD(REG_D0, REG_SP, 2 * 4);
break;
}
#endif
/* remove native stackframe info */
- M_AADD_IMM(REG_SP, (cd->stackframesize - 1) * 8, REG_A0);
+ M_MOV(REG_SP, REG_A0);
+ M_MOV(REG_PV, REG_A1);
disp = dseg_add_functionptr(cd, codegen_finish_native_call);
M_ALD(REG_ITMP3, REG_PV, disp);
M_JSR(REG_RA, REG_ITMP3);
M_MTCTR(REG_ITMP3);
M_JSR;
- /* print call trace */
-
- emit_verbosecall_exit(jd);
-
/* save return value */
switch (md->returntype.type) {
case TYPE_INT:
case TYPE_ADR:
- M_IST(REG_RESULT, REG_SP, LA_SIZE + 1 * 8);
+ M_IST(REG_RESULT, REG_SP, LA_SIZE + 2 * 4);
break;
case TYPE_LNG:
- M_LST(REG_RESULT_PACKED, REG_SP, LA_SIZE + 1 * 8);
+ M_LST(REG_RESULT_PACKED, REG_SP, LA_SIZE + 2 * 4);
break;
case TYPE_FLT:
case TYPE_DBL:
- M_DST(REG_FRESULT, REG_SP, LA_SIZE + 1 * 8);
+ M_DST(REG_FRESULT, REG_SP, LA_SIZE + 2 * 4);
break;
case TYPE_VOID:
break;
/* remove native stackframe info */
- M_AADD_IMM(REG_SP, cd->stackframesize * 8, REG_A0);
+ M_MOV(REG_SP, REG_A0);
+ M_MOV(REG_PV, REG_A1);
disp = dseg_add_functionptr(cd, codegen_finish_native_call);
M_ALD(REG_ITMP1, REG_PV, disp);
M_MTCTR(REG_ITMP1);
switch (md->returntype.type) {
case TYPE_INT:
case TYPE_ADR:
- M_ILD(REG_RESULT, REG_SP, LA_SIZE + 1 * 8);
+ M_ILD(REG_RESULT, REG_SP, LA_SIZE + 2 * 4);
break;
case TYPE_LNG:
- M_LLD(REG_RESULT_PACKED, REG_SP, LA_SIZE + 1 * 8);
+ M_LLD(REG_RESULT_PACKED, REG_SP, LA_SIZE + 2 * 4);
break;
case TYPE_FLT:
case TYPE_DBL:
- M_DLD(REG_FRESULT, REG_SP, LA_SIZE + 1 * 8);
+ M_DLD(REG_FRESULT, REG_SP, LA_SIZE + 2 * 4);
break;
case TYPE_VOID:
break;
if (md->returntype.type != TYPE_VOID) {
if (IS_INT_LNG_TYPE(md->returntype.type)) {
- M_LST(REG_RESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);
+ M_LST(REG_RESULT, REG_SP, LA_SIZE + PA_SIZE + 2 * 8);
}
else {
- M_DST(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);
+ M_DST(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 2 * 8);
}
}
/* remove native stackframe info */
- M_AADD_IMM(REG_SP, cd->stackframesize * 8, REG_A0);
+ M_MOV(REG_SP, REG_A0);
+ M_MOV(REG_PV, REG_A1);
disp = dseg_add_functionptr(cd, codegen_finish_native_call);
M_ALD(REG_ITMP1, REG_PV, disp);
M_ALD(REG_ITMP1, REG_ITMP1, 0); /* XXX what about TOC? */
if (md->returntype.type != TYPE_VOID) {
if (IS_INT_LNG_TYPE(md->returntype.type)) {
- M_LLD(REG_RESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);
+ M_LLD(REG_RESULT, REG_SP, LA_SIZE + PA_SIZE + 2 * 8);
}
else {
/* if (IS_2_WORD_TYPE(md->returntype.type)) */
- M_DLD(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);
+ M_DLD(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 2 * 8);
/* else
- M_FLD(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8); F XXX
+ M_FLD(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 2 * 8); F XXX
*/
}
}
/* remove native stackframe info */
- N_LAE(REG_A0, (cd->stackframesize - 1) * 8, RN, REG_SP); /* datasp */
+ N_MOV(REG_SP, REG_A0); /* currentsp */
+ N_LA(REG_A1, -N_PV_OFFSET, RN, REG_PV); /* pv */
disp = dseg_add_functionptr(cd, codegen_finish_native_call);
M_ALD_DSEG(REG_ITMP1, disp);
M_CALL(REG_ITMP1);
/* remove native stackframe info */
- M_ALEA(REG_SP, cd->stackframesize * 8, REG_A0);
+ M_MOV(REG_SP, REG_A0);
+ emit_lea_membase_reg(cd, RIP, -((cd->mcodeptr + 7) - cd->mcodebase), REG_A1);
M_MOV_IMM(codegen_finish_native_call, REG_ITMP1);
M_CALL(REG_ITMP1);
M_MOV(REG_RESULT, REG_ITMP3);