* Removed all Id tags.
[cacao.git] / src / vm / jit / i386 / darwin / md-os.c
index dd9672c96382bc6065768d83ec65868ed57cb722..0c593d052cf217d9ccf55b7a6985acf256385681 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/jit/i386/darwin/md-os.c - machine dependent i386 Darwin functions
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: md-os.c 5074 2006-07-04 16:05:35Z twisti $
-
 */
 
 
@@ -37,6 +29,7 @@
 
 #include <assert.h>
 #include <signal.h>
+#include <stdint.h>
 #include <ucontext.h>
 
 #include "vm/types.h"
@@ -74,11 +67,11 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
     u1                   opc;
     u1                   mod;
     u1                   rm;
-    s4                   d;
-    s4                   disp;
-    ptrint               val;
-    s4                   type;
-    java_objectheader   *o;
+    int                  d;
+    int32_t              disp;
+       intptr_t             val;
+    int                  type;
+    void                *p;
 
        _uc = (ucontext_t *) _p;
        _mc = _uc->uc_mcontext;
@@ -121,15 +114,23 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
         type = EXCEPTION_HARDWARE_NULLPOINTER;
     }
 
-    /* generate appropriate exception */
+       /* create stackframeinfo */
+
+       stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+       /* Handle the type. */
+
+       p = signal_handle(xpc, type, val);
+
+       /* remove stackframeinfo */
 
-    o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+       stacktrace_remove_stackframeinfo(&sfi);
 
     /* set registers */
 
-    _ss->eax = (ptrint) o;
-       _ss->ecx = (ptrint) xpc;
-       _ss->eip = (ptrint) asm_handle_exception;
+    _ss->eax = (intptr_t) p;
+       _ss->ecx = (intptr_t) xpc;
+       _ss->eip = (intptr_t) asm_handle_exception;
 }
 
 
@@ -150,9 +151,9 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
        u1                  *sp;
        u1                  *ra;
        u1                  *xpc;
-    s4                   type;
-    ptrint               val;
-    java_objectheader   *o;
+    int                  type;
+    intptr_t             val;
+    void                *p;
 
 
        _uc = (ucontext_t *) _p;
@@ -169,13 +170,21 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
     type = EXCEPTION_HARDWARE_ARITHMETIC;
     val  = 0;
 
-    /* generate appropriate exception */
+       /* create stackframeinfo */
 
-    o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+       stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
 
-    _ss->eax = (ptrint) o;
-       _ss->ecx = (ptrint) xpc;
-       _ss->eip = (ptrint) asm_handle_exception;
+       /* Handle the type. */
+
+       p = signal_handle(xpc, type, val);
+
+       /* remove stackframeinfo */
+
+       stacktrace_remove_stackframeinfo(&sfi);
+
+    _ss->eax = (intptr_t) p;
+       _ss->ecx = (intptr_t) xpc;
+       _ss->eip = (intptr_t) asm_handle_exception;
 }
 
 
@@ -205,6 +214,13 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_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 thread_restartcriticalsection(ucontext_t *_uc)
 {