From: Zoltan Varga Date: Thu, 24 Feb 2011 12:55:13 +0000 (+0100) Subject: Only use memory barriers on arm when running on armv6 or later. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=731db97325c15356c2c888d47207e73bc36c05f1;p=mono.git Only use memory barriers on arm when running on armv6 or later. --- diff --git a/configure.in b/configure.in index 572c37bacc7..c14339f267d 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/mono/mini/mini-arm.c b/mono/mini/mini-arm.c index d210943de13..bf032adf167 100644 --- a/mono/mini/mini-arm.c +++ b/mono/mini/mini-arm.c @@ -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; diff --git a/mono/utils/mono-membar.h b/mono/utils/mono-membar.h index 1c343b0d454..0bd56dbeaa6 100644 --- a/mono/utils/mono-membar.h +++ b/mono/utils/mono-membar.h @@ -10,6 +10,8 @@ #ifndef _MONO_UTILS_MONO_MEMBAR_H_ #define _MONO_UTILS_MONO_MEMBAR_H_ +#include + #include #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)