Fix Bug 15586: REGRESSION (r26759-r26785): Windows nightly builds crash with...
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Oct 2007 07:18:46 +0000 (07:18 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Oct 2007 07:18:46 +0000 (07:18 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=15586

        Also fixes: <rdar://5565303> Cannot use regsvr32.exe to register WebKit.dll

        Use Win32 TLS functions instead of __declspec(thread), which breaks
        delay-loading.

        Reviewed by Steve.

        * wtf/FastMalloc.cpp:
        (WTF::getThreadHeap):
        (WTF::TCMalloc_ThreadCache::InitModule):

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

JavaScriptCore/ChangeLog
JavaScriptCore/wtf/FastMalloc.cpp

index 1bd410a10907c7bbdcf2c8861563b3e990a1c4b9..66a69544c37a374906575535d5c6619e72f32d0d 100644 (file)
@@ -1,3 +1,20 @@
+2007-10-30  Adam Roben  <aroben@apple.com>
+
+        Fix Bug 15586: REGRESSION (r26759-r26785): Windows nightly builds crash with Safari 3 Public Beta
+
+        http://bugs.webkit.org/show_bug.cgi?id=15586
+
+        Also fixes: <rdar://5565303> Cannot use regsvr32.exe to register WebKit.dll
+
+        Use Win32 TLS functions instead of __declspec(thread), which breaks
+        delay-loading.
+
+        Reviewed by Steve.
+
+        * wtf/FastMalloc.cpp:
+        (WTF::getThreadHeap):
+        (WTF::TCMalloc_ThreadCache::InitModule):
+
 2007-10-30  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Oliver.
index 4dc3f1c32863f68cc78c57daa7f1b06710692d76..97d2ca3b1cd232a2872382078e5c232e930ef00e 100644 (file)
@@ -190,6 +190,10 @@ extern "C" const int jscore_fastmalloc_introspection = 0;
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
+#if COMPILER(MSVC)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
 
 #if WTF_CHANGES
 
@@ -1293,13 +1297,13 @@ static inline TCMalloc_PageHeap* getPageHeap()
 static bool tsd_inited = false;
 static pthread_key_t heap_key;
 #if COMPILER(MSVC)
-__declspec(thread) TCMalloc_ThreadCache* threadHeap;
+DWORD tlsIndex = TLS_OUT_OF_INDEXES;
 #endif
 
 static ALWAYS_INLINE TCMalloc_ThreadCache* getThreadHeap()
 {
 #if COMPILER(MSVC)
-    return threadHeap;
+    return static_cast<TCMalloc_ThreadCache*>(TlsGetValue(tlsIndex));
 #else
     return static_cast<TCMalloc_ThreadCache*>(pthread_getspecific(heap_key));
 #endif
@@ -1311,7 +1315,7 @@ static ALWAYS_INLINE void setThreadHeap(TCMalloc_ThreadCache* heap)
     // benefit from the delete callback.
     pthread_setspecific(heap_key, heap);
 #if COMPILER(MSVC)
-    threadHeap = heap;
+    TlsSetValue(tlsIndex, heap);
 #endif
 }
 
@@ -1642,6 +1646,9 @@ void TCMalloc_ThreadCache::InitModule() {
 void TCMalloc_ThreadCache::InitTSD() {
   ASSERT(!tsd_inited);
   pthread_key_create(&heap_key, DeleteCache);
+#if COMPILER(MSVC)
+  tlsIndex = TlsAlloc();
+#endif
   tsd_inited = true;
     
   // We may have used a fake pthread_t for the main thread.  Fix it.