Merged revisions 7797-7917 via svnmerge from
[cacao.git] / src / vm / jit / alpha / codegen.c
index a0c49618d522312250570367daf3ae93a9aaeea9..419ba3728a845c604ba62cecf291a54020dbb1e0 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: codegen.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -45,9 +45,7 @@
 #include "native/jni.h"
 #include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -2710,42 +2708,24 @@ gen_method:
 
                case ICMD_CHECKCAST:  /* ..., objectref ==> ..., objectref            */
 
-                                     /* val.a: (classinfo*) superclass               */
-
-                       /*  superclass is an interface:
-                        *      
-                        *  OK if ((sub == NULL) ||
-                        *         (sub->vftbl->interfacetablelength > super->index) &&
-                        *         (sub->vftbl->interfacetable[-super->index] != NULL));
-                        *      
-                        *  superclass is a class:
-                        *      
-                        *  OK if ((sub == NULL) || (0
-                        *         <= (sub->vftbl->baseval - super->vftbl->baseval) <=
-                        *         super->vftbl->diffval));
-                        */
-
                        if (!(iptr->flags.bits & INS_FLAG_ARRAY)) {
                                /* object type cast-check */
 
                                classinfo *super;
-                               vftbl_t   *supervftbl;
                                s4         superindex;
 
                                if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
-                                       super = NULL;
+                                       super      = NULL;
                                        superindex = 0;
-                                       supervftbl = NULL;
                                }
                                else {
-                                       super = iptr->sx.s23.s3.c.cls;
+                                       super      = iptr->sx.s23.s3.c.cls;
                                        superindex = super->index;
-                                       supervftbl = super->vftbl;
                                }
 
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
+                                       CODEGEN_CRITICAL_SECTION_NEW;
+
                                s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                                /* if class is not resolved, check which code to call */
@@ -2809,16 +2789,16 @@ gen_method:
                                                                                          disp);
                                        }
                                        else {
-                                               disp = dseg_add_address(cd, supervftbl);
+                                               disp = dseg_add_address(cd, super->vftbl);
 
                                                emit_label_beqz(cd, BRANCH_LABEL_5, s1);
                                        }
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
                                        M_ALD(REG_ITMP3, REG_PV, disp);
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_START;
+
                                        M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                        /*                              if (s1 != REG_ITMP1) { */
                                        /*                                      M_ILD(REG_ITMP1, REG_ITMP3, OFFSET(vftbl_t, baseval)); */
@@ -2833,9 +2813,9 @@ gen_method:
                                        M_ISUB(REG_ITMP2, REG_ITMP3, REG_ITMP2);
                                        M_ALD(REG_ITMP3, REG_PV, disp);
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_END;
+
                                        /*                              } */
                                        M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3);
                                        emit_classcast_check(cd, iptr, BRANCH_EQ, REG_ITMP3, s1);
@@ -2887,21 +2867,6 @@ gen_method:
 
                case ICMD_INSTANCEOF: /* ..., objectref ==> ..., intresult            */
 
-                                     /* val.a: (classinfo*) superclass               */
-
-                       /*  superclass is an interface:
-                        *      
-                        *  return (sub != NULL) &&
-                        *         (sub->vftbl->interfacetablelength > super->index) &&
-                        *         (sub->vftbl->interfacetable[-super->index] != NULL);
-                        *      
-                        *  superclass is a class:
-                        *      
-                        *  return ((sub != NULL) && (0
-                        *          <= (sub->vftbl->baseval - super->vftbl->baseval) <=
-                        *          super->vftbl->diffvall));
-                        */
-
                        {
                        classinfo *super;
                        vftbl_t   *supervftbl;
@@ -2918,9 +2883,9 @@ gen_method:
                                supervftbl = super->vftbl;
                        }
 
-#if defined(ENABLE_THREADS)
-                       codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                       if ((super == NULL) || !(super->flags & ACC_INTERFACE))
+                               CODEGEN_CRITICAL_SECTION_NEW;
+
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
@@ -3002,15 +2967,15 @@ gen_method:
 
                                M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               CODEGEN_CRITICAL_SECTION_START;
+
                                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(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               CODEGEN_CRITICAL_SECTION_END;
+
                                M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                M_CMPULE(REG_ITMP1, REG_ITMP2, d);
 
@@ -3170,7 +3135,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                sizeof(stackframeinfo) / SIZEOF_VOID_P +
                sizeof(localref_table) / SIZEOF_VOID_P +
                1 +                             /* methodinfo for call trace          */
-               (md->paramcount > INT_ARG_CNT ? INT_ARG_CNT : md->paramcount) +
+               md->paramcount +
                nmd->memuse;
 
        /* create method header */
@@ -3218,17 +3183,21 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
        /* save integer and float argument registers */
 
-       for (i = 0, j = 0; i < md->paramcount && i < INT_ARG_CNT; i++) {
-               if (IS_INT_LNG_TYPE(md->paramtypes[i].type)) {
-                       M_LST(abi_registers_integer_argument[i], REG_SP, j * 8);
-                       j++;
-               }
-       }
+       for (i = 0; i < md->paramcount; i++) {
+               if (!md->params[i].inmemory) {
+                       s1 = md->params[i].regoff;
 
-       for (i = 0; i < md->paramcount && i < FLT_ARG_CNT; i++) {
-               if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
-                       M_DST(abi_registers_float_argument[i], REG_SP, j * 8);
-                       j++;
+                       switch (md->paramtypes[i].type) {
+                       case TYPE_INT:
+                       case TYPE_LNG:
+                       case TYPE_ADR:
+                               M_LST(s1, REG_SP, i * 8);
+                               break;
+                       case TYPE_FLT:
+                       case TYPE_DBL:
+                               M_DST(s1, REG_SP, i * 8);
+                               break;
+                       }
                }
        }
 
@@ -3246,17 +3215,21 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
        /* restore integer and float argument registers */
 
-       for (i = 0, j = 0; i < md->paramcount && i < INT_ARG_CNT; i++) {
-               if (IS_INT_LNG_TYPE(md->paramtypes[i].type)) {
-                       M_LLD(abi_registers_integer_argument[i], REG_SP, j * 8);
-                       j++;
-               }
-       }
+       for (i = 0; i < md->paramcount; i++) {
+               if (!md->params[i].inmemory) {
+                       s1 = md->params[i].regoff;
 
-       for (i = 0; i < md->paramcount && i < FLT_ARG_CNT; i++) {
-               if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
-                       M_DLD(abi_registers_float_argument[i], REG_SP, j * 8);
-                       j++;
+                       switch (md->paramtypes[i].type) {
+                       case TYPE_INT:
+                       case TYPE_LNG:
+                       case TYPE_ADR:
+                               M_LLD(s1, REG_SP, i * 8);
+                               break;
+                       case TYPE_FLT:
+                       case TYPE_DBL:
+                               M_DLD(s1, REG_SP, i * 8);
+                               break;
+                       }
                }
        }