#include "vm/types.h"
#include "vm/jit/x86_64/codegen.h"
+#include "vm/jit/x86_64/md.h"
#if defined(ENABLE_THREADS)
# include "threads/native/threads.h"
#endif
+#include "vm/builtin.h"
#include "vm/exceptions.h"
#include "vm/signallocal.h"
{
ucontext_t *_uc;
mcontext_t *_mc;
+ void *pv;
u1 *sp;
u1 *ra;
u1 *xpc;
int type;
intptr_t val;
void *p;
- java_handle_t *o;
+ java_object_t *o;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
/* 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 (type == EXCEPTION_HARDWARE_COMPILER) {
if (p == NULL) {
- o = exceptions_get_and_clear_exception();
-
- log_println("compiler exception");
- ra = ra - 3; /* XPC is before the actual call */
+ o = builtin_retrieve_exception();
_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 {
_mc = &_uc->uc_mcontext;
/* read special registers */
- es->pc = (u1 *) _mc->gregs[REG_RSP];
+ es->pc = (u1 *) _mc->gregs[REG_RIP];
es->sp = (u1 *) _mc->gregs[REG_RSP];
es->pv = NULL;