* src/vm/jit/emit-common.c (emit_patcher_traps): Added.
authormichi <none@none>
Mon, 6 Aug 2007 12:19:01 +0000 (12:19 +0000)
committermichi <none@none>
Mon, 6 Aug 2007 12:19:01 +0000 (12:19 +0000)
* src/vm/jit/emit-common.h (emit_trap): Added prototype.

* src/vm/jit/alpha/emit.c (emit_patcher_traps): Removed (moved to emit-common).
(emit_trap): Implemented.

* src/vm/jit/arm/emit.c: Likewise.

* src/vm/jit/powerpc/emit.c: Likewise.

* src/vm/jit/s390/emit.c: Likewise.

src/vm/jit/alpha/emit.c
src/vm/jit/arm/emit.c
src/vm/jit/emit-common.c
src/vm/jit/emit-common.h
src/vm/jit/powerpc/emit.c
src/vm/jit/s390/emit.c

index 6a9dabd3d0cc78279576e41b548d46813c462d1d..044a01bd14f3d619aaf266564d8b7025f19e7bd2 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: emit.c 8211 2007-07-18 19:52:23Z michi $
+   $Id: emit.c 8260 2007-08-06 12:19:01Z michi $
 
 */
 
@@ -31,6 +31,7 @@
 #include "vm/types.h"
 
 #include <assert.h>
+#include <stdint.h>
 
 #include "md-abi.h"
 
@@ -408,45 +409,26 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
 }
 
 
-/* emit_patcher_traps **********************************************************
+/* emit_trap *******************************************************************
 
-   Generates the code for the patcher traps.
+   Emit a trap instruction and return the original machine code.
 
 *******************************************************************************/
 
-void emit_patcher_traps(jitdata *jd)
+uint32_t emit_trap(codegendata *cd)
 {
-       codegendata *cd;
-       codeinfo    *code;
-       patchref_t  *pr;
-       u1          *savedmcodeptr;
-       u1          *tmpmcodeptr;
-
-       /* get required compiler data */
-
-       cd =   jd->cd;
-       code = jd->code;
-
-       /* generate patcher traps code */
+       uint32_t mcode;
 
-       for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
+       /* Get machine code which is patched back in later. The
+          trap is 1 instruction word long. */
 
-               /* Get machine code which is patched back in later. The
-                  trap is 1 instruction word long. */
+       mcode = *((u4 *) cd->mcodeptr);
 
-               tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
-               pr->mcode = *((u4 *) tmpmcodeptr);
+       /* Destination register must not be REG_ZERO, because then no
+          SIGSEGV is thrown. */
+       M_ALD_INTERN(REG_RESULT, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
 
-               /* Patch in the trap to call the signal handler (done at
-                  compile time). */
-
-               savedmcodeptr = cd->mcodeptr;   /* save current mcodeptr              */
-               cd->mcodeptr  = tmpmcodeptr;    /* set mcodeptr to patch position     */
-
-               M_ALD_INTERN(REG_RESULT, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
-
-               cd->mcodeptr = savedmcodeptr;   /* restore the current mcodeptr       */
-       }
+       return mcode;
 }
 
 
index 2967a7872d14f65d4fecf28f8eecb382cd62c09b..ccd5e740245ab0a965269a2793a04eb384121263 100644 (file)
@@ -30,6 +30,7 @@
 #include "config.h"
 
 #include <assert.h>
+#include <stdint.h>
 
 #include "vm/types.h"
 
@@ -561,46 +562,24 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
 }
 
 
-/* emit_patcher_traps **********************************************************
+/* emit_trap *******************************************************************
 
-   Generates the code for the patcher traps.
+   Emit a trap instruction and return the original machine code.
 
 *******************************************************************************/
 
-void emit_patcher_traps(jitdata *jd)
+uint32_t emit_trap(codegendata *cd)
 {
-       codegendata *cd;
-       codeinfo    *code;
-       patchref_t  *pr;
-       u1          *savedmcodeptr;
-       u1          *tmpmcodeptr;
-
-       /* get required compiler data */
-
-       cd   = jd->cd;
-       code = jd->code;
-
-       /* generate patcher traps code */
+       uint32_t mcode;
 
-       for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
+       /* Get machine code which is patched back in later. The
+          trap is 1 instruction word long. */
 
-               /* Get machine code which is patched back in later. The
-                  trap is 1 instruction word long. */
+       mcode = *((u4 *) cd->mcodeptr);
 
-               tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
+       M_TRAP(0, EXCEPTION_HARDWARE_PATCHER);
 
-               pr->mcode = *((u4 *) tmpmcodeptr);
-
-               /* Patch in the trap to call the signal handler (done at
-                  compile time). */
-
-               savedmcodeptr = cd->mcodeptr;   /* save current mcodeptr              */
-               cd->mcodeptr  = tmpmcodeptr;    /* set mcodeptr to patch position     */
-
-               M_TRAP(0, EXCEPTION_HARDWARE_PATCHER);
-
-               cd->mcodeptr = savedmcodeptr;   /* restore the current mcodeptr       */
-       }
+       return mcode;
 }
 
 
index c02566c5396a6db4f2efa38c1041c710087faa48..8e4a72ce9ab6d8856f3505c241f0cebffd079943 100644 (file)
@@ -30,6 +30,7 @@
 #include "config.h"
 
 #include <assert.h>
+#include <stdint.h>
 
 #include "vm/types.h"
 
@@ -38,6 +39,7 @@
 
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
+#include "vm/jit/patcher-common.h"
 
 #include "vmcore/options.h"
 #include "vmcore/statistics.h"
@@ -247,6 +249,53 @@ void emit_store_dst(jitdata *jd, instruction *iptr, s4 d)
 }
 
 
+/* emit_patcher_traps **********************************************************
+
+   Generates the code for the patcher traps.
+
+*******************************************************************************/
+
+void emit_patcher_traps(jitdata *jd)
+{
+       codegendata *cd;
+       codeinfo    *code;
+       patchref_t  *pr;
+       u1          *savedmcodeptr;
+       u1          *tmpmcodeptr;
+       uint32_t     mcode;
+
+       /* get required compiler data */
+
+       cd   = jd->cd;
+       code = jd->code;
+
+       /* generate patcher traps code */
+
+       for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
+
+               /* Calculate the patch position where the original machine
+                  code is located and the trap should be placed. */
+
+               tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
+
+               /* Patch in the trap to call the signal handler (done at
+                  compile time). */
+
+               savedmcodeptr = cd->mcodeptr;   /* save current mcodeptr          */
+               cd->mcodeptr  = tmpmcodeptr;    /* set mcodeptr to patch position */
+
+               mcode = emit_trap(cd);
+
+               cd->mcodeptr = savedmcodeptr;   /* restore the current mcodeptr   */
+
+               /* Remember the original machine code which is patched
+                  back in later (done at runtime). */
+
+               pr->mcode = mcode;
+       }
+}
+
+
 /* emit_bccz *******************************************************************
 
    Emit conditional and unconditional branch instructions on integer
index 99c4b7216113d2fc0c6a64fcf2f3aa9151775884..72aeb029af4daf571144a567b531739fc1e6e9dd 100644 (file)
@@ -178,6 +178,8 @@ void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 r
 void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg);
 void emit_exception_check(codegendata *cd, instruction *iptr);
 
+uint32_t emit_trap(codegendata *cd);
+
 void emit_patcher_stubs(jitdata *jd);
 void emit_patcher_traps(jitdata *jd);
 
index 5a86e5cecbd376d79f09bef69f1dd9d534da2a9b..28c883e37857df84ef90dfbb2e97df82439a6a60 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: emit.c 8216 2007-07-19 13:51:21Z michi $
+   $Id: emit.c 8260 2007-08-06 12:19:01Z michi $
 
 */
 
@@ -51,7 +51,6 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
 
 #include "vmcore/options.h"
@@ -507,46 +506,24 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
 }
 
 
-/* emit_patcher_traps **********************************************************
+/* emit_trap *******************************************************************
 
-   Generates the code for the patcher stubs.
+   Emit a trap instruction and return the original machine code.
 
 *******************************************************************************/
 
-void emit_patcher_traps(jitdata *jd)
+uint32_t emit_trap(codegendata *cd)
 {
-       codegendata *cd;
-       codeinfo    *code;
-       patchref_t  *pr;
-       u1          *savedmcodeptr;
-       u1          *tmpmcodeptr;
-
-       /* get required compiler data */
-
-       cd   = jd->cd;
-       code = jd->code;
-
-       /* generate code patching stub call code */
+       uint32_t mcode;
 
-       for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
+       /* Get machine code which is patched back in later. The
+          trap is 1 instruction word long. */
 
-               /* Get machine code which is patched back in later. The
-                  trap is 1 instruction word long. */
+       mcode = *((u4 *) cd->mcodeptr);
 
-               tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
+       M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
 
-               pr->mcode = *((u4 *) tmpmcodeptr);
-
-               /* Patch in the trap to call the signal handler (done at
-                  compile time). */
-
-               savedmcodeptr = cd->mcodeptr;   /* save current mcodeptr          */
-               cd->mcodeptr  = tmpmcodeptr;    /* set mcodeptr to patch position */
-
-               M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
-
-               cd->mcodeptr = savedmcodeptr;   /* restore the current mcodeptr   */
-       }
+       return mcode;
 }
 
 
index 6b765d63a549261700cac037c6f0803ec36f3704..d00836281a7cd1e9f2362569c46fee02680dde29 100644 (file)
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: emit.c 8251 2007-08-01 15:26:59Z pm $
+   $Id: emit.c 8260 2007-08-06 12:19:01Z michi $
 
 */
 
 #include "config.h"
 
 #include <assert.h>
+#include <stdint.h>
 
 #include "mm/memory.h"
 #if defined(ENABLE_THREADS)
@@ -205,45 +206,24 @@ void emit_copy(jitdata *jd, instruction *iptr)
        }
 }
 
-/* emit_patcher_traps **********************************************************
+/* emit_trap *******************************************************************
 
-   Generates the code for the patcher traps.
+   Emit a trap instruction and return the original machine code.
 
 *******************************************************************************/
 
-void emit_patcher_traps(jitdata *jd)
+uint32_t emit_trap(codegendata *cd)
 {
-       codegendata *cd;
-       codeinfo    *code;
-       patchref_t  *pr;
-       u1          *savedmcodeptr;
-       u1          *tmpmcodeptr;
-
-       /* get required compiler data */
-
-       cd =   jd->cd;
-       code = jd->code;
-
-       /* generate patcher traps code */
-
-       for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
+       uint32_t mcode;
 
-               /* Get machine code which is patched back in later. The
-                  trap is 2 bytes long. */
+       /* Get machine code which is patched back in later. The
+          trap is 2 bytes long. */
 
-               tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
-               pr->mcode = *((u2 *) tmpmcodeptr);
+       mcode = *((u2 *) cd->mcodeptr);
 
-               /* Patch in the trap to call the signal handler (done at
-                  compile time). */
+       M_ILL(EXCEPTION_HARDWARE_PATCHER);
 
-               savedmcodeptr = cd->mcodeptr;   /* save current mcodeptr              */
-               cd->mcodeptr  = tmpmcodeptr;    /* set mcodeptr to patch position     */
-
-               M_ILL(EXCEPTION_HARDWARE_PATCHER);
-
-               cd->mcodeptr = savedmcodeptr;   /* restore the current mcodeptr       */
-       }
+       return mcode;
 }
 
 /* emit_replacement_stubs ******************************************************