From b2b679a08bb73fd08c9dd97606d1779cacfcd925 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 20 Jun 2012 13:02:56 +0200 Subject: [WIN] Remove dependency on pthread from MachineStackMarker https://bugs.webkit.org/show_bug.cgi?id=68429 Patch by Patrick Gansterer on 2012-06-13 Reviewed by NOBODY (OOPS!). Implement pthread TLS functionality with native windows functions. * heap/MachineStackMarker.cpp: Use the new functions instead of pthread directly. * heap/MachineStackMarker.h: * wtf/ThreadSpecific.h: (WTF::ThreadSpecificKeyCreate): Added wrapper around pthread_key_create. (WTF::ThreadSpecificKeyDelete): Added wrapper around pthread_key_delete. (WTF::ThreadSpecificSet): Added wrapper around pthread_setspecific. (WTF::ThreadSpecificGet): Added wrapper around pthread_getspecific. * wtf/ThreadSpecificWin.cpp: --- Source/JavaScriptCore/heap/MachineStackMarker.cpp | 14 +++++--------- Source/JavaScriptCore/heap/MachineStackMarker.h | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'Source/JavaScriptCore/heap') diff --git a/Source/JavaScriptCore/heap/MachineStackMarker.cpp b/Source/JavaScriptCore/heap/MachineStackMarker.cpp index 7eb57479b..8e0c57b6a 100644 --- a/Source/JavaScriptCore/heap/MachineStackMarker.cpp +++ b/Source/JavaScriptCore/heap/MachineStackMarker.cpp @@ -141,10 +141,8 @@ MachineThreads::MachineThreads(Heap* heap) MachineThreads::~MachineThreads() { - if (m_threadSpecific) { - int error = pthread_key_delete(m_threadSpecific); - ASSERT_UNUSED(error, !error); - } + if (m_threadSpecific) + ThreadSpecificKeyDelete(m_threadSpecific); MutexLocker registeredThreadsLock(m_registeredThreadsMutex); for (Thread* t = m_registeredThreads; t;) { @@ -181,19 +179,17 @@ void MachineThreads::makeUsableFromMultipleThreads() if (m_threadSpecific) return; - int error = pthread_key_create(&m_threadSpecific, removeThread); - if (error) - CRASH(); + ThreadSpecificKeyCreate(&m_threadSpecific, removeThread); } void MachineThreads::addCurrentThread() { ASSERT(!m_heap->globalData()->exclusiveThread || m_heap->globalData()->exclusiveThread == currentThread()); - if (!m_threadSpecific || pthread_getspecific(m_threadSpecific)) + if (!m_threadSpecific || ThreadSpecificGet(m_threadSpecific)) return; - pthread_setspecific(m_threadSpecific, this); + ThreadSpecificSet(m_threadSpecific, this); Thread* thread = new Thread(getCurrentPlatformThread(), wtfThreadData().stack().origin()); MutexLocker lock(m_registeredThreadsMutex); diff --git a/Source/JavaScriptCore/heap/MachineStackMarker.h b/Source/JavaScriptCore/heap/MachineStackMarker.h index 5c7705fcf..3d4aa22d4 100644 --- a/Source/JavaScriptCore/heap/MachineStackMarker.h +++ b/Source/JavaScriptCore/heap/MachineStackMarker.h @@ -22,8 +22,8 @@ #ifndef MachineThreads_h #define MachineThreads_h -#include #include +#include #include namespace JSC { @@ -55,7 +55,7 @@ namespace JSC { Heap* m_heap; Mutex m_registeredThreadsMutex; Thread* m_registeredThreads; - pthread_key_t m_threadSpecific; + WTF::ThreadSpecificKey m_threadSpecific; }; } // namespace JSC -- cgit v1.2.1