/* src/vm/jit/i386/linux/md-os.c - machine dependent i386 Linux functions
- Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
- C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
- E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
- J. Wenninger, Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include "vm/jit/i386/codegen.h"
#include "vm/jit/i386/md.h"
-#include "threads/threads-common.h"
+#include "threads/thread.h"
#include "vm/builtin.h"
-#include "vm/exceptions.h"
#include "vm/signallocal.h"
#include "vm/stringlocal.h"
#include "vm/jit/asmpart.h"
+#include "vm/jit/executionstate.h"
#include "vm/jit/stacktrace.h"
+#include "vm/jit/trap.h"
/* md_signal_handler_sigsegv ***************************************************
val = _mc->gregs[REG_EAX - d];
- if (type == EXCEPTION_HARDWARE_COMPILER) {
+ if (type == TRAP_COMPILER) {
/* The PV from the compiler stub is equal to the XPC. */
pv = xpc;
else {
/* this was a normal NPE */
- type = EXCEPTION_HARDWARE_NULLPOINTER;
+ type = TRAP_NullPointerException;
val = 0;
}
- /* Handle the type. */
+ /* Handle the trap. */
- p = signal_handle(type, val, pv, sp, ra, xpc, _p);
+ p = trap_handle(type, val, pv, sp, ra, xpc, _p);
/* Set registers. */
- if (type == EXCEPTION_HARDWARE_COMPILER) {
+ if (type == TRAP_COMPILER) {
if (p == NULL) {
o = builtin_retrieve_exception();
_mc->gregs[REG_EIP] = (uintptr_t) p;
}
}
+#if defined(ENABLE_REPLACEMENT)
+ else if (type == TRAP_COUNTDOWN) {
+ /* context has been written by md_replace_executionstate_write */
+ }
+#endif
else {
- _mc->gregs[REG_EAX] = (intptr_t) p;
- _mc->gregs[REG_ECX] = (intptr_t) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_EIP] = (intptr_t) asm_handle_exception;
+ _mc->gregs[REG_EAX] = (uintptr_t) p;
+ _mc->gregs[REG_ECX] = (uintptr_t) xpc; /* REG_ITMP2_XPC */
+ _mc->gregs[REG_EIP] = (uintptr_t) asm_handle_exception;
}
}
xpc = (u1 *) _mc->gregs[REG_EIP];
ra = xpc; /* return address is equal to xpc */
- /* this is an ArithmeticException */
+ /* This is an ArithmeticException. */
- type = EXCEPTION_HARDWARE_ARITHMETIC;
+ type = TRAP_ArithmeticException;
val = 0;
- /* Handle the type. */
+ /* Handle the trap. */
- p = signal_handle(type, val, pv, sp, ra, xpc, _p);
+ p = trap_handle(type, val, pv, sp, ra, xpc, _p);
- /* set registers */
+ /* Set registers. */
- _mc->gregs[REG_EAX] = (intptr_t) p;
- _mc->gregs[REG_ECX] = (intptr_t) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_EIP] = (intptr_t) asm_handle_exception;
+ _mc->gregs[REG_EAX] = (uintptr_t) p;
+ _mc->gregs[REG_ECX] = (uintptr_t) xpc; /* REG_ITMP2_XPC */
+ _mc->gregs[REG_EIP] = (uintptr_t) asm_handle_exception;
}
xpc = (u1 *) _mc->gregs[REG_EIP];
ra = xpc; /* return address is equal to xpc */
- /* this is an ArithmeticException */
-
- type = EXCEPTION_HARDWARE_PATCHER;
+ type = TRAP_PATCHER;
val = 0;
- /* generate appropriate exception */
+ /* Handle the trap. */
- p = signal_handle(type, val, pv, sp, ra, xpc, _p);
+ p = trap_handle(type, val, pv, sp, ra, xpc, _p);
- /* set registers (only if exception object ready) */
+ /* Set registers. */
if (p != NULL) {
- _mc->gregs[REG_EAX] = (ptrint) p;
- _mc->gregs[REG_ECX] = (ptrint) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_EIP] = (ptrint) asm_handle_exception;
+ _mc->gregs[REG_EAX] = (uintptr_t) p;
+ _mc->gregs[REG_ECX] = (uintptr_t) xpc; /* REG_ITMP2_XPC */
+ _mc->gregs[REG_EIP] = (uintptr_t) asm_handle_exception;
}
}
#endif
-/* md_replace_executionstate_read **********************************************
+/* md_executionstate_read ******************************************************
Read the given context into an executionstate for Replacement.
*******************************************************************************/
-#if defined(ENABLE_REPLACEMENT)
-void md_replace_executionstate_read(executionstate_t *es, void *context)
+void md_executionstate_read(executionstate_t *es, void *context)
{
ucontext_t *_uc;
mcontext_t *_mc;
for (i = 0; i < FLT_REG_CNT; i++)
es->fltregs[i] = 0xdeadbeefdeadbeefULL;
}
-#endif
-/* md_replace_executionstate_write *********************************************
+/* md_executionstate_write *****************************************************
Write the given executionstate back to the context for Replacement.
*******************************************************************************/
-#if defined(ENABLE_REPLACEMENT)
-void md_replace_executionstate_write(executionstate_t *es, void *context)
+void md_executionstate_write(executionstate_t *es, void *context)
{
ucontext_t *_uc;
mcontext_t *_mc;
_mc->gregs[REG_EIP] = (ptrint) es->pc;
_mc->gregs[REG_ESP] = (ptrint) es->sp;
}
-#endif
-
-
-/* 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;
-
- pc = (u1 *) _mc->gregs[REG_EIP];
-
- npc = critical_find_restart_point(pc);
-
- if (npc != NULL)
- _mc->gregs[REG_EIP] = (ptrint) npc;
-}
-#endif
/*