Compiler data structure changes.
authortwisti <none@none>
Mon, 8 Nov 2004 13:29:58 +0000 (13:29 +0000)
committertwisti <none@none>
Mon, 8 Nov 2004 13:29:58 +0000 (13:29 +0000)
jit/alpha/codegen.c
jit/alpha/codegen.h
src/vm/jit/alpha/codegen.c
src/vm/jit/alpha/codegen.h

index 9b12a802e8278e9ca7dc485dd1ed84293374997f..7a4d9810f749f72a11a41f0086ca94aa4b0056a4 100644 (file)
@@ -28,7 +28,7 @@
    Authors: Andreas Krall
             Reinhard Grafl
 
-   $Id: codegen.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: codegen.c 1468 2004-11-08 13:29:58Z twisti $
 
 */
 
 #include "native.h"
 #include "main.h"
 
-/* include independent code generation stuff */
-#include "jit/codegen.inc"
-#include "jit/reg.inc"
-
 
 /* *****************************************************************************
 
@@ -110,11 +106,16 @@ int nregdescfloat[] = {
 
 /* for use of reserved registers, see comment above */
 
+/* include independent code generation stuff -- include after register        */
+/* descriptions to avoid extern definitions                                   */
+
+#include "jit/codegen.inc"
+#include "jit/reg.inc"
+
 
 /* NullPointerException handlers and exception handling initialisation        */
 
 typedef struct sigctx_struct {
-
        long          sc_onstack;           /* sigstack state to restore          */
        long          sc_mask;              /* signal mask to restore             */
        long          sc_pc;                /* pc at time of signal               */
@@ -230,7 +231,7 @@ ieee_set_fp_control(ieee_get_fp_control()
 
 *******************************************************************************/
 
-void codegen(methodinfo *m)
+void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
 {
        s4 len, s1, s2, s3, d;
        s4 a;
@@ -241,12 +242,6 @@ void codegen(methodinfo *m)
        basicblock     *bptr;
        instruction    *iptr;
        exceptiontable *ex;
-       registerdata   *r;
-       codegendata    *cd;
-
-       /* keep code size smaller */
-       r = m->registerdata;
-       cd = m->codegendata;
 
        {
        s4 i, p, pa, t, l;
@@ -256,10 +251,10 @@ void codegen(methodinfo *m)
 
        /* space to save used callee saved registers */
 
-       savedregs_num += (r->savintregcnt - r->maxsavintreguse);
-       savedregs_num += (r->savfltregcnt - r->maxsavfltreguse);
+       savedregs_num += (rd->savintregcnt - rd->maxsavintreguse);
+       savedregs_num += (rd->savfltregcnt - rd->maxsavfltreguse);
 
-       parentargs_base = r->maxmemuse + savedregs_num;
+       parentargs_base = rd->maxmemuse + savedregs_num;
 
 #if defined(USE_THREADS)           /* space to save argument of monitor_enter */
 
@@ -270,8 +265,8 @@ void codegen(methodinfo *m)
 
        /* create method header */
 
-       (void) dseg_addaddress(m, m);                           /* MethodPointer  */
-       (void) dseg_adds4(m, parentargs_base * 8);                 /* FrameSize      */
+       (void) dseg_addaddress(cd, m);                          /* MethodPointer  */
+       (void) dseg_adds4(cd, parentargs_base * 8);             /* FrameSize      */
 
 #if defined(USE_THREADS)
 
@@ -282,28 +277,28 @@ void codegen(methodinfo *m)
        */
 
        if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               (void) dseg_adds4(m, (r->maxmemuse + 1) * 8);       /* IsSync         */
+               (void) dseg_adds4(cd, (rd->maxmemuse + 1) * 8);     /* IsSync         */
        else
 
 #endif
 
-       (void) dseg_adds4(m, 0);                                /* IsSync         */
+       (void) dseg_adds4(cd, 0);                               /* IsSync         */
                                               
-       (void) dseg_adds4(m, m->isleafmethod);                  /* IsLeaf         */
-       (void) dseg_adds4(m, r->savintregcnt - r->maxsavintreguse);/* IntSave     */
-       (void) dseg_adds4(m, r->savfltregcnt - r->maxsavfltreguse);/* FltSave     */
+       (void) dseg_adds4(cd, m->isleafmethod);                 /* IsLeaf         */
+       (void) dseg_adds4(cd, rd->savintregcnt - rd->maxsavintreguse);/* IntSave  */
+       (void) dseg_adds4(cd, rd->savfltregcnt - rd->maxsavfltreguse);/* FltSave  */
 
-       dseg_addlinenumbertablesize(m);
+       dseg_addlinenumbertablesize(cd);
 
-       (void) dseg_adds4(m, cd->exceptiontablelength);          /* ExTableSize    */
+       (void) dseg_adds4(cd, cd->exceptiontablelength);        /* ExTableSize    */
 
        /* create exception table */
 
        for (ex = cd->exceptiontable; ex != NULL; ex = ex->down) {
-               dseg_addtarget(m, ex->start);
-               dseg_addtarget(m, ex->end);
-               dseg_addtarget(m, ex->handler);
-               (void) dseg_addaddress(m, ex->catchtype);
+               dseg_addtarget(cd, ex->start);
+               dseg_addtarget(cd, ex->end);
+               dseg_addtarget(cd, ex->handler);
+               (void) dseg_addaddress(cd, ex->catchtype);
        }
        
        /* initialize mcode variables */
@@ -315,7 +310,7 @@ void codegen(methodinfo *m)
        /* create stack frame (if necessary) */
 
        if (parentargs_base) {
-               M_LDA (REG_SP, REG_SP, -parentargs_base * 8);
+               M_LDA(REG_SP, REG_SP, -parentargs_base * 8);
        }
 
        /* save return address and used callee saved registers */
@@ -324,11 +319,11 @@ void codegen(methodinfo *m)
        if (!m->isleafmethod) {
                p--; M_AST(REG_RA, REG_SP, p * 8);
        }
-       for (i = r->savintregcnt - 1; i >= r->maxsavintreguse; i--) {
-               p--; M_LST(r->savintregs[i], REG_SP, p * 8);
+       for (i = rd->savintregcnt - 1; i >= rd->maxsavintreguse; i--) {
+               p--; M_LST(rd->savintregs[i], REG_SP, p * 8);
        }
-       for (i = r->savfltregcnt - 1; i >= r->maxsavfltreguse; i--) {
-               p--; M_DST(r->savfltregs[i], REG_SP, p * 8);
+       for (i = rd->savfltregcnt - 1; i >= rd->maxsavfltreguse; i--) {
+               p--; M_DST(rd->savfltregs[i], REG_SP, p * 8);
        }
 
        /* save monitorenter argument */
@@ -336,12 +331,12 @@ void codegen(methodinfo *m)
 #if defined(USE_THREADS)
        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                if (m->flags & ACC_STATIC) {
-                       p = dseg_addaddress(m, m->class);
+                       p = dseg_addaddress(cd, m->class);
                        M_ALD(REG_ITMP1, REG_PV, p);
-                       M_AST(REG_ITMP1, REG_SP, r->maxmemuse * 8);
+                       M_AST(REG_ITMP1, REG_SP, rd->maxmemuse * 8);
 
                } else {
-                       M_AST(r->argintregs[0], REG_SP, r->maxmemuse * 8);
+                       M_AST(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
                }
        }                       
 #endif
@@ -357,7 +352,7 @@ void codegen(methodinfo *m)
 
                /* save integer argument registers */
                for (p = 0; /* p < m->paramcount && */ p < INT_ARG_CNT; p++) {
-                       M_LST(r->argintregs[p], REG_SP,  (2 + p) * 8);
+                       M_LST(rd->argintregs[p], REG_SP,  (2 + p) * 8);
                }
 
                /* save and copy float arguments into integer registers */
@@ -366,23 +361,23 @@ void codegen(methodinfo *m)
 
                        if (IS_FLT_DBL_TYPE(t)) {
                                if (IS_2_WORD_TYPE(t)) {
-                                       M_DST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
 
                                } else {
-                                       M_FST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_FST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                                }
 
-                               M_LLD(r->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                               M_LLD(rd->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                                
                        } else {
-                               M_DST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                               M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                        }
                }
 
-               p = dseg_addaddress(m, m);
+               p = dseg_addaddress(cd, m);
                M_ALD(REG_ITMP1, REG_PV, p);
                M_AST(REG_ITMP1, REG_SP, 0 * 8);
-               p = dseg_addaddress(m, (void *) builtin_trace_args);
+               p = dseg_addaddress(cd, (void *) builtin_trace_args);
                M_ALD(REG_PV, REG_PV, p);
                M_JSR(REG_RA, REG_PV);
                disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
@@ -390,7 +385,7 @@ void codegen(methodinfo *m)
                M_ALD(REG_RA, REG_SP, 1 * 8);
 
                for (p = 0; /* p < mparamcount && */ p < INT_ARG_CNT; p++) {
-                       M_LLD(r->argintregs[p], REG_SP,  (2 + p) * 8);
+                       M_LLD(rd->argintregs[p], REG_SP,  (2 + p) * 8);
                }
 
                for (p = 0; /* p < mparamcount && */ p < FLT_ARG_CNT; p++) {
@@ -398,14 +393,14 @@ void codegen(methodinfo *m)
 
                        if (IS_FLT_DBL_TYPE(t)) {
                                if (IS_2_WORD_TYPE(t)) {
-                                       M_DLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
 
                                } else {
-                                       M_FLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_FLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                                }
 
                        } else {
-                               M_DLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                               M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                        }
                }
 
@@ -416,7 +411,7 @@ void codegen(methodinfo *m)
 
        for (p = 0, l = 0; p < m->paramcount; p++) {
                t = m->paramtypes[p];
-               var = &(r->locals[l][t]);
+               var = &(rd->locals[l][t]);
                l++;
                if (IS_2_WORD_TYPE(t))    /* increment local counter for 2 word types */
                        l++;
@@ -425,9 +420,9 @@ void codegen(methodinfo *m)
                if (IS_INT_LNG_TYPE(t)) {                    /* integer args          */
                        if (p < INT_ARG_CNT) {                   /* register arguments    */
                                if (!(var->flags & INMEMORY)) {      /* reg arg -> register   */
-                                       M_INTMOVE(r->argintregs[p], var->regoff);
+                                       M_INTMOVE(rd->argintregs[p], var->regoff);
                                } else {                             /* reg arg -> spilled    */
-                                       M_LST(r->argintregs[p], REG_SP, 8 * var->regoff);
+                                       M_LST(rd->argintregs[p], REG_SP, 8 * var->regoff);
                                }
 
                        } else {                                 /* stack arguments       */
@@ -444,10 +439,10 @@ void codegen(methodinfo *m)
                } else {                                     /* floating args         */
                        if (p < FLT_ARG_CNT) {                   /* register arguments    */
                                if (!(var->flags & INMEMORY)) {      /* reg arg -> register   */
-                                       M_FLTMOVE(r->argfltregs[p], var->regoff);
+                                       M_FLTMOVE(rd->argfltregs[p], var->regoff);
 
                                } else {                                         /* reg arg -> spilled    */
-                                       M_DST(r->argfltregs[p], REG_SP, 8 * var->regoff);
+                                       M_DST(rd->argfltregs[p], REG_SP, 8 * var->regoff);
                                }
 
                        } else {                                 /* stack arguments       */
@@ -470,9 +465,9 @@ void codegen(methodinfo *m)
                s4 disp;
                s8 func_enter = (m->flags & ACC_STATIC) ?
                        (s8) builtin_staticmonitorenter : (s8) builtin_monitorenter;
-               p = dseg_addaddress(m, (void*) func_enter);
+               p = dseg_addaddress(cd, (void*) func_enter);
                M_ALD(REG_PV, REG_PV, p);
-               M_ALD(r->argintregs[0], REG_SP, r->maxmemuse * 8);
+               M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
                M_JSR(REG_RA, REG_PV);
                disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
                M_LDA(REG_PV, REG_RA, disp);
@@ -507,31 +502,31 @@ void codegen(methodinfo *m)
                while (src != NULL) {
                        len--;
                        if ((len == 0) && (bptr->type != BBTYPE_STD)) {
-                               d = reg_of_var(m, src, REG_ITMP1);
+                               d = reg_of_var(rd, src, REG_ITMP1);
                                M_INTMOVE(REG_ITMP1, d);
                                store_reg_to_var_int(src, d);
                                }
                        else {
-                               d = reg_of_var(m, src, REG_IFTMP);
+                               d = reg_of_var(rd, src, REG_IFTMP);
                                if ((src->varkind != STACKVAR)) {
                                        s2 = src->type;
                                        if (IS_FLT_DBL_TYPE(s2)) {
-                                               if (!(r->interfaces[len][s2].flags & INMEMORY)) {
-                                                       s1 = r->interfaces[len][s2].regoff;
+                                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+                                                       s1 = rd->interfaces[len][s2].regoff;
                                                        M_FLTMOVE(s1,d);
                                                        }
                                                else {
-                                                       M_DLD(d, REG_SP, 8 * r->interfaces[len][s2].regoff);
+                                                       M_DLD(d, REG_SP, 8 * rd->interfaces[len][s2].regoff);
                                                        }
                                                store_reg_to_var_flt(src, d);
                                                }
                                        else {
-                                               if (!(r->interfaces[len][s2].flags & INMEMORY)) {
-                                                       s1 = r->interfaces[len][s2].regoff;
+                                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+                                                       s1 = rd->interfaces[len][s2].regoff;
                                                        M_INTMOVE(s1,d);
                                                        }
                                                else {
-                                                       M_LLD(d, REG_SP, 8 * r->interfaces[len][s2].regoff);
+                                                       M_LLD(d, REG_SP, 8 * rd->interfaces[len][s2].regoff);
                                                        }
                                                store_reg_to_var_int(src, d);
                                                }
@@ -558,7 +553,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_BEQZ(s1, 0);
-                       codegen_addxnullrefs(m, mcodeptr);
+                       codegen_addxnullrefs(cd, mcodeptr);
                        break;
 
                /* constant operations ************************************************/
@@ -566,7 +561,7 @@ void codegen(methodinfo *m)
                case ICMD_ICONST:     /* ...  ==> ..., constant                       */
                                      /* op1 = 0, val.i = constant                    */
 
-                       d = reg_of_var(m, iptr->dst, REG_ITMP1);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP1);
                        ICONST(d, iptr->val.i);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -574,7 +569,7 @@ void codegen(methodinfo *m)
                case ICMD_LCONST:     /* ...  ==> ..., constant                       */
                                      /* op1 = 0, val.l = constant                    */
 
-                       d = reg_of_var(m, iptr->dst, REG_ITMP1);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP1);
                        LCONST(d, iptr->val.l);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -582,8 +577,8 @@ void codegen(methodinfo *m)
                case ICMD_FCONST:     /* ...  ==> ..., constant                       */
                                      /* op1 = 0, val.f = constant                    */
 
-                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
-                       a = dseg_addfloat(m, iptr->val.f);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+                       a = dseg_addfloat(cd, iptr->val.f);
                        M_FLD(d, REG_PV, a);
                        store_reg_to_var_flt(iptr->dst, d);
                        break;
@@ -591,8 +586,8 @@ void codegen(methodinfo *m)
                case ICMD_DCONST:     /* ...  ==> ..., constant                       */
                                      /* op1 = 0, val.d = constant                    */
 
-                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
-                       a = dseg_adddouble(m, iptr->val.d);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+                       a = dseg_adddouble(cd, iptr->val.d);
                        M_DLD(d, REG_PV, a);
                        store_reg_to_var_flt(iptr->dst, d);
                        break;
@@ -600,9 +595,9 @@ void codegen(methodinfo *m)
                case ICMD_ACONST:     /* ...  ==> ..., constant                       */
                                      /* op1 = 0, val.a = constant                    */
 
-                       d = reg_of_var(m, iptr->dst, REG_ITMP1);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP1);
                        if (iptr->val.a) {
-                               a = dseg_addaddress(m, iptr->val.a);
+                               a = dseg_addaddress(cd, iptr->val.a);
                                M_ALD(d, REG_PV, a);
                        } else {
                                M_INTMOVE(REG_ZERO, d);
@@ -617,11 +612,11 @@ void codegen(methodinfo *m)
                case ICMD_LLOAD:      /* op1 = local variable                         */
                case ICMD_ALOAD:
 
-                       d = reg_of_var(m, iptr->dst, REG_ITMP1);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP1);
                        if ((iptr->dst->varkind == LOCALVAR) &&
                            (iptr->dst->varnum == iptr->op1))
                                break;
-                       var = &(r->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
+                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
                        if (var->flags & INMEMORY)
                                M_LLD(d, REG_SP, 8 * var->regoff);
                        else
@@ -632,11 +627,11 @@ void codegen(methodinfo *m)
                case ICMD_FLOAD:      /* ...  ==> ..., content of local variable      */
                case ICMD_DLOAD:      /* op1 = local variable                         */
 
-                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
                        if ((iptr->dst->varkind == LOCALVAR) &&
                            (iptr->dst->varnum == iptr->op1))
                                break;
-                       var = &(r->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
+                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
                        if (var->flags & INMEMORY)
                                M_DLD(d, REG_SP, 8 * var->regoff);
                        else
@@ -652,7 +647,7 @@ void codegen(methodinfo *m)
                        if ((src->varkind == LOCALVAR) &&
                            (src->varnum == iptr->op1))
                                break;
-                       var = &(r->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
+                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
                        if (var->flags & INMEMORY) {
                                var_to_reg_int(s1, src, REG_ITMP1);
                                M_LST(s1, REG_SP, 8 * var->regoff);
@@ -669,7 +664,7 @@ void codegen(methodinfo *m)
                        if ((src->varkind == LOCALVAR) &&
                            (src->varnum == iptr->op1))
                                break;
-                       var = &(r->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
+                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
                        if (var->flags & INMEMORY) {
                                var_to_reg_flt(s1, src, REG_FTMP1);
                                M_DST(s1, REG_SP, 8 * var->regoff);
@@ -745,7 +740,7 @@ void codegen(methodinfo *m)
                case ICMD_INEG:       /* ..., value  ==> ..., - value                 */
 
                        var_to_reg_int(s1, src, REG_ITMP1); 
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_ISUB(REG_ZERO, s1, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -753,7 +748,7 @@ void codegen(methodinfo *m)
                case ICMD_LNEG:       /* ..., value  ==> ..., - value                 */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_LSUB(REG_ZERO, s1, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -761,7 +756,7 @@ void codegen(methodinfo *m)
                case ICMD_I2L:        /* ..., value  ==> ..., value                   */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_INTMOVE(s1, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -769,7 +764,7 @@ void codegen(methodinfo *m)
                case ICMD_L2I:        /* ..., value  ==> ..., value                   */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_IADD(s1, REG_ZERO, d );
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -777,7 +772,7 @@ void codegen(methodinfo *m)
                case ICMD_INT2BYTE:   /* ..., value  ==> ..., value                   */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (has_ext_instr_set) {
                                M_BSEXT(s1, d);
                                }
@@ -791,7 +786,7 @@ void codegen(methodinfo *m)
                case ICMD_INT2CHAR:   /* ..., value  ==> ..., value                   */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
             M_CZEXT(s1, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -799,7 +794,7 @@ void codegen(methodinfo *m)
                case ICMD_INT2SHORT:  /* ..., value  ==> ..., value                   */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (has_ext_instr_set) {
                                M_SSEXT(s1, d);
                                }
@@ -815,7 +810,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_IADD(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -824,7 +819,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_IADD_IMM(s1, iptr->val.i, d);
                                }
@@ -839,7 +834,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_LADD(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -848,7 +843,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_LADD_IMM(s1, iptr->val.l, d);
                                }
@@ -863,7 +858,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_ISUB(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -872,7 +867,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_ISUB_IMM(s1, iptr->val.i, d);
                                }
@@ -887,7 +882,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_LSUB(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -896,7 +891,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_LSUB_IMM(s1, iptr->val.l, d);
                                }
@@ -911,7 +906,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_IMUL(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -920,7 +915,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_IMUL_IMM(s1, iptr->val.i, d);
                                }
@@ -935,7 +930,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_LMUL (s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -944,7 +939,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_LMUL_IMM(s1, iptr->val.l, d);
                                }
@@ -959,7 +954,7 @@ void codegen(methodinfo *m)
                case ICMD_LDIVPOW2:   /* val.i = constant                             */
                                      
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->val.i <= 15) {
                                M_LDA(REG_ITMP2, s1, (1 << iptr->val.i) -1);
                                M_CMOVGE(s1, s1, REG_ITMP2);
@@ -977,7 +972,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_AND_IMM(s2, 0x1f, REG_ITMP3);
                        M_SLL(s1, REG_ITMP3, d);
                        M_IADD(d, REG_ZERO, d);
@@ -988,7 +983,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SLL_IMM(s1, iptr->val.i & 0x1f, d);
                        M_IADD(d, REG_ZERO, d);
                        store_reg_to_var_int(iptr->dst, d);
@@ -998,7 +993,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_AND_IMM(s2, 0x1f, REG_ITMP3);
                        M_SRA(s1, REG_ITMP3, d);
                        store_reg_to_var_int(iptr->dst, d);
@@ -1008,7 +1003,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SRA_IMM(s1, iptr->val.i & 0x1f, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1017,7 +1012,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_AND_IMM(s2, 0x1f, REG_ITMP2);
             M_IZEXT(s1, d);
                        M_SRL(d, REG_ITMP2, d);
@@ -1029,7 +1024,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
             M_IZEXT(s1, d);
                        M_SRL_IMM(d, iptr->val.i & 0x1f, d);
                        M_IADD(d, REG_ZERO, d);
@@ -1040,7 +1035,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SLL(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1049,7 +1044,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SLL_IMM(s1, iptr->val.i & 0x3f, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1058,7 +1053,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SRA(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1067,7 +1062,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SRA_IMM(s1, iptr->val.i & 0x3f, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1076,7 +1071,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SRL(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1085,7 +1080,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SRL_IMM(s1, iptr->val.i & 0x3f, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1095,7 +1090,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_AND(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1104,7 +1099,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_AND_IMM(s1, iptr->val.i, d);
                                }
@@ -1125,7 +1120,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (s1 == d) {
                                M_MOV(s1, REG_ITMP1);
                                s1 = REG_ITMP1;
@@ -1163,7 +1158,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_AND_IMM(s1, iptr->val.l, d);
                                }
@@ -1196,7 +1191,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (s1 == d) {
                                M_MOV(s1, REG_ITMP1);
                                s1 = REG_ITMP1;
@@ -1259,7 +1254,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_OR( s1,s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1268,7 +1263,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_OR_IMM(s1, iptr->val.i, d);
                                }
@@ -1283,7 +1278,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_OR_IMM(s1, iptr->val.l, d);
                                }
@@ -1299,7 +1294,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_XOR(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1308,7 +1303,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_XOR_IMM(s1, iptr->val.i, d);
                                }
@@ -1323,7 +1318,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_XOR_IMM(s1, iptr->val.l, d);
                                }
@@ -1339,7 +1334,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_CMPLT(s1, s2, REG_ITMP3);
                        M_CMPLT(s2, s1, REG_ITMP1);
                        M_LSUB (REG_ITMP1, REG_ITMP3, d);
@@ -1350,7 +1345,7 @@ void codegen(methodinfo *m)
                case ICMD_IINC:       /* ..., value  ==> ..., value + constant        */
                                      /* op1 = variable, val.i = constant             */
 
-                       var = &(r->locals[iptr->op1][TYPE_INT]);
+                       var = &(rd->locals[iptr->op1][TYPE_INT]);
                        if (var->flags & INMEMORY) {
                                s1 = REG_ITMP1;
                                M_LLD(s1, REG_SP, 8 * var->regoff);
@@ -1377,7 +1372,7 @@ void codegen(methodinfo *m)
                case ICMD_FNEG:       /* ..., value  ==> ..., - value                 */
 
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        M_FMOVN(s1, d);
                        store_reg_to_var_flt(iptr->dst, d);
                        break;
@@ -1385,7 +1380,7 @@ void codegen(methodinfo *m)
                case ICMD_DNEG:       /* ..., value  ==> ..., - value                 */
 
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        M_FMOVN(s1, d);
                        store_reg_to_var_flt(iptr->dst, d);
                        break;
@@ -1394,7 +1389,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_FADD(s1, s2, d);
                                }
@@ -1416,7 +1411,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_DADD(s1, s2, d);
                                }
@@ -1438,7 +1433,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_FSUB(s1, s2, d);
                                }
@@ -1460,7 +1455,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_DSUB(s1, s2, d);
                                }
@@ -1482,7 +1477,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_FMUL(s1, s2, d);
                                }
@@ -1504,7 +1499,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_DMUL(s1, s2, d);
                                }
@@ -1526,7 +1521,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_FDIV(s1, s2, d);
                                }
@@ -1548,7 +1543,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_DDIV(s1, s2, d);
                                }
@@ -1569,8 +1564,8 @@ void codegen(methodinfo *m)
                case ICMD_I2F:       /* ..., value  ==> ..., (float) value            */
                case ICMD_L2F:
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
-                       a = dseg_adddouble(m, 0.0);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
+                       a = dseg_adddouble(cd, 0.0);
                        M_LST (s1, REG_PV, a);
                        M_DLD (d, REG_PV, a);
                        M_CVTLF(d, d);
@@ -1580,8 +1575,8 @@ void codegen(methodinfo *m)
                case ICMD_I2D:       /* ..., value  ==> ..., (double) value           */
                case ICMD_L2D:
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
-                       a = dseg_adddouble(m, 0.0);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
+                       a = dseg_adddouble(cd, 0.0);
                        M_LST (s1, REG_PV, a);
                        M_DLD (d, REG_PV, a);
                        M_CVTLD(d, d);
@@ -1591,8 +1586,8 @@ void codegen(methodinfo *m)
                case ICMD_F2I:       /* ..., value  ==> ..., (int) value              */
                case ICMD_D2I:
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
-                       a = dseg_adddouble(m, 0.0);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
+                       a = dseg_adddouble(cd, 0.0);
                        M_CVTDL_C(s1, REG_FTMP2);
                        M_CVTLI(REG_FTMP2, REG_FTMP3);
                        M_DST (REG_FTMP3, REG_PV, a);
@@ -1603,8 +1598,8 @@ void codegen(methodinfo *m)
                case ICMD_F2L:       /* ..., value  ==> ..., (long) value             */
                case ICMD_D2L:
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
-                       a = dseg_adddouble(m, 0.0);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
+                       a = dseg_adddouble(cd, 0.0);
                        M_CVTDL_C(s1, REG_FTMP2);
                        M_DST (REG_FTMP2, REG_PV, a);
                        M_LLD (d, REG_PV, a);
@@ -1614,7 +1609,7 @@ void codegen(methodinfo *m)
                case ICMD_F2D:       /* ..., value  ==> ..., (double) value           */
 
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        M_CVTFDS(s1, d);
                        M_TRAPB;
                        store_reg_to_var_flt(iptr->dst, d);
@@ -1623,7 +1618,7 @@ void codegen(methodinfo *m)
                case ICMD_D2F:       /* ..., value  ==> ..., (float) value            */
 
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_CVTDF(s1, d);
                                }
@@ -1638,7 +1633,7 @@ void codegen(methodinfo *m)
                case ICMD_DCMPL:
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (opt_noieee) {
                                M_LSUB_IMM(REG_ZERO, 1, d);
                                M_FCMPEQ(s1, s2, REG_FTMP3);
@@ -1666,7 +1661,7 @@ void codegen(methodinfo *m)
                case ICMD_DCMPG:
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (opt_noieee) {
                                M_LADD_IMM(REG_ZERO, 1, d);
                                M_FCMPEQ(s1, s2, REG_FTMP3);
@@ -1696,7 +1691,7 @@ void codegen(methodinfo *m)
                case ICMD_ARRAYLENGTH: /* ..., arrayref  ==> ..., length              */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        gen_nullptr_check(s1);
                        M_ILD(d, s1, OFFSET(java_arrayheader, size));
                        store_reg_to_var_int(iptr->dst, d);
@@ -1706,7 +1701,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1720,7 +1715,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1734,7 +1729,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1749,7 +1744,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1763,7 +1758,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1777,7 +1772,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1801,7 +1796,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1827,7 +1822,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -2107,9 +2102,9 @@ void codegen(methodinfo *m)
                        /* if class isn't yet initialized, do it */
                        if (!((fieldinfo *) iptr->val.a)->class->initialized) {
                                /* call helper function which patches this code */
-                               a = dseg_addaddress(m, ((fieldinfo *) iptr->val.a)->class);
+                               a = dseg_addaddress(cd, ((fieldinfo *) iptr->val.a)->class);
                                M_ALD(REG_ITMP1, REG_PV, a);
-                               a = dseg_addaddress(m, asm_check_clinit);
+                               a = dseg_addaddress(cd, asm_check_clinit);
                                M_ALD(REG_PV, REG_PV, a);
                                M_JSR(REG_RA, REG_PV);
 
@@ -2127,7 +2122,7 @@ void codegen(methodinfo *m)
                                }
                        }
                        
-                       a = dseg_addaddress(m, &(((fieldinfo *)(iptr->val.a))->value));
+                       a = dseg_addaddress(cd, &(((fieldinfo *)(iptr->val.a))->value));
                        M_ALD(REG_ITMP1, REG_PV, a);
                        switch (iptr->op1) {
                                case TYPE_INT:
@@ -2160,9 +2155,9 @@ void codegen(methodinfo *m)
                        /* if class isn't yet initialized, do it */
                        if (!((fieldinfo *) iptr->val.a)->class->initialized) {
                                /* call helper function which patches this code */
-                               a = dseg_addaddress(m, ((fieldinfo *) iptr->val.a)->class);
+                               a = dseg_addaddress(cd, ((fieldinfo *) iptr->val.a)->class);
                                M_ALD(REG_ITMP1, REG_PV, a);
-                               a = dseg_addaddress(m, asm_check_clinit);
+                               a = dseg_addaddress(cd, asm_check_clinit);
                                M_ALD(REG_PV, REG_PV, a);
                                M_JSR(REG_RA, REG_PV);
 
@@ -2180,31 +2175,31 @@ void codegen(methodinfo *m)
                                }
                        }
                        
-                       a = dseg_addaddress(m, &(((fieldinfo *) iptr->val.a)->value));
+                       a = dseg_addaddress(cd, &(((fieldinfo *) iptr->val.a)->value));
                        M_ALD(REG_ITMP1, REG_PV, a);
                        switch (iptr->op1) {
                                case TYPE_INT:
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        M_ILD(d, REG_ITMP1, 0);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_LNG:
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        M_LLD(d, REG_ITMP1, 0);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_ADR:
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        M_ALD(d, REG_ITMP1, 0);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_FLT:
-                                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
+                                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
                                        M_FLD(d, REG_ITMP1, 0);
                                        store_reg_to_var_flt(iptr->dst, d);
                                        break;
                                case TYPE_DBL:                          
-                                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
+                                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
                                        M_DLD(d, REG_ITMP1, 0);
                                        store_reg_to_var_flt(iptr->dst, d);
                                        break;
@@ -2259,35 +2254,35 @@ void codegen(methodinfo *m)
                        switch (iptr->op1) {
                                case TYPE_INT:
                                        var_to_reg_int(s1, src, REG_ITMP1);
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        gen_nullptr_check(s1);
                                        M_ILD(d, s1, a);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_LNG:
                                        var_to_reg_int(s1, src, REG_ITMP1);
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        gen_nullptr_check(s1);
                                        M_LLD(d, s1, a);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_ADR:
                                        var_to_reg_int(s1, src, REG_ITMP1);
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        gen_nullptr_check(s1);
                                        M_ALD(d, s1, a);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_FLT:
                                        var_to_reg_int(s1, src, REG_ITMP1);
-                                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
+                                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
                                        gen_nullptr_check(s1);
                                        M_FLD(d, s1, a);
                                        store_reg_to_var_flt(iptr->dst, d);
                                        break;
                                case TYPE_DBL:                          
                                        var_to_reg_int(s1, src, REG_ITMP1);
-                                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
+                                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
                                        gen_nullptr_check(s1);
                                        M_DLD(d, s1, a);
                                        store_reg_to_var_flt(iptr->dst, d);
@@ -2305,7 +2300,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_INTMOVE(s1, REG_ITMP1_XPTR);
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP2, REG_PV, a);
                        M_JMP(REG_ITMP2_XPC, REG_ITMP2);
                        M_NOP;              /* nop ensures that XPC is less than the end */
@@ -2316,7 +2311,7 @@ void codegen(methodinfo *m)
                case ICMD_GOTO:         /* ... ==> ...                                */
                                        /* op1 = target JavaVM pc                     */
                        M_BR(0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        ALIGNCODENOP;
                        break;
 
@@ -2324,13 +2319,13 @@ void codegen(methodinfo *m)
                                        /* op1 = target JavaVM pc                     */
 
                        M_BSR(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
                        
                case ICMD_RET:          /* ... ==> ...                                */
                                        /* op1 = local variable                       */
 
-                       var = &(r->locals[iptr->op1][TYPE_ADR]);
+                       var = &(rd->locals[iptr->op1][TYPE_ADR]);
                        if (var->flags & INMEMORY) {
                                M_ALD(REG_ITMP1, REG_SP, 8 * var->regoff);
                                M_RET(REG_ZERO, REG_ITMP1);
@@ -2345,7 +2340,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_BEQZ(s1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFNONNULL:    /* ..., value ==> ...                         */
@@ -2353,7 +2348,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_BNEZ(s1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFEQ:         /* ..., value ==> ...                         */
@@ -2373,7 +2368,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFLT:         /* ..., value ==> ...                         */
@@ -2393,7 +2388,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFLE:         /* ..., value ==> ...                         */
@@ -2413,7 +2408,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFNE:         /* ..., value ==> ...                         */
@@ -2433,7 +2428,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFGT:         /* ..., value ==> ...                         */
@@ -2453,7 +2448,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFGE:         /* ..., value ==> ...                         */
@@ -2473,7 +2468,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LEQ:       /* ..., value ==> ...                         */
@@ -2493,7 +2488,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LLT:       /* ..., value ==> ...                         */
@@ -2513,7 +2508,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LLE:       /* ..., value ==> ...                         */
@@ -2533,7 +2528,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LNE:       /* ..., value ==> ...                         */
@@ -2553,7 +2548,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LGT:       /* ..., value ==> ...                         */
@@ -2573,7 +2568,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LGE:       /* ..., value ==> ...                         */
@@ -2593,7 +2588,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPEQ:    /* ..., value, value ==> ...                  */
@@ -2604,7 +2599,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPEQ(s1, s2, REG_ITMP1);
                        M_BNEZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPNE:    /* ..., value, value ==> ...                  */
@@ -2615,7 +2610,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPEQ(s1, s2, REG_ITMP1);
                        M_BEQZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPLT:    /* ..., value, value ==> ...                  */
@@ -2625,7 +2620,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPLT(s1, s2, REG_ITMP1);
                        M_BNEZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPGT:    /* ..., value, value ==> ...                  */
@@ -2635,7 +2630,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPLE(s1, s2, REG_ITMP1);
                        M_BEQZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPLE:    /* ..., value, value ==> ...                  */
@@ -2645,7 +2640,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPLE(s1, s2, REG_ITMP1);
                        M_BNEZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPGE:    /* ..., value, value ==> ...                  */
@@ -2655,7 +2650,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPLT(s1, s2, REG_ITMP1);
                        M_BEQZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                /* (value xx 0) ? IFxx_ICONST : ELSE_ICONST                           */
@@ -2667,7 +2662,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if (iptr[1].opc == ICMD_ELSE_ICONST) {
                                if ((s3 == 1) && (iptr[1].val.i == 0)) {
@@ -2701,7 +2696,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if (iptr[1].opc == ICMD_ELSE_ICONST) {
                                if ((s3 == 0) && (iptr[1].val.i == 1)) {
@@ -2735,7 +2730,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
                                if ((s3 == 1) && (iptr[1].val.i == 0)) {
@@ -2768,7 +2763,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
                                if ((s3 == 1) && (iptr[1].val.i == 0)) {
@@ -2801,7 +2796,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
                                if ((s3 == 1) && (iptr[1].val.i == 0)) {
@@ -2834,7 +2829,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
                                if ((s3 == 1) && (iptr[1].val.i == 0)) {
@@ -2874,14 +2869,14 @@ void codegen(methodinfo *m)
 #if defined(USE_THREADS)
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                                s4 disp;
-                               a = dseg_addaddress(m, (void *) (builtin_monitorexit));
+                               a = dseg_addaddress(cd, (void *) (builtin_monitorexit));
                                M_ALD(REG_PV, REG_PV, a);
-                               M_ALD(r->argintregs[0], REG_SP, r->maxmemuse * 8);
-                               M_LST(REG_RESULT, REG_SP, r->maxmemuse * 8);
+                               M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
+                               M_LST(REG_RESULT, REG_SP, rd->maxmemuse * 8);
                                M_JSR(REG_RA, REG_PV);
                                disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
                                M_LDA(REG_PV, REG_RA, disp);
-                               M_LLD(REG_RESULT, REG_SP, r->maxmemuse * 8);
+                               M_LLD(REG_RESULT, REG_SP, rd->maxmemuse * 8);
                        }
 #endif
 
@@ -2896,14 +2891,14 @@ void codegen(methodinfo *m)
 #if defined(USE_THREADS)
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                                s4 disp;
-                               a = dseg_addaddress(m, (void *) (builtin_monitorexit));
+                               a = dseg_addaddress(cd, (void *) (builtin_monitorexit));
                                M_ALD(REG_PV, REG_PV, a);
-                               M_ALD(r->argintregs[0], REG_SP, r->maxmemuse * 8);
-                               M_DST(REG_FRESULT, REG_SP, r->maxmemuse * 8);
+                               M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
+                               M_DST(REG_FRESULT, REG_SP, rd->maxmemuse * 8);
                                M_JSR(REG_RA, REG_PV);
                                disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
                                M_LDA(REG_PV, REG_RA, disp);
-                               M_DLD(REG_FRESULT, REG_SP, r->maxmemuse * 8);
+                               M_DLD(REG_FRESULT, REG_SP, rd->maxmemuse * 8);
                        }
 #endif
 
@@ -2914,9 +2909,9 @@ void codegen(methodinfo *m)
 #if defined(USE_THREADS)
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                                s4 disp;
-                               a = dseg_addaddress(m, (void *) (builtin_monitorexit));
+                               a = dseg_addaddress(cd, (void *) (builtin_monitorexit));
                                M_ALD(REG_PV, REG_PV, a);
-                               M_ALD(r->argintregs[0], REG_SP, r->maxmemuse * 8);
+                               M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
                                M_JSR(REG_RA, REG_PV);
                                disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
                                M_LDA(REG_PV, REG_RA, disp);
@@ -2937,11 +2932,11 @@ nowperformreturn:
 
                        /* restore saved registers                                        */
 
-                       for (i = r->savintregcnt - 1; i >= r->maxsavintreguse; i--) {
-                               p--; M_LLD(r->savintregs[i], REG_SP, p * 8);
+                       for (i = rd->savintregcnt - 1; i >= rd->maxsavintreguse; i--) {
+                               p--; M_LLD(rd->savintregs[i], REG_SP, p * 8);
                        }
-                       for (i = r->savfltregcnt - 1; i >= r->maxsavfltreguse; i--) {
-                               p--; M_DLD(r->savfltregs[i], REG_SP, p * 8);
+                       for (i = rd->savfltregcnt - 1; i >= rd->maxsavfltreguse; i--) {
+                               p--; M_DLD(rd->savfltregs[i], REG_SP, p * 8);
                        }
 
                        /* deallocate stack                                               */
@@ -2957,12 +2952,12 @@ nowperformreturn:
                                M_AST(REG_RA, REG_SP, 0 * 8);
                                M_LST(REG_RESULT, REG_SP, 1 * 8);
                                M_DST(REG_FRESULT, REG_SP, 2 * 8);
-                               a = dseg_addaddress(m, m);
-                               M_ALD(r->argintregs[0], REG_PV, a);
-                               M_MOV(REG_RESULT, r->argintregs[1]);
-                               M_FLTMOVE(REG_FRESULT, r->argfltregs[2]);
-                               M_FLTMOVE(REG_FRESULT, r->argfltregs[3]);
-                               a = dseg_addaddress(m, (void *) builtin_displaymethodstop);
+                               a = dseg_addaddress(cd, m);
+                               M_ALD(rd->argintregs[0], REG_PV, a);
+                               M_MOV(REG_RESULT, rd->argintregs[1]);
+                               M_FLTMOVE(REG_FRESULT, rd->argfltregs[2]);
+                               M_FLTMOVE(REG_FRESULT, rd->argfltregs[3]);
+                               a = dseg_addaddress(cd, (void *) builtin_displaymethodstop);
                                M_ALD(REG_PV, REG_PV, a);
                                M_JSR(REG_RA, REG_PV);
                                s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
@@ -3019,8 +3014,8 @@ nowperformreturn:
                        M_BEQZ(REG_ITMP2, 0);
 
 
-                       /* codegen_addreference(m, BlockPtrOfPC(s4ptr[0]), mcodeptr); */
-                       codegen_addreference(m, (basicblock *) tptr[0], mcodeptr);
+                       /* codegen_addreference(cd, BlockPtrOfPC(s4ptr[0]), mcodeptr); */
+                       codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr);
 
                        /* build jump table top down and use address of lowest entry */
 
@@ -3028,8 +3023,8 @@ nowperformreturn:
                        tptr += i;
 
                        while (--i >= 0) {
-                               /* dseg_addtarget(m, BlockPtrOfPC(*--s4ptr)); */
-                               dseg_addtarget(m, (basicblock *) tptr[0]); 
+                               /* dseg_addtarget(cd, BlockPtrOfPC(*--s4ptr)); */
+                               dseg_addtarget(cd, (basicblock *) tptr[0]); 
                                --tptr;
                                }
                        }
@@ -3069,21 +3064,21 @@ nowperformreturn:
                                                M_LDA(REG_ITMP2, REG_ZERO, val);
                                                } 
                                        else {
-                                               a = dseg_adds4(m, val);
+                                               a = dseg_adds4(cd, val);
                                                M_ILD(REG_ITMP2, REG_PV, a);
                                                }
                                        M_CMPEQ(s1, REG_ITMP2, REG_ITMP2);
                                        }
                                M_BNEZ(REG_ITMP2, 0);
-                               /* codegen_addreference(m, BlockPtrOfPC(s4ptr[1]), mcodeptr); */
-                               codegen_addreference(m, (basicblock *) tptr[0], mcodeptr); 
+                               /* codegen_addreference(cd, BlockPtrOfPC(s4ptr[1]), mcodeptr); */
+                               codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr); 
                                }
 
                        M_BR(0);
-                       /* codegen_addreference(m, BlockPtrOfPC(l), mcodeptr); */
+                       /* codegen_addreference(cd, BlockPtrOfPC(l), mcodeptr); */
                        
                        tptr = (void **) iptr->target;
-                       codegen_addreference(m, (basicblock *) tptr[0], mcodeptr);
+                       codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr);
 
                        ALIGNCODENOP;
                        break;
@@ -3131,7 +3126,7 @@ gen_method: {
                                        continue;
                                if (IS_INT_LNG_TYPE(src->type)) {
                                        if (s3 < INT_ARG_CNT) {
-                                               s1 = r->argintregs[s3];
+                                               s1 = rd->argintregs[s3];
                                                var_to_reg_int(d, src, s1);
                                                M_INTMOVE(d, s1);
 
@@ -3142,7 +3137,7 @@ gen_method: {
 
                                } else {
                                        if (s3 < FLT_ARG_CNT) {
-                                               s1 = r->argfltregs[s3];
+                                               s1 = rd->argfltregs[s3];
                                                var_to_reg_flt(d, src, s1);
                                                M_FLTMOVE(d, s1);
 
@@ -3158,7 +3153,7 @@ gen_method: {
                        case ICMD_BUILTIN3:
                        case ICMD_BUILTIN2:
                        case ICMD_BUILTIN1:
-                               a = dseg_addaddress(m, (void *) lm);
+                               a = dseg_addaddress(cd, (void *) lm);
                                d = iptr->op1;
 
                                M_ALD(REG_PV, REG_PV, a);     /* Pointer to built-in-function */
@@ -3166,7 +3161,7 @@ gen_method: {
 
                        case ICMD_INVOKESTATIC:
                        case ICMD_INVOKESPECIAL:
-                               a = dseg_addaddress(m, lm->stubroutine);
+                               a = dseg_addaddress(cd, lm->stubroutine);
                                d = lm->returntype;
 
                                M_ALD(REG_PV, REG_PV, a);            /* method pointer in r27 */
@@ -3175,8 +3170,8 @@ gen_method: {
                        case ICMD_INVOKEVIRTUAL:
                                d = lm->returntype;
 
-                               gen_nullptr_check(r->argintregs[0]);
-                               M_ALD(REG_METHODPTR, r->argintregs[0],
+                               gen_nullptr_check(rd->argintregs[0]);
+                               M_ALD(REG_METHODPTR, rd->argintregs[0],
                                          OFFSET(java_objectheader, vftbl));
                                M_ALD(REG_PV, REG_METHODPTR, OFFSET(vftbl_t, table[0]) +
                                          sizeof(methodptr) * lm->vftblindex);
@@ -3185,8 +3180,8 @@ gen_method: {
                        case ICMD_INVOKEINTERFACE:
                                d = lm->returntype;
                                        
-                               gen_nullptr_check(r->argintregs[0]);
-                               M_ALD(REG_METHODPTR, r->argintregs[0],
+                               gen_nullptr_check(rd->argintregs[0]);
+                               M_ALD(REG_METHODPTR, rd->argintregs[0],
                                          OFFSET(java_objectheader, vftbl));    
                                M_ALD(REG_METHODPTR, REG_METHODPTR,
                                          OFFSET(vftbl_t, interfacetable[0]) -
@@ -3213,12 +3208,12 @@ gen_method: {
 
                        if (d != TYPE_VOID) {
                                if (IS_INT_LNG_TYPE(iptr->dst->type)) {
-                                       s1 = reg_of_var(m, iptr->dst, REG_RESULT);
+                                       s1 = reg_of_var(rd, iptr->dst, REG_RESULT);
                                        M_INTMOVE(REG_RESULT, s1);
                                        store_reg_to_var_int(iptr->dst, s1);
 
                                } else {
-                                       s1 = reg_of_var(m, iptr->dst, REG_FRESULT);
+                                       s1 = reg_of_var(rd, iptr->dst, REG_FRESULT);
                                        M_FLTMOVE(REG_FRESULT, s1);
                                        store_reg_to_var_flt(iptr->dst, s1);
                                }
@@ -3249,10 +3244,10 @@ gen_method: {
                        classinfo *super = (classinfo*) iptr->val.a;
                        
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                       codegen_threadcritrestart(m, (u1 *) mcodeptr - cd->mcodebase);
+                       codegen_threadcritrestart(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (s1 == d) {
                                M_MOV(s1, REG_ITMP1);
                                s1 = REG_ITMP1;
@@ -3286,16 +3281,16 @@ gen_method: {
 */
                                        M_BEQZ(s1, 7);
                                        M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
-                                       a = dseg_addaddress(m, (void*) super->vftbl);
+                                       a = dseg_addaddress(cd, (void*) super->vftbl);
                                        M_ALD(REG_ITMP2, REG_PV, a);
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                                       codegen_threadcritstart(m, (u1 *) mcodeptr - cd->mcodebase);
+                                       codegen_threadcritstart(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                                        M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                        M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                        M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                                       codegen_threadcritstop(m, (u1 *) mcodeptr - cd->mcodebase);
+                                       codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                                        M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                        M_CMPULE(REG_ITMP1, REG_ITMP2, d);
@@ -3329,9 +3324,9 @@ gen_method: {
                        classinfo *super = (classinfo *) iptr->val.a;
                        
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                       codegen_threadcritrestart(m, (u1 *) mcodeptr - cd->mcodebase);
+                       codegen_threadcritrestart(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        var_to_reg_int(s1, src, d);
                        if (iptr->op1) {                               /* class/interface */
                                if (super->flags & ACC_INTERFACE) {        /* interface       */
@@ -3340,12 +3335,12 @@ gen_method: {
                                        M_ILD(REG_ITMP2, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength));
                                        M_LDA(REG_ITMP2, REG_ITMP2, - super->index);
                                        M_BLEZ(REG_ITMP2, 0);
-                                       codegen_addxcastrefs(m, mcodeptr);
+                                       codegen_addxcastrefs(cd, mcodeptr);
                                        M_ALD(REG_ITMP2, REG_ITMP1,
                                              OFFSET(vftbl_t, interfacetable[0]) -
                                              super->index * sizeof(methodptr*));
                                        M_BEQZ(REG_ITMP2, 0);
-                                       codegen_addxcastrefs(m, mcodeptr);
+                                       codegen_addxcastrefs(cd, mcodeptr);
                                        }
                                else {                                     /* class           */
 /*
@@ -3369,17 +3364,17 @@ gen_method: {
 */
                                        M_BEQZ(s1, 8 + (d == REG_ITMP3));
                                        M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
-                                       a = dseg_addaddress(m, (void *) super->vftbl);
+                                       a = dseg_addaddress(cd, (void *) super->vftbl);
                                        M_ALD(REG_ITMP2, REG_PV, a);
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                                       codegen_threadcritstart(m, (u1 *) mcodeptr - cd->mcodebase);
+                                       codegen_threadcritstart(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                                        M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                        if (d != REG_ITMP3) {
                                                M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                                               codegen_threadcritstop(m, (u1 *) mcodeptr - cd->mcodebase);
+                                               codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                                                M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                                }
@@ -3389,12 +3384,12 @@ gen_method: {
                                                M_ALD(REG_ITMP2, REG_PV, a);
                                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                                               codegen_threadcritstop(m, (u1 *) mcodeptr - cd->mcodebase);
+                                               codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                                                }
                                        M_CMPULE(REG_ITMP1, REG_ITMP2, REG_ITMP2);
                                        M_BEQZ(REG_ITMP2, 0);
-                                       codegen_addxcastrefs(m, mcodeptr);
+                                       codegen_addxcastrefs(cd, mcodeptr);
                                        }
                                }
                        else
@@ -3408,13 +3403,13 @@ gen_method: {
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_BLTZ(s1, 0);
-                       codegen_addxcheckarefs(m, mcodeptr);
+                       codegen_addxcheckarefs(cd, mcodeptr);
                        break;
 
                case ICMD_CHECKEXCEPTION:    /* ... ==> ...                           */
 
                        M_BEQZ(REG_RESULT, 0);
-                       codegen_addxexceptionrefs(m, mcodeptr);
+                       codegen_addxexceptionrefs(cd, mcodeptr);
                        break;
 
                case ICMD_MULTIANEWARRAY:/* ..., cnt1, [cnt2, ...] ==> ..., arrayref  */
@@ -3427,7 +3422,7 @@ gen_method: {
                        for (s1 = iptr->op1; --s1 >= 0; src = src->prev) {
                                var_to_reg_int(s2, src, REG_ITMP1);
                                M_BLTZ(s2, 0);
-                               codegen_addxcheckarefs(m, mcodeptr);
+                               codegen_addxcheckarefs(cd, mcodeptr);
 
                                /* copy sizes to stack (argument numbers >= INT_ARG_CNT)      */
 
@@ -3438,18 +3433,18 @@ gen_method: {
 
                        /* a0 = dimension count */
 
-                       ICONST(r->argintregs[0], iptr->op1);
+                       ICONST(rd->argintregs[0], iptr->op1);
 
                        /* a1 = arraydescriptor */
 
-                       a = dseg_addaddress(m, iptr->val.a);
-                       M_ALD(r->argintregs[1], REG_PV, a);
+                       a = dseg_addaddress(cd, iptr->val.a);
+                       M_ALD(rd->argintregs[1], REG_PV, a);
 
                        /* a2 = pointer to dimensions = stack pointer */
 
-                       M_INTMOVE(REG_SP, r->argintregs[2]);
+                       M_INTMOVE(REG_SP, rd->argintregs[2]);
 
-                       a = dseg_addaddress(m, (void *) builtin_nmultianewarray);
+                       a = dseg_addaddress(cd, (void *) builtin_nmultianewarray);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
                        s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
@@ -3461,7 +3456,7 @@ gen_method: {
                                M_LDA(REG_PV, REG_RA, ml);
                                M_LDAH(REG_PV, REG_PV, mh);
                        }
-                       s1 = reg_of_var(m, iptr->dst, REG_RESULT);
+                       s1 = reg_of_var(rd, iptr->dst, REG_RESULT);
                        M_INTMOVE(REG_RESULT, s1);
                        store_reg_to_var_int(iptr->dst, s1);
                        break;
@@ -3486,20 +3481,20 @@ gen_method: {
                        s2 = src->type;
                        if (IS_FLT_DBL_TYPE(s2)) {
                                var_to_reg_flt(s1, src, REG_FTMP1);
-                               if (!(r->interfaces[len][s2].flags & INMEMORY)) {
-                                       M_FLTMOVE(s1,r->interfaces[len][s2].regoff);
+                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+                                       M_FLTMOVE(s1,rd->interfaces[len][s2].regoff);
                                        }
                                else {
-                                       M_DST(s1, REG_SP, 8 * r->interfaces[len][s2].regoff);
+                                       M_DST(s1, REG_SP, 8 * rd->interfaces[len][s2].regoff);
                                        }
                                }
                        else {
                                var_to_reg_int(s1, src, REG_ITMP1);
-                               if (!(r->interfaces[len][s2].flags & INMEMORY)) {
-                                       M_INTMOVE(s1,r->interfaces[len][s2].regoff);
+                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+                                       M_INTMOVE(s1,rd->interfaces[len][s2].regoff);
                                        }
                                else {
-                                       M_LST(s1, REG_SP, 8 * r->interfaces[len][s2].regoff);
+                                       M_LST(s1, REG_SP, 8 * rd->interfaces[len][s2].regoff);
                                        }
                                }
                        }
@@ -3534,11 +3529,11 @@ gen_method: {
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       a = dseg_addaddress(m, string_java_lang_ArrayIndexOutOfBoundsException);
-                       M_ALD(r->argintregs[0], REG_PV, a);
-                       M_MOV(REG_ITMP1, r->argintregs[1]);
+                       a = dseg_addaddress(cd, string_java_lang_ArrayIndexOutOfBoundsException);
+                       M_ALD(rd->argintregs[0], REG_PV, a);
+                       M_MOV(REG_ITMP1, rd->argintregs[1]);
 
-                       a = dseg_addaddress(m, new_exception_int);
+                       a = dseg_addaddress(cd, new_exception_int);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
 
@@ -3557,7 +3552,7 @@ gen_method: {
                        M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
                        M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
 
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP3, REG_PV, a);
 
                        M_JMP(REG_ZERO, REG_ITMP3);
@@ -3593,10 +3588,10 @@ gen_method: {
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       a = dseg_addaddress(m, string_java_lang_NegativeArraySizeException);
-                       M_ALD(r->argintregs[0], REG_PV, a);
+                       a = dseg_addaddress(cd, string_java_lang_NegativeArraySizeException);
+                       M_ALD(rd->argintregs[0], REG_PV, a);
 
-                       a = dseg_addaddress(m, new_exception);
+                       a = dseg_addaddress(cd, new_exception);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
 
@@ -3615,7 +3610,7 @@ gen_method: {
                        M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
                        M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
 
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP3, REG_PV, a);
 
                        M_JMP(REG_ZERO, REG_ITMP3);
@@ -3651,10 +3646,10 @@ gen_method: {
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       a = dseg_addaddress(m, string_java_lang_ClassCastException);
-                       M_ALD(r->argintregs[0], REG_PV, a);
+                       a = dseg_addaddress(cd, string_java_lang_ClassCastException);
+                       M_ALD(rd->argintregs[0], REG_PV, a);
 
-                       a = dseg_addaddress(m, new_exception);
+                       a = dseg_addaddress(cd, new_exception);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
 
@@ -3673,7 +3668,7 @@ gen_method: {
                        M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
                        M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
 
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP3, REG_PV, a);
 
                        M_JMP(REG_ZERO, REG_ITMP3);
@@ -3710,7 +3705,7 @@ gen_method: {
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       a = dseg_addaddress(m, &builtin_get_exceptionptrptr);
+                       a = dseg_addaddress(cd, &builtin_get_exceptionptrptr);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
 
@@ -3730,13 +3725,13 @@ gen_method: {
                        M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
                        M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
 #else
-                       a = dseg_addaddress(m, &_exceptionptr);
+                       a = dseg_addaddress(cd, &_exceptionptr);
                        M_ALD(REG_ITMP3, REG_PV, a);
                        M_ALD(REG_ITMP1_XPTR, REG_ITMP3, 0);
                        M_AST(REG_ZERO, REG_ITMP3, 0);
 #endif
 
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP3, REG_PV, a);
 
                        M_JMP(REG_ZERO, REG_ITMP3);
@@ -3772,10 +3767,10 @@ gen_method: {
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       a = dseg_addaddress(m, string_java_lang_NullPointerException);
-                       M_ALD(r->argintregs[0], REG_PV, a);
+                       a = dseg_addaddress(cd, string_java_lang_NullPointerException);
+                       M_ALD(rd->argintregs[0], REG_PV, a);
 
-                       a = dseg_addaddress(m, new_exception);
+                       a = dseg_addaddress(cd, new_exception);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
 
@@ -3794,7 +3789,7 @@ gen_method: {
                        M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
                        M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
 
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP3, REG_PV, a);
 
                        M_JMP(REG_ZERO, REG_ITMP3);
@@ -3802,7 +3797,7 @@ gen_method: {
        }
        }
 
-       codegen_finish(m, (s4) ((u1 *) mcodeptr - cd->mcodebase));
+       codegen_finish(m, cd, (s4) ((u1 *) mcodeptr - cd->mcodebase));
 }
 
 
@@ -3874,11 +3869,21 @@ u1 *createnativestub(functionptr f, methodinfo *m)
        s4 stackframesize = 0;              /* size of stackframe if needed       */
        s4 disp;
        s4 stubsize;
-       registerdata *r;
+       s4 dumpsize;
+       registerdata *rd;
+       t_inlining_globals *id;
+
+       /* mark start of dump memory area */
 
-       /* keep code size smaller */
-       reg_init(m);
-       r = m->registerdata;
+       dumpsize = dump_size();
+
+       /* setup registers before using it */
+       
+       rd = DNEW(registerdata);
+       id = DNEW(t_inlining_globals);
+
+       inlining_setup(m, id);
+       reg_setup(m, rd, id);
 
        descriptor2types(m);                /* set paramcount and paramtypes      */
 
@@ -3934,7 +3939,7 @@ u1 *createnativestub(functionptr f, methodinfo *m)
 
                /* save integer argument registers */
                for (p = 0; p < m->paramcount && p < INT_ARG_CNT; p++) {
-                       M_LST(r->argintregs[p], REG_SP, (2 + p) * 8);
+                       M_LST(rd->argintregs[p], REG_SP, (2 + p) * 8);
                }
 
                /* save and copy float arguments into integer registers */
@@ -3943,16 +3948,16 @@ u1 *createnativestub(functionptr f, methodinfo *m)
 
                        if (IS_FLT_DBL_TYPE(t)) {
                                if (IS_2_WORD_TYPE(t)) {
-                                       M_DST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
-                                       M_LLD(r->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_LLD(rd->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
 
                                } else {
-                                       M_FST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
-                                       M_ILD(r->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_FST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_ILD(rd->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                                }
                                
                        } else {
-                               M_DST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                               M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                        }
                }
 
@@ -3964,7 +3969,7 @@ u1 *createnativestub(functionptr f, methodinfo *m)
                M_LDA(REG_PV, REG_RA, disp);
 
                for (p = 0; p < m->paramcount && p < INT_ARG_CNT; p++) {
-                       M_LLD(r->argintregs[p], REG_SP, (2 + p) * 8);
+                       M_LLD(rd->argintregs[p], REG_SP, (2 + p) * 8);
                }
 
                for (p = 0; p < m->paramcount && p < FLT_ARG_CNT; p++) {
@@ -3972,14 +3977,14 @@ u1 *createnativestub(functionptr f, methodinfo *m)
 
                        if (IS_FLT_DBL_TYPE(t)) {
                                if (IS_2_WORD_TYPE(t)) {
-                                       M_DLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
 
                                } else {
-                                       M_FLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_FLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                                }
 
                        } else {
-                               M_DLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                               M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                        }
                }
 
@@ -4005,54 +4010,54 @@ u1 *createnativestub(functionptr f, methodinfo *m)
 
                if (m->flags & ACC_STATIC) {
                        if (IS_FLT_DBL_TYPE(m->paramtypes[5])) {
-                               M_DST(r->argfltregs[5], REG_SP, 1 * 8);
+                               M_DST(rd->argfltregs[5], REG_SP, 1 * 8);
                        } else {
-                               M_LST(r->argintregs[5], REG_SP, 1 * 8);
+                               M_LST(rd->argintregs[5], REG_SP, 1 * 8);
                        }
 
                        if (IS_FLT_DBL_TYPE(m->paramtypes[4])) {
-                               M_DST(r->argfltregs[4], REG_SP, 0 * 8);
+                               M_DST(rd->argfltregs[4], REG_SP, 0 * 8);
                        } else {
-                               M_LST(r->argintregs[4], REG_SP, 0 * 8);
+                               M_LST(rd->argintregs[4], REG_SP, 0 * 8);
                        }
 
                } else {
                        if (IS_FLT_DBL_TYPE(m->paramtypes[5])) {
-                               M_DST(r->argfltregs[5], REG_SP, 0 * 8);
+                               M_DST(rd->argfltregs[5], REG_SP, 0 * 8);
                        } else {
-                               M_LST(r->argintregs[5], REG_SP, 0 * 8);
+                               M_LST(rd->argintregs[5], REG_SP, 0 * 8);
                        }
                }
        }
 
        if (m->flags & ACC_STATIC) {
-               M_MOV(r->argintregs[3], r->argintregs[5]);
-               M_MOV(r->argintregs[2], r->argintregs[4]);
-               M_MOV(r->argintregs[1], r->argintregs[3]);
-               M_MOV(r->argintregs[0], r->argintregs[2]);
-               M_FMOV(r->argfltregs[3], r->argfltregs[5]);
-               M_FMOV(r->argfltregs[2], r->argfltregs[4]);
-               M_FMOV(r->argfltregs[1], r->argfltregs[3]);
-               M_FMOV(r->argfltregs[0], r->argfltregs[2]);
+               M_MOV(rd->argintregs[3], rd->argintregs[5]);
+               M_MOV(rd->argintregs[2], rd->argintregs[4]);
+               M_MOV(rd->argintregs[1], rd->argintregs[3]);
+               M_MOV(rd->argintregs[0], rd->argintregs[2]);
+               M_FMOV(rd->argfltregs[3], rd->argfltregs[5]);
+               M_FMOV(rd->argfltregs[2], rd->argfltregs[4]);
+               M_FMOV(rd->argfltregs[1], rd->argfltregs[3]);
+               M_FMOV(rd->argfltregs[0], rd->argfltregs[2]);
 
                /* put class into second argument register */
-               M_ALD(r->argintregs[1], REG_PV, -8 * 8);
+               M_ALD(rd->argintregs[1], REG_PV, -8 * 8);
 
        } else {
-               M_MOV(r->argintregs[4], r->argintregs[5]);
-               M_MOV(r->argintregs[3], r->argintregs[4]);
-               M_MOV(r->argintregs[2], r->argintregs[3]);
-               M_MOV(r->argintregs[1], r->argintregs[2]);
-               M_MOV(r->argintregs[0], r->argintregs[1]);
-               M_FMOV(r->argfltregs[4], r->argfltregs[5]);
-               M_FMOV(r->argfltregs[3], r->argfltregs[4]);
-               M_FMOV(r->argfltregs[2], r->argfltregs[3]);
-               M_FMOV(r->argfltregs[1], r->argfltregs[2]);
-               M_FMOV(r->argfltregs[0], r->argfltregs[1]);
+               M_MOV(rd->argintregs[4], rd->argintregs[5]);
+               M_MOV(rd->argintregs[3], rd->argintregs[4]);
+               M_MOV(rd->argintregs[2], rd->argintregs[3]);
+               M_MOV(rd->argintregs[1], rd->argintregs[2]);
+               M_MOV(rd->argintregs[0], rd->argintregs[1]);
+               M_FMOV(rd->argfltregs[4], rd->argfltregs[5]);
+               M_FMOV(rd->argfltregs[3], rd->argfltregs[4]);
+               M_FMOV(rd->argfltregs[2], rd->argfltregs[3]);
+               M_FMOV(rd->argfltregs[1], rd->argfltregs[2]);
+               M_FMOV(rd->argfltregs[0], rd->argfltregs[1]);
        }
 
        /* put env into first argument register */
-       M_ALD(r->argintregs[0], REG_PV, -4 * 8);
+       M_ALD(rd->argintregs[0], REG_PV, -4 * 8);
 
        M_ALD(REG_PV, REG_PV, -1 * 8);      /* load adress of native method       */
        M_JSR(REG_RA, REG_PV);              /* call native method                 */
@@ -4067,12 +4072,12 @@ u1 *createnativestub(functionptr f, methodinfo *m)
        /* 13 instructions */
        if (runverbose) {
                M_LDA(REG_SP, REG_SP, -2 * 8);
-               M_ALD(r->argintregs[0], REG_PV, -6 * 8); /* load method adress        */
+               M_ALD(rd->argintregs[0], REG_PV, -6 * 8); /* load method adress       */
                M_LST(REG_RESULT, REG_SP, 0 * 8);
                M_DST(REG_FRESULT, REG_SP, 1 * 8);
-               M_MOV(REG_RESULT, r->argintregs[1]);
-               M_FMOV(REG_FRESULT, r->argfltregs[2]);
-               M_FMOV(REG_FRESULT, r->argfltregs[3]);
+               M_MOV(REG_RESULT, rd->argintregs[1]);
+               M_FMOV(REG_FRESULT, rd->argfltregs[2]);
+               M_FMOV(REG_FRESULT, rd->argfltregs[3]);
                M_ALD(REG_PV, REG_PV, -7 * 8);  /* builtin_displaymethodstop          */
                M_JSR(REG_RA, REG_PV);
                disp = -(s4) (mcodeptr - (s4 *) cs) * 4;
@@ -4123,6 +4128,10 @@ u1 *createnativestub(functionptr f, methodinfo *m)
                count_nstub_len += NATIVESTUBSIZE * 8;
 #endif
 
+       /* release dump area */
+
+       dump_release(dumpsize);
+
        return (u1 *) (s + NATIVESTUBOFFSET);
 }
 
index 83af6b005cae7ab269e7829a0153541de58c917a..98ceed5102c58dcfae313408d5ace6f9002bd9c3 100644 (file)
@@ -28,7 +28,7 @@
    Authors: Andreas Krall
             Reinhard Grafl
 
-   $Id: codegen.h 1347 2004-07-21 23:29:39Z twisti $
+   $Id: codegen.h 1468 2004-11-08 13:29:58Z twisti $
 
 */
 
@@ -98,7 +98,7 @@
 #define gen_nullptr_check(objreg) \
     if (checknull) { \
         M_BEQZ((objreg), 0); \
-        codegen_addxnullrefs(m, mcodeptr); \
+        codegen_addxnullrefs(cd, mcodeptr); \
     }
 
 #define gen_bound_check \
         M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
         M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\
         M_BEQZ(REG_ITMP3, 0);\
-        codegen_addxboundrefs(m, mcodeptr, s2); \
+        codegen_addxboundrefs(cd, mcodeptr, s2); \
     }
 
 
 
 #define MCODECHECK(icnt) \
        if ((mcodeptr + (icnt)) > cd->mcodeend) \
-        mcodeptr = codegen_increase(m, (u1 *) mcodeptr)
+        mcodeptr = codegen_increase(cd, (u1 *) mcodeptr)
 
 /* M_INTMOVE:
      generates an integer-move from register a to b.
 */
 
 #define var_to_reg_int(regnr,v,tempnr) { \
-       if ((v)->flags & INMEMORY) \
-               {COUNT_SPILLS;M_LLD(tempnr,REG_SP,8*(v)->regoff);regnr=tempnr;} \
-       else regnr=(v)->regoff; \
+       if ((v)->flags & INMEMORY) { \
+               COUNT_SPILLS; \
+        M_LLD(tempnr, REG_SP, 8 * (v)->regoff); \
+        regnr = tempnr; \
+    } else regnr = (v)->regoff; \
 }
 
 
 #define var_to_reg_flt(regnr,v,tempnr) { \
-       if ((v)->flags & INMEMORY) \
-               {COUNT_SPILLS;M_DLD(tempnr,REG_SP,8*(v)->regoff);regnr=tempnr;} \
-       else regnr=(v)->regoff; \
+       if ((v)->flags & INMEMORY) { \
+               COUNT_SPILLS; \
+        M_DLD(tempnr, REG_SP, 8 * (v)->regoff); \
+        regnr = tempnr; \
+    } else regnr = (v)->regoff; \
 }
 
 
 
 
 #define M_COPY(from,to) \
-       d = reg_of_var(m, to, REG_IFTMP); \
+       d = reg_of_var(rd, to, REG_IFTMP); \
        if ((from->regoff != to->regoff) || \
            ((from->flags ^ to->flags) & INMEMORY)) { \
                if (IS_FLT_DBL_TYPE(from->type)) { \
     if ((c) >= -32768 && (c) <= 32767) { \
         M_LDA((r), REG_ZERO, c); \
     } else { \
-        a = dseg_adds4(m, (c)); \
+        a = dseg_adds4(cd, (c)); \
         M_ILD((r), REG_PV, a); \
     }
 
     if ((c) >= -32768 && (c) <= 32767) { \
         M_LDA((r), REG_ZERO, (c)); \
     } else { \
-        a = dseg_adds8(m, (c)); \
+        a = dseg_adds8(cd, (c)); \
         M_LLD((r), REG_PV, a); \
     }
 
 
 *******************************************************************************/
 
-#define gen_resolvebranch(ip,so,to) ((s4*)(ip))[-1]|=((s4)(to)-(so))>>2&0x1fffff
+#define gen_resolvebranch(ip,so,to) \
+    ((s4 *) (ip))[-1] |= ((s4) (to) - (so)) >> 2 & 0x1fffff
 
-#define SOFTNULLPTRCHECK       /* soft null pointer check supportet as option */
 
 /* function prototypes */
 
index 9b12a802e8278e9ca7dc485dd1ed84293374997f..7a4d9810f749f72a11a41f0086ca94aa4b0056a4 100644 (file)
@@ -28,7 +28,7 @@
    Authors: Andreas Krall
             Reinhard Grafl
 
-   $Id: codegen.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: codegen.c 1468 2004-11-08 13:29:58Z twisti $
 
 */
 
 #include "native.h"
 #include "main.h"
 
-/* include independent code generation stuff */
-#include "jit/codegen.inc"
-#include "jit/reg.inc"
-
 
 /* *****************************************************************************
 
@@ -110,11 +106,16 @@ int nregdescfloat[] = {
 
 /* for use of reserved registers, see comment above */
 
+/* include independent code generation stuff -- include after register        */
+/* descriptions to avoid extern definitions                                   */
+
+#include "jit/codegen.inc"
+#include "jit/reg.inc"
+
 
 /* NullPointerException handlers and exception handling initialisation        */
 
 typedef struct sigctx_struct {
-
        long          sc_onstack;           /* sigstack state to restore          */
        long          sc_mask;              /* signal mask to restore             */
        long          sc_pc;                /* pc at time of signal               */
@@ -230,7 +231,7 @@ ieee_set_fp_control(ieee_get_fp_control()
 
 *******************************************************************************/
 
-void codegen(methodinfo *m)
+void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
 {
        s4 len, s1, s2, s3, d;
        s4 a;
@@ -241,12 +242,6 @@ void codegen(methodinfo *m)
        basicblock     *bptr;
        instruction    *iptr;
        exceptiontable *ex;
-       registerdata   *r;
-       codegendata    *cd;
-
-       /* keep code size smaller */
-       r = m->registerdata;
-       cd = m->codegendata;
 
        {
        s4 i, p, pa, t, l;
@@ -256,10 +251,10 @@ void codegen(methodinfo *m)
 
        /* space to save used callee saved registers */
 
-       savedregs_num += (r->savintregcnt - r->maxsavintreguse);
-       savedregs_num += (r->savfltregcnt - r->maxsavfltreguse);
+       savedregs_num += (rd->savintregcnt - rd->maxsavintreguse);
+       savedregs_num += (rd->savfltregcnt - rd->maxsavfltreguse);
 
-       parentargs_base = r->maxmemuse + savedregs_num;
+       parentargs_base = rd->maxmemuse + savedregs_num;
 
 #if defined(USE_THREADS)           /* space to save argument of monitor_enter */
 
@@ -270,8 +265,8 @@ void codegen(methodinfo *m)
 
        /* create method header */
 
-       (void) dseg_addaddress(m, m);                           /* MethodPointer  */
-       (void) dseg_adds4(m, parentargs_base * 8);                 /* FrameSize      */
+       (void) dseg_addaddress(cd, m);                          /* MethodPointer  */
+       (void) dseg_adds4(cd, parentargs_base * 8);             /* FrameSize      */
 
 #if defined(USE_THREADS)
 
@@ -282,28 +277,28 @@ void codegen(methodinfo *m)
        */
 
        if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               (void) dseg_adds4(m, (r->maxmemuse + 1) * 8);       /* IsSync         */
+               (void) dseg_adds4(cd, (rd->maxmemuse + 1) * 8);     /* IsSync         */
        else
 
 #endif
 
-       (void) dseg_adds4(m, 0);                                /* IsSync         */
+       (void) dseg_adds4(cd, 0);                               /* IsSync         */
                                               
-       (void) dseg_adds4(m, m->isleafmethod);                  /* IsLeaf         */
-       (void) dseg_adds4(m, r->savintregcnt - r->maxsavintreguse);/* IntSave     */
-       (void) dseg_adds4(m, r->savfltregcnt - r->maxsavfltreguse);/* FltSave     */
+       (void) dseg_adds4(cd, m->isleafmethod);                 /* IsLeaf         */
+       (void) dseg_adds4(cd, rd->savintregcnt - rd->maxsavintreguse);/* IntSave  */
+       (void) dseg_adds4(cd, rd->savfltregcnt - rd->maxsavfltreguse);/* FltSave  */
 
-       dseg_addlinenumbertablesize(m);
+       dseg_addlinenumbertablesize(cd);
 
-       (void) dseg_adds4(m, cd->exceptiontablelength);          /* ExTableSize    */
+       (void) dseg_adds4(cd, cd->exceptiontablelength);        /* ExTableSize    */
 
        /* create exception table */
 
        for (ex = cd->exceptiontable; ex != NULL; ex = ex->down) {
-               dseg_addtarget(m, ex->start);
-               dseg_addtarget(m, ex->end);
-               dseg_addtarget(m, ex->handler);
-               (void) dseg_addaddress(m, ex->catchtype);
+               dseg_addtarget(cd, ex->start);
+               dseg_addtarget(cd, ex->end);
+               dseg_addtarget(cd, ex->handler);
+               (void) dseg_addaddress(cd, ex->catchtype);
        }
        
        /* initialize mcode variables */
@@ -315,7 +310,7 @@ void codegen(methodinfo *m)
        /* create stack frame (if necessary) */
 
        if (parentargs_base) {
-               M_LDA (REG_SP, REG_SP, -parentargs_base * 8);
+               M_LDA(REG_SP, REG_SP, -parentargs_base * 8);
        }
 
        /* save return address and used callee saved registers */
@@ -324,11 +319,11 @@ void codegen(methodinfo *m)
        if (!m->isleafmethod) {
                p--; M_AST(REG_RA, REG_SP, p * 8);
        }
-       for (i = r->savintregcnt - 1; i >= r->maxsavintreguse; i--) {
-               p--; M_LST(r->savintregs[i], REG_SP, p * 8);
+       for (i = rd->savintregcnt - 1; i >= rd->maxsavintreguse; i--) {
+               p--; M_LST(rd->savintregs[i], REG_SP, p * 8);
        }
-       for (i = r->savfltregcnt - 1; i >= r->maxsavfltreguse; i--) {
-               p--; M_DST(r->savfltregs[i], REG_SP, p * 8);
+       for (i = rd->savfltregcnt - 1; i >= rd->maxsavfltreguse; i--) {
+               p--; M_DST(rd->savfltregs[i], REG_SP, p * 8);
        }
 
        /* save monitorenter argument */
@@ -336,12 +331,12 @@ void codegen(methodinfo *m)
 #if defined(USE_THREADS)
        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                if (m->flags & ACC_STATIC) {
-                       p = dseg_addaddress(m, m->class);
+                       p = dseg_addaddress(cd, m->class);
                        M_ALD(REG_ITMP1, REG_PV, p);
-                       M_AST(REG_ITMP1, REG_SP, r->maxmemuse * 8);
+                       M_AST(REG_ITMP1, REG_SP, rd->maxmemuse * 8);
 
                } else {
-                       M_AST(r->argintregs[0], REG_SP, r->maxmemuse * 8);
+                       M_AST(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
                }
        }                       
 #endif
@@ -357,7 +352,7 @@ void codegen(methodinfo *m)
 
                /* save integer argument registers */
                for (p = 0; /* p < m->paramcount && */ p < INT_ARG_CNT; p++) {
-                       M_LST(r->argintregs[p], REG_SP,  (2 + p) * 8);
+                       M_LST(rd->argintregs[p], REG_SP,  (2 + p) * 8);
                }
 
                /* save and copy float arguments into integer registers */
@@ -366,23 +361,23 @@ void codegen(methodinfo *m)
 
                        if (IS_FLT_DBL_TYPE(t)) {
                                if (IS_2_WORD_TYPE(t)) {
-                                       M_DST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
 
                                } else {
-                                       M_FST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_FST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                                }
 
-                               M_LLD(r->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                               M_LLD(rd->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                                
                        } else {
-                               M_DST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                               M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                        }
                }
 
-               p = dseg_addaddress(m, m);
+               p = dseg_addaddress(cd, m);
                M_ALD(REG_ITMP1, REG_PV, p);
                M_AST(REG_ITMP1, REG_SP, 0 * 8);
-               p = dseg_addaddress(m, (void *) builtin_trace_args);
+               p = dseg_addaddress(cd, (void *) builtin_trace_args);
                M_ALD(REG_PV, REG_PV, p);
                M_JSR(REG_RA, REG_PV);
                disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
@@ -390,7 +385,7 @@ void codegen(methodinfo *m)
                M_ALD(REG_RA, REG_SP, 1 * 8);
 
                for (p = 0; /* p < mparamcount && */ p < INT_ARG_CNT; p++) {
-                       M_LLD(r->argintregs[p], REG_SP,  (2 + p) * 8);
+                       M_LLD(rd->argintregs[p], REG_SP,  (2 + p) * 8);
                }
 
                for (p = 0; /* p < mparamcount && */ p < FLT_ARG_CNT; p++) {
@@ -398,14 +393,14 @@ void codegen(methodinfo *m)
 
                        if (IS_FLT_DBL_TYPE(t)) {
                                if (IS_2_WORD_TYPE(t)) {
-                                       M_DLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
 
                                } else {
-                                       M_FLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_FLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                                }
 
                        } else {
-                               M_DLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                               M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                        }
                }
 
@@ -416,7 +411,7 @@ void codegen(methodinfo *m)
 
        for (p = 0, l = 0; p < m->paramcount; p++) {
                t = m->paramtypes[p];
-               var = &(r->locals[l][t]);
+               var = &(rd->locals[l][t]);
                l++;
                if (IS_2_WORD_TYPE(t))    /* increment local counter for 2 word types */
                        l++;
@@ -425,9 +420,9 @@ void codegen(methodinfo *m)
                if (IS_INT_LNG_TYPE(t)) {                    /* integer args          */
                        if (p < INT_ARG_CNT) {                   /* register arguments    */
                                if (!(var->flags & INMEMORY)) {      /* reg arg -> register   */
-                                       M_INTMOVE(r->argintregs[p], var->regoff);
+                                       M_INTMOVE(rd->argintregs[p], var->regoff);
                                } else {                             /* reg arg -> spilled    */
-                                       M_LST(r->argintregs[p], REG_SP, 8 * var->regoff);
+                                       M_LST(rd->argintregs[p], REG_SP, 8 * var->regoff);
                                }
 
                        } else {                                 /* stack arguments       */
@@ -444,10 +439,10 @@ void codegen(methodinfo *m)
                } else {                                     /* floating args         */
                        if (p < FLT_ARG_CNT) {                   /* register arguments    */
                                if (!(var->flags & INMEMORY)) {      /* reg arg -> register   */
-                                       M_FLTMOVE(r->argfltregs[p], var->regoff);
+                                       M_FLTMOVE(rd->argfltregs[p], var->regoff);
 
                                } else {                                         /* reg arg -> spilled    */
-                                       M_DST(r->argfltregs[p], REG_SP, 8 * var->regoff);
+                                       M_DST(rd->argfltregs[p], REG_SP, 8 * var->regoff);
                                }
 
                        } else {                                 /* stack arguments       */
@@ -470,9 +465,9 @@ void codegen(methodinfo *m)
                s4 disp;
                s8 func_enter = (m->flags & ACC_STATIC) ?
                        (s8) builtin_staticmonitorenter : (s8) builtin_monitorenter;
-               p = dseg_addaddress(m, (void*) func_enter);
+               p = dseg_addaddress(cd, (void*) func_enter);
                M_ALD(REG_PV, REG_PV, p);
-               M_ALD(r->argintregs[0], REG_SP, r->maxmemuse * 8);
+               M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
                M_JSR(REG_RA, REG_PV);
                disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
                M_LDA(REG_PV, REG_RA, disp);
@@ -507,31 +502,31 @@ void codegen(methodinfo *m)
                while (src != NULL) {
                        len--;
                        if ((len == 0) && (bptr->type != BBTYPE_STD)) {
-                               d = reg_of_var(m, src, REG_ITMP1);
+                               d = reg_of_var(rd, src, REG_ITMP1);
                                M_INTMOVE(REG_ITMP1, d);
                                store_reg_to_var_int(src, d);
                                }
                        else {
-                               d = reg_of_var(m, src, REG_IFTMP);
+                               d = reg_of_var(rd, src, REG_IFTMP);
                                if ((src->varkind != STACKVAR)) {
                                        s2 = src->type;
                                        if (IS_FLT_DBL_TYPE(s2)) {
-                                               if (!(r->interfaces[len][s2].flags & INMEMORY)) {
-                                                       s1 = r->interfaces[len][s2].regoff;
+                                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+                                                       s1 = rd->interfaces[len][s2].regoff;
                                                        M_FLTMOVE(s1,d);
                                                        }
                                                else {
-                                                       M_DLD(d, REG_SP, 8 * r->interfaces[len][s2].regoff);
+                                                       M_DLD(d, REG_SP, 8 * rd->interfaces[len][s2].regoff);
                                                        }
                                                store_reg_to_var_flt(src, d);
                                                }
                                        else {
-                                               if (!(r->interfaces[len][s2].flags & INMEMORY)) {
-                                                       s1 = r->interfaces[len][s2].regoff;
+                                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+                                                       s1 = rd->interfaces[len][s2].regoff;
                                                        M_INTMOVE(s1,d);
                                                        }
                                                else {
-                                                       M_LLD(d, REG_SP, 8 * r->interfaces[len][s2].regoff);
+                                                       M_LLD(d, REG_SP, 8 * rd->interfaces[len][s2].regoff);
                                                        }
                                                store_reg_to_var_int(src, d);
                                                }
@@ -558,7 +553,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_BEQZ(s1, 0);
-                       codegen_addxnullrefs(m, mcodeptr);
+                       codegen_addxnullrefs(cd, mcodeptr);
                        break;
 
                /* constant operations ************************************************/
@@ -566,7 +561,7 @@ void codegen(methodinfo *m)
                case ICMD_ICONST:     /* ...  ==> ..., constant                       */
                                      /* op1 = 0, val.i = constant                    */
 
-                       d = reg_of_var(m, iptr->dst, REG_ITMP1);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP1);
                        ICONST(d, iptr->val.i);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -574,7 +569,7 @@ void codegen(methodinfo *m)
                case ICMD_LCONST:     /* ...  ==> ..., constant                       */
                                      /* op1 = 0, val.l = constant                    */
 
-                       d = reg_of_var(m, iptr->dst, REG_ITMP1);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP1);
                        LCONST(d, iptr->val.l);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -582,8 +577,8 @@ void codegen(methodinfo *m)
                case ICMD_FCONST:     /* ...  ==> ..., constant                       */
                                      /* op1 = 0, val.f = constant                    */
 
-                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
-                       a = dseg_addfloat(m, iptr->val.f);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+                       a = dseg_addfloat(cd, iptr->val.f);
                        M_FLD(d, REG_PV, a);
                        store_reg_to_var_flt(iptr->dst, d);
                        break;
@@ -591,8 +586,8 @@ void codegen(methodinfo *m)
                case ICMD_DCONST:     /* ...  ==> ..., constant                       */
                                      /* op1 = 0, val.d = constant                    */
 
-                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
-                       a = dseg_adddouble(m, iptr->val.d);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+                       a = dseg_adddouble(cd, iptr->val.d);
                        M_DLD(d, REG_PV, a);
                        store_reg_to_var_flt(iptr->dst, d);
                        break;
@@ -600,9 +595,9 @@ void codegen(methodinfo *m)
                case ICMD_ACONST:     /* ...  ==> ..., constant                       */
                                      /* op1 = 0, val.a = constant                    */
 
-                       d = reg_of_var(m, iptr->dst, REG_ITMP1);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP1);
                        if (iptr->val.a) {
-                               a = dseg_addaddress(m, iptr->val.a);
+                               a = dseg_addaddress(cd, iptr->val.a);
                                M_ALD(d, REG_PV, a);
                        } else {
                                M_INTMOVE(REG_ZERO, d);
@@ -617,11 +612,11 @@ void codegen(methodinfo *m)
                case ICMD_LLOAD:      /* op1 = local variable                         */
                case ICMD_ALOAD:
 
-                       d = reg_of_var(m, iptr->dst, REG_ITMP1);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP1);
                        if ((iptr->dst->varkind == LOCALVAR) &&
                            (iptr->dst->varnum == iptr->op1))
                                break;
-                       var = &(r->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
+                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
                        if (var->flags & INMEMORY)
                                M_LLD(d, REG_SP, 8 * var->regoff);
                        else
@@ -632,11 +627,11 @@ void codegen(methodinfo *m)
                case ICMD_FLOAD:      /* ...  ==> ..., content of local variable      */
                case ICMD_DLOAD:      /* op1 = local variable                         */
 
-                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
                        if ((iptr->dst->varkind == LOCALVAR) &&
                            (iptr->dst->varnum == iptr->op1))
                                break;
-                       var = &(r->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
+                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ILOAD]);
                        if (var->flags & INMEMORY)
                                M_DLD(d, REG_SP, 8 * var->regoff);
                        else
@@ -652,7 +647,7 @@ void codegen(methodinfo *m)
                        if ((src->varkind == LOCALVAR) &&
                            (src->varnum == iptr->op1))
                                break;
-                       var = &(r->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
+                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
                        if (var->flags & INMEMORY) {
                                var_to_reg_int(s1, src, REG_ITMP1);
                                M_LST(s1, REG_SP, 8 * var->regoff);
@@ -669,7 +664,7 @@ void codegen(methodinfo *m)
                        if ((src->varkind == LOCALVAR) &&
                            (src->varnum == iptr->op1))
                                break;
-                       var = &(r->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
+                       var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]);
                        if (var->flags & INMEMORY) {
                                var_to_reg_flt(s1, src, REG_FTMP1);
                                M_DST(s1, REG_SP, 8 * var->regoff);
@@ -745,7 +740,7 @@ void codegen(methodinfo *m)
                case ICMD_INEG:       /* ..., value  ==> ..., - value                 */
 
                        var_to_reg_int(s1, src, REG_ITMP1); 
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_ISUB(REG_ZERO, s1, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -753,7 +748,7 @@ void codegen(methodinfo *m)
                case ICMD_LNEG:       /* ..., value  ==> ..., - value                 */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_LSUB(REG_ZERO, s1, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -761,7 +756,7 @@ void codegen(methodinfo *m)
                case ICMD_I2L:        /* ..., value  ==> ..., value                   */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_INTMOVE(s1, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -769,7 +764,7 @@ void codegen(methodinfo *m)
                case ICMD_L2I:        /* ..., value  ==> ..., value                   */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_IADD(s1, REG_ZERO, d );
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -777,7 +772,7 @@ void codegen(methodinfo *m)
                case ICMD_INT2BYTE:   /* ..., value  ==> ..., value                   */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (has_ext_instr_set) {
                                M_BSEXT(s1, d);
                                }
@@ -791,7 +786,7 @@ void codegen(methodinfo *m)
                case ICMD_INT2CHAR:   /* ..., value  ==> ..., value                   */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
             M_CZEXT(s1, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -799,7 +794,7 @@ void codegen(methodinfo *m)
                case ICMD_INT2SHORT:  /* ..., value  ==> ..., value                   */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (has_ext_instr_set) {
                                M_SSEXT(s1, d);
                                }
@@ -815,7 +810,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_IADD(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -824,7 +819,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_IADD_IMM(s1, iptr->val.i, d);
                                }
@@ -839,7 +834,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_LADD(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -848,7 +843,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_LADD_IMM(s1, iptr->val.l, d);
                                }
@@ -863,7 +858,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_ISUB(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -872,7 +867,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_ISUB_IMM(s1, iptr->val.i, d);
                                }
@@ -887,7 +882,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_LSUB(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -896,7 +891,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_LSUB_IMM(s1, iptr->val.l, d);
                                }
@@ -911,7 +906,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_IMUL(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -920,7 +915,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_IMUL_IMM(s1, iptr->val.i, d);
                                }
@@ -935,7 +930,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_LMUL (s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -944,7 +939,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_LMUL_IMM(s1, iptr->val.l, d);
                                }
@@ -959,7 +954,7 @@ void codegen(methodinfo *m)
                case ICMD_LDIVPOW2:   /* val.i = constant                             */
                                      
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->val.i <= 15) {
                                M_LDA(REG_ITMP2, s1, (1 << iptr->val.i) -1);
                                M_CMOVGE(s1, s1, REG_ITMP2);
@@ -977,7 +972,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_AND_IMM(s2, 0x1f, REG_ITMP3);
                        M_SLL(s1, REG_ITMP3, d);
                        M_IADD(d, REG_ZERO, d);
@@ -988,7 +983,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SLL_IMM(s1, iptr->val.i & 0x1f, d);
                        M_IADD(d, REG_ZERO, d);
                        store_reg_to_var_int(iptr->dst, d);
@@ -998,7 +993,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_AND_IMM(s2, 0x1f, REG_ITMP3);
                        M_SRA(s1, REG_ITMP3, d);
                        store_reg_to_var_int(iptr->dst, d);
@@ -1008,7 +1003,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SRA_IMM(s1, iptr->val.i & 0x1f, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1017,7 +1012,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_AND_IMM(s2, 0x1f, REG_ITMP2);
             M_IZEXT(s1, d);
                        M_SRL(d, REG_ITMP2, d);
@@ -1029,7 +1024,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
             M_IZEXT(s1, d);
                        M_SRL_IMM(d, iptr->val.i & 0x1f, d);
                        M_IADD(d, REG_ZERO, d);
@@ -1040,7 +1035,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SLL(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1049,7 +1044,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SLL_IMM(s1, iptr->val.i & 0x3f, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1058,7 +1053,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SRA(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1067,7 +1062,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SRA_IMM(s1, iptr->val.i & 0x3f, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1076,7 +1071,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SRL(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1085,7 +1080,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_SRL_IMM(s1, iptr->val.i & 0x3f, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1095,7 +1090,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_AND(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1104,7 +1099,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_AND_IMM(s1, iptr->val.i, d);
                                }
@@ -1125,7 +1120,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (s1 == d) {
                                M_MOV(s1, REG_ITMP1);
                                s1 = REG_ITMP1;
@@ -1163,7 +1158,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_AND_IMM(s1, iptr->val.l, d);
                                }
@@ -1196,7 +1191,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (s1 == d) {
                                M_MOV(s1, REG_ITMP1);
                                s1 = REG_ITMP1;
@@ -1259,7 +1254,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_OR( s1,s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1268,7 +1263,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_OR_IMM(s1, iptr->val.i, d);
                                }
@@ -1283,7 +1278,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_OR_IMM(s1, iptr->val.l, d);
                                }
@@ -1299,7 +1294,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_XOR(s1, s2, d);
                        store_reg_to_var_int(iptr->dst, d);
                        break;
@@ -1308,7 +1303,7 @@ void codegen(methodinfo *m)
                                      /* val.i = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) {
                                M_XOR_IMM(s1, iptr->val.i, d);
                                }
@@ -1323,7 +1318,7 @@ void codegen(methodinfo *m)
                                      /* val.l = constant                             */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) {
                                M_XOR_IMM(s1, iptr->val.l, d);
                                }
@@ -1339,7 +1334,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        M_CMPLT(s1, s2, REG_ITMP3);
                        M_CMPLT(s2, s1, REG_ITMP1);
                        M_LSUB (REG_ITMP1, REG_ITMP3, d);
@@ -1350,7 +1345,7 @@ void codegen(methodinfo *m)
                case ICMD_IINC:       /* ..., value  ==> ..., value + constant        */
                                      /* op1 = variable, val.i = constant             */
 
-                       var = &(r->locals[iptr->op1][TYPE_INT]);
+                       var = &(rd->locals[iptr->op1][TYPE_INT]);
                        if (var->flags & INMEMORY) {
                                s1 = REG_ITMP1;
                                M_LLD(s1, REG_SP, 8 * var->regoff);
@@ -1377,7 +1372,7 @@ void codegen(methodinfo *m)
                case ICMD_FNEG:       /* ..., value  ==> ..., - value                 */
 
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        M_FMOVN(s1, d);
                        store_reg_to_var_flt(iptr->dst, d);
                        break;
@@ -1385,7 +1380,7 @@ void codegen(methodinfo *m)
                case ICMD_DNEG:       /* ..., value  ==> ..., - value                 */
 
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        M_FMOVN(s1, d);
                        store_reg_to_var_flt(iptr->dst, d);
                        break;
@@ -1394,7 +1389,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_FADD(s1, s2, d);
                                }
@@ -1416,7 +1411,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_DADD(s1, s2, d);
                                }
@@ -1438,7 +1433,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_FSUB(s1, s2, d);
                                }
@@ -1460,7 +1455,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_DSUB(s1, s2, d);
                                }
@@ -1482,7 +1477,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_FMUL(s1, s2, d);
                                }
@@ -1504,7 +1499,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_DMUL(s1, s2, d);
                                }
@@ -1526,7 +1521,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_FDIV(s1, s2, d);
                                }
@@ -1548,7 +1543,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_DDIV(s1, s2, d);
                                }
@@ -1569,8 +1564,8 @@ void codegen(methodinfo *m)
                case ICMD_I2F:       /* ..., value  ==> ..., (float) value            */
                case ICMD_L2F:
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
-                       a = dseg_adddouble(m, 0.0);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
+                       a = dseg_adddouble(cd, 0.0);
                        M_LST (s1, REG_PV, a);
                        M_DLD (d, REG_PV, a);
                        M_CVTLF(d, d);
@@ -1580,8 +1575,8 @@ void codegen(methodinfo *m)
                case ICMD_I2D:       /* ..., value  ==> ..., (double) value           */
                case ICMD_L2D:
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
-                       a = dseg_adddouble(m, 0.0);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
+                       a = dseg_adddouble(cd, 0.0);
                        M_LST (s1, REG_PV, a);
                        M_DLD (d, REG_PV, a);
                        M_CVTLD(d, d);
@@ -1591,8 +1586,8 @@ void codegen(methodinfo *m)
                case ICMD_F2I:       /* ..., value  ==> ..., (int) value              */
                case ICMD_D2I:
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
-                       a = dseg_adddouble(m, 0.0);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
+                       a = dseg_adddouble(cd, 0.0);
                        M_CVTDL_C(s1, REG_FTMP2);
                        M_CVTLI(REG_FTMP2, REG_FTMP3);
                        M_DST (REG_FTMP3, REG_PV, a);
@@ -1603,8 +1598,8 @@ void codegen(methodinfo *m)
                case ICMD_F2L:       /* ..., value  ==> ..., (long) value             */
                case ICMD_D2L:
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
-                       a = dseg_adddouble(m, 0.0);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
+                       a = dseg_adddouble(cd, 0.0);
                        M_CVTDL_C(s1, REG_FTMP2);
                        M_DST (REG_FTMP2, REG_PV, a);
                        M_LLD (d, REG_PV, a);
@@ -1614,7 +1609,7 @@ void codegen(methodinfo *m)
                case ICMD_F2D:       /* ..., value  ==> ..., (double) value           */
 
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        M_CVTFDS(s1, d);
                        M_TRAPB;
                        store_reg_to_var_flt(iptr->dst, d);
@@ -1623,7 +1618,7 @@ void codegen(methodinfo *m)
                case ICMD_D2F:       /* ..., value  ==> ..., (float) value            */
 
                        var_to_reg_flt(s1, src, REG_FTMP1);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (opt_noieee) {
                                M_CVTDF(s1, d);
                                }
@@ -1638,7 +1633,7 @@ void codegen(methodinfo *m)
                case ICMD_DCMPL:
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (opt_noieee) {
                                M_LSUB_IMM(REG_ZERO, 1, d);
                                M_FCMPEQ(s1, s2, REG_FTMP3);
@@ -1666,7 +1661,7 @@ void codegen(methodinfo *m)
                case ICMD_DCMPG:
                        var_to_reg_flt(s1, src->prev, REG_FTMP1);
                        var_to_reg_flt(s2, src, REG_FTMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (opt_noieee) {
                                M_LADD_IMM(REG_ZERO, 1, d);
                                M_FCMPEQ(s1, s2, REG_FTMP3);
@@ -1696,7 +1691,7 @@ void codegen(methodinfo *m)
                case ICMD_ARRAYLENGTH: /* ..., arrayref  ==> ..., length              */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        gen_nullptr_check(s1);
                        M_ILD(d, s1, OFFSET(java_arrayheader, size));
                        store_reg_to_var_int(iptr->dst, d);
@@ -1706,7 +1701,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1720,7 +1715,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1734,7 +1729,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1749,7 +1744,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1763,7 +1758,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_FTMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_FTMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1777,7 +1772,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1801,7 +1796,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -1827,7 +1822,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src->prev, REG_ITMP1);
                        var_to_reg_int(s2, src, REG_ITMP2);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (iptr->op1 == 0) {
                                gen_nullptr_check(s1);
                                gen_bound_check;
@@ -2107,9 +2102,9 @@ void codegen(methodinfo *m)
                        /* if class isn't yet initialized, do it */
                        if (!((fieldinfo *) iptr->val.a)->class->initialized) {
                                /* call helper function which patches this code */
-                               a = dseg_addaddress(m, ((fieldinfo *) iptr->val.a)->class);
+                               a = dseg_addaddress(cd, ((fieldinfo *) iptr->val.a)->class);
                                M_ALD(REG_ITMP1, REG_PV, a);
-                               a = dseg_addaddress(m, asm_check_clinit);
+                               a = dseg_addaddress(cd, asm_check_clinit);
                                M_ALD(REG_PV, REG_PV, a);
                                M_JSR(REG_RA, REG_PV);
 
@@ -2127,7 +2122,7 @@ void codegen(methodinfo *m)
                                }
                        }
                        
-                       a = dseg_addaddress(m, &(((fieldinfo *)(iptr->val.a))->value));
+                       a = dseg_addaddress(cd, &(((fieldinfo *)(iptr->val.a))->value));
                        M_ALD(REG_ITMP1, REG_PV, a);
                        switch (iptr->op1) {
                                case TYPE_INT:
@@ -2160,9 +2155,9 @@ void codegen(methodinfo *m)
                        /* if class isn't yet initialized, do it */
                        if (!((fieldinfo *) iptr->val.a)->class->initialized) {
                                /* call helper function which patches this code */
-                               a = dseg_addaddress(m, ((fieldinfo *) iptr->val.a)->class);
+                               a = dseg_addaddress(cd, ((fieldinfo *) iptr->val.a)->class);
                                M_ALD(REG_ITMP1, REG_PV, a);
-                               a = dseg_addaddress(m, asm_check_clinit);
+                               a = dseg_addaddress(cd, asm_check_clinit);
                                M_ALD(REG_PV, REG_PV, a);
                                M_JSR(REG_RA, REG_PV);
 
@@ -2180,31 +2175,31 @@ void codegen(methodinfo *m)
                                }
                        }
                        
-                       a = dseg_addaddress(m, &(((fieldinfo *) iptr->val.a)->value));
+                       a = dseg_addaddress(cd, &(((fieldinfo *) iptr->val.a)->value));
                        M_ALD(REG_ITMP1, REG_PV, a);
                        switch (iptr->op1) {
                                case TYPE_INT:
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        M_ILD(d, REG_ITMP1, 0);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_LNG:
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        M_LLD(d, REG_ITMP1, 0);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_ADR:
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        M_ALD(d, REG_ITMP1, 0);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_FLT:
-                                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
+                                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
                                        M_FLD(d, REG_ITMP1, 0);
                                        store_reg_to_var_flt(iptr->dst, d);
                                        break;
                                case TYPE_DBL:                          
-                                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
+                                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
                                        M_DLD(d, REG_ITMP1, 0);
                                        store_reg_to_var_flt(iptr->dst, d);
                                        break;
@@ -2259,35 +2254,35 @@ void codegen(methodinfo *m)
                        switch (iptr->op1) {
                                case TYPE_INT:
                                        var_to_reg_int(s1, src, REG_ITMP1);
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        gen_nullptr_check(s1);
                                        M_ILD(d, s1, a);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_LNG:
                                        var_to_reg_int(s1, src, REG_ITMP1);
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        gen_nullptr_check(s1);
                                        M_LLD(d, s1, a);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_ADR:
                                        var_to_reg_int(s1, src, REG_ITMP1);
-                                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                                        gen_nullptr_check(s1);
                                        M_ALD(d, s1, a);
                                        store_reg_to_var_int(iptr->dst, d);
                                        break;
                                case TYPE_FLT:
                                        var_to_reg_int(s1, src, REG_ITMP1);
-                                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
+                                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
                                        gen_nullptr_check(s1);
                                        M_FLD(d, s1, a);
                                        store_reg_to_var_flt(iptr->dst, d);
                                        break;
                                case TYPE_DBL:                          
                                        var_to_reg_int(s1, src, REG_ITMP1);
-                                       d = reg_of_var(m, iptr->dst, REG_FTMP1);
+                                       d = reg_of_var(rd, iptr->dst, REG_FTMP1);
                                        gen_nullptr_check(s1);
                                        M_DLD(d, s1, a);
                                        store_reg_to_var_flt(iptr->dst, d);
@@ -2305,7 +2300,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_INTMOVE(s1, REG_ITMP1_XPTR);
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP2, REG_PV, a);
                        M_JMP(REG_ITMP2_XPC, REG_ITMP2);
                        M_NOP;              /* nop ensures that XPC is less than the end */
@@ -2316,7 +2311,7 @@ void codegen(methodinfo *m)
                case ICMD_GOTO:         /* ... ==> ...                                */
                                        /* op1 = target JavaVM pc                     */
                        M_BR(0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        ALIGNCODENOP;
                        break;
 
@@ -2324,13 +2319,13 @@ void codegen(methodinfo *m)
                                        /* op1 = target JavaVM pc                     */
 
                        M_BSR(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
                        
                case ICMD_RET:          /* ... ==> ...                                */
                                        /* op1 = local variable                       */
 
-                       var = &(r->locals[iptr->op1][TYPE_ADR]);
+                       var = &(rd->locals[iptr->op1][TYPE_ADR]);
                        if (var->flags & INMEMORY) {
                                M_ALD(REG_ITMP1, REG_SP, 8 * var->regoff);
                                M_RET(REG_ZERO, REG_ITMP1);
@@ -2345,7 +2340,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_BEQZ(s1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFNONNULL:    /* ..., value ==> ...                         */
@@ -2353,7 +2348,7 @@ void codegen(methodinfo *m)
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_BNEZ(s1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFEQ:         /* ..., value ==> ...                         */
@@ -2373,7 +2368,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFLT:         /* ..., value ==> ...                         */
@@ -2393,7 +2388,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFLE:         /* ..., value ==> ...                         */
@@ -2413,7 +2408,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFNE:         /* ..., value ==> ...                         */
@@ -2433,7 +2428,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFGT:         /* ..., value ==> ...                         */
@@ -2453,7 +2448,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IFGE:         /* ..., value ==> ...                         */
@@ -2473,7 +2468,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LEQ:       /* ..., value ==> ...                         */
@@ -2493,7 +2488,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LLT:       /* ..., value ==> ...                         */
@@ -2513,7 +2508,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LLE:       /* ..., value ==> ...                         */
@@ -2533,7 +2528,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BNEZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LNE:       /* ..., value ==> ...                         */
@@ -2553,7 +2548,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LGT:       /* ..., value ==> ...                         */
@@ -2573,7 +2568,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_LGE:       /* ..., value ==> ...                         */
@@ -2593,7 +2588,7 @@ void codegen(methodinfo *m)
                                        }
                                M_BEQZ(REG_ITMP1, 0);
                                }
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPEQ:    /* ..., value, value ==> ...                  */
@@ -2604,7 +2599,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPEQ(s1, s2, REG_ITMP1);
                        M_BNEZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPNE:    /* ..., value, value ==> ...                  */
@@ -2615,7 +2610,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPEQ(s1, s2, REG_ITMP1);
                        M_BEQZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPLT:    /* ..., value, value ==> ...                  */
@@ -2625,7 +2620,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPLT(s1, s2, REG_ITMP1);
                        M_BNEZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPGT:    /* ..., value, value ==> ...                  */
@@ -2635,7 +2630,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPLE(s1, s2, REG_ITMP1);
                        M_BEQZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPLE:    /* ..., value, value ==> ...                  */
@@ -2645,7 +2640,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPLE(s1, s2, REG_ITMP1);
                        M_BNEZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                case ICMD_IF_ICMPGE:    /* ..., value, value ==> ...                  */
@@ -2655,7 +2650,7 @@ void codegen(methodinfo *m)
                        var_to_reg_int(s2, src, REG_ITMP2);
                        M_CMPLT(s1, s2, REG_ITMP1);
                        M_BEQZ(REG_ITMP1, 0);
-                       codegen_addreference(m, BlockPtrOfPC(iptr->op1), mcodeptr);
+                       codegen_addreference(cd, BlockPtrOfPC(iptr->op1), mcodeptr);
                        break;
 
                /* (value xx 0) ? IFxx_ICONST : ELSE_ICONST                           */
@@ -2667,7 +2662,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if (iptr[1].opc == ICMD_ELSE_ICONST) {
                                if ((s3 == 1) && (iptr[1].val.i == 0)) {
@@ -2701,7 +2696,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if (iptr[1].opc == ICMD_ELSE_ICONST) {
                                if ((s3 == 0) && (iptr[1].val.i == 1)) {
@@ -2735,7 +2730,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
                                if ((s3 == 1) && (iptr[1].val.i == 0)) {
@@ -2768,7 +2763,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
                                if ((s3 == 1) && (iptr[1].val.i == 0)) {
@@ -2801,7 +2796,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
                                if ((s3 == 1) && (iptr[1].val.i == 0)) {
@@ -2834,7 +2829,7 @@ void codegen(methodinfo *m)
                                        /* val.i = constant                           */
 
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        s3 = iptr->val.i;
                        if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
                                if ((s3 == 1) && (iptr[1].val.i == 0)) {
@@ -2874,14 +2869,14 @@ void codegen(methodinfo *m)
 #if defined(USE_THREADS)
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                                s4 disp;
-                               a = dseg_addaddress(m, (void *) (builtin_monitorexit));
+                               a = dseg_addaddress(cd, (void *) (builtin_monitorexit));
                                M_ALD(REG_PV, REG_PV, a);
-                               M_ALD(r->argintregs[0], REG_SP, r->maxmemuse * 8);
-                               M_LST(REG_RESULT, REG_SP, r->maxmemuse * 8);
+                               M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
+                               M_LST(REG_RESULT, REG_SP, rd->maxmemuse * 8);
                                M_JSR(REG_RA, REG_PV);
                                disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
                                M_LDA(REG_PV, REG_RA, disp);
-                               M_LLD(REG_RESULT, REG_SP, r->maxmemuse * 8);
+                               M_LLD(REG_RESULT, REG_SP, rd->maxmemuse * 8);
                        }
 #endif
 
@@ -2896,14 +2891,14 @@ void codegen(methodinfo *m)
 #if defined(USE_THREADS)
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                                s4 disp;
-                               a = dseg_addaddress(m, (void *) (builtin_monitorexit));
+                               a = dseg_addaddress(cd, (void *) (builtin_monitorexit));
                                M_ALD(REG_PV, REG_PV, a);
-                               M_ALD(r->argintregs[0], REG_SP, r->maxmemuse * 8);
-                               M_DST(REG_FRESULT, REG_SP, r->maxmemuse * 8);
+                               M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
+                               M_DST(REG_FRESULT, REG_SP, rd->maxmemuse * 8);
                                M_JSR(REG_RA, REG_PV);
                                disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
                                M_LDA(REG_PV, REG_RA, disp);
-                               M_DLD(REG_FRESULT, REG_SP, r->maxmemuse * 8);
+                               M_DLD(REG_FRESULT, REG_SP, rd->maxmemuse * 8);
                        }
 #endif
 
@@ -2914,9 +2909,9 @@ void codegen(methodinfo *m)
 #if defined(USE_THREADS)
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                                s4 disp;
-                               a = dseg_addaddress(m, (void *) (builtin_monitorexit));
+                               a = dseg_addaddress(cd, (void *) (builtin_monitorexit));
                                M_ALD(REG_PV, REG_PV, a);
-                               M_ALD(r->argintregs[0], REG_SP, r->maxmemuse * 8);
+                               M_ALD(rd->argintregs[0], REG_SP, rd->maxmemuse * 8);
                                M_JSR(REG_RA, REG_PV);
                                disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase);
                                M_LDA(REG_PV, REG_RA, disp);
@@ -2937,11 +2932,11 @@ nowperformreturn:
 
                        /* restore saved registers                                        */
 
-                       for (i = r->savintregcnt - 1; i >= r->maxsavintreguse; i--) {
-                               p--; M_LLD(r->savintregs[i], REG_SP, p * 8);
+                       for (i = rd->savintregcnt - 1; i >= rd->maxsavintreguse; i--) {
+                               p--; M_LLD(rd->savintregs[i], REG_SP, p * 8);
                        }
-                       for (i = r->savfltregcnt - 1; i >= r->maxsavfltreguse; i--) {
-                               p--; M_DLD(r->savfltregs[i], REG_SP, p * 8);
+                       for (i = rd->savfltregcnt - 1; i >= rd->maxsavfltreguse; i--) {
+                               p--; M_DLD(rd->savfltregs[i], REG_SP, p * 8);
                        }
 
                        /* deallocate stack                                               */
@@ -2957,12 +2952,12 @@ nowperformreturn:
                                M_AST(REG_RA, REG_SP, 0 * 8);
                                M_LST(REG_RESULT, REG_SP, 1 * 8);
                                M_DST(REG_FRESULT, REG_SP, 2 * 8);
-                               a = dseg_addaddress(m, m);
-                               M_ALD(r->argintregs[0], REG_PV, a);
-                               M_MOV(REG_RESULT, r->argintregs[1]);
-                               M_FLTMOVE(REG_FRESULT, r->argfltregs[2]);
-                               M_FLTMOVE(REG_FRESULT, r->argfltregs[3]);
-                               a = dseg_addaddress(m, (void *) builtin_displaymethodstop);
+                               a = dseg_addaddress(cd, m);
+                               M_ALD(rd->argintregs[0], REG_PV, a);
+                               M_MOV(REG_RESULT, rd->argintregs[1]);
+                               M_FLTMOVE(REG_FRESULT, rd->argfltregs[2]);
+                               M_FLTMOVE(REG_FRESULT, rd->argfltregs[3]);
+                               a = dseg_addaddress(cd, (void *) builtin_displaymethodstop);
                                M_ALD(REG_PV, REG_PV, a);
                                M_JSR(REG_RA, REG_PV);
                                s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
@@ -3019,8 +3014,8 @@ nowperformreturn:
                        M_BEQZ(REG_ITMP2, 0);
 
 
-                       /* codegen_addreference(m, BlockPtrOfPC(s4ptr[0]), mcodeptr); */
-                       codegen_addreference(m, (basicblock *) tptr[0], mcodeptr);
+                       /* codegen_addreference(cd, BlockPtrOfPC(s4ptr[0]), mcodeptr); */
+                       codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr);
 
                        /* build jump table top down and use address of lowest entry */
 
@@ -3028,8 +3023,8 @@ nowperformreturn:
                        tptr += i;
 
                        while (--i >= 0) {
-                               /* dseg_addtarget(m, BlockPtrOfPC(*--s4ptr)); */
-                               dseg_addtarget(m, (basicblock *) tptr[0]); 
+                               /* dseg_addtarget(cd, BlockPtrOfPC(*--s4ptr)); */
+                               dseg_addtarget(cd, (basicblock *) tptr[0]); 
                                --tptr;
                                }
                        }
@@ -3069,21 +3064,21 @@ nowperformreturn:
                                                M_LDA(REG_ITMP2, REG_ZERO, val);
                                                } 
                                        else {
-                                               a = dseg_adds4(m, val);
+                                               a = dseg_adds4(cd, val);
                                                M_ILD(REG_ITMP2, REG_PV, a);
                                                }
                                        M_CMPEQ(s1, REG_ITMP2, REG_ITMP2);
                                        }
                                M_BNEZ(REG_ITMP2, 0);
-                               /* codegen_addreference(m, BlockPtrOfPC(s4ptr[1]), mcodeptr); */
-                               codegen_addreference(m, (basicblock *) tptr[0], mcodeptr); 
+                               /* codegen_addreference(cd, BlockPtrOfPC(s4ptr[1]), mcodeptr); */
+                               codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr); 
                                }
 
                        M_BR(0);
-                       /* codegen_addreference(m, BlockPtrOfPC(l), mcodeptr); */
+                       /* codegen_addreference(cd, BlockPtrOfPC(l), mcodeptr); */
                        
                        tptr = (void **) iptr->target;
-                       codegen_addreference(m, (basicblock *) tptr[0], mcodeptr);
+                       codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr);
 
                        ALIGNCODENOP;
                        break;
@@ -3131,7 +3126,7 @@ gen_method: {
                                        continue;
                                if (IS_INT_LNG_TYPE(src->type)) {
                                        if (s3 < INT_ARG_CNT) {
-                                               s1 = r->argintregs[s3];
+                                               s1 = rd->argintregs[s3];
                                                var_to_reg_int(d, src, s1);
                                                M_INTMOVE(d, s1);
 
@@ -3142,7 +3137,7 @@ gen_method: {
 
                                } else {
                                        if (s3 < FLT_ARG_CNT) {
-                                               s1 = r->argfltregs[s3];
+                                               s1 = rd->argfltregs[s3];
                                                var_to_reg_flt(d, src, s1);
                                                M_FLTMOVE(d, s1);
 
@@ -3158,7 +3153,7 @@ gen_method: {
                        case ICMD_BUILTIN3:
                        case ICMD_BUILTIN2:
                        case ICMD_BUILTIN1:
-                               a = dseg_addaddress(m, (void *) lm);
+                               a = dseg_addaddress(cd, (void *) lm);
                                d = iptr->op1;
 
                                M_ALD(REG_PV, REG_PV, a);     /* Pointer to built-in-function */
@@ -3166,7 +3161,7 @@ gen_method: {
 
                        case ICMD_INVOKESTATIC:
                        case ICMD_INVOKESPECIAL:
-                               a = dseg_addaddress(m, lm->stubroutine);
+                               a = dseg_addaddress(cd, lm->stubroutine);
                                d = lm->returntype;
 
                                M_ALD(REG_PV, REG_PV, a);            /* method pointer in r27 */
@@ -3175,8 +3170,8 @@ gen_method: {
                        case ICMD_INVOKEVIRTUAL:
                                d = lm->returntype;
 
-                               gen_nullptr_check(r->argintregs[0]);
-                               M_ALD(REG_METHODPTR, r->argintregs[0],
+                               gen_nullptr_check(rd->argintregs[0]);
+                               M_ALD(REG_METHODPTR, rd->argintregs[0],
                                          OFFSET(java_objectheader, vftbl));
                                M_ALD(REG_PV, REG_METHODPTR, OFFSET(vftbl_t, table[0]) +
                                          sizeof(methodptr) * lm->vftblindex);
@@ -3185,8 +3180,8 @@ gen_method: {
                        case ICMD_INVOKEINTERFACE:
                                d = lm->returntype;
                                        
-                               gen_nullptr_check(r->argintregs[0]);
-                               M_ALD(REG_METHODPTR, r->argintregs[0],
+                               gen_nullptr_check(rd->argintregs[0]);
+                               M_ALD(REG_METHODPTR, rd->argintregs[0],
                                          OFFSET(java_objectheader, vftbl));    
                                M_ALD(REG_METHODPTR, REG_METHODPTR,
                                          OFFSET(vftbl_t, interfacetable[0]) -
@@ -3213,12 +3208,12 @@ gen_method: {
 
                        if (d != TYPE_VOID) {
                                if (IS_INT_LNG_TYPE(iptr->dst->type)) {
-                                       s1 = reg_of_var(m, iptr->dst, REG_RESULT);
+                                       s1 = reg_of_var(rd, iptr->dst, REG_RESULT);
                                        M_INTMOVE(REG_RESULT, s1);
                                        store_reg_to_var_int(iptr->dst, s1);
 
                                } else {
-                                       s1 = reg_of_var(m, iptr->dst, REG_FRESULT);
+                                       s1 = reg_of_var(rd, iptr->dst, REG_FRESULT);
                                        M_FLTMOVE(REG_FRESULT, s1);
                                        store_reg_to_var_flt(iptr->dst, s1);
                                }
@@ -3249,10 +3244,10 @@ gen_method: {
                        classinfo *super = (classinfo*) iptr->val.a;
                        
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                       codegen_threadcritrestart(m, (u1 *) mcodeptr - cd->mcodebase);
+                       codegen_threadcritrestart(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                        var_to_reg_int(s1, src, REG_ITMP1);
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        if (s1 == d) {
                                M_MOV(s1, REG_ITMP1);
                                s1 = REG_ITMP1;
@@ -3286,16 +3281,16 @@ gen_method: {
 */
                                        M_BEQZ(s1, 7);
                                        M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
-                                       a = dseg_addaddress(m, (void*) super->vftbl);
+                                       a = dseg_addaddress(cd, (void*) super->vftbl);
                                        M_ALD(REG_ITMP2, REG_PV, a);
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                                       codegen_threadcritstart(m, (u1 *) mcodeptr - cd->mcodebase);
+                                       codegen_threadcritstart(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                                        M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                        M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                        M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                                       codegen_threadcritstop(m, (u1 *) mcodeptr - cd->mcodebase);
+                                       codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                                        M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                        M_CMPULE(REG_ITMP1, REG_ITMP2, d);
@@ -3329,9 +3324,9 @@ gen_method: {
                        classinfo *super = (classinfo *) iptr->val.a;
                        
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                       codegen_threadcritrestart(m, (u1 *) mcodeptr - cd->mcodebase);
+                       codegen_threadcritrestart(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
-                       d = reg_of_var(m, iptr->dst, REG_ITMP3);
+                       d = reg_of_var(rd, iptr->dst, REG_ITMP3);
                        var_to_reg_int(s1, src, d);
                        if (iptr->op1) {                               /* class/interface */
                                if (super->flags & ACC_INTERFACE) {        /* interface       */
@@ -3340,12 +3335,12 @@ gen_method: {
                                        M_ILD(REG_ITMP2, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength));
                                        M_LDA(REG_ITMP2, REG_ITMP2, - super->index);
                                        M_BLEZ(REG_ITMP2, 0);
-                                       codegen_addxcastrefs(m, mcodeptr);
+                                       codegen_addxcastrefs(cd, mcodeptr);
                                        M_ALD(REG_ITMP2, REG_ITMP1,
                                              OFFSET(vftbl_t, interfacetable[0]) -
                                              super->index * sizeof(methodptr*));
                                        M_BEQZ(REG_ITMP2, 0);
-                                       codegen_addxcastrefs(m, mcodeptr);
+                                       codegen_addxcastrefs(cd, mcodeptr);
                                        }
                                else {                                     /* class           */
 /*
@@ -3369,17 +3364,17 @@ gen_method: {
 */
                                        M_BEQZ(s1, 8 + (d == REG_ITMP3));
                                        M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
-                                       a = dseg_addaddress(m, (void *) super->vftbl);
+                                       a = dseg_addaddress(cd, (void *) super->vftbl);
                                        M_ALD(REG_ITMP2, REG_PV, a);
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                                       codegen_threadcritstart(m, (u1 *) mcodeptr - cd->mcodebase);
+                                       codegen_threadcritstart(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                                        M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                        if (d != REG_ITMP3) {
                                                M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                                               codegen_threadcritstop(m, (u1 *) mcodeptr - cd->mcodebase);
+                                               codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                                                M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                                }
@@ -3389,12 +3384,12 @@ gen_method: {
                                                M_ALD(REG_ITMP2, REG_PV, a);
                                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                                               codegen_threadcritstop(m, (u1 *) mcodeptr - cd->mcodebase);
+                                               codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase);
 #endif
                                                }
                                        M_CMPULE(REG_ITMP1, REG_ITMP2, REG_ITMP2);
                                        M_BEQZ(REG_ITMP2, 0);
-                                       codegen_addxcastrefs(m, mcodeptr);
+                                       codegen_addxcastrefs(cd, mcodeptr);
                                        }
                                }
                        else
@@ -3408,13 +3403,13 @@ gen_method: {
 
                        var_to_reg_int(s1, src, REG_ITMP1);
                        M_BLTZ(s1, 0);
-                       codegen_addxcheckarefs(m, mcodeptr);
+                       codegen_addxcheckarefs(cd, mcodeptr);
                        break;
 
                case ICMD_CHECKEXCEPTION:    /* ... ==> ...                           */
 
                        M_BEQZ(REG_RESULT, 0);
-                       codegen_addxexceptionrefs(m, mcodeptr);
+                       codegen_addxexceptionrefs(cd, mcodeptr);
                        break;
 
                case ICMD_MULTIANEWARRAY:/* ..., cnt1, [cnt2, ...] ==> ..., arrayref  */
@@ -3427,7 +3422,7 @@ gen_method: {
                        for (s1 = iptr->op1; --s1 >= 0; src = src->prev) {
                                var_to_reg_int(s2, src, REG_ITMP1);
                                M_BLTZ(s2, 0);
-                               codegen_addxcheckarefs(m, mcodeptr);
+                               codegen_addxcheckarefs(cd, mcodeptr);
 
                                /* copy sizes to stack (argument numbers >= INT_ARG_CNT)      */
 
@@ -3438,18 +3433,18 @@ gen_method: {
 
                        /* a0 = dimension count */
 
-                       ICONST(r->argintregs[0], iptr->op1);
+                       ICONST(rd->argintregs[0], iptr->op1);
 
                        /* a1 = arraydescriptor */
 
-                       a = dseg_addaddress(m, iptr->val.a);
-                       M_ALD(r->argintregs[1], REG_PV, a);
+                       a = dseg_addaddress(cd, iptr->val.a);
+                       M_ALD(rd->argintregs[1], REG_PV, a);
 
                        /* a2 = pointer to dimensions = stack pointer */
 
-                       M_INTMOVE(REG_SP, r->argintregs[2]);
+                       M_INTMOVE(REG_SP, rd->argintregs[2]);
 
-                       a = dseg_addaddress(m, (void *) builtin_nmultianewarray);
+                       a = dseg_addaddress(cd, (void *) builtin_nmultianewarray);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
                        s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
@@ -3461,7 +3456,7 @@ gen_method: {
                                M_LDA(REG_PV, REG_RA, ml);
                                M_LDAH(REG_PV, REG_PV, mh);
                        }
-                       s1 = reg_of_var(m, iptr->dst, REG_RESULT);
+                       s1 = reg_of_var(rd, iptr->dst, REG_RESULT);
                        M_INTMOVE(REG_RESULT, s1);
                        store_reg_to_var_int(iptr->dst, s1);
                        break;
@@ -3486,20 +3481,20 @@ gen_method: {
                        s2 = src->type;
                        if (IS_FLT_DBL_TYPE(s2)) {
                                var_to_reg_flt(s1, src, REG_FTMP1);
-                               if (!(r->interfaces[len][s2].flags & INMEMORY)) {
-                                       M_FLTMOVE(s1,r->interfaces[len][s2].regoff);
+                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+                                       M_FLTMOVE(s1,rd->interfaces[len][s2].regoff);
                                        }
                                else {
-                                       M_DST(s1, REG_SP, 8 * r->interfaces[len][s2].regoff);
+                                       M_DST(s1, REG_SP, 8 * rd->interfaces[len][s2].regoff);
                                        }
                                }
                        else {
                                var_to_reg_int(s1, src, REG_ITMP1);
-                               if (!(r->interfaces[len][s2].flags & INMEMORY)) {
-                                       M_INTMOVE(s1,r->interfaces[len][s2].regoff);
+                               if (!(rd->interfaces[len][s2].flags & INMEMORY)) {
+                                       M_INTMOVE(s1,rd->interfaces[len][s2].regoff);
                                        }
                                else {
-                                       M_LST(s1, REG_SP, 8 * r->interfaces[len][s2].regoff);
+                                       M_LST(s1, REG_SP, 8 * rd->interfaces[len][s2].regoff);
                                        }
                                }
                        }
@@ -3534,11 +3529,11 @@ gen_method: {
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       a = dseg_addaddress(m, string_java_lang_ArrayIndexOutOfBoundsException);
-                       M_ALD(r->argintregs[0], REG_PV, a);
-                       M_MOV(REG_ITMP1, r->argintregs[1]);
+                       a = dseg_addaddress(cd, string_java_lang_ArrayIndexOutOfBoundsException);
+                       M_ALD(rd->argintregs[0], REG_PV, a);
+                       M_MOV(REG_ITMP1, rd->argintregs[1]);
 
-                       a = dseg_addaddress(m, new_exception_int);
+                       a = dseg_addaddress(cd, new_exception_int);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
 
@@ -3557,7 +3552,7 @@ gen_method: {
                        M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
                        M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
 
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP3, REG_PV, a);
 
                        M_JMP(REG_ZERO, REG_ITMP3);
@@ -3593,10 +3588,10 @@ gen_method: {
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       a = dseg_addaddress(m, string_java_lang_NegativeArraySizeException);
-                       M_ALD(r->argintregs[0], REG_PV, a);
+                       a = dseg_addaddress(cd, string_java_lang_NegativeArraySizeException);
+                       M_ALD(rd->argintregs[0], REG_PV, a);
 
-                       a = dseg_addaddress(m, new_exception);
+                       a = dseg_addaddress(cd, new_exception);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
 
@@ -3615,7 +3610,7 @@ gen_method: {
                        M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
                        M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
 
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP3, REG_PV, a);
 
                        M_JMP(REG_ZERO, REG_ITMP3);
@@ -3651,10 +3646,10 @@ gen_method: {
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       a = dseg_addaddress(m, string_java_lang_ClassCastException);
-                       M_ALD(r->argintregs[0], REG_PV, a);
+                       a = dseg_addaddress(cd, string_java_lang_ClassCastException);
+                       M_ALD(rd->argintregs[0], REG_PV, a);
 
-                       a = dseg_addaddress(m, new_exception);
+                       a = dseg_addaddress(cd, new_exception);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
 
@@ -3673,7 +3668,7 @@ gen_method: {
                        M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
                        M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
 
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP3, REG_PV, a);
 
                        M_JMP(REG_ZERO, REG_ITMP3);
@@ -3710,7 +3705,7 @@ gen_method: {
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       a = dseg_addaddress(m, &builtin_get_exceptionptrptr);
+                       a = dseg_addaddress(cd, &builtin_get_exceptionptrptr);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
 
@@ -3730,13 +3725,13 @@ gen_method: {
                        M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
                        M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
 #else
-                       a = dseg_addaddress(m, &_exceptionptr);
+                       a = dseg_addaddress(cd, &_exceptionptr);
                        M_ALD(REG_ITMP3, REG_PV, a);
                        M_ALD(REG_ITMP1_XPTR, REG_ITMP3, 0);
                        M_AST(REG_ZERO, REG_ITMP3, 0);
 #endif
 
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP3, REG_PV, a);
 
                        M_JMP(REG_ZERO, REG_ITMP3);
@@ -3772,10 +3767,10 @@ gen_method: {
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       a = dseg_addaddress(m, string_java_lang_NullPointerException);
-                       M_ALD(r->argintregs[0], REG_PV, a);
+                       a = dseg_addaddress(cd, string_java_lang_NullPointerException);
+                       M_ALD(rd->argintregs[0], REG_PV, a);
 
-                       a = dseg_addaddress(m, new_exception);
+                       a = dseg_addaddress(cd, new_exception);
                        M_ALD(REG_PV, REG_PV, a);
                        M_JSR(REG_RA, REG_PV);
 
@@ -3794,7 +3789,7 @@ gen_method: {
                        M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
                        M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
 
-                       a = dseg_addaddress(m, asm_handle_exception);
+                       a = dseg_addaddress(cd, asm_handle_exception);
                        M_ALD(REG_ITMP3, REG_PV, a);
 
                        M_JMP(REG_ZERO, REG_ITMP3);
@@ -3802,7 +3797,7 @@ gen_method: {
        }
        }
 
-       codegen_finish(m, (s4) ((u1 *) mcodeptr - cd->mcodebase));
+       codegen_finish(m, cd, (s4) ((u1 *) mcodeptr - cd->mcodebase));
 }
 
 
@@ -3874,11 +3869,21 @@ u1 *createnativestub(functionptr f, methodinfo *m)
        s4 stackframesize = 0;              /* size of stackframe if needed       */
        s4 disp;
        s4 stubsize;
-       registerdata *r;
+       s4 dumpsize;
+       registerdata *rd;
+       t_inlining_globals *id;
+
+       /* mark start of dump memory area */
 
-       /* keep code size smaller */
-       reg_init(m);
-       r = m->registerdata;
+       dumpsize = dump_size();
+
+       /* setup registers before using it */
+       
+       rd = DNEW(registerdata);
+       id = DNEW(t_inlining_globals);
+
+       inlining_setup(m, id);
+       reg_setup(m, rd, id);
 
        descriptor2types(m);                /* set paramcount and paramtypes      */
 
@@ -3934,7 +3939,7 @@ u1 *createnativestub(functionptr f, methodinfo *m)
 
                /* save integer argument registers */
                for (p = 0; p < m->paramcount && p < INT_ARG_CNT; p++) {
-                       M_LST(r->argintregs[p], REG_SP, (2 + p) * 8);
+                       M_LST(rd->argintregs[p], REG_SP, (2 + p) * 8);
                }
 
                /* save and copy float arguments into integer registers */
@@ -3943,16 +3948,16 @@ u1 *createnativestub(functionptr f, methodinfo *m)
 
                        if (IS_FLT_DBL_TYPE(t)) {
                                if (IS_2_WORD_TYPE(t)) {
-                                       M_DST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
-                                       M_LLD(r->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_LLD(rd->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
 
                                } else {
-                                       M_FST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
-                                       M_ILD(r->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_FST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_ILD(rd->argintregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                                }
                                
                        } else {
-                               M_DST(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                               M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                        }
                }
 
@@ -3964,7 +3969,7 @@ u1 *createnativestub(functionptr f, methodinfo *m)
                M_LDA(REG_PV, REG_RA, disp);
 
                for (p = 0; p < m->paramcount && p < INT_ARG_CNT; p++) {
-                       M_LLD(r->argintregs[p], REG_SP, (2 + p) * 8);
+                       M_LLD(rd->argintregs[p], REG_SP, (2 + p) * 8);
                }
 
                for (p = 0; p < m->paramcount && p < FLT_ARG_CNT; p++) {
@@ -3972,14 +3977,14 @@ u1 *createnativestub(functionptr f, methodinfo *m)
 
                        if (IS_FLT_DBL_TYPE(t)) {
                                if (IS_2_WORD_TYPE(t)) {
-                                       M_DLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
 
                                } else {
-                                       M_FLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                                       M_FLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                                }
 
                        } else {
-                               M_DLD(r->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
+                               M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
                        }
                }
 
@@ -4005,54 +4010,54 @@ u1 *createnativestub(functionptr f, methodinfo *m)
 
                if (m->flags & ACC_STATIC) {
                        if (IS_FLT_DBL_TYPE(m->paramtypes[5])) {
-                               M_DST(r->argfltregs[5], REG_SP, 1 * 8);
+                               M_DST(rd->argfltregs[5], REG_SP, 1 * 8);
                        } else {
-                               M_LST(r->argintregs[5], REG_SP, 1 * 8);
+                               M_LST(rd->argintregs[5], REG_SP, 1 * 8);
                        }
 
                        if (IS_FLT_DBL_TYPE(m->paramtypes[4])) {
-                               M_DST(r->argfltregs[4], REG_SP, 0 * 8);
+                               M_DST(rd->argfltregs[4], REG_SP, 0 * 8);
                        } else {
-                               M_LST(r->argintregs[4], REG_SP, 0 * 8);
+                               M_LST(rd->argintregs[4], REG_SP, 0 * 8);
                        }
 
                } else {
                        if (IS_FLT_DBL_TYPE(m->paramtypes[5])) {
-                               M_DST(r->argfltregs[5], REG_SP, 0 * 8);
+                               M_DST(rd->argfltregs[5], REG_SP, 0 * 8);
                        } else {
-                               M_LST(r->argintregs[5], REG_SP, 0 * 8);
+                               M_LST(rd->argintregs[5], REG_SP, 0 * 8);
                        }
                }
        }
 
        if (m->flags & ACC_STATIC) {
-               M_MOV(r->argintregs[3], r->argintregs[5]);
-               M_MOV(r->argintregs[2], r->argintregs[4]);
-               M_MOV(r->argintregs[1], r->argintregs[3]);
-               M_MOV(r->argintregs[0], r->argintregs[2]);
-               M_FMOV(r->argfltregs[3], r->argfltregs[5]);
-               M_FMOV(r->argfltregs[2], r->argfltregs[4]);
-               M_FMOV(r->argfltregs[1], r->argfltregs[3]);
-               M_FMOV(r->argfltregs[0], r->argfltregs[2]);
+               M_MOV(rd->argintregs[3], rd->argintregs[5]);
+               M_MOV(rd->argintregs[2], rd->argintregs[4]);
+               M_MOV(rd->argintregs[1], rd->argintregs[3]);
+               M_MOV(rd->argintregs[0], rd->argintregs[2]);
+               M_FMOV(rd->argfltregs[3], rd->argfltregs[5]);
+               M_FMOV(rd->argfltregs[2], rd->argfltregs[4]);
+               M_FMOV(rd->argfltregs[1], rd->argfltregs[3]);
+               M_FMOV(rd->argfltregs[0], rd->argfltregs[2]);
 
                /* put class into second argument register */
-               M_ALD(r->argintregs[1], REG_PV, -8 * 8);
+               M_ALD(rd->argintregs[1], REG_PV, -8 * 8);
 
        } else {
-               M_MOV(r->argintregs[4], r->argintregs[5]);
-               M_MOV(r->argintregs[3], r->argintregs[4]);
-               M_MOV(r->argintregs[2], r->argintregs[3]);
-               M_MOV(r->argintregs[1], r->argintregs[2]);
-               M_MOV(r->argintregs[0], r->argintregs[1]);
-               M_FMOV(r->argfltregs[4], r->argfltregs[5]);
-               M_FMOV(r->argfltregs[3], r->argfltregs[4]);
-               M_FMOV(r->argfltregs[2], r->argfltregs[3]);
-               M_FMOV(r->argfltregs[1], r->argfltregs[2]);
-               M_FMOV(r->argfltregs[0], r->argfltregs[1]);
+               M_MOV(rd->argintregs[4], rd->argintregs[5]);
+               M_MOV(rd->argintregs[3], rd->argintregs[4]);
+               M_MOV(rd->argintregs[2], rd->argintregs[3]);
+               M_MOV(rd->argintregs[1], rd->argintregs[2]);
+               M_MOV(rd->argintregs[0], rd->argintregs[1]);
+               M_FMOV(rd->argfltregs[4], rd->argfltregs[5]);
+               M_FMOV(rd->argfltregs[3], rd->argfltregs[4]);
+               M_FMOV(rd->argfltregs[2], rd->argfltregs[3]);
+               M_FMOV(rd->argfltregs[1], rd->argfltregs[2]);
+               M_FMOV(rd->argfltregs[0], rd->argfltregs[1]);
        }
 
        /* put env into first argument register */
-       M_ALD(r->argintregs[0], REG_PV, -4 * 8);
+       M_ALD(rd->argintregs[0], REG_PV, -4 * 8);
 
        M_ALD(REG_PV, REG_PV, -1 * 8);      /* load adress of native method       */
        M_JSR(REG_RA, REG_PV);              /* call native method                 */
@@ -4067,12 +4072,12 @@ u1 *createnativestub(functionptr f, methodinfo *m)
        /* 13 instructions */
        if (runverbose) {
                M_LDA(REG_SP, REG_SP, -2 * 8);
-               M_ALD(r->argintregs[0], REG_PV, -6 * 8); /* load method adress        */
+               M_ALD(rd->argintregs[0], REG_PV, -6 * 8); /* load method adress       */
                M_LST(REG_RESULT, REG_SP, 0 * 8);
                M_DST(REG_FRESULT, REG_SP, 1 * 8);
-               M_MOV(REG_RESULT, r->argintregs[1]);
-               M_FMOV(REG_FRESULT, r->argfltregs[2]);
-               M_FMOV(REG_FRESULT, r->argfltregs[3]);
+               M_MOV(REG_RESULT, rd->argintregs[1]);
+               M_FMOV(REG_FRESULT, rd->argfltregs[2]);
+               M_FMOV(REG_FRESULT, rd->argfltregs[3]);
                M_ALD(REG_PV, REG_PV, -7 * 8);  /* builtin_displaymethodstop          */
                M_JSR(REG_RA, REG_PV);
                disp = -(s4) (mcodeptr - (s4 *) cs) * 4;
@@ -4123,6 +4128,10 @@ u1 *createnativestub(functionptr f, methodinfo *m)
                count_nstub_len += NATIVESTUBSIZE * 8;
 #endif
 
+       /* release dump area */
+
+       dump_release(dumpsize);
+
        return (u1 *) (s + NATIVESTUBOFFSET);
 }
 
index 83af6b005cae7ab269e7829a0153541de58c917a..98ceed5102c58dcfae313408d5ace6f9002bd9c3 100644 (file)
@@ -28,7 +28,7 @@
    Authors: Andreas Krall
             Reinhard Grafl
 
-   $Id: codegen.h 1347 2004-07-21 23:29:39Z twisti $
+   $Id: codegen.h 1468 2004-11-08 13:29:58Z twisti $
 
 */
 
@@ -98,7 +98,7 @@
 #define gen_nullptr_check(objreg) \
     if (checknull) { \
         M_BEQZ((objreg), 0); \
-        codegen_addxnullrefs(m, mcodeptr); \
+        codegen_addxnullrefs(cd, mcodeptr); \
     }
 
 #define gen_bound_check \
         M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
         M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\
         M_BEQZ(REG_ITMP3, 0);\
-        codegen_addxboundrefs(m, mcodeptr, s2); \
+        codegen_addxboundrefs(cd, mcodeptr, s2); \
     }
 
 
 
 #define MCODECHECK(icnt) \
        if ((mcodeptr + (icnt)) > cd->mcodeend) \
-        mcodeptr = codegen_increase(m, (u1 *) mcodeptr)
+        mcodeptr = codegen_increase(cd, (u1 *) mcodeptr)
 
 /* M_INTMOVE:
      generates an integer-move from register a to b.
 */
 
 #define var_to_reg_int(regnr,v,tempnr) { \
-       if ((v)->flags & INMEMORY) \
-               {COUNT_SPILLS;M_LLD(tempnr,REG_SP,8*(v)->regoff);regnr=tempnr;} \
-       else regnr=(v)->regoff; \
+       if ((v)->flags & INMEMORY) { \
+               COUNT_SPILLS; \
+        M_LLD(tempnr, REG_SP, 8 * (v)->regoff); \
+        regnr = tempnr; \
+    } else regnr = (v)->regoff; \
 }
 
 
 #define var_to_reg_flt(regnr,v,tempnr) { \
-       if ((v)->flags & INMEMORY) \
-               {COUNT_SPILLS;M_DLD(tempnr,REG_SP,8*(v)->regoff);regnr=tempnr;} \
-       else regnr=(v)->regoff; \
+       if ((v)->flags & INMEMORY) { \
+               COUNT_SPILLS; \
+        M_DLD(tempnr, REG_SP, 8 * (v)->regoff); \
+        regnr = tempnr; \
+    } else regnr = (v)->regoff; \
 }
 
 
 
 
 #define M_COPY(from,to) \
-       d = reg_of_var(m, to, REG_IFTMP); \
+       d = reg_of_var(rd, to, REG_IFTMP); \
        if ((from->regoff != to->regoff) || \
            ((from->flags ^ to->flags) & INMEMORY)) { \
                if (IS_FLT_DBL_TYPE(from->type)) { \
     if ((c) >= -32768 && (c) <= 32767) { \
         M_LDA((r), REG_ZERO, c); \
     } else { \
-        a = dseg_adds4(m, (c)); \
+        a = dseg_adds4(cd, (c)); \
         M_ILD((r), REG_PV, a); \
     }
 
     if ((c) >= -32768 && (c) <= 32767) { \
         M_LDA((r), REG_ZERO, (c)); \
     } else { \
-        a = dseg_adds8(m, (c)); \
+        a = dseg_adds8(cd, (c)); \
         M_LLD((r), REG_PV, a); \
     }
 
 
 *******************************************************************************/
 
-#define gen_resolvebranch(ip,so,to) ((s4*)(ip))[-1]|=((s4)(to)-(so))>>2&0x1fffff
+#define gen_resolvebranch(ip,so,to) \
+    ((s4 *) (ip))[-1] |= ((s4) (to) - (so)) >> 2 & 0x1fffff
 
-#define SOFTNULLPTRCHECK       /* soft null pointer check supportet as option */
 
 /* function prototypes */