Use thread_local compiler specifics

Much faster then pthread_getspecific() but still a
speed regression against the original code.

Following are the nps on a bench:

Position
454165
454838
455433

tls
441046
442767
442767

ms (Win)
450521
447510
451105

ms (pthread)
422115
422115
424276

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2012-04-06 17:01:41 +01:00
parent bed4075580
commit b1f57e92ce
7 changed files with 17 additions and 24 deletions

View File

@@ -120,8 +120,6 @@ public:
int min_split_depth() const { return minimumSplitDepth; }
int size() const { return (int)threads.size(); }
Thread* main_thread() const { return threads[0]; }
Thread* this_thread() const { return (Thread*)tls_get(tlsKey); }
void set_this_thread(Thread* th) const { tls_set(tlsKey, th); }
void wake_up() const;
void sleep() const;
@@ -140,7 +138,6 @@ private:
std::vector<Thread*> threads;
Thread* timer;
ThreadLocalStorageKey tlsKey;
Lock splitLock;
WaitCondition sleepCond;
Depth minimumSplitDepth;
@@ -149,5 +146,6 @@ private:
};
extern ThreadsManager Threads;
extern THREAD_LOCAL Thread* this_thread;
#endif // !defined(THREAD_H_INCLUDED)