]> granicus.if.org Git - gc/commitdiff
Enable prefetch operations by default (GCC 3.0+)
authorIvan Maidanski <ivmai@mail.ru>
Sat, 16 Nov 2013 09:06:34 +0000 (13:06 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 16 Nov 2013 09:07:14 +0000 (13:07 +0400)
* include/private/gcconfig.h (PREFETCH): Update comment; remove FIXME.
* include/private/gcconfig.h (NO_PREFETCH_FOR_WRITE): Define if
USE_I686_PREFETCH defined but not FORCE_WRITE_PREFETCH.
* include/private/gcconfig.h (PREFETCH, PREFETCH_FOR_WRITE,
CLEAR_DOUBLE): Reformat code (for IA64).
* include/private/gcconfig.h (PREFETCH, PREFETCH_FOR_WRITE): Make
default definition to GCC (v3+) built-in operation for all platforms
(instead of only for Linux/x64) unless NO_PREFETCH (or
NO_PREFETCH_FOR_WRITE, respectively) defined.

include/private/gcconfig.h

index d56917870e7fb3af9fd9438db2cc51c44a9abf57..789ba46a92e3937438ef0be137cc7ea91ec67e0f 100644 (file)
  * defined GC_register_dynamic_libraries() for the architecture.
  *
  * An architecture may define PREFETCH(x) to preload the cache with *x.
- * This defaults to a no-op.
+ * This defaults to GCC built-in operation (or a no-op for other compilers).
  *
  * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
  *
 #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
 #       endif
 #       ifdef USE_I686_PREFETCH
-          /* FIXME: Thus should use __builtin_prefetch, but we'll leave */
-          /* that for the next release.                                 */
 #         define PREFETCH(x) \
             __asm__ __volatile__ ("prefetchnta %0" : : "m"(*(char *)(x)))
             /* Empirically prefetcht0 is much more effective at reducing     */
             /* impact on performance, at least for a PIII/500.               */
 #           define PREFETCH_FOR_WRITE(x) \
               __asm__ __volatile__ ("prefetcht0 %0" : : "m"(*(char *)(x)))
+#         else
+#           define NO_PREFETCH_FOR_WRITE
 #         endif
-#       endif
-#       ifdef USE_3DNOW_PREFETCH
+#       elif defined(USE_3DNOW_PREFETCH)
 #         define PREFETCH(x) \
             __asm__ __volatile__ ("prefetch %0" : : "m"(*(char *)(x)))
 #         define PREFETCH_FOR_WRITE(x) \
               __asm__ ("        stf.spill       [%0]=f0": : "r"((void *)(x)))
 #         else
 #           include <ia64intrin.h>
-#           define PREFETCH(x) \
-              __lfetch(__lfhint_none, (x))
-#           define PREFETCH_FOR_WRITE(x) \
-              __lfetch(__lfhint_nta,  (x))
-#           define CLEAR_DOUBLE(x) \
-              __stf_spill((void *)(x), 0)
+#           define PREFETCH(x) __lfetch(__lfhint_none, (x))
+#           define PREFETCH_FOR_WRITE(x) __lfetch(__lfhint_nta, (x))
+#           define CLEAR_DOUBLE(x) __stf_spill((void *)(x), 0)
 #         endif /* __INTEL_COMPILER */
 #       endif
 #   endif
              extern int etext[];
 #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
 #       endif
-#       if defined(__GNUC__) && __GNUC__ >= 3
-#           define PREFETCH(x) __builtin_prefetch((x), 0, 0)
-#           define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
-#       endif
 #       if defined(__GLIBC__)
           /* At present, there's a bug in GLibc getcontext() on         */
           /* Linux/x64 (it clears FPU exception mask).  We define this  */
 #endif
 
 #ifndef PREFETCH
-# define PREFETCH(x) (void)0
-# define NO_PREFETCH
+# if defined(__GNUC__) && __GNUC__ >= 3 && !defined(NO_PREFETCH)
+#   define PREFETCH(x) __builtin_prefetch((x), 0, 0)
+# else
+#   define PREFETCH(x) (void)0
+# endif
 #endif
 
 #ifndef PREFETCH_FOR_WRITE
-# define PREFETCH_FOR_WRITE(x) (void)0
-# define NO_PREFETCH_FOR_WRITE
+# if defined(__GNUC__) && __GNUC__ >= 3 && !defined(NO_PREFETCH_FOR_WRITE)
+#   define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
+# else
+#   define PREFETCH_FOR_WRITE(x) (void)0
+# endif
 #endif
 
 #ifndef CACHE_LINE_SIZE