From: Ivan Maidanski Date: Mon, 31 Jul 2017 07:57:14 +0000 (+0300) Subject: Do not use asm in GC_pause X-Git-Tag: v8.0.0~622 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb87ef1ca189e198398bdfb24301537e5db11976;p=gc Do not use asm in GC_pause * pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS && (USE_SPIN_LOCK || !NO_PTHREAD_TRYLOCK)] (GC_PAUSE_SPIN_CYCLES): New macro. * pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS && (USE_SPIN_LOCK || !NO_PTHREAD_TRYLOCK)] (GC_pause): Replace "10" with GC_PAUSE_SPIN_CYCLES; remove "dummy" local variable; use AO_compiler_barrier() instead of __asm__("") and GC_noop1(++dummy). --- diff --git a/pthread_support.c b/pthread_support.c index ed00ff99..6f80a41c 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1842,20 +1842,14 @@ GC_API int WRAP_FUNC(pthread_create)(pthread_t *new_thread, #if defined(USE_SPIN_LOCK) || !defined(NO_PTHREAD_TRYLOCK) /* Spend a few cycles in a way that can't introduce contention with */ /* other threads. */ +#define GC_PAUSE_SPIN_CYCLES 10 STATIC void GC_pause(void) { int i; -# if !defined(__GNUC__) || defined(__INTEL_COMPILER) - volatile word dummy = 0; -# endif - for (i = 0; i < 10; ++i) { -# if defined(__GNUC__) && !defined(__INTEL_COMPILER) - __asm__ __volatile__ (" " : : : "memory"); -# else + for (i = 0; i < GC_PAUSE_SPIN_CYCLES; ++i) { /* Something that's unlikely to be optimized away. */ - GC_noop1(++dummy); -# endif + AO_compiler_barrier(); } } #endif