* src/vm/jit/linenumbertable.c (linenumbertable_create, linenumbertable_linenumber_fo...
authorPeter Molnar <pm@complang.tuwien.ac.at>
Sat, 27 Oct 2007 00:55:32 +0000 (00:55 +0000)
committerPeter Molnar <pm@complang.tuwien.ac.at>
Sat, 27 Oct 2007 00:55:32 +0000 (00:55 +0000)
* src/vm/jit/s390/codegen.c (codegen_emit_stub_native): In case of exception, use branch (not following) instruction as XPC.
* src/vm/jit/s390/md.c (md_signal_handler_sigill): Fixes to scenario where JIT compiler fails.

src/vm/jit/linenumbertable.c
src/vm/jit/s390/codegen.c
src/vm/jit/s390/md.c

index 9909fc0c57641560603a77aa6aaf991e01c50a66..c8a7e64018f842de0644f8182ac6975b6ac1e66a 100644 (file)
 # include "vmcore/statistics.h"
 #endif
 
+#if defined(__S390__)
+#  define ADDR_MASK(type, x) ((type)((uintptr_t)(x) & 0x7FFFFFFF))
+#else
+#  define ADDR_MASK(type, x) (x)
+#endif
 
 /* linenumbertable_create ******************************************************
 
@@ -94,7 +99,7 @@ void linenumbertable_create(jitdata *jd)
        /* Fill the linenumber table entries in reverse order, so the
           search can be forward. */
 
-       pv = code->entrypoint;
+       pv = ADDR_MASK(uint8_t *, code->entrypoint);
 
        for (le = list_last_unsynced(l); le != NULL;
                 le = list_prev_unsynced(l, le), lnte++) {
@@ -225,6 +230,8 @@ static s4 linenumbertable_linenumber_for_pc_intern(methodinfo **pm, linenumberta
 {
        linenumbertable_entry_t *lntinline;   /* special entry for inlined method */
 
+       pc = ADDR_MASK(void *, pc);
+
        for (; lntsize > 0; lntsize--, lnte++) {
                /* Note: In case of inlining this may actually compare the pc
                   against a methodinfo *, yielding a non-sensical
index 689ca19b930bbea51408972f25afdab9d3c41638..b0a1516f029a7cfbfc4eaa59d84c4ede7e936204 100644 (file)
@@ -3750,6 +3750,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
        /* handle exception */
 
        M_MOV(REG_RA, REG_ITMP1_XPC);
+       M_ASUB_IMM(2, REG_ITMP1_XPC);
 
        disp = dseg_add_functionptr(cd, asm_handle_nat_exception);
        M_ALD_DSEG(REG_ITMP2, disp);
index 626f382349d2a094da487cd131ea13722a6b67f8..1371bc1ccc9847ba207e6f031e54856bb1bf4f6e 100644 (file)
@@ -244,6 +244,8 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
                        /* The return address in is REG_RA */
 
                        ra = (u1 *)_mc->gregs[REG_RA];
+
+                       xpc = ra - 2;
                }
 
                /* Handle the type. */
@@ -253,7 +255,8 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
                if (EXCEPTION_HARDWARE_COMPILER == type) {
                        if (NULL == p) {
                                _mc->gregs[REG_ITMP3_XPTR] = (intptr_t) builtin_retrieve_exception();
-                               _mc->gregs[REG_ITMP1_XPC]  = (intptr_t) xpc;
+                               _mc->gregs[REG_ITMP1_XPC]  = (intptr_t) ra - 2;
+                               _mc->gregs[REG_PV]         = (intptr_t) md_codegen_get_pv_from_pc(ra);
                                _mc->psw.addr              = (intptr_t) asm_handle_exception;
                        } else {
                                _mc->gregs[REG_PV]         = (intptr_t) p;
@@ -679,7 +682,7 @@ void md_handle_exception(int32_t *regs, int64_t *fregs, int32_t *out) {
 
                        /* new xpc is call before return address */
 
-                       xpc = ra;
+                       xpc = ra - 2;
 
                } else {
                        xpc = handler;