+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.
#include <stddef.h>
#include <stdio.h>
#include <string.h>
+#if COMPILER(MSVC)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
#if WTF_CHANGES
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
// benefit from the delete callback.
pthread_setspecific(heap_key, heap);
#if COMPILER(MSVC)
- threadHeap = heap;
+ TlsSetValue(tlsIndex, heap);
#endif
}
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.