intptr_t val = 0;
// Handle the trap.
- void* p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
- // Set registers
- if (p == NULL) {
- // We need to set the PC because we adjusted it above.
- _mc->sc_pc = (uintptr_t) xpc;
- }
+ trap_handle(type, val, pv, sp, ra, xpc, _p);
}
switch (type) {
case TRAP_COMPILER:
- // The default case for a compiler trap is to jump directly to
+ // The normal case for a compiler trap is to jump directly to
// the newly compiled method.
if (p != NULL) {
es.intregs[REG_ITMP1_XPTR] = (uintptr_t) LLNI_DIRECT(e);
es.intregs[REG_ITMP2_XPC] = (uintptr_t) xpc;
es.pc = (uint8_t *) (uintptr_t) asm_handle_exception;
-
break;
+ case TRAP_PATCHER:
+ // The normal case for a patcher trap is to continue execution at
+ // the trap instruction. On some archs the PC may point after the
+ // trap instruction, so we reset it here.
+
+ if (p == NULL) {
+ es.pc = (uint8_t *) (uintptr_t) xpc;
+ break;
+ }
+
+ /* fall-through */
+
default:
if (p != NULL) {
es.intregs[REG_ITMP1_XPTR] = (uintptr_t) LLNI_DIRECT(p);