* src/vm/jit/powerpc/emit.c (emit_replacement_stubs): Prepared for
authoredwin <none@none>
Thu, 7 Dec 2006 22:25:42 +0000 (22:25 +0000)
committeredwin <none@none>
Thu, 7 Dec 2006 22:25:42 +0000 (22:25 +0000)
removal of rplpoint.mcode.
* src/vm/jit/alpha/emit.c: Likewise.
* src/vm/jit/mips/emit.c: Likewise.
* src/vm/jit/i386/emit.c: Likewise.
* src/vm/jit/x86_64/emit.c: Likewise.

src/vm/jit/alpha/emit.c
src/vm/jit/i386/emit.c
src/vm/jit/mips/emit.c
src/vm/jit/powerpc/emit.c
src/vm/jit/x86_64/emit.c

index 133e91695a94e228c42d989d6a465e47b0b43dde..019ed4f34ee3fc729b29e125968b6e7bdfbfa044 100644 (file)
@@ -468,10 +468,11 @@ void emit_replacement_stubs(jitdata *jd)
        codegendata *cd;
        codeinfo    *code;
        rplpoint    *rplp;
-       u1          *savedmcodeptr;
        s4           disp;
        s4           i;
-       u1          *outcode;
+#if !defined(NDEBUG)
+       u1          *savedmcodeptr;
+#endif
 
        /* get required compiler data */
 
@@ -480,24 +481,23 @@ void emit_replacement_stubs(jitdata *jd)
 
        rplp = code->rplpoints;
 
-       for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
-               /* check code segment size */
-
-               MCODECHECK(100);
+       /* store beginning of replacement stubs */
 
-               /* note start of stub code */
+       code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
 
-               outcode = (u1 *) (ptrint) (cd->mcodeptr - cd->mcodebase);
+       for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
+               /* do not generate stubs for non-trappable points */
 
-               /* make machine code for patching */
+               if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
+                       continue;
 
-               savedmcodeptr = cd->mcodeptr;
-               cd->mcodeptr  = (u1 *) &(rplp->mcode);
+               /* check code segment size */
 
-               disp = (ptrint) ((s4 *) outcode - (s4 *) rplp->pc) - 1;
-               M_BR(disp);
+               MCODECHECK(100);
 
-               cd->mcodeptr = savedmcodeptr;
+#if !defined(NDEBUG)
+               savedmcodeptr = cd->mcodeptr;
+#endif
 
                /* create stack frame - 16-byte aligned */
 
@@ -514,6 +514,8 @@ void emit_replacement_stubs(jitdata *jd)
                disp = dseg_add_functionptr(cd, asm_replacement_out);
                M_ALD(REG_ITMP3, REG_PV, disp);
                M_JMP(REG_ZERO, REG_ITMP3);
+
+               assert((cd->mcodeptr - savedmcodeptr) == 4*REPLACEMENT_STUB_SIZE);
        }
 }
 
index 424363fdaa336d3b4411183c2a6d457ad18202f7..a83cc4c8a907e1ac918d334de73f1f8894b76a88 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: emit.c 6136 2006-12-07 22:19:12Z edwin $
+   $Id: emit.c 6137 2006-12-07 22:25:42Z edwin $
 
 */
 
@@ -546,7 +546,9 @@ void emit_replacement_stubs(jitdata *jd)
        rplpoint    *rplp;
        s4           disp;
        s4           i;
-       u1          *outcode;
+#if !defined(NDEBUG)
+       u1          *savedmcodeptr;
+#endif
 
        /* get required compiler data */
 
@@ -555,20 +557,25 @@ void emit_replacement_stubs(jitdata *jd)
 
        rplp = code->rplpoints;
 
+       /* store beginning of replacement stubs */
+
+       code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
+
        for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
+               /* do not generate stubs for non-trappable points */
+
+               if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
+                       continue;
+
                /* check code segment size */
 
                MCODECHECK(512);
 
                /* note start of stub code */
 
-               outcode = (u1 *) (ptrint) (cd->mcodeptr - cd->mcodebase);
-
-               /* make machine code for patching */
-
-               disp = (ptrint) (outcode - rplp->pc) - 5;
-
-               rplp->mcode = 0xe9 | ((u8) disp << 8);
+#if !defined(NDEBUG)
+               savedmcodeptr = cd->mcodeptr;
+#endif
 
                /* push address of `rplpoint` struct */
                        
@@ -578,6 +585,8 @@ void emit_replacement_stubs(jitdata *jd)
 
                M_PUSH_IMM(asm_replacement_out);
                M_RET;
+
+               assert((cd->mcodeptr - savedmcodeptr) == REPLACEMENT_STUB_SIZE);
        }
 }
        
index 08043a8fe72786d5ea59094d75f3578153c3d715..273e9968456529511dd6f8242500f03dd375e29a 100644 (file)
@@ -667,10 +667,11 @@ void emit_replacement_stubs(jitdata *jd)
        codegendata *cd;
        codeinfo    *code;
        rplpoint    *rplp;
-       u1          *savedmcodeptr;
        s4           disp;
        s4           i;
-       u1          *outcode;
+#if !defined(NDEBUG)
+       u1          *savedmcodeptr;
+#endif
 
        /* get required compiler data */
 
@@ -679,33 +680,23 @@ void emit_replacement_stubs(jitdata *jd)
 
        rplp = code->rplpoints;
 
-       for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
-               /* check code segment size */
+       /* store beginning of replacement stubs */
 
-               MCODECHECK(100);
-
-               /* note start of stub code */
-
-               outcode = (u1 *) (ptrint) (cd->mcodeptr - cd->mcodebase);
+       code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
 
-               /* make machine code for patching */
-
-               savedmcodeptr = cd->mcodeptr;
-               cd->mcodeptr  = (u1 *) &(rplp->mcode);
+       for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
+               /* do not generate stubs for non-trappable points */
 
-               disp = (ptrint) ((s4 *) outcode - (s4 *) rplp->pc) - 1;
+               if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
+                       continue;
 
-               if ((disp < (s4) 0xffff8000) || (disp > (s4) 0x00007fff)) {
-                       *exceptionptr =
-                               new_internalerror("Jump offset is out of range: %d > +/-%d",
-                                                                 disp, 0x00007fff);
-                       return;
-               }
+               /* check code segment size */
 
-               M_BR(disp);
-               M_NOP; /* delay slot */
+               MCODECHECK(100);
 
-               cd->mcodeptr = savedmcodeptr;
+#if !defined(NDEBUG)
+               savedmcodeptr = cd->mcodeptr;
+#endif
 
                /* create stack frame - 16-byte aligned */
 
@@ -723,6 +714,8 @@ void emit_replacement_stubs(jitdata *jd)
                M_ALD(REG_ITMP3, REG_PV, disp);
                M_JMP(REG_ITMP3);
                M_NOP; /* delay slot */
+
+               assert((cd->mcodeptr - savedmcodeptr) == 4*REPLACEMENT_STUB_SIZE);
        }
 }
 
index d95c47e0d9332b13d6ac21b6dcaa40d8605ffabb..b6e060a5ac5e341065a57d293dfebf233d6e753e 100644 (file)
@@ -537,10 +537,11 @@ void emit_replacement_stubs(jitdata *jd)
        codegendata *cd;
        codeinfo    *code;
        rplpoint    *rplp;
-       u1          *savedmcodeptr;
        s4           disp;
        s4           i;
-       u1          *outcode;
+#if !defined(NDEBUG)
+       u1          *savedmcodeptr;
+#endif
 
        /* get required compiler data */
 
@@ -549,24 +550,23 @@ void emit_replacement_stubs(jitdata *jd)
 
        rplp = code->rplpoints;
 
-       for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
-               /* check code segment size */
-
-               MCODECHECK(100);
+       /* store beginning of replacement stubs */
 
-               /* note start of stub code */
+       code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
 
-               outcode = (u1 *) (cd->mcodeptr - cd->mcodebase);
+       for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
+               /* do not generate stubs for non-trappable points */
 
-               /* make machine code for patching */
+               if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
+                       continue;
 
-               savedmcodeptr = cd->mcodeptr;
-               cd->mcodeptr  = (u1 *) &(rplp->mcode) + 1;              /* big-endian */
+               /* check code segment size */
 
-               disp = (ptrint) ((s4 *) outcode - (s4 *) rplp->pc) - 1;
-               M_BR(disp);
+               MCODECHECK(100);
 
-               cd->mcodeptr = savedmcodeptr;
+#if !defined(NDEBUG)
+               savedmcodeptr = cd->mcodeptr;
+#endif
 
                /* create stack frame - keep 16-byte aligned */
 
@@ -584,6 +584,8 @@ void emit_replacement_stubs(jitdata *jd)
                M_ALD(REG_ITMP3, REG_PV, disp);
                M_MTCTR(REG_ITMP3);
                M_RTS;
+
+               assert((cd->mcodeptr - savedmcodeptr) == 4*REPLACEMENT_STUB_SIZE);
        }
 }
 
index 227f03090dcc781641a424220e13ce078925f466..d7cad9f4c91737714bda5f2f21b13d1cede71371 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: emit.c 6136 2006-12-07 22:19:12Z edwin $
+   $Id: emit.c 6137 2006-12-07 22:25:42Z edwin $
 
 */
 
@@ -466,7 +466,9 @@ void emit_replacement_stubs(jitdata *jd)
        rplpoint    *rplp;
        s4           disp;
        s4           i;
-       u1          *outcode;
+#if !defined(NDEBUG)
+       u1          *savedmcodeptr;
+#endif
 
        /* get required compiler data */
 
@@ -475,33 +477,39 @@ void emit_replacement_stubs(jitdata *jd)
 
        rplp = code->rplpoints;
 
+       /* store beginning of replacement stubs */
+
+       code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
+
        for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
+               /* do not generate stubs for non-trappable points */
+
+               if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
+                       continue;
+
                /* check code segment size */
 
                MCODECHECK(512);
 
                /* note start of stub code */
 
-               outcode = (u1 *) (ptrint) (cd->mcodeptr - cd->mcodebase);
-
-               /* make machine code for patching */
-
-               disp = (ptrint) (outcode - rplp->pc) - 5;
-
-               rplp->mcode = 0xe9 | ((u8) disp << 8);
+#if !defined(NDEBUG)
+               savedmcodeptr = cd->mcodeptr;
+#endif
 
                /* push address of `rplpoint` struct */
                        
-               M_MOV_IMM(rplp, REG_ITMP3);
-               M_PUSH(REG_ITMP3);
+               M_PUSH_IMM(rplp);
 
                /* jump to replacement function */
 
-               M_MOV_IMM(asm_replacement_out, REG_ITMP3);
-               M_JMP(REG_ITMP3);
+               M_PUSH_IMM(asm_replacement_out);
+               M_RET;
+
+               assert((cd->mcodeptr - savedmcodeptr) == REPLACEMENT_STUB_SIZE);
        }
 }
-       
+
 
 /* emit_verbosecall_enter ******************************************************