Only use memory barriers on arm when running on armv6 or later.
authorZoltan Varga <vargaz@gmail.com>
Thu, 24 Feb 2011 12:55:13 +0000 (13:55 +0100)
committerZoltan Varga <vargaz@gmail.com>
Thu, 24 Feb 2011 12:55:51 +0000 (13:55 +0100)
configure.in
mono/mini/mini-arm.c
mono/utils/mono-membar.h

index 572c37bacc7eaa1e3bf25f797374f5386e5addaa..c14339f267d80c8b9a8e2b9b2f1f621734899a05 100644 (file)
@@ -2539,6 +2539,16 @@ if test ${TARGET} = ARM && test x$cross_compiling = xno && test x$enable_mcs_bui
        AC_MSG_RESULT($fpu)
        CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu=1"
        unset fpu
+
+       AC_MSG_CHECKING(for ARMV6)
+       AC_TRY_RUN([
+               int main () { __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory"); return 0; }
+                       ], armv6=yes, armv6=no)
+
+       AC_MSG_RESULT($armv6)
+       if test ${armv6} = yes; then
+          AC_DEFINE(HAVE_ARMV6, 1, "Host supports ARMV6 instructions")
+       fi
 fi
 
 if test ${TARGET} = unknown; then
index d210943de131e97e24424ec3b77103c161b1df2e..bf032adf16729bbef46a9da6731d41e67f74a88e 100644 (file)
@@ -37,6 +37,7 @@ static gint lmf_addr_tls_offset = -1;
 static CRITICAL_SECTION mini_arch_mutex;
 
 static int v5_supported = 0;
+static int v6_supported = 0;
 static int v7_supported = 0;
 static int thumb_supported = 0;
 /*
@@ -508,6 +509,7 @@ mono_arch_cpu_optimizazions (guint32 *exclude_mask)
                thumb_supported = strstr (cpu_arch, "thumb") != NULL;
                if (strncmp (cpu_arch, "armv", 4) == 0) {
                        v5_supported = cpu_arch [4] >= '5';
+                       v6_supported = cpu_arch [4] >= '6';
                        v7_supported = cpu_arch [4] >= '7';
                }
        } else {
@@ -526,6 +528,8 @@ mono_arch_cpu_optimizazions (guint32 *exclude_mask)
                                char *ver = strstr (line, "(v");
                                if (ver && (ver [2] == '5' || ver [2] == '6' || ver [2] == '7'))
                                        v5_supported = TRUE;
+                               if (ver && (ver [2] == '6' || ver [2] == '7'))
+                                       v6_supported = TRUE;
                                if (ver && (ver [2] == '7'))
                                        v7_supported = TRUE;
                                continue;
@@ -3291,8 +3295,10 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 
                switch (ins->opcode) {
                case OP_MEMORY_BARRIER:
-                       ARM_MOV_REG_IMM8 (code, ARMREG_R0, 0);
-                       ARM_MCR (code, 15, 0, ARMREG_R0, 7, 10, 5);
+                       if (v6_supported) {
+                               ARM_MOV_REG_IMM8 (code, ARMREG_R0, 0);
+                               ARM_MCR (code, 15, 0, ARMREG_R0, 7, 10, 5);
+                       }
                        break;
                case OP_TLS_GET:
 #ifdef HAVE_AEABI_READ_TP
@@ -5875,8 +5881,13 @@ void
 mono_arch_set_target (char *mtriple)
 {
        /* The GNU target triple format is not very well documented */
-       if (strstr (mtriple, "armv7"))
+       if (strstr (mtriple, "armv7")) {
+               v6_supported = TRUE;
                v7_supported = TRUE;
+       }
+       if (strstr (mtriple, "armv7")) {
+               v6_supported = TRUE;
+       }
        if (strstr (mtriple, "darwin")) {
                v5_supported = TRUE;
                thumb_supported = TRUE;
index 1c343b0d454fb10ed0bf4dfb4cf239818ceacc27..0bd56dbeaa697c4d4a37344808309d163bfab099 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef _MONO_UTILS_MONO_MEMBAR_H_
 #define _MONO_UTILS_MONO_MEMBAR_H_
 
+#include <config.h>
+
 #include <glib.h>
 
 #ifdef __x86_64__
@@ -129,7 +131,9 @@ static inline void mono_memory_write_barrier (void)
 #elif defined(__arm__)
 static inline void mono_memory_barrier (void)
 {
+#ifdef HAVE_ARMV6
        __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory");
+#endif
 }
 
 static inline void mono_memory_read_barrier (void)