Chromium Code Reviews| Index: Source/heap/ThreadState.h |
| diff --git a/Source/heap/ThreadState.h b/Source/heap/ThreadState.h |
| index 2f92dbd49c344d8cf8f1ceb07827083630681468..fd1ba4e1977c0cbbc7196ee2ec0ba9a7eb1089eb 100644 |
| --- a/Source/heap/ThreadState.h |
| +++ b/Source/heap/ThreadState.h |
| @@ -52,7 +52,7 @@ enum ThreadAffinity { |
| // By default all types are considered to be used on the main thread only. |
| template<typename T> |
| struct ThreadingTrait { |
| - static const ThreadAffinity Affinity = MainThreadOnly; |
| + static const ThreadAffinity Affinity = AnyThread; |
| }; |
| // Marks specified class as requiring thread safe handles which can be used from any thread. |
| @@ -225,7 +225,13 @@ public: |
| static void attach(intptr_t* startOfStack); |
| static void detach(); |
| - static ThreadState* Current() { return **s_threadSpecific; } |
| + static ThreadState* Current() |
| + { |
| + intptr_t dummy; |
| + if (LIKELY(s_mainThreadStackTop < &dummy && &dummy <= s_mainThreadStackBottom)) |
|
haraken
2013/12/12 06:33:47
Of a couple of approaches I have tried, this is th
Mads Ager (chromium)
2013/12/12 06:51:56
I find this rather nasty. It is probably true that
|
| + return MainThreadState(); |
| + return **s_threadSpecific; |
| + } |
| static ThreadState* MainThreadState() { return &s_mainThreadState; } |
| static bool IsMainThread() { return Current() == MainThreadState(); } |
| @@ -274,6 +280,8 @@ public: |
| Interruptor* interruptor() const { return m_interruptor; } |
| private: |
| + static intptr_t* s_mainThreadStackBottom; |
| + static intptr_t* s_mainThreadStackTop; |
| static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; |
| static ThreadState s_mainThreadState; |
| static SafePointBarrier* s_safePointBarrier; |