#include "vm/jit/x86_64/codegen.h"
#include "vm/jit/x86_64/md.h"
-#include "threads/thread.h"
+#include "threads/thread.hpp"
-#include "vm/builtin.h"
-#include "vm/signallocal.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/signallocal.hpp"
#include "vm/jit/asmpart.h"
#include "vm/jit/executionstate.h"
-#include "vm/jit/trap.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/trap.hpp"
+#include "vm/jit/stacktrace.hpp"
/* md_signal_handler_sigsegv ***************************************************
int type;
intptr_t val;
void *p;
- java_object_t *o;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
if (type == TRAP_COMPILER) {
if (p == NULL) {
- 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) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception;
- }
- else {
- _mc->gregs[REG_RIP] = (uintptr_t) p;
}
}
- else {
- _mc->gregs[REG_RAX] = (uintptr_t) p;
- _mc->gregs[REG_R10] = (uintptr_t) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception;
- }
}
u1 *xpc;
int type;
intptr_t val;
- void *p;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
/* Handle the trap. */
- p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
- /* set registers */
-
- _mc->gregs[REG_RAX] = (intptr_t) p;
- _mc->gregs[REG_R10] = (intptr_t) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception;
+ trap_handle(type, val, pv, sp, ra, xpc, _p);
}
u1 *xpc;
int type;
intptr_t val;
- void *p;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
xpc = (u1 *) _mc->gregs[REG_RIP];
ra = xpc; /* return address is equal to xpc */
+ // Check if the trap instruction is valid.
+ // TODO Move this into patcher_handler.
+ if (patcher_is_valid_trap_instruction_at(xpc) == false) {
+ // Check if the PC has been patched during our way to this
+ // signal handler (see PR85).
+ if (patcher_is_patched_at(xpc) == true)
+ return;
+
+ // We have a problem...
+ log_println("md_signal_handler_sigill: Unknown illegal instruction at 0x%lx", xpc);
+#if defined(ENABLE_DISASSEMBLER)
+ (void) disassinstr(xpc);
+#endif
+ vm_abort("Aborting...");
+ }
+
/* This is a patcher. */
type = TRAP_PATCHER;
/* Handle the trap. */
- p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
- /* set registers */
-
- if (p != NULL) {
- _mc->gregs[REG_RAX] = (intptr_t) p;
- _mc->gregs[REG_R10] = (intptr_t) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception;
- }
+ trap_handle(type, val, pv, sp, ra, xpc, _p);
}
}
-/* md_critical_section_restart *************************************************
-
- Search the critical sections tree for a matching section and set
- the PC to the restart point, if necessary.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
-{
- mcontext_t *_mc;
- u1 *pc;
- u1 *npc;
-
- _mc = &_uc->uc_mcontext;
-
- /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
- different to the ones in <ucontext.h>. */
-
- pc = (u1 *) _mc->gregs[REG_RIP];
-
- npc = critical_find_restart_point(pc);
-
- if (npc != NULL)
- _mc->gregs[REG_RIP] = (ptrint) npc;
-}
-#endif
-
-
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where