Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

9 changed files:

Changes:

  • rts/Task.c
    ... ... @@ -52,11 +52,7 @@ Mutex all_tasks_mutex;
    52 52
     // A thread-local-storage key that we can use to get access to the
    
    53 53
     // current thread's Task structure.
    
    54 54
     #if defined(THREADED_RTS)
    
    55
    -# if CC_SUPPORTS_TLS
    
    56 55
     __thread Task *my_task;
    
    57
    -# else
    
    58
    -ThreadLocalKey currentTaskKey;
    
    59
    -# endif
    
    60 56
     #else
    
    61 57
     Task *my_task;
    
    62 58
     #endif
    
    ... ... @@ -75,9 +71,6 @@ initTaskManager (void)
    75 71
             peakWorkerCount = 0;
    
    76 72
             tasksInitialized = 1;
    
    77 73
     #if defined(THREADED_RTS)
    
    78
    -#if !CC_SUPPORTS_TLS
    
    79
    -        newThreadLocalKey(&currentTaskKey);
    
    80
    -#endif
    
    81 74
             initMutex(&all_tasks_mutex);
    
    82 75
     #endif
    
    83 76
         }
    
    ... ... @@ -109,9 +102,6 @@ freeTaskManager (void)
    109 102
     
    
    110 103
     #if defined(THREADED_RTS)
    
    111 104
         closeMutex(&all_tasks_mutex);
    
    112
    -#if !CC_SUPPORTS_TLS
    
    113
    -    freeThreadLocalKey(&currentTaskKey);
    
    114
    -#endif
    
    115 105
     #endif
    
    116 106
     
    
    117 107
         tasksInitialized = 0;
    

  • rts/Task.h
    ... ... @@ -265,12 +265,8 @@ extern uint32_t peakWorkerCount;
    265 265
     // A thread-local-storage key that we can use to get access to the
    
    266 266
     // current thread's Task structure.
    
    267 267
     #if defined(THREADED_RTS)
    
    268
    -#if CC_SUPPORTS_TLS
    
    269 268
     extern __thread Task *my_task;
    
    270 269
     #else
    
    271
    -extern ThreadLocalKey currentTaskKey;
    
    272
    -#endif
    
    273
    -#else
    
    274 270
     extern Task *my_task;
    
    275 271
     #endif
    
    276 272
     
    
    ... ... @@ -283,21 +279,13 @@ extern Task *my_task;
    283 279
     INLINE_HEADER Task *
    
    284 280
     myTask (void)
    
    285 281
     {
    
    286
    -#if defined(THREADED_RTS) && !CC_SUPPORTS_TLS
    
    287
    -    return (Task*) getThreadLocalVar(&currentTaskKey);
    
    288
    -#else
    
    289 282
         return my_task;
    
    290
    -#endif
    
    291 283
     }
    
    292 284
     
    
    293 285
     INLINE_HEADER void
    
    294 286
     setMyTask (Task *task)
    
    295 287
     {
    
    296
    -#if defined(THREADED_RTS) && !CC_SUPPORTS_TLS
    
    297
    -    setThreadLocalVar(&currentTaskKey,task);
    
    298
    -#else
    
    299 288
         my_task = task;
    
    300
    -#endif
    
    301 289
     }
    
    302 290
     
    
    303 291
     // Tasks are identified by their OS thread ID, which can be serialised
    

  • rts/configure.ac
    ... ... @@ -234,19 +234,6 @@ AC_CHECK_FUNCS([eventfd])
    234 234
     
    
    235 235
     AC_CHECK_FUNCS([getpid getuid raise])
    
    236 236
     
    
    237
    -dnl ** Check for __thread support in the compiler
    
    238
    -AC_MSG_CHECKING(for __thread support)
    
    239
    -AC_COMPILE_IFELSE(
    
    240
    -  [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ],
    
    241
    -  [
    
    242
    -   AC_MSG_RESULT(yes)
    
    243
    -   AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported])
    
    244
    -  ],
    
    245
    -  [
    
    246
    -   AC_MSG_RESULT(no)
    
    247
    -   AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported])
    
    248
    -  ])
    
    249
    -
    
    250 237
     dnl large address space support (see rts/include/rts/storage/MBlock.h)
    
    251 238
     dnl
    
    252 239
     dnl Darwin has vm_allocate/vm_protect
    

  • rts/include/rts/OSThreads.h
    ... ... @@ -40,7 +40,6 @@ typedef struct {
    40 40
     } Condition;
    
    41 41
     typedef pthread_mutex_t Mutex;
    
    42 42
     typedef pthread_t       OSThreadId;
    
    43
    -typedef pthread_key_t   ThreadLocalKey;
    
    44 43
     
    
    45 44
     #define OSThreadProcAttr /* nothing */
    
    46 45
     
    
    ... ... @@ -107,7 +106,6 @@ typedef CONDITION_VARIABLE Condition;
    107 106
     typedef DWORD OSThreadId;
    
    108 107
     // don't be tempted to use HANDLE as the OSThreadId: there can be
    
    109 108
     // many HANDLES to a given thread, so comparison would not work.
    
    110
    -typedef DWORD ThreadLocalKey;
    
    111 109
     
    
    112 110
     #define OSThreadProcAttr
    
    113 111
     
    
    ... ... @@ -168,7 +166,6 @@ typedef SRWLOCK Mutex;
    168 166
     typedef void* Condition;
    
    169 167
     typedef void* Mutex;
    
    170 168
     typedef void* OSThreadId;
    
    171
    -typedef void* ThreadLocalKey;
    
    172 169
     
    
    173 170
     #define OSThreadProcAttr
    
    174 171
     
    
    ... ... @@ -216,14 +213,6 @@ extern bool timedWaitCondition ( Condition* pCond, Mutex* pMut, Time timeout)
    216 213
     extern void initMutex             ( Mutex* pMut );
    
    217 214
     extern void closeMutex            ( Mutex* pMut );
    
    218 215
     
    
    219
    -//
    
    220
    -// Thread-local storage
    
    221
    -//
    
    222
    -void  newThreadLocalKey (ThreadLocalKey *key);
    
    223
    -void *getThreadLocalVar (ThreadLocalKey *key);
    
    224
    -void  setThreadLocalVar (ThreadLocalKey *key, void *value);
    
    225
    -void  freeThreadLocalKey (ThreadLocalKey *key);
    
    226
    -
    
    227 216
     // Processors and affinity
    
    228 217
     void setThreadAffinity (uint32_t n, uint32_t m);
    
    229 218
     void setThreadNode (uint32_t node);
    

  • rts/posix/OSThreads.c
    ... ... @@ -286,43 +286,6 @@ closeMutex(Mutex* pMut)
    286 286
         pthread_mutex_destroy(pMut);
    
    287 287
     }
    
    288 288
     
    
    289
    -void
    
    290
    -newThreadLocalKey (ThreadLocalKey *key)
    
    291
    -{
    
    292
    -    int r;
    
    293
    -    if ((r = pthread_key_create(key, NULL)) != 0) {
    
    294
    -        barf("newThreadLocalKey: %s", strerror(r));
    
    295
    -    }
    
    296
    -}
    
    297
    -
    
    298
    -void *
    
    299
    -getThreadLocalVar (ThreadLocalKey *key)
    
    300
    -{
    
    301
    -    return pthread_getspecific(*key);
    
    302
    -    // Note: a return value of NULL can indicate that either the key
    
    303
    -    // is not valid, or the key is valid and the data value has not
    
    304
    -    // yet been set.  We need to use the latter case, so we cannot
    
    305
    -    // detect errors here.
    
    306
    -}
    
    307
    -
    
    308
    -void
    
    309
    -setThreadLocalVar (ThreadLocalKey *key, void *value)
    
    310
    -{
    
    311
    -    int r;
    
    312
    -    if ((r = pthread_setspecific(*key,value)) != 0) {
    
    313
    -        barf("setThreadLocalVar: %s", strerror(r));
    
    314
    -    }
    
    315
    -}
    
    316
    -
    
    317
    -void
    
    318
    -freeThreadLocalKey (ThreadLocalKey *key)
    
    319
    -{
    
    320
    -    int r;
    
    321
    -    if ((r = pthread_key_delete(*key)) != 0) {
    
    322
    -        barf("freeThreadLocalKey: %s", strerror(r));
    
    323
    -    }
    
    324
    -}
    
    325
    -
    
    326 289
     #if defined(THREADED_RTS)
    
    327 290
     
    
    328 291
     static void *
    

  • rts/sm/GCTDecl.h
    ... ... @@ -50,23 +50,10 @@ extern StgWord8 the_gc_thread[];
    50 50
     
    
    51 51
     /* -------------------------------------------------------------------------- */
    
    52 52
     
    
    53
    -/* Now, llvm-gcc and some older Clang compilers do not support
    
    54
    -   __thread. So we have to fallback to the extremely slow case,
    
    55
    -   unfortunately.
    
    56
    -
    
    57
    -   Also, the iOS Clang compiler doesn't support __thread either for
    
    58
    -   some bizarre reason, so there's not much we can do about that... */
    
    59
    -#if defined(CC_LLVM_BACKEND) && (CC_SUPPORTS_TLS == 0)
    
    60
    -#define gct ((gc_thread *)(pthread_getspecific(gctKey)))
    
    61
    -#define SET_GCT(to) (pthread_setspecific(gctKey, to))
    
    62
    -#define DECLARE_GCT ThreadLocalKey gctKey;
    
    63
    -
    
    64
    -/* -------------------------------------------------------------------------- */
    
    65
    -
    
    66
    -/* However, if we *are* using an LLVM based compiler with __thread
    
    53
    +/* If we *are* using an LLVM based compiler with __thread
    
    67 54
        support, then use that (since LLVM doesn't support global register
    
    68 55
        variables.) */
    
    69
    -#elif defined(CC_LLVM_BACKEND) && (CC_SUPPORTS_TLS == 1)
    
    56
    +#if defined(CC_LLVM_BACKEND)
    
    70 57
     extern __thread gc_thread* gct;
    
    71 58
     #define SET_GCT(to) gct = (to)
    
    72 59
     #define DECLARE_GCT __thread gc_thread* gct;
    
    ... ... @@ -107,16 +94,11 @@ GCT_REG_DECL(gc_thread*, gct, REG_R1);
    107 94
     
    
    108 95
     /* Finally, as an absolute fallback, if none of the above tests check
    
    109 96
        out but we *do* have __thread support, then use that. */
    
    110
    -#elif CC_SUPPORTS_TLS == 1
    
    97
    +#else
    
    111 98
     extern __thread gc_thread* gct;
    
    112 99
     #define SET_GCT(to) gct = (to)
    
    113 100
     #define DECLARE_GCT __thread gc_thread* gct;
    
    114 101
     
    
    115
    -/* -------------------------------------------------------------------------- */
    
    116
    -
    
    117
    -/* Impossible! */
    
    118
    -#else
    
    119
    -#error Cannot find a way to declare the thread-local gc variable!
    
    120 102
     #endif
    
    121 103
     
    
    122 104
     #endif // THREADED_RTS
    

  • rts/sm/GCThread.h
    ... ... @@ -212,8 +212,4 @@ extern uint32_t n_gc_threads;
    212 212
     
    
    213 213
     extern gc_thread **gc_threads;
    
    214 214
     
    
    215
    -#if defined(THREADED_RTS) && defined(CC_LLVM_BACKEND)
    
    216
    -extern ThreadLocalKey gctKey;
    
    217
    -#endif
    
    218
    -
    
    219 215
     #include "EndPrivate.h"

  • rts/sm/Storage.c
    ... ... @@ -326,10 +326,6 @@ void storageAddCapabilities (uint32_t from, uint32_t to)
    326 326
             }
    
    327 327
         }
    
    328 328
     
    
    329
    -#if defined(THREADED_RTS) && defined(CC_LLVM_BACKEND) && (CC_SUPPORTS_TLS == 0)
    
    330
    -    newThreadLocalKey(&gctKey);
    
    331
    -#endif
    
    332
    -
    
    333 329
         initGcThreads(from, to);
    
    334 330
     }
    
    335 331
     
    
    ... ... @@ -351,9 +347,6 @@ freeStorage (bool free_heap)
    351 347
         closeMutex(&sm_mutex);
    
    352 348
     #endif
    
    353 349
         stgFree(nurseries);
    
    354
    -#if defined(THREADED_RTS) && defined(CC_LLVM_BACKEND) && (CC_SUPPORTS_TLS == 0)
    
    355
    -    freeThreadLocalKey(&gctKey);
    
    356
    -#endif
    
    357 350
         freeGcThreads();
    
    358 351
     }
    
    359 352
     
    

  • rts/win32/OSThreads.c
    ... ... @@ -87,56 +87,6 @@ osThreadIsAlive(OSThreadId id)
    87 87
         return (exit_code == STILL_ACTIVE);
    
    88 88
     }
    
    89 89
     
    
    90
    -void
    
    91
    -newThreadLocalKey (ThreadLocalKey *key)
    
    92
    -{
    
    93
    -    DWORD r;
    
    94
    -    r = TlsAlloc();
    
    95
    -    if (r == TLS_OUT_OF_INDEXES) {
    
    96
    -        barf("newThreadLocalKey: out of keys");
    
    97
    -    }
    
    98
    -    *key = r;
    
    99
    -}
    
    100
    -
    
    101
    -void *
    
    102
    -getThreadLocalVar (ThreadLocalKey *key)
    
    103
    -{
    
    104
    -    void *r;
    
    105
    -    r = TlsGetValue(*key);
    
    106
    -#if defined(DEBUG)
    
    107
    -    // r is allowed to be NULL - it can mean that either there was an
    
    108
    -    // error or the stored value is in fact NULL.
    
    109
    -    if (GetLastError() != NO_ERROR) {
    
    110
    -        sysErrorBelch("getThreadLocalVar");
    
    111
    -        stg_exit(EXIT_FAILURE);
    
    112
    -    }
    
    113
    -#endif
    
    114
    -    return r;
    
    115
    -}
    
    116
    -
    
    117
    -void
    
    118
    -setThreadLocalVar (ThreadLocalKey *key, void *value)
    
    119
    -{
    
    120
    -    BOOL b;
    
    121
    -    b = TlsSetValue(*key, value);
    
    122
    -    if (!b) {
    
    123
    -        sysErrorBelch("setThreadLocalVar");
    
    124
    -        stg_exit(EXIT_FAILURE);
    
    125
    -    }
    
    126
    -}
    
    127
    -
    
    128
    -void
    
    129
    -freeThreadLocalKey (ThreadLocalKey *key)
    
    130
    -{
    
    131
    -    BOOL r;
    
    132
    -    r = TlsFree(*key);
    
    133
    -    if (r == 0) {
    
    134
    -        DWORD dw = GetLastError();
    
    135
    -        barf("freeThreadLocalKey failed: %lu", dw);
    
    136
    -    }
    
    137
    -}
    
    138
    -
    
    139
    -
    
    140 90
     static unsigned
    
    141 91
     forkOS_createThreadWrapper ( void * entry )
    
    142 92
     {