Unreviewed, rolling out r148462.
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Apr 2013 02:55:44 +0000 (02:55 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Apr 2013 02:55:44 +0000 (02:55 +0000)
http://trac.webkit.org/changeset/148462
https://bugs.webkit.org/show_bug.cgi?id=114658

Broke Windows builds (Requested by rniwa on #webkit).

* wtf/FastMalloc.cpp:
(WTF):
(WTF::setThreadHeap):
(WTF::TCMalloc_ThreadCache::GetThreadHeap):
(WTF::TCMalloc_ThreadCache::InitTSD):
* wtf/ThreadSpecificWin.cpp:
(WTF::destructorsList):
(WTF::destructorsMutex):
(WTF::threadSpecificKeyCreate):
(WTF::threadSpecificKeyDelete):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148488 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/FastMalloc.cpp
Source/WTF/wtf/ThreadSpecificWin.cpp

index b8a4c790f9779eac5c2ebfa73e9d2dc74355cf97..9d0443e206f961f24ea4a34ef0ad865fbc8136e1 100644 (file)
@@ -1,3 +1,22 @@
+2013-04-15  Commit Queue  <rniwa@webkit.org>
+
+        Unreviewed, rolling out r148462.
+        http://trac.webkit.org/changeset/148462
+        https://bugs.webkit.org/show_bug.cgi?id=114658
+
+        Broke Windows builds (Requested by rniwa on #webkit).
+
+        * wtf/FastMalloc.cpp:
+        (WTF):
+        (WTF::setThreadHeap):
+        (WTF::TCMalloc_ThreadCache::GetThreadHeap):
+        (WTF::TCMalloc_ThreadCache::InitTSD):
+        * wtf/ThreadSpecificWin.cpp:
+        (WTF::destructorsList):
+        (WTF::destructorsMutex):
+        (WTF::threadSpecificKeyCreate):
+        (WTF::threadSpecificKeyDelete):
+
 2013-04-15  Julien Brianceau  <jbrianceau@nds.com>
 
         LLInt SH4 backend implementation
index 457f591e716a080492037a0d5abeab24ec4e532f..b066959739bc297e3bfc2b8ed8d2114841d8fc8d 100644 (file)
@@ -428,7 +428,6 @@ extern "C" WTF_EXPORT_PRIVATE const int jscore_fastmalloc_introspection = 0;
 #include "TCPageMap.h"
 #include "TCSpinLock.h"
 #include "TCSystemAlloc.h"
-#include "ThreadSpecific.h"
 #include <algorithm>
 #include <pthread.h>
 #include <stdarg.h>
@@ -2842,7 +2841,10 @@ static bool tsd_inited = false;
 #if USE(PTHREAD_GETSPECIFIC_DIRECT)
 static const pthread_key_t heap_key = __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0;
 #else
-static ThreadSpecificKey heap_key;
+static pthread_key_t heap_key;
+#endif
+#if OS(WINDOWS)
+DWORD tlsIndex = TLS_OUT_OF_INDEXES;
 #endif
 
 static ALWAYS_INLINE void setThreadHeap(TCMalloc_ThreadCache* heap)
@@ -2854,12 +2856,12 @@ static ALWAYS_INLINE void setThreadHeap(TCMalloc_ThreadCache* heap)
         CRASH();
 #endif
 
-#if OS(DARWIN)
     // Still do pthread_setspecific even if there's an alternate form
     // of thread-local storage in use, to benefit from the delete callback.
     pthread_setspecific(heap_key, heap);
-#else
-    threadSpecificSet(heap_key, heap);
+
+#if OS(WINDOWS)
+    TlsSetValue(tlsIndex, heap);
 #endif
 }
 
@@ -3405,10 +3407,10 @@ inline TCMalloc_ThreadCache* TCMalloc_ThreadCache::GetThreadHeap() {
     // __thread is faster, but only when the kernel supports it
   if (KernelSupportsTLS())
     return threadlocal_heap;
-#elif OS(DARWIN)
-    return static_cast<TCMalloc_ThreadCache*>(pthread_getspecific(heap_key));
+#elif OS(WINDOWS)
+    return static_cast<TCMalloc_ThreadCache*>(TlsGetValue(tlsIndex));
 #else
-    return static_cast<TCMalloc_ThreadCache*>(threadSpecificGet(heap_key));
+    return static_cast<TCMalloc_ThreadCache*>(pthread_getspecific(heap_key));
 #endif
 }
 
@@ -3437,7 +3439,10 @@ void TCMalloc_ThreadCache::InitTSD() {
 #if USE(PTHREAD_GETSPECIFIC_DIRECT)
   pthread_key_init_np(heap_key, DestroyThreadCache);
 #else
-  threadSpecificKeyCreate(&heap_key, DestroyThreadCache);
+  pthread_key_create(&heap_key, DestroyThreadCache);
+#endif
+#if OS(WINDOWS)
+  tlsIndex = TlsAlloc();
 #endif
   tsd_inited = true;
     
index 9b70bbbcaa6ad44d58cbcb74ed59485f8b62d38a..1fb7398e2176ad963e9adfd6d3a43ff8518109bf 100644 (file)
@@ -34,13 +34,13 @@ namespace WTF {
 
 static DoublyLinkedList<PlatformThreadSpecificKey>& destructorsList()
 {
-    static DoublyLinkedList<PlatformThreadSpecificKey> staticList;
+    DEFINE_STATIC_LOCAL(DoublyLinkedList<PlatformThreadSpecificKey>, staticList, ());
     return staticList;
 }
 
 static Mutex& destructorsMutex()
 {
-    static Mutex staticMutex;
+    DEFINE_STATIC_LOCAL(Mutex, staticMutex, ());
     return staticMutex;
 }
 
@@ -91,9 +91,7 @@ DWORD* tlsKeys()
 
 void threadSpecificKeyCreate(ThreadSpecificKey* key, void (*destructor)(void *))
 {
-    // Use the original malloc() instead of fastMalloc() to use this function in FastMalloc code.
-    *key = static_cast<PlatformThreadSpecificKey*>(::malloc(sizeof(PlatformThreadSpecificKey)));
-    new (*key) PlatformThreadSpecificKey(destructor);
+    *key = new PlatformThreadSpecificKey(destructor);
 
     MutexLocker locker(destructorsMutex());
     destructorsList().push(*key);
@@ -103,8 +101,7 @@ void threadSpecificKeyDelete(ThreadSpecificKey key)
 {
     MutexLocker locker(destructorsMutex());
     destructorsList().remove(key);
-    key->~PlatformThreadSpecificKey();
-    ::free(key);
+    delete key;
 }
 
 void threadSpecificSet(ThreadSpecificKey key, void* data)