* src/vm/jit/jit.h: Likewise.
* src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): Set PV
and XPC correctly.
* src/vm/signal.c (signal_handle): Get the methodinfo pointer and pass
it to jit_compile_handle.
*******************************************************************************/
-void *jit_compile_handle(void *pc, void *pv, void *ra, void *mptr)
+void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
{
- methodinfo *m;
void *newpv; /* new compiled method PV */
+ void *parentpv; /* PV from the parent Java method */
void *pa; /* patch address */
uintptr_t *p; /* convenience pointer */
- /* Get methodinfo pointer. */
-
- m = *((methodinfo **) (((intptr_t) pc) - 2 * SIZEOF_VOID_P));
-
/* Compile the method. */
newpv = jit_compile(m);
*p = (uintptr_t) newpv;
- /* Flush the instruction cache. */
+ /* Flush both caches. */
- md_icacheflush(pa, SIZEOF_VOID_P);
+ md_cacheflush(pa, SIZEOF_VOID_P);
return newpv;
}
#if !defined(JIT_COMPILER_VIA_SIGNAL)
u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra);
#endif
-void *jit_compile_handle(void *pc, void *pv, void *ra, void *mptr);
+void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr);
s4 jit_complement_condition(s4 opcode);
{
ucontext_t *_uc;
mcontext_t *_mc;
+ void *pv;
u1 *sp;
u1 *ra;
u1 *xpc;
/* ATTENTION: Don't use CACAO's internal REG_* defines as they are
different to the ones in <ucontext.h>. */
+ pv = NULL; /* is resolved during stackframeinfo creation */
sp = (u1 *) _mc->gregs[REG_RSP];
xpc = (u1 *) _mc->gregs[REG_RIP];
- ra = xpc; /* return address is equal to xpc */
+ ra = xpc; /* return address is equal to XPC */
#if 0
/* check for StackOverflowException */
val = _mc->gregs[d];
if (type == EXCEPTION_HARDWARE_COMPILER) {
+ /* The PV from the compiler stub is equal to the XPC. */
+
+ pv = xpc;
+
/* We use a framesize of zero here because the call pushed
the return addres onto the stack. */
ra = md_stacktrace_get_returnaddress(sp, 0);
- /* And remove the RA from the stack. */
+ /* Skip the RA on the stack. */
sp = sp + 1 * SIZEOF_VOID_P;
+
+ /* The XPC is the RA minus 1, because the RA points to the
+ instruction after the call. */
+
+ xpc = ra - 3;
}
}
else {
/* Handle the type. */
- p = signal_handle(type, val, NULL, sp, ra, xpc, _p);
+ p = signal_handle(type, val, pv, sp, ra, xpc, _p);
/* Set registers. */
if (p == NULL) {
o = exceptions_get_and_clear_exception();
- ra = ra - 3; /* XPC is before the actual call */
-
_mc->gregs[REG_RSP] = (uintptr_t) sp; /* Remove RA from stack. */
_mc->gregs[REG_RAX] = (uintptr_t) o;
- _mc->gregs[REG_R10] = (uintptr_t) ra; /* REG_ITMP2_XPC */
+ _mc->gregs[REG_R10] = (uintptr_t) xpc; /* REG_ITMP2_XPC */
_mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception;
}
else {
stackframeinfo sfi;
int32_t index;
java_handle_t *o;
+ methodinfo *m;
java_handle_t *p;
/* wrap the value into a handle if it is a reference */
o = LLNI_WRAP((java_object_t *) val);
break;
+ case EXCEPTION_HARDWARE_COMPILER:
+ /* In this case the passed PV points to the compiler stub. We
+ get the methodinfo pointer here and set PV to NULL so
+ stacktrace_stackframeinfo_create determines the PV for the
+ parent Java method. */
+
+ m = code_get_methodinfo_for_pv(pv);
+ pv = NULL;
+ break;
+
default:
/* do nothing */
break;
break;
case EXCEPTION_HARDWARE_COMPILER:
- p = jit_compile_handle(xpc, pv, ra, (void *) val);
+ p = jit_compile_handle(m, sfi.pv, ra, (void *) val);
break;
default: