* src/vm/jit/trap.c (trap_handle) [__I386__]: Use executionstate for
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Fri, 12 Sep 2008 10:58:48 +0000 (12:58 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Fri, 12 Sep 2008 10:58:48 +0000 (12:58 +0200)
trap handling.
* src/vm/jit/i386/darwin/md-os.c: Simplified signal handlers.
* src/vm/jit/i386/linux/md-os.c: Likewise.
* src/vm/jit/i386/solaris/md-os.c: Likewise.

src/vm/jit/i386/darwin/md-os.c
src/vm/jit/i386/linux/md-os.c
src/vm/jit/i386/solaris/md-os.c
src/vm/jit/trap.c

index 89514f4b8f287e0741f63b2693a68f0e98b68542..87157e5009984fac885e9903971efb261fd67628 100644 (file)
@@ -72,7 +72,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        intptr_t             val;
        int                  type;
        void                *p;
-       java_object_t       *o;
 
        _uc = (ucontext_t *) _p;
        _mc = _uc->uc_mcontext;
@@ -142,23 +141,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        /* Set registers. */
 
        if (type == TRAP_COMPILER) {
-               if (p == NULL) { 
-                       o = builtin_retrieve_exception();
-
+               if (p == NULL) {
                        _ss->__esp = (uintptr_t) sp;  /* Remove RA from stack. */
-
-                       _ss->__eax = (uintptr_t) o;
-                       _ss->__ecx = (uintptr_t) xpc;           /* REG_ITMP2_XPC */
-                       _ss->__eip = (uintptr_t) asm_handle_exception;
                }
-               else {
-                       _ss->__eip = (uintptr_t) p;
-               }
-       }
-       else {
-               _ss->__eax = (uintptr_t) p;
-               _ss->__ecx = (uintptr_t) xpc;            /* REG_ITMP2_XPC */
-               _ss->__eip = (uintptr_t) asm_handle_exception;
        }
 }
 
@@ -181,7 +166,6 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
        u1                  *xpc;
        int                  type;
        intptr_t             val;
-       void                *p;
 
 
        _uc = (ucontext_t *) _p;
@@ -200,13 +184,7 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       _ss->__eax = (uintptr_t) p;
-       _ss->__ecx = (uintptr_t) xpc;            /* REG_ITMP2_XPC */
-       _ss->__eip = (uintptr_t) asm_handle_exception;
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -253,7 +231,6 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
        u1                  *xpc;
        int                  type;
        intptr_t             val;
-       void                *p;
 
 
        _uc = (ucontext_t *) _p;
@@ -270,15 +247,7 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       if (p != NULL) {
-               _ss->__eax = (uintptr_t) p;
-               _ss->__ecx = (uintptr_t) xpc;            /* REG_ITMP2_XPC */
-               _ss->__eip = (uintptr_t) asm_handle_exception;
-       }
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 /* md_executionstate_read ******************************************************
index deac6bc698d69c583e84c6acbd0da6aeda865f5d..f046f37d6cfbddacd0746d1706ec511cf416d36c 100644 (file)
@@ -68,7 +68,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        ptrint          val;
        s4              type;
        void           *p;
-       java_object_t  *o;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -138,28 +137,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        if (type == TRAP_COMPILER) {
                if (p == NULL) {
-                       o = builtin_retrieve_exception();
-
                        _mc->gregs[REG_ESP] = (uintptr_t) sp;    /* Remove RA from stack. */
-
-                       _mc->gregs[REG_EAX] = (uintptr_t) o;
-                       _mc->gregs[REG_ECX] = (uintptr_t) xpc;           /* REG_ITMP2_XPC */
-                       _mc->gregs[REG_EIP] = (uintptr_t) asm_handle_exception;
-               }
-               else {
-                       _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] = (uintptr_t) p;
-               _mc->gregs[REG_ECX] = (uintptr_t) xpc;               /* REG_ITMP2_XPC */
-               _mc->gregs[REG_EIP] = (uintptr_t) asm_handle_exception;
-       }
 }
 
 
@@ -180,7 +160,6 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
        u1             *xpc;
        s4              type;
        ptrint          val;
-       void           *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -197,13 +176,7 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       _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;
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -223,7 +196,6 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
        u1                *xpc;
        s4                 type;
        ptrint             val;
-       void              *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -238,15 +210,7 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       if (p != NULL) {
-               _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;
-       }
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
index 7e9e0e40ec23dd53785b29b37feb4d642ec1286d..67363ec8d5c45948e7232997ca1f78a6d6a7a16e 100644 (file)
@@ -66,7 +66,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        ptrint          val;
        s4              type;
        void           *p;
-       java_object_t  *o;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -136,23 +135,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        if (type == TRAP_COMPILER) {
                if (p == NULL) {
-                       o = builtin_retrieve_exception();
-
                        _mc->gregs[ESP] = (uintptr_t) sp;    /* Remove RA from stack. */
-
-                       _mc->gregs[EAX] = (uintptr_t) o;
-                       _mc->gregs[ECX] = (uintptr_t) xpc;           /* REG_ITMP2_XPC */
-                       _mc->gregs[EIP] = (uintptr_t) asm_handle_exception;
-               }
-               else {
-                       _mc->gregs[EIP] = (uintptr_t) p;
                }
        }
-       else {
-               _mc->gregs[EAX] = (uintptr_t) p;
-               _mc->gregs[ECX] = (uintptr_t) xpc;               /* REG_ITMP2_XPC */
-               _mc->gregs[EIP] = (uintptr_t) asm_handle_exception;
-       }
 }
 
 
@@ -173,7 +158,6 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
        u1         *xpc;
        s4          type;
        ptrint      val;
-       void       *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -190,13 +174,7 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       _mc->gregs[EAX] = (uintptr_t) p;
-       _mc->gregs[ECX] = (uintptr_t) xpc;                   /* REG_ITMP2_XPC */
-       _mc->gregs[EIP] = (uintptr_t) asm_handle_exception;
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
@@ -216,7 +194,6 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
        u1         *xpc;
        s4          type;
        ptrint      val;
-       void       *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -231,15 +208,7 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the trap. */
 
-       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
-
-       /* Set registers. */
-
-       if (p != NULL) {
-               _mc->gregs[EAX] = (uintptr_t) p;
-               _mc->gregs[ECX] = (uintptr_t) xpc;               /* REG_ITMP2_XPC */
-               _mc->gregs[EIP] = (uintptr_t) asm_handle_exception;
-       }
+       trap_handle(type, val, pv, sp, ra, xpc, _p);
 }
 
 
index 87299ecc098cccd6487d9666357efddd49772e2d..d03ab5d8f3f80c31b261ae077107ea870aaca469 100644 (file)
@@ -119,7 +119,7 @@ void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xp
        o = NULL;
        m = NULL;
 
-#if defined(__X86_64__)
+#if defined(__I386__) || defined(__X86_64__)
 # if !defined(NDEBUG)
        /* Perform a sanity check on our execution state functions. */
 
@@ -239,7 +239,7 @@ void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xp
 
        stacktrace_stackframeinfo_remove(&sfi);
 
-#if defined(__X86_64__)
+#if defined(__I386__) || defined(__X86_64__)
        /* Update execution state and write it back to the current context. */
        /* AFTER: removing stackframeinfo */