* Removed all Id tags.
[cacao.git] / src / vm / jit / powerpc / emit.c
index 0406097713afc7486f8376fe76fe8ce60910bf8b..f616af44016f9aff61343a3aacf9a69b18ad8e27 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: emit.c 8211 2007-07-18 19:52:23Z michi $
-
 */
 
 
@@ -86,8 +84,6 @@ s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
                        M_LLD(tempreg, REG_SP, disp);
                        break;
                case TYPE_FLT:
-                       M_FLD(tempreg, REG_SP, disp);
-                       break;
                case TYPE_DBL:
                        M_DLD(tempreg, REG_SP, disp);
                        break;
@@ -201,8 +197,6 @@ void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
                        M_LST(d, REG_SP, disp);
                        break;
                case TYPE_FLT:
-                       M_FST(d, REG_SP, disp);
-                       break;
                case TYPE_DBL:
                        M_DST(d, REG_SP, disp);
                        break;
@@ -441,7 +435,7 @@ void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg)
 void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2)
 {
        if (INSTRUCTION_MUST_CHECK(iptr)) {
-               M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));
+               M_ILD(REG_ITMP3, s1, OFFSET(java_array_t, size));
                M_TRAPGEU(s2, REG_ITMP3);
        }
 }
@@ -506,115 +500,24 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
 }
 
 
-/* emit_patcher_stubs **********************************************************
+/* emit_trap *******************************************************************
 
-   Generates the code for the patcher stubs.
+   Emit a trap instruction and return the original machine code.
 
 *******************************************************************************/
 
-void emit_patcher_stubs(jitdata *jd)
+uint32_t emit_trap(codegendata *cd)
 {
-       codegendata *cd;
-       patchref    *pref;
-       u4           mcode;
-       u1          *savedmcodeptr;
-       u1          *tmpmcodeptr;
-       s4           targetdisp;
-       s4           disp;
-
-       /* get required compiler data */
-
-       cd = jd->cd;
-
-       /* generate code patching stub call code */
-
-       targetdisp = 0;
-
-       for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
-               /* check code segment size */
-
-               MCODECHECK(100);
-
-               /* Get machine code which is patched back in later. The
-                  call is 1 instruction word long. */
-
-               tmpmcodeptr = (u1 *) (cd->mcodebase + pref->branchpos);
-
-               mcode = *((u4 *) tmpmcodeptr);
-
-               /* Patch in the call to call the following code (done at
-                  compile time). */
-
-               savedmcodeptr = cd->mcodeptr;   /* save current mcodeptr          */
-               cd->mcodeptr  = tmpmcodeptr;    /* set mcodeptr to patch position */
-
-               disp = ((u4 *) savedmcodeptr) - (((u4 *) tmpmcodeptr) + 1);
-               M_BR(disp);
-
-               cd->mcodeptr = savedmcodeptr;   /* restore the current mcodeptr   */
+       uint32_t mcode;
 
-               /* create stack frame - keep stack 16-byte aligned */
+       /* Get machine code which is patched back in later. The
+          trap is 1 instruction word long. */
 
-               M_AADD_IMM(REG_SP, -8 * 4, REG_SP);
+       mcode = *((u4 *) cd->mcodeptr);
 
-               /* calculate return address and move it onto the stack */
+       M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
 
-               M_LDA(REG_ITMP3, REG_PV, pref->branchpos);
-               M_AST_INTERN(REG_ITMP3, REG_SP, 5 * 4);
-
-               /* move pointer to java_objectheader onto stack */
-
-#if defined(ENABLE_THREADS)
-               /* order reversed because of data segment layout */
-
-               (void) dseg_add_unique_address(cd, NULL);                  /* flcword */
-               (void) dseg_add_unique_address(cd, lock_get_initial_lock_word());
-               disp = dseg_add_unique_address(cd, NULL);                  /* vftbl   */
-
-               M_LDA(REG_ITMP3, REG_PV, disp);
-               M_AST_INTERN(REG_ITMP3, REG_SP, 4 * 4);
-#else
-               /* do nothing */
-#endif
-
-               /* move machine code onto stack */
-
-               disp = dseg_add_s4(cd, mcode);
-               M_ILD(REG_ITMP3, REG_PV, disp);
-               M_IST_INTERN(REG_ITMP3, REG_SP, 3 * 4);
-
-               /* move class/method/field reference onto stack */
-
-               disp = dseg_add_address(cd, pref->ref);
-               M_ALD(REG_ITMP3, REG_PV, disp);
-               M_AST_INTERN(REG_ITMP3, REG_SP, 2 * 4);
-
-               /* move data segment displacement onto stack */
-
-               disp = dseg_add_s4(cd, pref->disp);
-               M_ILD(REG_ITMP3, REG_PV, disp);
-               M_IST_INTERN(REG_ITMP3, REG_SP, 1 * 4);
-
-               /* move patcher function pointer onto stack */
-
-               disp = dseg_add_functionptr(cd, pref->patcher);
-               M_ALD(REG_ITMP3, REG_PV, disp);
-               M_AST_INTERN(REG_ITMP3, REG_SP, 0 * 4);
-
-               if (targetdisp == 0) {
-                       targetdisp = ((u4 *) cd->mcodeptr) - ((u4 *) cd->mcodebase);
-
-                       disp = dseg_add_functionptr(cd, asm_patcher_wrapper);
-                       M_ALD(REG_ITMP3, REG_PV, disp);
-                       M_MTCTR(REG_ITMP3);
-                       M_RTS;
-               }
-               else {
-                       disp = (((u4 *) cd->mcodebase) + targetdisp) -
-                               (((u4 *) cd->mcodeptr) + 1);
-                       M_BR(disp);
-               }
-       }
+       return mcode;
 }