* src/vm/jit/jit.c (jit_compile_handle): Changed signature.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 1 Oct 2007 15:33:19 +0000 (17:33 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 1 Oct 2007 15:33:19 +0000 (17:33 +0200)
* src/vm/jit/jit.h: Likewise.

* src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): Set PV
and XPC correctly.

* src/vm/signal.c (signal_handle): Get the methodinfo pointer and pass
it to jit_compile_handle.

src/vm/jit/jit.c
src/vm/jit/jit.h
src/vm/jit/x86_64/linux/md-os.c
src/vm/signal.c

index 33fade631e4e6bb376c35426d0812026bc856953..f19fd7b6fd8a9a32d0cc366020eb67c0952bac97 100644 (file)
@@ -1737,17 +1737,13 @@ u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
 
 *******************************************************************************/
 
-void *jit_compile_handle(void *pc, void *pv, void *ra, void *mptr)
+void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
 {
-       methodinfo *m;
        void       *newpv;                              /* new compiled method PV */
+       void       *parentpv;                   /* PV from the parent Java method */
        void       *pa;                                          /* patch address */
        uintptr_t  *p;                                     /* convenience pointer */
 
-       /* Get methodinfo pointer. */
-
-       m = *((methodinfo **) (((intptr_t) pc) - 2 * SIZEOF_VOID_P));
-
        /* Compile the method. */
 
        newpv = jit_compile(m);
@@ -1767,9 +1763,9 @@ void *jit_compile_handle(void *pc, void *pv, void *ra, void *mptr)
 
        *p = (uintptr_t) newpv;
 
-       /* Flush the instruction cache. */
+       /* Flush both caches. */
 
-       md_icacheflush(pa, SIZEOF_VOID_P);
+       md_cacheflush(pa, SIZEOF_VOID_P);
 
        return newpv;
 }
index e0a49df7a9b91b7ad1dc712d3aa31f1531550cbc..cdf8ecb49d6eac34eb2341fa1d53a9c8de1f0f5f 100644 (file)
@@ -1313,7 +1313,7 @@ void jit_request_optimization(methodinfo *m);
 #if !defined(JIT_COMPILER_VIA_SIGNAL)
 u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra);
 #endif
-void *jit_compile_handle(void *pc, void *pv, void *ra, void *mptr);
+void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr);
 
 s4 jit_complement_condition(s4 opcode);
 
index a814540e73701878e9283f7235a21d92652ae512..de459ad69c84e68c3443e1882b79aa980cc49d4c 100644 (file)
@@ -59,6 +59,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 {
        ucontext_t     *_uc;
        mcontext_t     *_mc;
+       void           *pv;
        u1             *sp;
        u1             *ra;
        u1             *xpc;
@@ -78,9 +79,10 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
           different to the ones in <ucontext.h>. */
 
+       pv  = NULL;                 /* is resolved during stackframeinfo creation */
        sp  = (u1 *) _mc->gregs[REG_RSP];
        xpc = (u1 *) _mc->gregs[REG_RIP];
-       ra  = xpc;                          /* return address is equal to xpc     */
+       ra  = xpc;                              /* return address is equal to XPC */
 
 #if 0
        /* check for StackOverflowException */
@@ -152,14 +154,23 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
                val = _mc->gregs[d];
 
                if (type == EXCEPTION_HARDWARE_COMPILER) {
+                       /* The PV from the compiler stub is equal to the XPC. */
+
+                       pv = xpc;
+
                        /* We use a framesize of zero here because the call pushed
                           the return addres onto the stack. */
 
                        ra = md_stacktrace_get_returnaddress(sp, 0);
 
-                       /* And remove the RA from the stack. */
+                       /* Skip the RA on the stack. */
 
                        sp = sp + 1 * SIZEOF_VOID_P;
+
+                       /* The XPC is the RA minus 1, because the RA points to the
+                          instruction after the call. */
+
+                       xpc = ra - 3;
                }
        }
        else {
@@ -171,7 +182,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        /* Handle the type. */
 
-       p = signal_handle(type, val, NULL, sp, ra, xpc, _p);
+       p = signal_handle(type, val, pv, sp, ra, xpc, _p);
 
        /* Set registers. */
 
@@ -179,12 +190,10 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
                if (p == NULL) {
                        o = exceptions_get_and_clear_exception();
 
-                       ra = ra - 3;                     /* XPC is before the actual call */
-
                        _mc->gregs[REG_RSP] = (uintptr_t) sp;    /* Remove RA from stack. */
 
                        _mc->gregs[REG_RAX] = (uintptr_t) o;
-                       _mc->gregs[REG_R10] = (uintptr_t) ra;            /* REG_ITMP2_XPC */
+                       _mc->gregs[REG_R10] = (uintptr_t) xpc;           /* REG_ITMP2_XPC */
                        _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception;
                }
                else {
index 979b0f521d57108de521257bb65128d6c7283b76..804922fbcfdc141c542830810ab98972a8da1c5f 100644 (file)
@@ -233,6 +233,7 @@ void *signal_handle(int type, intptr_t val,
        stackframeinfo  sfi;
        int32_t         index;
        java_handle_t  *o;
+       methodinfo     *m;
        java_handle_t  *p;
 
        /* wrap the value into a handle if it is a reference */
@@ -243,6 +244,16 @@ void *signal_handle(int type, intptr_t val,
                o = LLNI_WRAP((java_object_t *) val);
                break;
 
+       case EXCEPTION_HARDWARE_COMPILER:
+               /* In this case the passed PV points to the compiler stub.  We
+                  get the methodinfo pointer here and set PV to NULL so
+                  stacktrace_stackframeinfo_create determines the PV for the
+                  parent Java method. */
+
+               m  = code_get_methodinfo_for_pv(pv);
+               pv = NULL;
+               break;
+
        default:
                /* do nothing */
                break;
@@ -289,7 +300,7 @@ void *signal_handle(int type, intptr_t val,
                break;
 
        case EXCEPTION_HARDWARE_COMPILER:
-               p = jit_compile_handle(xpc, pv, ra, (void *) val);
+               p = jit_compile_handle(m, sfi.pv, ra, (void *) val);
                break;
 
        default: