Merged changes from trunk.
[cacao.git] / src / vm / jit / alpha / codegen.c
index f000b038fdec75b4b242ec9c4539d220988ef544..71a9f5095c6703e6d5b34a880fa44134f50532c0 100644 (file)
@@ -32,7 +32,7 @@
             Christian Ullrich
             Edwin Steiner
 
-   $Id: codegen.c 5266 2006-08-23 12:57:41Z twisti $
+   $Id: codegen.c 5323 2006-09-05 16:45:24Z edwin $
 
 */
 
@@ -128,21 +128,21 @@ bool codegen(jitdata *jd)
        savedregs_num += (INT_SAV_CNT - rd->savintreguse);
        savedregs_num += (FLT_SAV_CNT - rd->savfltreguse);
 
-       jd->stackframesize = rd->memuse + savedregs_num;
+       cd->stackframesize = rd->memuse + savedregs_num;
 
 #if defined(ENABLE_THREADS)        /* space to save argument of monitor_enter */
        if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               jd->stackframesize++;
+               cd->stackframesize++;
 #endif
 
        /* create method header */
 
 #if 0
-       jd->stackframesize = (jd->stackframesize + 1) & ~1; /* align stack to 16-bytes */
+       cd->stackframesize = (cd->stackframesize + 1) & ~1; /* align stack to 16-bytes */
 #endif
 
        (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
-       (void) dseg_add_unique_s4(cd, jd->stackframesize * 8); /* FrameSize       */
+       (void) dseg_add_unique_s4(cd, cd->stackframesize * 8); /* FrameSize       */
 
 #if defined(ENABLE_THREADS)
        /* IsSync contains the offset relative to the stack pointer for the
@@ -176,12 +176,12 @@ bool codegen(jitdata *jd)
        
        /* create stack frame (if necessary) */
 
-       if (jd->stackframesize)
-               M_LDA(REG_SP, REG_SP, -(jd->stackframesize * 8));
+       if (cd->stackframesize)
+               M_LDA(REG_SP, REG_SP, -(cd->stackframesize * 8));
 
        /* save return address and used callee saved registers */
 
-       p = jd->stackframesize;
+       p = cd->stackframesize;
        if (!jd->isleafmethod) {
                p--; M_AST(REG_RA, REG_SP, p * 8);
        }
@@ -217,10 +217,10 @@ bool codegen(jitdata *jd)
 
                        } else {                                 /* stack arguments       */
                                if (!(var->flags & INMEMORY)) {      /* stack arg -> register */
-                                       M_LLD(var->regoff, REG_SP, (jd->stackframesize + s1) * 8);
+                                       M_LLD(var->regoff, REG_SP, (cd->stackframesize + s1) * 8);
 
                                } else {                             /* stack arg -> spilled  */
-                                       var->regoff = jd->stackframesize + s1;
+                                       var->regoff = cd->stackframesize + s1;
                                }
                        }
 
@@ -236,10 +236,10 @@ bool codegen(jitdata *jd)
 
                        } else {                                 /* stack arguments       */
                                if (!(var->flags & INMEMORY)) {      /* stack-arg -> register */
-                                       M_DLD(var->regoff, REG_SP, (jd->stackframesize + s1) * 8);
+                                       M_DLD(var->regoff, REG_SP, (cd->stackframesize + s1) * 8);
 
                                } else {                             /* stack-arg -> spilled  */
-                                       var->regoff = jd->stackframesize + s1;
+                                       var->regoff = cd->stackframesize + s1;
                                }
                        }
                }
@@ -302,71 +302,9 @@ bool codegen(jitdata *jd)
        /* call trace function */
 
 #if !defined(NDEBUG)
-       if (opt_verbosecall) {
-               M_LDA(REG_SP, REG_SP, -((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8));
-               M_AST(REG_RA, REG_SP, 1 * 8);
-
-               /* save integer argument registers */
-
-               for (p = 0; p < md->paramcount && p < INT_ARG_CNT; p++)
-                       M_LST(rd->argintregs[p], REG_SP, (2 + p) * 8);
-
-               /* save and copy float arguments into integer registers */
-
-               for (p = 0; p < md->paramcount && p < FLT_ARG_CNT; p++) {
-                       t = md->paramtypes[p].type;
-
-                       if (IS_FLT_DBL_TYPE(t)) {
-                               if (IS_2_WORD_TYPE(t)) {
-                                       M_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
-
-                               } else {
-                                       M_FST(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_DST(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
-                       }
-               }
-
-               disp = dseg_add_address(cd, m);
-               M_ALD(REG_ITMP1, REG_PV, disp);
-               M_AST(REG_ITMP1, REG_SP, 0 * 8);
-               disp = dseg_add_functionptr(cd, builtin_trace_args);
-               M_ALD(REG_PV, REG_PV, disp);
-               M_JSR(REG_RA, REG_PV);
-               disp = (s4) (cd->mcodeptr - cd->mcodebase);
-               M_LDA(REG_PV, REG_RA, -disp);
-               M_ALD(REG_RA, REG_SP, 1 * 8);
-
-               /* restore integer argument registers */
-
-               for (p = 0; p < md->paramcount && p < INT_ARG_CNT; p++)
-                       M_LLD(rd->argintregs[p], REG_SP, (2 + p) * 8);
-
-               /* restore float argument registers */
-
-               for (p = 0; p < md->paramcount && p < FLT_ARG_CNT; p++) {
-                       t = md->paramtypes[p].type;
-
-                       if (IS_FLT_DBL_TYPE(t)) {
-                               if (IS_2_WORD_TYPE(t)) {
-                                       M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
-
-                               } else {
-                                       M_FLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
-                               }
-
-                       } else {
-                               M_DLD(rd->argfltregs[p], REG_SP, (2 + INT_ARG_CNT + p) * 8);
-                       }
-               }
-
-               M_LDA(REG_SP, REG_SP, (INT_ARG_CNT + FLT_ARG_CNT + 2) * 8);
-       }
-#endif /* !defined(NDEBUG) */
+       if (JITDATA_HAS_FLAG_VERBOSECALL(jd))
+               emit_verbosecall_enter(jd);
+#endif
 
        }
 
@@ -538,7 +476,8 @@ bool codegen(jitdata *jd)
                                   resolved the same class, the returned displacement
                                   of dseg_addaddress is ok to use. */
 
-                               codegen_addpatchref(cd, PATCHER_aconst, cr, disp);
+                               codegen_addpatchref(cd, PATCHER_resolve_classref_to_classinfo,
+                                                                       cr, disp);
 
                                if (opt_showdisassemble)
                                        M_NOP;
@@ -2062,7 +2001,8 @@ bool codegen(jitdata *jd)
                                disp = dseg_add_address(cd, &(fi->value));
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
-                                       codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0);
+                                       codegen_addpatchref(cd, PATCHER_initialize_class, fi->class,
+                                                                               0);
 
                                        if (opt_showdisassemble)
                                                M_NOP;
@@ -2114,7 +2054,8 @@ bool codegen(jitdata *jd)
                                disp = dseg_add_address(cd, &(fi->value));
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
-                                       codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0);
+                                       codegen_addpatchref(cd, PATCHER_initialize_class, fi->class,
+                                                                               0);
 
                                        if (opt_showdisassemble)
                                                M_NOP;
@@ -2124,24 +2065,24 @@ bool codegen(jitdata *jd)
                        M_ALD(REG_ITMP1, REG_PV, disp);
                        switch (iptr->op1) {
                        case TYPE_INT:
-                               s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                               M_IST(s2, REG_ITMP1, 0);
+                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP2);
+                               M_IST(s1, REG_ITMP1, 0);
                                break;
                        case TYPE_LNG:
-                               s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                               M_LST(s2, REG_ITMP1, 0);
+                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP2);
+                               M_LST(s1, REG_ITMP1, 0);
                                break;
                        case TYPE_ADR:
-                               s2 = emit_load_s2(jd, iptr, src, REG_ITMP2);
-                               M_AST(s2, REG_ITMP1, 0);
+                               s1 = emit_load_s1(jd, iptr, src, REG_ITMP2);
+                               M_AST(s1, REG_ITMP1, 0);
                                break;
                        case TYPE_FLT:
-                               s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
-                               M_FST(s2, REG_ITMP1, 0);
+                               s1 = emit_load_s1(jd, iptr, src, REG_FTMP2);
+                               M_FST(s1, REG_ITMP1, 0);
                                break;
                        case TYPE_DBL:
-                               s2 = emit_load_s2(jd, iptr, src, REG_FTMP2);
-                               M_DST(s2, REG_ITMP1, 0);
+                               s1 = emit_load_s1(jd, iptr, src, REG_FTMP2);
+                               M_DST(s1, REG_ITMP1, 0);
                                break;
                        }
                        break;
@@ -2167,7 +2108,8 @@ bool codegen(jitdata *jd)
                                disp = dseg_add_address(cd, &(fi->value));
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
-                                       codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0);
+                                       codegen_addpatchref(cd, PATCHER_initialize_class, fi->class,
+                                                                               0);
 
                                        if (opt_showdisassemble)
                                                M_NOP;
@@ -2341,7 +2283,7 @@ bool codegen(jitdata *jd)
                        if (iptr->val.a) {
                                unresolved_class *uc = INSTRUCTION_UNRESOLVED_CLASS(iptr);
 
-                               codegen_addpatchref(cd, PATCHER_athrow_areturn, uc, 0);
+                               codegen_addpatchref(cd, PATCHER_resolve_class, uc, 0);
 
                                if (opt_showdisassemble)
                                        M_NOP;
@@ -2718,7 +2660,7 @@ bool codegen(jitdata *jd)
                        if (iptr->val.a) {
                                unresolved_class *uc = INSTRUCTION_UNRESOLVED_CLASS(iptr);
 
-                               codegen_addpatchref(cd, PATCHER_athrow_areturn, uc, 0);
+                               codegen_addpatchref(cd, PATCHER_resolve_class, uc, 0);
 
                                if (opt_showdisassemble)
                                        M_NOP;
@@ -2739,34 +2681,13 @@ nowperformreturn:
                        {
                        s4 i, p;
                        
-                       p = jd->stackframesize;
+                       p = cd->stackframesize;
                        
                        /* call trace function */
 
 #if !defined(NDEBUG)
-                       if (opt_verbosecall) {
-                               M_LDA(REG_SP, REG_SP, -3 * 8);
-                               M_AST(REG_RA, REG_SP, 0 * 8);
-                               M_LST(REG_RESULT, REG_SP, 1 * 8);
-                               M_DST(REG_FRESULT, REG_SP, 2 * 8);
-
-                               disp = dseg_add_address(cd, m);
-                               M_ALD(rd->argintregs[0], REG_PV, disp);
-                               M_MOV(REG_RESULT, rd->argintregs[1]);
-                               M_FLTMOVE(REG_FRESULT, rd->argfltregs[2]);
-                               M_FLTMOVE(REG_FRESULT, rd->argfltregs[3]);
-
-                               disp = dseg_add_functionptr(cd, builtin_displaymethodstop);
-                               M_ALD(REG_PV, REG_PV, disp);
-                               M_JSR(REG_RA, REG_PV);
-                               disp = (s4) (cd->mcodeptr - cd->mcodebase);
-                               M_LDA(REG_PV, REG_RA, -disp);
-
-                               M_DLD(REG_FRESULT, REG_SP, 2 * 8);
-                               M_LLD(REG_RESULT, REG_SP, 1 * 8);
-                               M_ALD(REG_RA, REG_SP, 0 * 8);
-                               M_LDA(REG_SP, REG_SP, 3 * 8);
-                       }
+                       if (JITDATA_HAS_FLAG_VERBOSECALL(jd))
+                               emit_verbosecall_exit(jd);
 #endif
 
 #if defined(ENABLE_THREADS)
@@ -2822,8 +2743,8 @@ nowperformreturn:
 
                        /* deallocate stack                                               */
 
-                       if (jd->stackframesize)
-                               M_LDA(REG_SP, REG_SP, jd->stackframesize * 8);
+                       if (cd->stackframesize)
+                               M_LDA(REG_SP, REG_SP, cd->stackframesize * 8);
 
                        M_RET(REG_ZERO, REG_RA);
                        ALIGNCODENOP;
@@ -3169,7 +3090,7 @@ gen_method:
 
                                        disp = dseg_add_unique_s4(cd, 0);         /* super->flags */
 
-                                       codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags,
+                                       codegen_addpatchref(cd, PATCHER_resolve_classref_to_flags,
                                                                                (constant_classref *) iptr->target,
                                                                                disp);
 
@@ -3221,7 +3142,7 @@ gen_method:
                                                disp = dseg_add_unique_address(cd, NULL);
 
                                                codegen_addpatchref(cd,
-                                                                                       PATCHER_checkcast_instanceof_class,
+                                                                                       PATCHER_resolve_classref_to_vftbl,
                                                                                        (constant_classref *) iptr->target,
                                                                                        disp);
 
@@ -3273,7 +3194,8 @@ gen_method:
                                disp = dseg_addaddress(cd, iptr->val.a);
 
                                if (iptr->val.a == NULL) {
-                                       codegen_addpatchref(cd, PATCHER_builtin_arraycheckcast,
+                                       codegen_addpatchref(cd,
+                                                                               PATCHER_resolve_classref_to_classinfo,
                                                                                (constant_classref *) iptr->target,
                                                                                disp);
 
@@ -3363,7 +3285,7 @@ gen_method:
 
                                disp = dseg_add_unique_s4(cd, 0);             /* super->flags */
 
-                               codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags,
+                               codegen_addpatchref(cd, PATCHER_resolve_classref_to_flags,
                                                                        (constant_classref *) iptr->target, disp);
 
                                if (opt_showdisassemble)
@@ -3417,7 +3339,7 @@ gen_method:
                                if (super == NULL) {
                                        disp = dseg_add_unique_address(cd, NULL);
 
-                                       codegen_addpatchref(cd, PATCHER_checkcast_instanceof_class,
+                                       codegen_addpatchref(cd, PATCHER_resolve_classref_to_vftbl,
                                                                                (constant_classref *) iptr->target,
                                                                                disp);
 
@@ -3474,7 +3396,7 @@ gen_method:
                        if (iptr->val.a == NULL) {
                                disp = dseg_add_unique_address(cd, 0);
 
-                               codegen_addpatchref(cd, PATCHER_builtin_multianewarray,
+                               codegen_addpatchref(cd, PATCHER_resolve_classref_to_classinfo,
                                                                        (constant_classref *) iptr->target,
                                                                        disp);
 
@@ -3665,7 +3587,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
 
        /* calculate stack frame size */
 
-       jd->stackframesize =
+       cd->stackframesize =
                1 +                             /* return address                     */
                sizeof(stackframeinfo) / SIZEOF_VOID_P +
                sizeof(localref_table) / SIZEOF_VOID_P +
@@ -3676,7 +3598,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
        /* create method header */
 
        (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
-       (void) dseg_add_unique_s4(cd, jd->stackframesize * 8); /* FrameSize       */
+       (void) dseg_add_unique_s4(cd, cd->stackframesize * 8); /* FrameSize       */
        (void) dseg_add_unique_s4(cd, 0);                      /* IsSync          */
        (void) dseg_add_unique_s4(cd, 0);                      /* IsLeaf          */
        (void) dseg_add_unique_s4(cd, 0);                      /* IntSave         */
@@ -3686,69 +3608,15 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
 
        /* generate stub code */
 
-       M_LDA(REG_SP, REG_SP, -(jd->stackframesize * 8));
-       M_AST(REG_RA, REG_SP, jd->stackframesize * 8 - SIZEOF_VOID_P);
+       M_LDA(REG_SP, REG_SP, -(cd->stackframesize * 8));
+       M_AST(REG_RA, REG_SP, cd->stackframesize * 8 - SIZEOF_VOID_P);
 
        /* call trace function */
 
 #if !defined(NDEBUG)
-       if (opt_verbosecall) {
-               /* save integer argument registers */
-
-               for (i = 0, j = 1; i < md->paramcount && i < INT_ARG_CNT; i++) {
-                       if (IS_INT_LNG_TYPE(md->paramtypes[i].type)) {
-                               M_LST(rd->argintregs[i], REG_SP, j * 8);
-                               j++;
-                       }
-               }
-
-               /* save and copy float arguments into integer registers */
-
-               for (i = 0; i < md->paramcount && i < FLT_ARG_CNT; i++) {
-                       t = md->paramtypes[i].type;
-
-                       if (IS_FLT_DBL_TYPE(t)) {
-                               if (IS_2_WORD_TYPE(t)) {
-                                       M_DST(rd->argfltregs[i], REG_SP, j * 8);
-                                       M_LLD(rd->argintregs[i], REG_SP, j * 8);
-                               } else {
-                                       M_FST(rd->argfltregs[i], REG_SP, j * 8);
-                                       M_ILD(rd->argintregs[i], REG_SP, j * 8);
-                               }
-                               j++;
-                       }
-               }
-
-               disp = dseg_add_address(cd, m);
-               M_ALD(REG_ITMP1, REG_PV, disp);
-               M_AST(REG_ITMP1, REG_SP, 0 * 8);
-               disp = dseg_add_functionptr(cd, builtin_trace_args);
-               M_ALD(REG_PV, REG_PV, disp);
-               M_JSR(REG_RA, REG_PV);
-               disp = (s4) (cd->mcodeptr - cd->mcodebase);
-               M_LDA(REG_PV, REG_RA, -disp);
-
-               for (i = 0, j = 1; i < md->paramcount && i < INT_ARG_CNT; i++) {
-                       if (IS_INT_LNG_TYPE(md->paramtypes[i].type)) {
-                               M_LLD(rd->argintregs[i], REG_SP, j * 8);
-                               j++;
-                       }
-               }
-
-               for (i = 0; i < md->paramcount && i < FLT_ARG_CNT; i++) {
-                       t = md->paramtypes[i].type;
-
-                       if (IS_FLT_DBL_TYPE(t)) {
-                               if (IS_2_WORD_TYPE(t)) {
-                                       M_DLD(rd->argfltregs[i], REG_SP, j * 8);
-                               } else {
-                                       M_FLD(rd->argfltregs[i], REG_SP, j * 8);
-                               }
-                               j++;
-                       }
-               }
-       }
-#endif /* !defined(NDEBUG) */
+       if (JITDATA_HAS_FLAG_VERBOSECALL(jd))
+               emit_verbosecall_enter(jd);
+#endif
 
        /* get function address (this must happen before the stackframeinfo) */
 
@@ -3756,7 +3624,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
 
 #if !defined(WITH_STATIC_CLASSPATH)
        if (f == NULL) {
-               codegen_addpatchref(cd, PATCHER_resolve_native, m, funcdisp);
+               codegen_addpatchref(cd, PATCHER_resolve_native_function, m, funcdisp);
 
                if (opt_showdisassemble)
                        M_NOP;
@@ -3781,10 +3649,10 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
 
        /* prepare data structures for native function call */
 
-       M_LDA(rd->argintregs[0], REG_SP, jd->stackframesize * 8 - SIZEOF_VOID_P);
+       M_LDA(rd->argintregs[0], REG_SP, cd->stackframesize * 8 - SIZEOF_VOID_P);
        M_MOV(REG_PV, rd->argintregs[1]);
-       M_LDA(rd->argintregs[2], REG_SP, jd->stackframesize * 8);
-       M_ALD(rd->argintregs[3], REG_SP, jd->stackframesize * 8 - SIZEOF_VOID_P);
+       M_LDA(rd->argintregs[2], REG_SP, cd->stackframesize * 8);
+       M_ALD(rd->argintregs[3], REG_SP, cd->stackframesize * 8 - SIZEOF_VOID_P);
        disp = dseg_add_functionptr(cd, codegen_start_native_call);
        M_ALD(REG_PV, REG_PV, disp);
        M_JSR(REG_RA, REG_PV);
@@ -3826,7 +3694,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                                }
 
                        } else {
-                               s1 = md->params[i].regoff + jd->stackframesize;
+                               s1 = md->params[i].regoff + cd->stackframesize;
                                s2 = nmd->params[j].regoff;
                                M_LLD(REG_ITMP1, REG_SP, s1 * 8);
                                M_LST(REG_ITMP1, REG_SP, s2 * 8);
@@ -3849,7 +3717,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                                }
 
                        } else {
-                               s1 = md->params[i].regoff + jd->stackframesize;
+                               s1 = md->params[i].regoff + cd->stackframesize;
                                s2 = nmd->params[j].regoff;
                                M_DLD(REG_FTMP1, REG_SP, s1 * 8);
                                if (IS_2_WORD_TYPE(t))
@@ -3891,34 +3759,13 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
        /* call finished trace */
 
 #if !defined(NDEBUG)
-       if (opt_verbosecall) {
-               /* just restore the value we need, don't care about the other */
-
-               if (md->returntype.type != TYPE_VOID) {
-                       if (IS_INT_LNG_TYPE(md->returntype.type))
-                               M_LLD(REG_RESULT, REG_SP, 0 * 8);
-                       else
-                               M_DLD(REG_FRESULT, REG_SP, 0 * 8);
-               }
-
-               disp = dseg_add_address(cd, m);
-               M_ALD(rd->argintregs[0], REG_PV, disp);
-
-               M_MOV(REG_RESULT, rd->argintregs[1]);
-               M_FMOV(REG_FRESULT, rd->argfltregs[2]);
-               M_FMOV(REG_FRESULT, rd->argfltregs[3]);
-
-               disp = dseg_add_functionptr(cd, builtin_displaymethodstop);
-               M_ALD(REG_PV, REG_PV, disp);
-               M_JSR(REG_RA, REG_PV);
-               disp = (s4) (cd->mcodeptr - cd->mcodebase);
-               M_LDA(REG_PV, REG_RA, -disp);
-       }
-#endif /* !defined(NDEBUG) */
+       if (JITDATA_HAS_FLAG_VERBOSECALL(jd))
+               emit_verbosecall_exit(jd);
+#endif
 
        /* remove native stackframe info */
 
-       M_LDA(rd->argintregs[0], REG_SP, jd->stackframesize * 8 - SIZEOF_VOID_P);
+       M_LDA(rd->argintregs[0], REG_SP, cd->stackframesize * 8 - SIZEOF_VOID_P);
        disp = dseg_add_functionptr(cd, codegen_finish_native_call);
        M_ALD(REG_PV, REG_PV, disp);
        M_JSR(REG_RA, REG_PV);
@@ -3935,8 +3782,8 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                        M_DLD(REG_FRESULT, REG_SP, 0 * 8);
        }
 
-       M_ALD(REG_RA, REG_SP, (jd->stackframesize - 1) * 8); /* get RA            */
-       M_LDA(REG_SP, REG_SP, jd->stackframesize * 8);
+       M_ALD(REG_RA, REG_SP, (cd->stackframesize - 1) * 8); /* get RA            */
+       M_LDA(REG_SP, REG_SP, cd->stackframesize * 8);
 
        /* check for exception */