Merged revisions 8183-8186 via svnmerge from
authormichi <none@none>
Thu, 5 Jul 2007 23:52:19 +0000 (23:52 +0000)
committermichi <none@none>
Thu, 5 Jul 2007 23:52:19 +0000 (23:52 +0000)
svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk

........
  r8184 | michi | 2007-07-05 23:11:01 +0200 (Thu, 05 Jul 2007) | 5 lines

  * src/vm/jit/code.c (code_get_stack_frame_size): Removed.
  * src/vm/jit/code.h: Likewise.

  * src/vm/jit/replace.c: Use code->stackframesize instead of above function.
........
  r8185 | michi | 2007-07-05 23:34:47 +0200 (Thu, 05 Jul 2007) | 3 lines

  * src/vm/jit/arm/md.c (md_get_method_patch_address): Added the replacement
  magic about mptr being NULL sometimes.
........
  r8186 | michi | 2007-07-06 01:48:16 +0200 (Fri, 06 Jul 2007) | 18 lines

  * src/vm/jit/alpha/emit.c (emit_patcher_traps): Formerly known
  as emit_patcher_stubs, now emits traps instead of stubs.

  * src/vm/jit/alpha/codegen.c (codegen_emit, codegen_emit_stub_native): Call the
  new patcher functions and adapted to above change.

  * src/vm/jit/alpha/patcher.c: Adapted patchers to new signature for traps.
  (patcher_wrapper): Removed, this is obsolete.

  * src/vm/jit/alpha/asmpart.S (asm_patcher_wrapper): Removed, this is obsolete.

  * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Only calls the
  exception handling if exception object present.

  * src/vm/jit/patcher-common.h [__ALPHA__]: Enabled new patcher stuff.

  * src/vm/jit/patcher.h [__ALPHA__]: Defined away old patcher stuff.
........

--HG--
branch : exact-gc

src/vm/jit/alpha/asmpart.S
src/vm/jit/alpha/codegen.c
src/vm/jit/alpha/emit.c
src/vm/jit/alpha/linux/md-os.c
src/vm/jit/alpha/patcher.c
src/vm/jit/arm/md.c
src/vm/jit/code.c
src/vm/jit/code.h
src/vm/jit/patcher.h
src/vm/jit/replace.c

index d5ba25312f08e4eb544d8420cf9e9c04dac4c08a..142e758a386e2683d11a461b88f82c1394fc29ac 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: asmpart.S 7678 2007-04-09 17:23:55Z twisti $
+   $Id: asmpart.S 8186 2007-07-05 23:48:16Z michi $
 
 */
 
@@ -59,8 +59,6 @@
 
        .globl asm_abstractmethoderror
 
-       .globl asm_patcher_wrapper
-
 #if defined(ENABLE_REPLACEMENT)
        .globl asm_replacement_out
        .globl asm_replacement_in
@@ -432,73 +430,6 @@ asm_abstractmethoderror:
        .end    asm_abstractmethoderror
 
 
-/* asm_patcher_wrapper *********************************************************
-
-   XXX
-
-   Stack layout:
-     40   return address into JIT code (patch position)
-     32   pointer to virtual java_objectheader
-     24   machine code (which is patched back later)
-     16   unresolved class/method/field reference
-      8   data segment displacement from load instructions
-      0   patcher function pointer to call (pv afterwards)
-
-   ATTENTION: itmp3 == gp! But we don't need gp do call the patcher function.
-
-*******************************************************************************/
-               
-       .ent    asm_patcher_wrapper
-
-asm_patcher_wrapper:
-       lda     sp,-((2+12+27+4)*8)(sp) /* create stack frame                     */
-
-       SAVE_RETURN_REGISTERS(0)      /* save 1 int/1 float return registers      */
-       SAVE_ARGUMENT_REGISTERS(2)    /* save 6 int/6 float argument registers    */
-       SAVE_TEMPORARY_REGISTERS(14)  /* save 11 int/16 float temporary registers */
-
-       stq     itmp1,(2+12+27+0)*8(sp) /* save itmp1                             */
-       stq     itmp2,(2+12+27+1)*8(sp) /* save itmp2                             */
-       stq     ra,(2+12+27+2)*8(sp)  /* save method return address (for leafs)   */
-       stq     pv,(2+12+27+3)*8(sp)  /* save pv of calling java function         */
-
-       br      ra,L_asm_patcher_wrapper_load_gp
-L_asm_patcher_wrapper_load_gp:
-       ldgp    gp,0(ra)              /* load gp (it's not set correctly in jit)  */
-
-       lda     a0,(2+12+27+4)*8(sp)  /* pass SP of patcher stub                  */
-       mov     pv,a1                 /* pass PV                                  */
-       ldq     a2,(2+12+27+2)*8(sp)  /* pass RA (correct for leafs)              */
-       jsr     ra,patcher_wrapper
-       ldgp    gp,0(ra)
-       stq     v0,(0+2+12+27+4)*8(sp) /* save return value                       */
-
-       RESTORE_RETURN_REGISTERS(0)   /* restore 1 int/1 float return registers   */
-       RESTORE_ARGUMENT_REGISTERS(2) /* restore 6 int/6 float argument registers */
-       RESTORE_TEMPORARY_REGISTERS(14) /* restore 11 integer temporary registers */
-
-       ldq     itmp1,(2+12+27+0)*8(sp) /* restore itmp1                          */
-       ldq     itmp2,(2+12+27+1)*8(sp) /* restore itmp2                          */
-       ldq     ra,(2+12+27+2)*8(sp)  /* restore method return address (for leafs)*/
-       ldq     pv,(2+12+27+3)*8(sp)  /* restore pv of calling java function      */
-
-       ldq     itmp3,(0+2+12+27+4)*8(sp) /* get return value                     */
-       bne     itmp3,L_asm_patcher_wrapper_exception
-
-       ldq     itmp3,(5+2+12+27+4)*8(sp) /* get RA to JIT                        */
-       lda     sp,(6+2+12+27+4)*8(sp) /* remove stack frame                      */
-
-       jmp     zero,(itmp3)          /* jump to new patched code                 */
-
-L_asm_patcher_wrapper_exception:
-       mov     itmp3,xptr            /* get exception                            */
-       ldq     xpc,(5+2+12+27+4)*8(sp) /* RA is xpc                              */
-       lda     sp,(6+2+12+27+4)*8(sp) /* remove stack frame                      */
-       br      L_asm_handle_exception
-
-       .end    asm_patcher_wrapper
-
-               
 #if defined(ENABLE_REPLACEMENT)
 
 /* asm_replacement_out *********************************************************
index 4ecb6e6d0f68999847adfadc74744e62134522a1..4e7b247acdc57c1e950581b4e93959494f1bf34e 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: codegen.c 8187 2007-07-05 23:52:19Z michi $
 
 */
 
@@ -59,7 +59,7 @@
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
 #include "vm/jit/parse.h"
-#include "vm/jit/patcher.h"
+#include "vm/jit/patcher-common.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/stacktrace.h"
@@ -450,7 +450,7 @@ bool codegen_emit(jitdata *jd)
                                   resolved the same class, the returned displacement
                                   of dseg_add_address is ok to use. */
 
-                               codegen_add_patch_ref(cd, PATCHER_resolve_classref_to_classinfo,
+                               patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo,
                                                                          cr, disp);
 
                                M_ALD(d, REG_PV, disp);
@@ -1795,7 +1795,7 @@ bool codegen_emit(jitdata *jd)
                                fieldtype = uf->fieldref->parseddesc.fd->type;
                                disp      = dseg_add_unique_address(cd, uf);
 
-                               codegen_add_patch_ref(cd, PATCHER_get_putstatic, uf, disp);
+                               patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp);
                        }
                        else {
                                fi        = iptr->sx.s23.s3.fmiref->p.field;
@@ -1803,7 +1803,7 @@ bool codegen_emit(jitdata *jd)
                                disp      = dseg_add_address(cd, &(fi->value));
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class))
-                                       codegen_add_patch_ref(cd, PATCHER_initialize_class, fi->class,
+                                       patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class,
                                                                                  0);
                        }
 
@@ -1840,7 +1840,7 @@ bool codegen_emit(jitdata *jd)
                                fieldtype = uf->fieldref->parseddesc.fd->type;
                                disp      = dseg_add_unique_address(cd, uf);
 
-                               codegen_add_patch_ref(cd, PATCHER_get_putstatic, uf, disp);
+                               patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp);
                        }
                        else {
                                fi        = iptr->sx.s23.s3.fmiref->p.field;
@@ -1848,7 +1848,7 @@ bool codegen_emit(jitdata *jd)
                                disp      = dseg_add_address(cd, &(fi->value));
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class))
-                                       codegen_add_patch_ref(cd, PATCHER_initialize_class, fi->class,
+                                       patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class,
                                                                                  0);
                        }
 
@@ -1886,7 +1886,7 @@ bool codegen_emit(jitdata *jd)
                                fieldtype = uf->fieldref->parseddesc.fd->type;
                                disp      = dseg_add_unique_address(cd, uf);
 
-                               codegen_add_patch_ref(cd, PATCHER_get_putstatic, uf, disp);
+                               patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp);
                        }
                        else {
                                fi        = iptr->sx.s23.s3.fmiref->p.field;
@@ -1894,7 +1894,7 @@ bool codegen_emit(jitdata *jd)
                                disp      = dseg_add_address(cd, &(fi->value));
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class))
-                                       codegen_add_patch_ref(cd, PATCHER_initialize_class, fi->class,
+                                       patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class,
                                                                                  0);
                        }
                        
@@ -1928,7 +1928,7 @@ bool codegen_emit(jitdata *jd)
                                fieldtype = uf->fieldref->parseddesc.fd->type;
                                disp      = 0;
 
-                               codegen_add_patch_ref(cd, PATCHER_get_putfield, uf, 0);
+                               patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0);
                        }
                        else {
                                fi        = iptr->sx.s23.s3.fmiref->p.field;
@@ -1984,7 +1984,7 @@ bool codegen_emit(jitdata *jd)
                                s2 = emit_load_s2(jd, iptr, REG_FTMP2);
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr))
-                               codegen_add_patch_ref(cd, PATCHER_get_putfield, uf, 0);
+                               patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0);
 
                        /* implicit null-pointer check */
                        switch (fieldtype) {
@@ -2017,7 +2017,7 @@ bool codegen_emit(jitdata *jd)
                                fieldtype = uf->fieldref->parseddesc.fd->type;
                                disp      = 0;
 
-                               codegen_add_patch_ref(cd, PATCHER_get_putfield, uf, 0);
+                               patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0);
                        }
                        else {
                                fi        = iptr->sx.s23.s3.fmiref->p.field;
@@ -2057,7 +2057,7 @@ bool codegen_emit(jitdata *jd)
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                unresolved_class *uc = iptr->sx.s23.s2.uc;
 
-                               codegen_add_patch_ref(cd, PATCHER_resolve_class, uc, 0);
+                               patcher_add_patch_ref(jd, PATCHER_resolve_class, uc, 0);
                        }
 #endif /* ENABLE_VERIFIER */
 
@@ -2356,7 +2356,7 @@ bool codegen_emit(jitdata *jd)
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                unresolved_class *uc = iptr->sx.s23.s2.uc;
 
-                               codegen_add_patch_ref(cd, PATCHER_resolve_class, uc, 0);
+                               patcher_add_patch_ref(jd, PATCHER_resolve_class, uc, 0);
                        }
 #endif /* ENABLE_VERIFIER */
                        goto nowperformreturn;
@@ -2622,7 +2622,7 @@ gen_method:
                                if (lm == NULL) {
                                        disp = dseg_add_unique_address(cd, um);
 
-                                       codegen_add_patch_ref(cd, PATCHER_invokestatic_special,
+                                       patcher_add_patch_ref(jd, PATCHER_invokestatic_special,
                                                                                  um, disp);
                                }
                                else
@@ -2640,7 +2640,7 @@ gen_method:
 
                        case ICMD_INVOKEVIRTUAL:
                                if (lm == NULL) {
-                                       codegen_add_patch_ref(cd, PATCHER_invokevirtual, um, 0);
+                                       patcher_add_patch_ref(jd, PATCHER_invokevirtual, um, 0);
 
                                        s1 = 0;
                                }
@@ -2662,7 +2662,7 @@ gen_method:
 
                        case ICMD_INVOKEINTERFACE:
                                if (lm == NULL) {
-                                       codegen_add_patch_ref(cd, PATCHER_invokeinterface, um, 0);
+                                       patcher_add_patch_ref(jd, PATCHER_invokeinterface, um, 0);
 
                                        s1 = 0;
                                        s2 = 0;
@@ -2735,7 +2735,7 @@ gen_method:
 
                                        disp = dseg_add_unique_s4(cd, 0);         /* super->flags */
 
-                                       codegen_add_patch_ref(cd, PATCHER_resolve_classref_to_flags,
+                                       patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_flags,
                                                                                  iptr->sx.s23.s3.c.ref,
                                                                                  disp);
 
@@ -2750,7 +2750,7 @@ gen_method:
 
                                if ((super == NULL) || (super->flags & ACC_INTERFACE)) {
                                        if (super == NULL) {
-                                               codegen_add_patch_ref(cd,
+                                               patcher_add_patch_ref(jd,
                                                                                          PATCHER_checkcast_interface,
                                                                                          iptr->sx.s23.s3.c.ref,
                                                                                          0);
@@ -2783,7 +2783,7 @@ gen_method:
 
                                                disp = dseg_add_unique_address(cd, NULL);
 
-                                               codegen_add_patch_ref(cd,
+                                               patcher_add_patch_ref(jd,
                                                                                          PATCHER_resolve_classref_to_vftbl,
                                                                                          iptr->sx.s23.s3.c.ref,
                                                                                          disp);
@@ -2840,7 +2840,7 @@ gen_method:
                                if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                        disp = dseg_add_unique_address(cd, NULL);
 
-                                       codegen_add_patch_ref(cd,
+                                       patcher_add_patch_ref(jd,
                                                                                  PATCHER_resolve_classref_to_classinfo,
                                                                                  iptr->sx.s23.s3.c.ref,
                                                                                  disp);
@@ -2902,7 +2902,7 @@ gen_method:
 
                                disp = dseg_add_unique_s4(cd, 0);             /* super->flags */
 
-                               codegen_add_patch_ref(cd, PATCHER_resolve_classref_to_flags,
+                               patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_flags,
                                                                          iptr->sx.s23.s3.c.ref, disp);
 
                                M_ILD(REG_ITMP3, REG_PV, disp);
@@ -2922,7 +2922,7 @@ gen_method:
                                        if (d == REG_ITMP2)
                                                M_CLR(d);
 
-                                       codegen_add_patch_ref(cd,
+                                       patcher_add_patch_ref(jd,
                                                                                  PATCHER_instanceof_interface,
                                                                                  iptr->sx.s23.s3.c.ref, 0);
                                }
@@ -2954,7 +2954,7 @@ gen_method:
 
                                        disp = dseg_add_unique_address(cd, NULL);
 
-                                       codegen_add_patch_ref(cd, PATCHER_resolve_classref_to_vftbl,
+                                       patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_vftbl,
                                                                                  iptr->sx.s23.s3.c.ref,
                                                                                  disp);
                                }
@@ -3021,7 +3021,7 @@ gen_method:
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                disp = dseg_add_unique_address(cd, 0);
 
-                               codegen_add_patch_ref(cd, PATCHER_resolve_classref_to_classinfo,
+                               patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo,
                                                                          iptr->sx.s23.s3.c.ref,
                                                                          disp);
                        }
@@ -3066,7 +3066,7 @@ gen_method:
 
        /* generate stubs */
 
-       emit_patcher_stubs(jd);
+       emit_patcher_traps(jd);
        REPLACEMENT_EMIT_STUBS(jd);
 
        /* everything's ok */
@@ -3167,7 +3167,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
 #if !defined(WITH_STATIC_CLASSPATH)
        if (f == NULL)
-               codegen_add_patch_ref(cd, PATCHER_resolve_native_function, m, funcdisp);
+               patcher_add_patch_ref(jd, PATCHER_resolve_native_function, m, funcdisp);
 #endif
 
 #if defined(ENABLE_GC_CACAO)
@@ -3378,7 +3378,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        
        /* generate patcher stubs */
 
-       emit_patcher_stubs(jd);
+       emit_patcher_traps(jd);
 }
 
 
index 0c93184cca1e9cb023a3cdbfc87c89d7031be59d..d0e08dce33b3bacab539035cdc3efd8b426c0ad6 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: emit.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: emit.c 8186 2007-07-05 23:48:16Z michi $
 
 */
 
@@ -49,6 +49,7 @@
 #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"
@@ -407,113 +408,44 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
 }
 
 
-/* emit_patcher_stubs **********************************************************
+/* emit_patcher_traps **********************************************************
 
-   Generates the code for the patcher stubs.
+   Generates the code for the patcher traps.
 
 *******************************************************************************/
 
-void emit_patcher_stubs(jitdata *jd)
+void emit_patcher_traps(jitdata *jd)
 {
        codegendata *cd;
-       patchref    *pref;
-       u4           mcode;
+       codeinfo    *code;
+       patchref_t  *pr;
        u1          *savedmcodeptr;
        u1          *tmpmcodeptr;
-       s4           targetdisp;
-       s4           disp;
 
        /* get required compiler data */
 
-       cd = jd->cd;
-
-       /* generate code patching stub call code */
-
-       targetdisp = 0;
+       cd =   jd->cd;
+       code = jd->code;
 
-       for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
-               /* check code segment size */
+       /* generate patcher traps code */
 
-               MCODECHECK(100);
+       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
-                  call is 1 instruction word long. */
-
-               tmpmcodeptr = (u1 *) (cd->mcodebase + pref->branchpos);
+                  trap is 1 instruction word long. */
 
-               mcode = *((u4 *) tmpmcodeptr);
+               tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
+               pr->mcode = *((u4 *) tmpmcodeptr);
 
-               /* Patch in the call to call the following code (done at
+               /* 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     */
 
-               disp = ((u4 *) savedmcodeptr) - (((u4 *) tmpmcodeptr) + 1);
-               M_BSR(REG_ITMP3, disp);
+               M_ALD_INTERN(REG_RESULT, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
 
                cd->mcodeptr = savedmcodeptr;   /* restore the current mcodeptr       */
-
-               /* create stack frame */
-
-               M_LSUB_IMM(REG_SP, 6 * 8, REG_SP);
-
-               /* move return address onto stack */
-
-               M_AST(REG_ITMP3, REG_SP, 5 * 8);
-
-               /* move pointer to java_objectheader onto stack */
-
-#if defined(ENABLE_THREADS)
-               /* create a virtual java_objectheader */
-
-               (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(REG_ITMP3, REG_SP, 4 * 8);
-#else
-               /* nothing to do */
-#endif
-
-               /* move machine code onto stack */
-
-               disp = dseg_add_s4(cd, mcode);
-               M_ILD(REG_ITMP3, REG_PV, disp);
-               M_IST(REG_ITMP3, REG_SP, 3 * 8);
-
-               /* move class/method/field reference onto stack */
-
-               disp = dseg_add_address(cd, pref->ref);
-               M_ALD(REG_ITMP3, REG_PV, disp);
-               M_AST(REG_ITMP3, REG_SP, 2 * 8);
-
-               /* move data segment displacement onto stack */
-
-               disp = dseg_add_s4(cd, pref->disp);
-               M_ILD(REG_ITMP3, REG_PV, disp);
-               M_IST(REG_ITMP3, REG_SP, 1 * 8);
-
-               /* move patcher function pointer onto stack */
-
-               disp = dseg_add_functionptr(cd, pref->patcher);
-               M_ALD(REG_ITMP3, REG_PV, disp);
-               M_AST(REG_ITMP3, REG_SP, 0 * 8);
-
-               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_JMP(REG_ZERO, REG_ITMP3);
-               }
-               else {
-                       disp = (((u4 *) cd->mcodebase) + targetdisp) -
-                               (((u4 *) cd->mcodeptr) + 1);
-
-                       M_BR(disp);
-               }
        }
 }
 
index ccd99ea2940e4c7f5fbf14401da5e5a491acd50a..e19a91247d18e026db12ab300cbaef746c08d590 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-os.c 8178 2007-07-05 11:13:20Z michi $
+   $Id: md-os.c 8186 2007-07-05 23:48:16Z michi $
 
 */
 
@@ -112,9 +112,11 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        /* set registers */
 
-       _mc->sc_regs[REG_ITMP1_XPTR] = (ptrint) e;
-       _mc->sc_regs[REG_ITMP2_XPC]  = (ptrint) xpc;
-       _mc->sc_pc                   = (ptrint) asm_handle_exception;
+       if (e != NULL) {
+               _mc->sc_regs[REG_ITMP1_XPTR] = (ptrint) e;
+               _mc->sc_regs[REG_ITMP2_XPC]  = (ptrint) xpc;
+               _mc->sc_pc                   = (ptrint) asm_handle_exception;
+       }
 }
 
 
index 17626af7916060fbd34f8a679eac03b8f2bf2e59..bf35d8cb3ce00b760ee984620b5c522809fb9bd9 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: patcher.c 7596 2007-03-28 21:05:53Z twisti $
+   $Id: patcher.c 8186 2007-07-05 23:48:16Z michi $
 
 */
 
@@ -42,7 +42,7 @@
 #include "vm/initialize.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 "vm/resolve.h"
 
 
-/* patcher_wrapper *************************************************************
+#define PATCH_BACK_ORIGINAL_MCODE \
+       *((u4 *) pr->mpc) = (u4) pr->mcode; \
+    md_icacheflush(NULL, 0);
 
-   Wrapper for all patchers.  It also creates the stackframe info
-   structure.
-
-   If the return value of the patcher function is false, it gets the
-   exception object, clears the exception pointer and returns the
-   exception.
-
-*******************************************************************************/
-
-java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
-{
-       stackframeinfo     sfi;
-       u1                *xpc;
-       java_objectheader *o;
-       u4                 mcode;
-       functionptr        f;
-       bool               result;
-       java_objectheader *e;
-
-       /* define the patcher function */
-
-       bool (*patcher_function)(u1 *);
-
-       assert(pv != NULL);
-
-       /* get stuff from the stack */
-
-       xpc   = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       f     = (functionptr)         *((ptrint *) (sp + 0 * 8));
-
-       /* calculate and set the new return address */
-
-       xpc = xpc - 1 * 4;
-
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) xpc;
-
-       /* store PV into the patcher function position */
-
-       *((ptrint *) (sp + 0 * 8)) = (ptrint) pv;
-
-       /* cast the passed function to a patcher function */
-
-       patcher_function = (bool (*)(u1 *)) (ptrint) f;
-
-       /* enter a monitor on the patching position */
-
-       PATCHER_MONITORENTER;
-
-       /* create the stackframeinfo */
-
-       stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + 6 * 8, ra, xpc);
-
-       /* call the proper patcher function */
-
-       result = (patcher_function)(sp);
-
-       /* remove the stackframeinfo */
-
-       stacktrace_remove_stackframeinfo(&sfi);
-
-       /* check for an error, get the exception and return it */
-
-       if (result == false) {
-               e = exceptions_get_and_clear_exception();
-
-               PATCHER_MONITOREXIT;
-
-               return e;
-       }
-
-       /* patch back original code */
-
-       mcode = *((u4 *) (sp + 3 * 8));
-
-       *((u4 *) xpc) = mcode;
-
-       /* synchronize instruction cache */
-
-       md_icacheflush(NULL, 0);
-
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
-       return NULL;
-}
 
 /* patcher_initialize_class ****************************************************
 
@@ -149,13 +66,13 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
 
 *******************************************************************************/
 
-bool patcher_initialize_class(u1 *sp)
+bool patcher_initialize_class(patchref_t *pr)
 {
        classinfo *c;
 
        /* get stuff from the stack */
 
-       c = (classinfo *) *((ptrint *) (sp + 2 * 8));
+       c = (classinfo *) pr->ref;
 
        /* check if the class is initialized */
 
@@ -163,6 +80,8 @@ bool patcher_initialize_class(u1 *sp)
                if (!initialize_class(c))
                        return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        return true;
 }
 
@@ -174,19 +93,21 @@ bool patcher_initialize_class(u1 *sp)
 *******************************************************************************/
 
 #ifdef ENABLE_VERIFIER
-bool patcher_resolve_class(u1 *sp)
+bool patcher_resolve_class(patchref_t *pr)
 {
        unresolved_class *uc;
 
        /* get stuff from the stack */
 
-       uc = (unresolved_class *)  *((ptrint *) (sp + 2 * 8));
+       uc = (unresolved_class *) pr->ref;
 
        /* resolve the class and check subtype constraints */
 
        if (!resolve_class_eager_no_access_check(uc))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        return true;
 }
 #endif /* ENABLE_VERIFIER */
@@ -216,27 +137,27 @@ bool patcher_resolve_class(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_resolve_classref_to_classinfo(u1 *sp)
+bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
 {
        constant_classref *cr;
-       s4                 disp;
-       u1                *pv;
+       u1                *datap;
        classinfo         *c;
 
        /* get stuff from the stack */
 
-       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
-       disp  =                       *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
+       cr    = (constant_classref *) pr->ref;
+       datap = (u1 *)                pr->datap;
 
        /* get the classinfo */
 
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* patch the classinfo pointer */
 
-       *((ptrint *) (pv + disp)) = (ptrint) c;
+       *((ptrint *) datap) = (ptrint) c;
 
        return true;
 }
@@ -253,27 +174,27 @@ bool patcher_resolve_classref_to_classinfo(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_resolve_classref_to_vftbl(u1 *sp)
+bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
 {
        constant_classref *cr;
-       s4                 disp;
-       u1                *pv;
+       u1                *datap;
        classinfo         *c;
 
        /* get stuff from the stack */
 
-       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
-       disp  =                       *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
+       cr    = (constant_classref *) pr->ref;
+       datap = (u1 *)                pr->datap;
 
        /* get the fieldinfo */
 
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* patch super class' vftbl */
 
-       *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
+       *((ptrint *) datap) = (ptrint) c->vftbl;
 
        return true;
 }
@@ -287,27 +208,27 @@ bool patcher_resolve_classref_to_vftbl(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_resolve_classref_to_flags(u1 *sp)
+bool patcher_resolve_classref_to_flags(patchref_t *pr)
 {
        constant_classref *cr;
-       s4                 disp;
-       u1                *pv;
+       u1                *datap;
        classinfo         *c;
 
        /* get stuff from the stack */
 
-       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
-       disp  =                       *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
+       cr    = (constant_classref *) pr->ref;
+       datap = (u1 *)                pr->datap;
 
        /* get the fieldinfo */
 
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* patch class flags */
 
-       *((s4 *) (pv + disp)) = (s4) c->flags;
+       *((s4 *) datap) = (s4) c->flags;
 
        return true;
 }
@@ -320,27 +241,27 @@ bool patcher_resolve_classref_to_flags(u1 *sp)
 *******************************************************************************/
 
 #if !defined(WITH_STATIC_CLASSPATH)
-bool patcher_resolve_native_function(u1 *sp)
+bool patcher_resolve_native_function(patchref_t *pr)
 {
        methodinfo  *m;
-       s4           disp;
-       u1          *pv;
+       u1          *datap;
        functionptr  f;
 
        /* get stuff from the stack */
 
-       m     = (methodinfo *) *((ptrint *) (sp + 2 * 8));
-       disp  =                *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)         *((ptrint *) (sp + 0 * 8));
+       m     = (methodinfo *) pr->ref;
+       datap = (u1 *)         pr->datap;
 
        /* resolve native function */
 
        if (!(f = native_resolve_function(m)))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* patch native function pointer */
 
-       *((ptrint *) (pv + disp)) = (ptrint) f;
+       *((ptrint *) datap) = (ptrint) f;
 
        return true;
 }
@@ -357,18 +278,16 @@ bool patcher_resolve_native_function(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_get_putstatic(u1 *sp)
+bool patcher_get_putstatic(patchref_t *pr)
 {
        unresolved_field *uf;
-       s4                disp;
-       u1               *pv;
+       u1               *datap;
        fieldinfo        *fi;
 
        /* get stuff from the stack */
 
-       uf    = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
-       disp  =                      *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)               *((ptrint *) (sp + 0 * 8));
+       uf    = (unresolved_field *) pr->ref;
+       datap = (u1 *)               pr->datap;
 
        /* get the fieldinfo */
 
@@ -381,9 +300,11 @@ bool patcher_get_putstatic(u1 *sp)
                if (!initialize_class(fi->class))
                        return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* patch the field value's address */
 
-       *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
+       *((ptrint *) datap) = (ptrint) &(fi->value);
 
        return true;
 }
@@ -398,32 +319,32 @@ 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;
 
-       ra    = (u1 *)               *((ptrint *) (sp + 5 * 8));
-       uf    = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
+       ra    = (u1 *)               pr->mpc;
+       uf    = (unresolved_field *) pr->ref;
 
        /* get the fieldinfo */
 
        if (!(fi = resolve_field_eager(uf)))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* if we show disassembly, we have to skip the nop */
 
-       if (opt_shownops) {
-               /* patch the field's offset into the instruction */
+       if (opt_shownops)
+               ra = ra + 4;
+
+       /* patch the field's offset into the instruction */
 
-               *((u4 *) (ra + 4)) |= (s2) (fi->offset & 0x0000ffff);
-       }
-       else {
-               /* otherwise store the patched instruction on the stack */
+       *((u4 *) ra) |= (s2) (fi->offset & 0x0000ffff);
 
-               *((u4 *) (sp + 3 * 8)) |= (s2) (fi->offset & 0x0000ffff);
-       }
+       md_icacheflush(NULL, 0);
 
        return true;
 }
@@ -439,27 +360,27 @@ bool patcher_get_putfield(u1 *sp)
 
 ******************************************************************************/
 
-bool patcher_invokestatic_special(u1 *sp)
+bool patcher_invokestatic_special(patchref_t *pr)
 {
        unresolved_method *um;
-       s4                 disp;
-       u1                *pv;
+       u1                *datap;
        methodinfo        *m;
 
        /* get stuff from the stack */
 
-       um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
-       disp  =                       *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
+       um    = (unresolved_method *) pr->ref;
+       datap = (u1 *)                pr->datap;
 
        /* get the fieldinfo */
 
        if (!(m = resolve_method_eager(um)))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* patch stubroutine */
 
-       *((ptrint *) (pv + disp)) = (ptrint) m->stubroutine;
+       *((ptrint *) datap) = (ptrint) m->stubroutine;
 
        return true;
 }
@@ -476,7 +397,7 @@ bool patcher_invokestatic_special(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_invokevirtual(u1 *sp)
+bool patcher_invokevirtual(patchref_t *pr)
 {
        u1                *ra;
        unresolved_method *um;
@@ -484,14 +405,16 @@ bool patcher_invokevirtual(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
+       ra    = (u1 *)                pr->mpc;
+       um    = (unresolved_method *) pr->ref;
 
        /* get the fieldinfo */
 
        if (!(m = resolve_method_eager(um)))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* if we show disassembly, we have to skip the nop */
 
        if (opt_shownops)
@@ -502,6 +425,8 @@ bool patcher_invokevirtual(u1 *sp)
        *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, table[0]) +
                                                                 sizeof(methodptr) * m->vftblindex) & 0x0000ffff);
 
+       md_icacheflush(NULL, 0);
+
        return true;
 }
 
@@ -518,7 +443,7 @@ bool patcher_invokevirtual(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_invokeinterface(u1 *sp)
+bool patcher_invokeinterface(patchref_t *pr)
 {
        u1                *ra;
        unresolved_method *um;
@@ -526,14 +451,16 @@ bool patcher_invokeinterface(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
+       ra    = (u1 *)                pr->mpc;
+       um    = (unresolved_method *) pr->ref;
 
        /* get the fieldinfo */
 
        if (!(m = resolve_method_eager(um)))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* if we show disassembly, we have to skip the nop */
 
        if (opt_shownops)
@@ -549,6 +476,8 @@ bool patcher_invokeinterface(u1 *sp)
        *((s4 *) (ra + 4 + 4)) |=
                (s4) ((sizeof(methodptr) * (m - m->class->methods)) & 0x0000ffff);
 
+       md_icacheflush(NULL, 0);
+
        return true;
 }
 
@@ -566,7 +495,7 @@ bool patcher_invokeinterface(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_checkcast_interface(u1 *sp)
+bool patcher_checkcast_interface(patchref_t *pr)
 {
        u1                *ra;
        constant_classref *cr;
@@ -574,14 +503,16 @@ bool patcher_checkcast_interface(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
+       ra    = (u1 *)                pr->mpc;
+       cr    = (constant_classref *) pr->ref;
 
        /* get the fieldinfo */
 
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* if we show disassembly, we have to skip the nop */
 
        if (opt_shownops)
@@ -594,6 +525,8 @@ bool patcher_checkcast_interface(u1 *sp)
        *((s4 *) (ra + 5 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
                                                                         c->index * sizeof(methodptr*)) & 0x0000ffff);
 
+       md_icacheflush(NULL, 0);
+
        return true;
 }
 
@@ -611,7 +544,7 @@ bool patcher_checkcast_interface(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_instanceof_interface(u1 *sp)
+bool patcher_instanceof_interface(patchref_t *pr)
 {
        u1                *ra;
        constant_classref *cr;
@@ -619,14 +552,16 @@ bool patcher_instanceof_interface(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
+       ra    = (u1 *)                pr->mpc;
+       cr    = (constant_classref *) pr->ref;
 
        /* get the fieldinfo */
 
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
+       PATCH_BACK_ORIGINAL_MCODE;
+
        /* if we show disassembly, we have to skip the nop */
 
        if (opt_shownops)
@@ -639,6 +574,8 @@ bool patcher_instanceof_interface(u1 *sp)
        *((s4 *) (ra + 4 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
                                                                         c->index * sizeof(methodptr*)) & 0x0000ffff);
 
+       md_icacheflush(NULL, 0);
+
        return true;
 }
 
index c8d08cf6edf3877316d66a9fb06378b2b3c18db1..e97ca5df4a968b6266a75c98561c8e68f8913bea 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md.c 7653 2007-04-03 14:34:23Z twisti $
+   $Id: md.c 8185 2007-07-05 21:34:47Z michi $
 
 */
 
@@ -128,6 +128,11 @@ u1 *md_get_method_patch_address(u1 *ra, stackframeinfo *sfi, u1 *mptr)
 
                assert((mcode & 0x00800000) == 0x00800000);
 
+               /* return NULL if no mptr was specified (used for replacement) */
+
+               if (mptr == NULL)
+                       return NULL;
+
                /* we loaded from REG_METHODPTR */
 
                pa = mptr + offset;
index 429263b795f1a10ec20c75c72751d367d8c3cf1d..8fae6af26badd766b47d12a72c5be27615be8c8e 100644 (file)
@@ -231,76 +231,6 @@ int code_get_sync_slot_count(codeinfo *code)
 #endif /* defined(ENABLE_REPLACEMENT) */
 
 
-/* code_get_stack_frame_size ***************************************************
-
-   Return the number of stack slots that the stack frame of the given code
-   comprises.
-
-   IMPORTANT: The return value does *not* include the saved return address 
-              slot, although it is part of non-leaf stack frames on RISC
-                         architectures. The rationale behind this is that the saved
-                         return address is never moved or changed by replacement, and
-                         this way CISC and RISC architectures can be treated the same.
-                         (See also doc/stack_frames.txt.)
-   
-   IN:
-       code.............the codeinfo of the code in question
-                           (must be != NULL)
-
-   RETURN VALUE:
-       the number of stack slots
-  
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-int code_get_stack_frame_size(codeinfo *code)
-{
-#if 0
-       int count;
-       
-       assert(code);
-
-       /* slots allocated by register allocator plus saved registers */
-
-#ifdef HAS_4BYTE_STACKSLOT
-       count = code->memuse + code->savedintcount + 2*code->savedfltcount;
-#else
-       count = code->memuse + code->savedintcount + code->savedfltcount;
-#endif
-
-       /* add slots needed in synchronized methods */
-
-       count += code_get_sync_slot_count(code);
-
-       /* keep stack aligned */
-
-#if defined(__X86_64__)
-       /* the x86_64 codegen only aligns the stack in non-leaf methods */
-       if (!code->isleafmethod || opt_verbosecall)
-               count |= 1; /* even when return address is added */
-#endif
-
-       /* XXX align stack on alpha */
-#if defined(__MIPS__)
-       if (code->isleafmethod)
-               count = (count + 1) & ~1;
-       else
-               count |= 1; /* even when return address is added */
-#endif
-
-#if defined(__POWERPC__)
-       /* keep stack 16-byte aligned */
-       count = (count + 3) & ~3;
-#endif
-
-       return count;
-#endif
-
-       return code->stackframesize;
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
 /* code_codeinfo_free **********************************************************
 
    Free the memory used by a codeinfo.
index 30c2e5ca6e5d95f84f4550945678e570a6371aee..d26bfdf80be41a47e67c35b73cb2e14b5a74854e 100644 (file)
@@ -130,7 +130,6 @@ methodinfo *code_get_methodinfo_for_pv(u1 *pv);
 
 #if defined(ENABLE_REPLACEMENT)
 int code_get_sync_slot_count(codeinfo *code);
-int code_get_stack_frame_size(codeinfo *code);
 #endif /* defined(ENABLE_REPLACEMENT) */
 
 void code_free_code_of_method(methodinfo *m);
index 5e9288371f429c0717b13b881ae74c9357c6a94f..2b15fb8bd728035325af5cc3fd1307965d24ae9b 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: patcher.h 8160 2007-06-28 01:52:19Z michi $
+   $Id: patcher.h 8186 2007-07-05 23:48:16Z michi $
 
 */
 
@@ -41,7 +41,7 @@
 #include "vm/global.h"
 
 
-#if defined(__ARM__)
+#if defined(__ALPHA__) || defined(__ARM__)
 # error "you should no longer include this file"
 #else
 
index eea3da4227201c76f4422a5417aa39126dfaffed..a4f16ff81b05f1b4e86f7548443263fb2e8ddc78 100644 (file)
@@ -1135,7 +1135,7 @@ static void replace_read_executionstate(rplpoint *rp,
 
        /* calculate base stack pointer */
 
-       basesp = sp + code_get_stack_frame_size(code);
+       basesp = sp + code->stackframesize;
 
        /* create the source frame */
 
@@ -1354,7 +1354,7 @@ static void replace_write_executionstate(rplpoint *rp,
 
        sp = (stackslot_t *) es->sp;
 
-       basesp = sp + code_get_stack_frame_size(code);
+       basesp = sp + code->stackframesize;
 
        /* in some cases the top stack slot is passed in REG_ITMP1 */
 
@@ -3305,7 +3305,7 @@ void replace_executionstate_println(executionstate_t *es)
 
        if (es->code) {
                methoddesc *md = es->code->m->parseddesc;
-               slots = code_get_stack_frame_size(es->code);
+               slots = es->code->stackframesize;
                extraslots = 1 + md->memuse;
        }
        else