(codegen_emit_stub_builtin): Removed.
authorRoland Lezuo <tbfg@complang.tuwien.ac.at>
Tue, 9 Oct 2007 09:43:50 +0000 (11:43 +0200)
committerRoland Lezuo <tbfg@complang.tuwien.ac.at>
Tue, 9 Oct 2007 09:43:50 +0000 (11:43 +0200)
(codegen_emit_stub_native): Ported to new interface.

Ported to new interface, removed warnings.
(md_signal_handler_sigill): Likewise.

(offset.h): Removed.

(PATCH_BACK_ORIGINAL_MCODE): Added.
(patcher_patch_back): Removed.
(patcher_patch_code): Added.
(patcher_*): Use patchref_t instead of void *sp everywhere.

src/vm/jit/m68k/codegen.c
src/vm/jit/m68k/linux/md-os.c
src/vm/jit/m68k/md.c
src/vm/jit/m68k/patcher.c
src/vm/jit/patcher-common.h

index 3b8787dea4422a9b3372cce207c6b04985efbe77..706619b6574dfa41bf8aba85d76dea38b5ade4c2 100644 (file)
@@ -75,7 +75,6 @@ bool codegen_emit(jitdata *jd)
        codegendata        *cd;
        registerdata       *rd;
        s4                  len, s1, s2, s3, d, disp;
-       ptrint              a;
        varinfo            *var;
        basicblock         *bptr;
        instruction        *iptr;
@@ -2410,181 +2409,20 @@ void codegen_emit_stub_compiler(jitdata *jd)
        M_AMOV_IMM(asm_call_jit_compiler, REG_ATMP3);
        M_JMP(REG_ATMP3);
 }
-
-/* codegen_emit_stub_builtin ***************************************************
-
-   Creates a stub routine which calls a builtin function.
-
-*******************************************************************************/
-
-void codegen_emit_stub_builtin(jitdata *jd, builtintable_entry *bte)
-{
-       codeinfo    *code;
-       codegendata *cd;
-       methoddesc  *md;
-       s4           i;
-       s4           disp;
-       s4           s1, s2;
-
-       /* get required compiler data */
-       code = jd->code;
-       cd   = jd->cd;
-
-       /* set some variables */
-       md = bte->md;
-
-       /* calculate stack frame size */
-       cd->stackframesize =
-               sizeof(stackframeinfo) / SIZEOF_VOID_P +
-               4;                              /* 4 arguments or return value        */
-
-       /* create method header */
-       (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
-       (void) dseg_add_unique_s4(cd, cd->stackframesize * 4); /* FrameSize       */
-       (void) dseg_add_unique_s4(cd, 0);                      /* IsSync          */
-       (void) dseg_add_unique_s4(cd, 0);                      /* IsLeaf          */
-       (void) dseg_add_unique_s4(cd, 0);                      /* IntSave         */
-       (void) dseg_add_unique_s4(cd, 0);                      /* FltSave         */
-       (void) dseg_addlinenumbertablesize(cd);
-       (void) dseg_add_unique_s4(cd, 0);                      /* ExTableSize     */
-
-       /* generate stub code */
-       M_AADD_IMM(-(cd->stackframesize*4), REG_SP);
-
-#if defined(ENABLE_GC_CACAO)
-       /* Save callee saved integer registers in stackframeinfo (GC may
-          need to recover them during a collection). */
-
-       disp = cd->stackframesize * 4 - sizeof(stackframeinfo) +
-               OFFSET(stackframeinfo, adrregs);
-
-       for (i = 0; i < ADR_SAV_CNT; i++)
-               M_AST(abi_registers_address_saved[i], REG_SP, disp + i * 4);
-#endif
-
-       /* create dynamic stack info */
-
-       M_AMOV(REG_SP, REG_ATMP1);
-       M_AADD_IMM(cd->stackframesize * 4, REG_ATMP1);
-       M_AST(REG_ATMP1, REG_SP, 0 * 4);        /* datasp */
-
-       M_AMOV_IMM(0, REG_ATMP1);                       /* we need pv patched in */
-       dseg_adddata(cd);                                       /* this does the trick */
-       M_AST(REG_ATMP1, REG_SP, 1 * 4);        /* pv */
-
-       M_AMOV(REG_SP, REG_ATMP1);
-       M_AADD_IMM(cd->stackframesize * 4 + SIZEOF_VOID_P, REG_ATMP1);
-       M_AST(REG_ATMP1, REG_SP, 2 * 4);                        /* sp */
-
-       M_ALD(REG_ATMP3, REG_SP, cd->stackframesize * 4);
-       M_AST(REG_ATMP3, REG_SP, 3 * 4);                        /* ra */
-
-       M_JSR_IMM(codegen_stub_builtin_enter);
-
-       /* copy arguments into new stackframe */
-
-       for (i = 0; i < md->paramcount; i++) {
-               if (!md->params[i].inmemory) {
-                       log_text("No integer argument registers available!");
-                       assert(0);
-
-               } else {       /* float/double in memory can be copied like int/longs */
-                       s1 = md->params[i].regoff + cd->stackframesize * 4 + 4;
-                       s2 = md->params[i].regoff;
-
-                       M_ILD(REG_ITMP1, REG_SP, s1);
-                       M_IST(REG_ITMP1, REG_SP, s2);
-                       if (IS_2_WORD_TYPE(md->paramtypes[i].type)) {
-                               M_ILD(REG_ITMP1, REG_SP, s1 + 4);
-                               M_IST(REG_ITMP1, REG_SP, s2 + 4);
-                       }
-
-               }
-       }
-
-       /* call the builtin function */
-
-       M_AMOV_IMM(bte->fp, REG_ATMP3);
-       M_JSR(REG_ATMP3);
-
-       /* save return value */
-       switch (md->returntype.type)    {
-               case TYPE_VOID: break;
-
-               /* natives return float arguments in %d0, %d1, cacao expects them in %fp0 */
-               case TYPE_DBL:
-               case TYPE_LNG:
-                       M_IST(REG_D1, REG_SP, 2 * 4);
-                       /* fall through */
-
-               case TYPE_FLT:
-               case TYPE_INT:
-               case TYPE_ADR:
-                       M_IST(REG_D0, REG_SP, 1 * 4);
-                       break;
-
-               default: assert(0);
-       }
-
-       /* remove native stackframe info */
-
-       M_AMOV(REG_SP, REG_ATMP1);
-       M_AADD_IMM(cd->stackframesize * 4, REG_ATMP1);
-       M_AST(REG_ATMP1, REG_SP, 0 * 4);
-
-       M_JSR_IMM(codegen_stub_builtin_exit);
-
-       /* restore return value */
-       switch (md->returntype.type)    {
-               case TYPE_VOID: break;
-
-               case TYPE_DBL:
-               case TYPE_LNG:
-                       M_ILD(REG_D1, REG_SP, 2 * 4);
-                       /* fall through */
-
-               case TYPE_FLT:
-               case TYPE_INT:
-               case TYPE_ADR:
-                       M_ILD(REG_D0, REG_SP, 1 * 4);
-                       break;
-
-               default: assert(0);
-       }
-
-#if defined(ENABLE_GC_CACAO)
-       /* Restore callee saved integer registers from stackframeinfo (GC
-          might have modified them during a collection). */
-        
-       disp = cd->stackframesize * 4 - sizeof(stackframeinfo) +
-               OFFSET(stackframeinfo, adrregs);
-
-       for (i = 0; i < ADR_SAV_CNT; i++)
-               M_ALD(abi_registers_address_saved[i], REG_SP, disp + i * 4);
-#endif
-
-       /* remove stackframe */
-       M_AADD_IMM(cd->stackframesize * 4, REG_SP);
-       M_RET;
-}
-
-
-
-
 /* codegen_emit_stub_native ****************************************************
 
    Emits a stub routine which calls a native method.
 
 *******************************************************************************/
 
-void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
+void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int skipparams)
 {
        methodinfo   *m;
        codeinfo     *code;
        codegendata  *cd;
        registerdata *rd;
        methoddesc   *md;
-       s4 nativeparams, i, j, t, s1, s2;
+       s4 i, j, t, s1, s2;
        
        /* get required compiler data */
 
@@ -2594,7 +2432,6 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        rd   = jd->rd;
 
        md = m->parseddesc;
-       nativeparams = (m->flags & ACC_STATIC) ? 2 : 1;
 
        /* calc stackframe size */
        cd->stackframesize =    sizeof(stackframeinfo) / SIZEOF_VOID_P +
@@ -2653,7 +2490,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        M_ALD(REG_ATMP2, REG_SP, 4 * 4);
 
        /* copy arguments into stackframe */
-       for (i = md->paramcount -1, j = i + nativeparams; i >= 0; --i, --j)     {
+       for (i = md->paramcount -1, j = i + skipparams; i >= 0; --i, --j)       {
                t = md->paramtypes[i].type;
                /* all arguments via stack */
                assert(md->params[i].inmemory);                                         
index 35e17026156def0c29ae0734e5ec4be840b322fe..1492d18f5be1ee997547fb386adc556835535fb6 100644 (file)
 #include "vm/vm.h"
 #include "vm/exceptions.h"
 #include "vm/jit/asmpart.h"
+#include "vm/signallocal.h"
 
 #include <assert.h>
 #include <stdlib.h>
-#include <signal.h>
+/*#include <signal.h>*/
 #include <stdint.h>
 #include <sys/ucontext.h> /* has br0ken ucontext_t*/
 
@@ -83,18 +84,21 @@ void md_init_linux()
 
 /* md_signal_handler_sigsegv ******************************************
  *
- * Invoked when a Nullpointerexception occured, or when the c
+ * Invoked when a Nullpointerexception occured, or when the v
  * crashes, hard to tell the difference. 
  **********************************************************************/
-void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, actual_ucontext_t *_uc) 
+void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 {      
        uint32_t        xpc, sp;
        uint16_t        opc;
        uint32_t        val, regval, off;
        bool            adrreg;
        void        *p;
-       mcontext_t      *_mc;
+       actual_mcontext_t       *_mc;
+       actual_ucontext_t       *_uc;
 
+
+       _uc = (actual_ucontext_t*)_p;
        _mc = &_uc->uc_mcontext;
        sp = _mc->gregs[R_SP];
        xpc = _mc->gregs[R_PC];
@@ -141,7 +145,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, actual_ucontext_t *_
 
        /* Handle the type. */
 
-       p = signal_handle(EXCEPTION_HARDWARE_NULLPOINTER, regval, NULL, sp, xpc, xpc, _p);
+       p = signal_handle(EXCEPTION_HARDWARE_NULLPOINTER, regval, NULL, (void*)sp, (void*)xpc, (void*)xpc, _p);
 
        _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1]     = (intptr_t) p;
        _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (intptr_t) xpc;
@@ -156,16 +160,18 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, actual_ucontext_t *_
  * been created directly before the trap instruction (2 bytes long).
  * the last 3 bit of this tst instruction contain the register number.
  **********************************************************************/
-void md_signal_handler_sigill(int sig, siginfo_t *siginfo, actual_ucontext_t *_uc) 
+void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
 {
        uint32_t        xpc, sp;
        uint16_t        opc;
        uint32_t        type;
        uint32_t        val, regval;
        void        *p;
-       mcontext_t      *_mc;
+       actual_mcontext_t       *_mc;
+       actual_ucontext_t       *_uc;
 
-       xpc = siginfo->si_addr;
+       _uc = (actual_ucontext_t*)_p;
+       xpc = (uint32_t)siginfo->si_addr;
 
        if (siginfo->si_code == ILL_ILLOPC)     {
                vm_abort("md_signal_handler_sigill: the illegal instruction @ 0x%x, aborting", xpc);
@@ -213,7 +219,7 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, actual_ucontext_t *_u
 
        /* Handle the type. */
 
-       p = signal_handle(type, val, NULL, sp, xpc, xpc, _p);
+       p = signal_handle(type, val, NULL, (void*)sp, (void*)xpc, (void*)xpc, _p);
 
        _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1]     = (intptr_t) p;
        _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (intptr_t) xpc;
index 01b5f6c82619038cf897f03dd3810206de1c6a56..1cf89e90c2d5c47e0526fe8eed4e81b9f1d8223a 100644 (file)
@@ -36,7 +36,6 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/md.h"
 
-#include "offsets.h"
 #include "vm/vm.h"
 #include "vmcore/class.h"
 #include "vmcore/linker.h"
  */
 void md_init(void) 
 {
-       assert(OFFSET(vftbl_t, baseval) == offbaseval);
-       assert(OFFSET(vftbl_t, diffval) == offdiffval);
-       assert(OFFSET(castinfo, super_baseval) == offcast_super_baseval);
-       assert(OFFSET(castinfo, super_diffval) == offcast_super_diffval);
-       assert(OFFSET(castinfo, sub_baseval) == offcast_sub_baseval);
-
-#if 0
-#if defined(ENABLE_REPLACEMENT)
-       assert(sizeof(executionstate_t) = sizeexecutionstate);
-       assert(OFFSET(executionstate_t, pc) == offes_pc);
-       assert(OFFSET(executionstate_t, sp) == offes_sp);
-       assert(OFFSET(executionstate_t, pv) == offes_pv);
-       assert(OFFSET(executionstate_t, intregs) == offes_intregs);
-       assert(OFFSET(executionstate_t, fltregs) == offes_fltregs);
-#endif
-#endif
-
 #ifdef __LINUX__
        md_init_linux();
 #endif
@@ -138,7 +120,7 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
                        /* we had a moveal XXX, %a3 which is a 3 word opcode */
                        /* 2679 0000 0000 */
                        assert(*(u2*)(pc - 8) == 0x2879);               /* moveal */
-                       pa = *((u4*)(pc - 6));                          /* another indirection ! */
+                       pa = (void*)*((u4*)(pc - 6));                           /* another indirection ! */
                }
        } else if (*((u2*)(pc - 2)) == 0x4e92)  {               /* jsr %a2@ */
                if (*(u2*)(pc - 8) == 0x247c)   {
@@ -209,9 +191,9 @@ extern int cacheflush(unsigned long addr, int scope, int cache, unsigned long le
 #include "asm/cachectl.h"      /* found more traces of the cacheflush function */
 #include "errno.h"
 
-void md_cacheflush(u1 *addr, s4 nbytes)  { cacheflush(addr, FLUSH_SCOPE_PAGE, FLUSH_CACHE_BOTH, nbytes); }
-void md_dcacheflush(u1 *addr, s4 nbytes) { cacheflush(addr, FLUSH_SCOPE_PAGE, FLUSH_CACHE_DATA, nbytes); }
-void md_icacheflush(u1* addr, s4 nbytes) { cacheflush(addr, FLUSH_SCOPE_LINE, FLUSH_CACHE_INSN, nbytes); }
+void md_cacheflush(u1 *addr, s4 nbytes)  { cacheflush((unsigned long)addr, FLUSH_SCOPE_PAGE, FLUSH_CACHE_BOTH, nbytes); }
+void md_dcacheflush(u1 *addr, s4 nbytes) { cacheflush((unsigned long)addr, FLUSH_SCOPE_PAGE, FLUSH_CACHE_DATA, nbytes); }
+void md_icacheflush(u1* addr, s4 nbytes) { cacheflush((unsigned long)addr, FLUSH_SCOPE_LINE, FLUSH_CACHE_INSN, nbytes); }
 
 /* md_stacktrace_get_returnaddress *********************************************
 
index 7ffae478b02f6996e362de2b239a941a209b0a30..9e8796b733a3663863a94d3374a6bc81244ffa3f 100644 (file)
@@ -40,9 +40,8 @@
 #include "vm/resolve.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/patcher.h"
+#include "vm/jit/patcher-common.h"
 #include "vm/jit/md.h"
-#include "vm/jit/methodheader.h"
 #include "vm/jit/stacktrace.h"
 
 #include "vmcore/class.h"
@@ -63,6 +62,7 @@
 
 *******************************************************************************/
 
+#if 0
 java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
 {
        stackframeinfo     sfi;
@@ -127,20 +127,36 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
 
        return NULL;
 }
+#endif
 
-/*     Helper
- */
-static void patcher_patch_back(u1 *sp) 
+
+#define PATCH_BACK_ORIGINAL_MCODE  *((u8*)(pr->mpc)) = pr->mcode
+
+/* patcher_initialize_class ****************************************************
+
+       just patch back original code
+
+*******************************************************************************/
+
+
+void patcher_patch_code(patchref_t *pr)        
 {
+#if 0
        u1* xpc    = (u1 *)      *((ptrint *) (sp + 6 * 4));
        u4 mcode  = *((u4*)      (sp + 3 * 4));
        u4 xmcode = *((u4*)      (sp + 2 * 4));
 
        *((u4*)(xpc))   = mcode;
        *((u4*)(xpc+4)) = xmcode;
-       md_icacheflush(xpc, 8);
+#endif
+
+       PATCH_BACK_ORIGINAL_MCODE;
+       md_icacheflush((void*)pr->mpc, 8);
+
 }
 
+
+#if 0
 /* patcher_initialize_class ****************************************************
 
    Initalizes a given classinfo pointer.  This function does not patch
@@ -148,7 +164,7 @@ static void patcher_patch_back(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_initialize_class(u1 *sp)
+bool patcher_initialize_class(patchref_t *pr)
 {
        classinfo *c;
        u4                 xpc, mcode, xmcode;
@@ -166,6 +182,7 @@ bool patcher_initialize_class(u1 *sp)
 
        return true;
 }
+#endif
 
 /* patcher_invokevirtual *******************************************************
 
@@ -178,7 +195,7 @@ bool patcher_initialize_class(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_invokevirtual(u1 *sp)
+bool patcher_invokevirtual(patchref_t *pr)
 {
        u1                *ra;
        unresolved_method *um;
@@ -186,15 +203,15 @@ bool patcher_invokevirtual(u1 *sp)
        s2                 disp;
 
        /* get stuff from the stack */
-       ra = (u1 *)                *((ptrint *) (sp + 6 * 4));
-       um = (unresolved_method *) *((ptrint *) (sp + 1 * 4));
+       ra = (u1 *)                pr->mpc;
+       um = (unresolved_method *) pr->ref;
 
        /* get the fieldinfo */
        if (!(m = resolve_method_eager(um)))
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* if we show NOPs, we have to skip them */
        if (opt_shownops) ra += PATCHER_CALL_SIZE;
@@ -222,22 +239,22 @@ bool patcher_invokevirtual(u1 *sp)
 
 ******************************************************************************/
 
-bool patcher_invokestatic_special(u1 *sp)
+bool patcher_invokestatic_special(patchref_t *pr)
 {
        unresolved_method *um;
        s4                 disp;
        methodinfo        *m;
 
        /* get stuff from the stack */
-       disp =                       *((s4 *)     (sp + 6 * 4));
-       um   = (unresolved_method *) *((ptrint *) (sp + 1 * 4));
+       disp =                       pr->mpc;
+       um   = (unresolved_method *) pr->ref;
 
        /* get the fieldinfo */
        if (!(m = resolve_method_eager(um)))
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* patch stubroutine */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
@@ -246,12 +263,13 @@ bool patcher_invokestatic_special(u1 *sp)
 
        /* synchronize inst cache */
 
-       md_icacheflush(disp+2, SIZEOF_VOID_P);
+       md_icacheflush((void*)(disp+2), SIZEOF_VOID_P);
 
        return true;
 }
 
 
+#if 0
 /* patcher_resolve_class *******************************************************
 
    Resolves a given unresolved_class pointer.  This function does not
@@ -260,7 +278,7 @@ bool patcher_invokestatic_special(u1 *sp)
 *******************************************************************************/
 
 #ifdef ENABLE_VERIFIER
-bool patcher_resolve_class(u1 *sp)
+bool patcher_resolve_class(patchref_t *pr)
 {
        unresolved_class *uc;
        classinfo        *c;
@@ -275,17 +293,19 @@ bool patcher_resolve_class(u1 *sp)
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        return true;
 }
 #endif /* ENABLE_VERIFIER */
+#endif
 
+#if 0
 /* patcher_resolve_classref_to_classinfo ***************************************
   ACONST:
        0x4028f2ca:   2479 0000 0000    moveal 0x00000000,%a2
 *******************************************************************************/
-bool patcher_resolve_classref_to_classinfo(u1 *sp)
+bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 {
        constant_classref *cr;
        s4                 disp;
@@ -301,7 +321,7 @@ bool patcher_resolve_classref_to_classinfo(u1 *sp)
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* patch the classinfo pointer */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
@@ -312,6 +332,7 @@ bool patcher_resolve_classref_to_classinfo(u1 *sp)
 
        return true;
 }
+#endif
 
 /* patcher_get_putstatic *******************************************************
 
@@ -319,17 +340,15 @@ bool patcher_resolve_classref_to_classinfo(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_get_putstatic(u1 *sp)
+bool patcher_get_putstatic(patchref_t *pr)
 {
-       u1               *ra;
        unresolved_field *uf;
        s4                disp;
-       u1               *pv;
        fieldinfo        *fi;
 
        /* get stuff from the stack */
-       uf    = (unresolved_field *)  *((ptrint *) (sp + 1 * 4));
-       disp  =                       *((s4 *)     (sp + 6 * 4));
+       uf    = (unresolved_field *)  pr->ref;
+       disp  =                       pr->mpc;
 
        /* get the fieldinfo */
        if (!(fi = resolve_field_eager(uf)))
@@ -341,7 +360,7 @@ bool patcher_get_putstatic(u1 *sp)
                        return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* patch the field value's address */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
@@ -349,7 +368,7 @@ bool patcher_get_putstatic(u1 *sp)
        *((intptr_t *) (disp+2)) = (intptr_t) fi->value;
 
        /* synchronize inst cache */
-       md_icacheflush(disp+2, SIZEOF_VOID_P);
+       md_icacheflush((void*)(disp+2), SIZEOF_VOID_P);
 
        return true;
 }
@@ -362,22 +381,21 @@ bool patcher_get_putstatic(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_get_putfield(u1 *sp)
+bool patcher_get_putfield(patchref_t *pr)
 {
        u1               *ra;
        unresolved_field *uf;
        fieldinfo        *fi;
-       s2                disp;
 
-       ra = (u1 *)               *((ptrint *) (sp + 6 * 4));
-       uf = (unresolved_field *) *((ptrint *) (sp + 1 * 4));
+       ra = (u1 *)               pr->mpc;
+       uf = (unresolved_field *) pr->ref;
 
        /* get the fieldinfo */
        if (!(fi = resolve_field_eager(uf)))
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* if we show NOPs, we have to skip them */
        if (opt_shownops) ra += PATCHER_CALL_SIZE;
@@ -448,22 +466,22 @@ INSTANCEOF:
 
 *******************************************************************************/
 
-bool patcher_resolve_classref_to_flags(u1 *sp)
+bool patcher_resolve_classref_to_flags(patchref_t *pr)
 {
        constant_classref *cr;
        s4                 disp;
        classinfo         *c;
 
        /* get stuff from the stack */
-       cr   = (constant_classref *) *((ptrint *) (sp + 1 * 4));
-       disp =                       *((s4 *)     (sp + 6 * 4));
+       cr   = (constant_classref *) pr->ref;
+       disp =                       pr->mpc;
 
        /* get the fieldinfo */
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* patch class flags */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
@@ -471,7 +489,7 @@ bool patcher_resolve_classref_to_flags(u1 *sp)
        *((s4 *) (disp + 2)) = (s4) c->flags;
 
        /* synchronize insn cache */
-       md_icacheflush(disp + 2, SIZEOF_VOID_P);
+       md_icacheflush((void*)(disp + 2), SIZEOF_VOID_P);
 
        return true;
 }
@@ -491,22 +509,22 @@ bool patcher_resolve_classref_to_flags(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_resolve_classref_to_vftbl(u1 *sp)
+bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
 {
        constant_classref *cr;
        s4                 disp;
        classinfo         *c;
 
        /* get stuff from the stack */
-       cr   = (constant_classref *) *((ptrint *) (sp + 1 * 4));
-       disp =                       *((s4 *)     (sp + 6 * 4));
+       cr   = (constant_classref *) pr->ref;
+       disp =                       pr->mpc;
 
        /* get the fieldinfo */
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* patch super class' vftbl */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
@@ -515,7 +533,7 @@ bool patcher_resolve_classref_to_vftbl(u1 *sp)
        *((s4 *) (disp+2)) = (s4) c->vftbl;
 
        /* synchronize insin cache */
-       md_icacheflush(disp+2, SIZEOF_VOID_P);
+       md_icacheflush((void*)(disp+2), SIZEOF_VOID_P);
 
        return true;
 }
@@ -534,7 +552,7 @@ bool patcher_resolve_classref_to_vftbl(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_instanceof_interface(u1 *sp)
+bool patcher_instanceof_interface(patchref_t *pr)
 {
        u1                *ra;
        constant_classref *cr;
@@ -543,15 +561,15 @@ bool patcher_instanceof_interface(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra = (u1 *)                *((ptrint *) (sp + 6 * 4));
-       cr = (constant_classref *) *((ptrint *) (sp + 1 * 4));
+       ra = (u1 *)                pr->mpc;
+       cr = (constant_classref *) pr->ref;
 
        /* get the fieldinfo */
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* if we show NOPs, we have to skip them */
        if (opt_shownops) ra += PATCHER_CALL_SIZE;
@@ -569,7 +587,7 @@ bool patcher_instanceof_interface(u1 *sp)
        *((s2 *) (ra + 20)) = disp;
 
        /* synchronize instruction cache */
-       md_icacheflush(ra + 10, 12);
+       md_icacheflush((void*)(ra + 10), 12);
 
        return true;
 }
@@ -588,7 +606,7 @@ bool patcher_instanceof_interface(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_checkcast_interface(u1 *sp)
+bool patcher_checkcast_interface(patchref_t *pr)
 {
        u1                *ra;
        constant_classref *cr;
@@ -596,15 +614,15 @@ bool patcher_checkcast_interface(u1 *sp)
        s4                 disp;
 
        /* get stuff from the stack */
-       ra = (u1 *)                *((ptrint *) (sp + 6 * 4));
-       cr = (constant_classref *) *((ptrint *) (sp + 1 * 4));
+       ra = (u1 *)                pr->mpc;
+       cr = (constant_classref *) pr->ref;
 
        /* get the fieldinfo */
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* if we show NOPs, we have to skip them */
        if (opt_shownops) ra += PATCHER_CALL_SIZE;
@@ -620,44 +638,45 @@ bool patcher_checkcast_interface(u1 *sp)
        *((s2 *) (ra + 24)) = disp;
        
        /* synchronize instruction cache */
-       md_icacheflush(ra + 10, 16);
+       md_icacheflush((void*)(ra + 10), 16);
 
        return true;
 }
 
+#if 0
 /* patcher_resolve_native_function *********************************************
 
    XXX
 
 *******************************************************************************/
 
-bool patcher_resolve_native_function(u1 *sp)
+bool patcher_resolve_native_function(patchref_t *pr)
 {
        methodinfo  *m;
        s4           disp;
        functionptr  f;
 
        /* get stuff from the stack */
-       m    = (methodinfo *) *((ptrint *) (sp + 1 * 4));
-       disp =                *((s4 *)     (sp + 6 * 4));
+       m    = (methodinfo *) pr->ref;
+       disp =                pr->mpc;
 
        /* resolve native function */
        if (!(f = native_resolve_function(m)))
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* patch native function pointer */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
        *((ptrint *) (disp + 2)) = (ptrint) f;
 
        /* synchronize data cache */
-       md_icacheflush(disp + 2, SIZEOF_VOID_P);
+       md_icacheflush((void*)(disp + 2), SIZEOF_VOID_P);
 
        return true;
 }
-
+#endif
 
 /* patcher_invokeinterface *****************************************************
 
@@ -670,7 +689,7 @@ bool patcher_resolve_native_function(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_invokeinterface(u1 *sp)
+bool patcher_invokeinterface(patchref_t *pr)
 {
        u1                *ra;
        unresolved_method *um;
@@ -678,8 +697,8 @@ bool patcher_invokeinterface(u1 *sp)
        s4                 disp;
 
        /* get stuff from the stack */
-       ra = (u1 *)                *((ptrint *) (sp + 6 * 4));
-       um = (unresolved_method *) *((ptrint *) (sp + 1 * 4));
+       ra = (u1 *)                pr->mpc;
+       um = (unresolved_method *) pr->ref;
 
 
        /* get the fieldinfo */
@@ -687,7 +706,7 @@ bool patcher_invokeinterface(u1 *sp)
                return false;
 
        /* patch back original code */
-       patcher_patch_back(sp);
+       PATCH_BACK_ORIGINAL_MCODE;
 
        /* if we show NOPs, we have to skip them */
        if (opt_shownops) ra += PATCHER_CALL_SIZE;
@@ -705,7 +724,7 @@ bool patcher_invokeinterface(u1 *sp)
        *((uint16_t *) (ra + 7 * 2)) = disp;
 
        /* synchronize instruction cache */
-       md_icacheflush(ra + 5 * 2, 2 * 2);
+       md_icacheflush((void*)(ra + 5 * 2), 2 * 2);
 
        return true;
 }
index 63e607e3001a24152d9dd7965b4b55a3e5cfc56f..ff37940cf6e089525ba60d96b70d87dcd923cce7 100644 (file)
@@ -81,7 +81,7 @@ void patcher_patch_code(patchref_t *pr);
 
 /* patcher prototypes and macros **********************************************/
 
-#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined (__S390__) || defined(__X86_64__)
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined (__S390__) || defined(__X86_64__) || defined(__M68K__)
 
 /* new patcher functions */