/* src/vm/jit/trap.cpp - hardware traps
- Copyright (C) 2008, 2009
+ Copyright (C) 2008, 2009, 2010
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
Copyright (C) 2009 Theobroma Systems Ltd.
#include "vm/jit/stacktrace.hpp"
#include "vm/jit/trap.hpp"
+#if defined(__S390__)
+#include "vm/jit/s390/codegen.h"
+#else
+#define N_PV_OFFSET 0
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
vm_abort("trap_handle: The program counter is NULL!");
#endif
-#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__X86_64__)
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
# if !defined(NDEBUG)
/* Perform a sanity check on our execution state functions. */
case TRAP_PATCHER:
p = NULL;
#if defined(ENABLE_REPLACEMENT)
- was_replaced = replace_me_wrapper((uint8_t*) xpc, context);
+ was_replaced = replace_handler((uint8_t*) xpc, &es);
if (was_replaced)
break;
#endif
# warning Port the below stuff to use the patching subsystem.
case TRAP_COUNTDOWN:
p = NULL;
- (void) replace_me_wrapper((uint8_t*) xpc - 13, context);
+ (void) replace_handler((uint8_t*) xpc - 13, &es);
break;
#endif
stacktrace_stackframeinfo_remove(&sfi);
-#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__X86_64__)
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
/* Update execution state and set registers. */
/* AFTER: removing stackframeinfo */
if (entry != NULL) {
es.pc = (uint8_t *) (uintptr_t) entry;
- es.pv = (uint8_t *) (uintptr_t) entry;
+ // The s390 executionstate offsets pv, so we need to
+ // compensate here.
+ es.pv = (uint8_t *) (uintptr_t) entry - N_PV_OFFSET;
break;
}
// Get and set the PV from the parent Java method.
- es.pv = (uint8_t*) md_codegen_get_pv_from_pc(ra);
+ es.pv = (uint8_t*) md_codegen_get_pv_from_pc(ra) - N_PV_OFFSET;
// Now fall-through to default exception handling.
trap_handle_exception:
default:
if (p != NULL) {
+#if defined(__ALPHA__) || defined(__I386__) || defined(__X86_64__)
+ // Perform stack unwinding for exceptions on execution state.
+ es.pc = (uint8_t *) (uintptr_t) xpc;
+ es.pv = (uint8_t *) (uintptr_t) sfi.pv;
+ executionstate_unwind_exception(&es, p);
+
+ // Pass the exception object to the exception handler.
+ es.intregs[REG_ITMP1_XPTR] = (uintptr_t) LLNI_DIRECT(p);
+#else
es.intregs[REG_ITMP1_XPTR] = (uintptr_t) LLNI_DIRECT(p);
es.intregs[REG_ITMP2_XPC] = (uintptr_t) xpc;
es.pc = (uint8_t *) (uintptr_t) asm_handle_exception;
+#endif
}
}