Changeset 31864 in webkit for trunk/JavaScriptCore
- Timestamp:
- Apr 14, 2008, 9:30:13 AM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r31862 r31864 1 2008-04-14 Alexey Proskuryakov <[email protected]> 2 3 Reviewed by Adam Roben. 4 5 https://bugs.webkit.org/show_bug.cgi?id=18488 6 FastMalloc doesn't release thread-specific data on Windows 7 8 * wtf/ThreadingWin.cpp: 9 (WTF::threadMapMutex): (WTF::initializeThreading): Call threadMapMutex once to initialize the static safely. 10 (WTF::ThreadFunctionInvocation::ThreadFunctionInvocation): Added a structure to wrap thread entry point and arguments. 11 (WTF::wtfThreadEntryPoint): Make sure to end all WTF threads with pthread_exit(), to give pthreads-win32 a chance to call 12 destructors of thread-specific data. 13 (WTF::createThread): Use _beginthreadex instead of CreateThread, because MSDN says so. Also removed a call to CreateEvent, 14 for which I could see no reason at all. 15 1 16 2008-04-14 Alexey Proskuryakov <[email protected]> 2 17 -
trunk/JavaScriptCore/wtf/ThreadingWin.cpp
r31730 r31864 65 65 66 66 #include "MainThread.h" 67 #include <process.h> 67 68 #include <windows.h> 68 69 #include <wtf/HashMap.h> 69 70 #include <wtf/MathExtras.h> 70 71 72 #if PLATFORM(WIN) 73 // Currently, Apple's Windows port uses a mixture of native and pthreads functions in FastMalloc. 74 // To ensure that thread-specific data is properly destroyed, we need to end each thread with pthread_exit(). 75 #include <pthreads.h> 76 #endif 77 71 78 namespace WTF { 72 79 … … 74 81 75 82 static ThreadIdentifier mainThreadIdentifier; 83 84 static Mutex& threadMapMutex() 85 { 86 static Mutex mutex; 87 return mutex; 88 } 76 89 77 90 void initializeThreading() … … 79 92 if (!atomicallyInitializedStaticMutex) { 80 93 atomicallyInitializedStaticMutex = new Mutex; 94 threadMapMutex(); 81 95 wtf_random_init(); 82 96 initializeMainThread(); … … 85 99 } 86 100 87 static Mutex& threadMapMutex()88 {89 static Mutex mutex;90 return mutex;91 }92 93 101 static HashMap<DWORD, HANDLE>& threadMap() 94 102 { … … 116 124 } 117 125 126 struct ThreadFunctionInvocation { 127 ThreadFunctionInvocation(ThreadFunction function, void* data) : function(function), data(data) {} 128 129 ThreadFunction function; 130 void* data; 131 }; 132 133 static unsigned __stdcall wtfThreadEntryPoint(void* param) 134 { 135 ThreadFunctionInvocation invocation = *static_cast<ThreadFunctionInvocation*>(param); 136 delete static_cast<ThreadFunctionInvocation*>(param); 137 138 void* result = invocation.function(invocation.data); 139 140 #if PLATFORM(WIN) 141 // pthreads-win32 knows how to work with threads created with Win32 or CRT functions, so it's OK to mix APIs. 142 pthread_exit(result); 143 #endif 144 145 return reinterpret_cast<unsigned>(result); 146 } 147 118 148 ThreadIdentifier createThread(ThreadFunction entryPoint, void* data) 119 149 { 120 DWORDthreadIdentifier = 0;150 unsigned threadIdentifier = 0; 121 151 ThreadIdentifier threadID = 0; 122 HANDLE hEvent = ::CreateEvent(0, FALSE, FALSE, 0);123 HANDLE threadHandle = ::CreateThread(0, 0, (LPTHREAD_START_ROUTINE)entryPoint, data, 0, &threadIdentifier);152 ThreadFunctionInvocation* invocation = new ThreadFunctionInvocation(entryPoint, data); 153 HANDLE threadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, wtfThreadEntryPoint, invocation, 0, &threadIdentifier)); 124 154 if (!threadHandle) { 125 LOG_ERROR("Failed to create thread at entry point %p with data %p ", entryPoint, data);155 LOG_ERROR("Failed to create thread at entry point %p with data %p: %ld", entryPoint, data, errno); 126 156 return 0; 127 157 }
Note:
See TracChangeset
for help on using the changeset viewer.