Permalink
Browse files

Changed gct access to use inline asm for clang

The change improves the performance of gc-intense
benchmarks. The average increase in exectuion time vs. a
straight register variable is about 9%.

NoFib Results
-----------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
-----------------------------------------------------------------------
        circsim          +0.1%     +0.0%     +8.2%     +7.5%     -0.1%
    constraints          +0.1%     +0.0%    +13.4%    +13.0%     +0.0%
       fibheaps          +0.1%  (stdout)  (stdout)  (stdout)  (stdout)
         fulsom          +0.1%     +0.0%     +9.5%    +10.0%     +0.0%
       gc_bench          +0.1%     -0.0%    +15.7%    +15.5%     +0.0%
          happy          +0.1%     +0.0%     +6.2%     +6.1%     +0.0%
           lcss          +0.1%     +0.0%    +11.0%    +10.0%     +0.0%
      mutstore1          +0.1%     -0.0%    +14.6%    +13.3%     +0.0%
      mutstore2          +0.1%     -0.0%     +4.1%     +3.9%     +0.0%
          power          +0.1%     +0.0%     +8.4%     +7.8%     +0.0%
     spellcheck          +0.1%     +0.0%     +2.0%     +1.9%     +0.0%
-----------------------------------------------------------------------
            Min          +0.1%     -0.0%     +2.0%     +1.9%     -0.1%
            Max          +0.1%     +0.0%    +15.7%    +15.5%     +0.0%
 Geometric Mean          +0.1%     +0.0%     +9.2%     +8.8%     -0.0%
  • Loading branch information...
1 parent 21b4765 commit 9e36b301e26a40275c33f9b90c778e7248f3f19f @dmpots committed Jul 5, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 rts/sm/GCTDecl.h
View
@@ -51,7 +51,14 @@ extern __thread gc_thread* gct;
// incorrect code for global register variables. If we are compiling
// with a C compiler that uses an LLVM back end (clang or llvm-gcc) then we
// use pthread_getspecific() to handle the thread local storage for gct.
-#define gct ((gc_thread *)(getThreadLocalVar(&gctKey)))
+#include <Task.h> // for gctKey declaration
+static gc_thread* __gct(void);
+static inline gc_thread* __gct(void) {
+ gc_thread *gct_tls;
+ __asm__("movq %%gs:0x60(,%[key],8),%[gct_tls]" : [gct_tls] "=r" (gct_tls) : [key] "r" (gctKey));
+ return gct_tls;
+}
+#define gct (__gct())
#define DECLARE_GCT /* nothing */
#elif defined(sparc_HOST_ARCH)

0 comments on commit 9e36b30

Please sign in to comment.