Merged revisions 7797-7917 via svnmerge from
[cacao.git] / src / vm / jit / powerpc / codegen.c
index 27a42d8c6414f12a5c8a8c7ad7d1b45a98897898..9bb705c19f6fc1c861a206fce176f3d2c5192936 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 $
 
 */
 
 #include "vm/jit/powerpc/codegen.h"
 
 #include "mm/memory.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"
@@ -2562,20 +2561,6 @@ 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->diffvall));
-                        */
 
                        if (!(iptr->flags.bits & INS_FLAG_ARRAY)) {
                                /* object type cast-check */
@@ -2592,9 +2577,8 @@ gen_method:
                                        superindex = super->index;
                                }
 
-#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);
 
@@ -2667,17 +2651,17 @@ gen_method:
                                        }
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_START;
+
                                        M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
                                        M_ALD(REG_ITMP2, REG_PV, disp);
                                        if (s1 != REG_ITMP1) {
                                                M_ILD(REG_ITMP1, 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_ITMP3, REG_ITMP1, REG_ITMP3);
                                        }
                                        else {
@@ -2685,9 +2669,8 @@ gen_method:
                                                M_ISUB(REG_ITMP3, REG_ITMP2, REG_ITMP3);
                                                M_ALD(REG_ITMP2, REG_PV, disp);
                                                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_CMPU(REG_ITMP3, REG_ITMP2);
                                        emit_classcast_check(cd, iptr, BRANCH_GT, REG_ITMP3, s1);
@@ -2735,20 +2718,6 @@ gen_method:
                        break;
 
                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;
@@ -2763,9 +2732,9 @@ gen_method:
                                superindex = super->index;
                        }
                        
-#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);
@@ -2843,15 +2812,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_CMPU(REG_ITMP1, REG_ITMP2);
                                M_CLR(d);