Changeset 41594 in webkit for trunk/JavaScriptCore
- Timestamp:
- Mar 11, 2009, 1:39:21 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.cpp
r38528 r41594 59 59 return 0; 60 60 } 61 61 62 62 if (completion.value()) 63 63 return toRef(completion.value()); -
trunk/JavaScriptCore/ChangeLog
r41565 r41594 1 2009-03-11 Adam Roben <[email protected]> 2 3 Change the Windows implementation of ThreadSpecific to use functions 4 instead of extern globals 5 6 This will make it easier to export ThreadSpecific from WebKit. 7 8 Reviewed by John Sullivan. 9 10 * API/JSBase.cpp: 11 (JSEvaluateScript): 12 Touched this file to force ThreadSpecific.h to be copied into 13 $WebKitOutputDir. 14 15 * wtf/ThreadSpecific.h: Replaced g_tls_key_count with tlsKeyCount() 16 and g_tls_keys with tlsKeys(). 17 18 (WTF::::ThreadSpecific): 19 (WTF::::~ThreadSpecific): 20 (WTF::::get): 21 (WTF::::set): 22 (WTF::::destroy): 23 Updated to use the new functions. 24 25 * wtf/ThreadSpecificWin.cpp: 26 (WTF::tlsKeyCount): 27 (WTF::tlsKeys): 28 Added. 29 30 (WTF::ThreadSpecificThreadExit): Changed to use the new functions. 31 1 32 2009-03-10 Cameron Zwarich <[email protected]> 2 33 -
trunk/JavaScriptCore/wtf/ThreadSpecific.h
r39708 r41594 130 130 const int kMaxTlsKeySize = 256; 131 131 132 extern long g_tls_key_count;133 extern DWORD g_tls_keys[kMaxTlsKeySize];132 long& tlsKeyCount(); 133 DWORD* tlsKeys(); 134 134 135 135 template<typename T> … … 141 141 CRASH(); 142 142 143 m_index = InterlockedIncrement(& g_tls_key_count) - 1;143 m_index = InterlockedIncrement(&tlsKeyCount()) - 1; 144 144 if (m_index >= kMaxTlsKeySize) 145 145 CRASH(); 146 g_tls_keys[m_index] = tls_key;146 tlsKeys()[m_index] = tls_key; 147 147 } 148 148 … … 151 151 { 152 152 // Does not invoke destructor functions. They will be called from ThreadSpecificThreadExit when the thread is detached. 153 TlsFree( g_tls_keys[m_index]);153 TlsFree(tlsKeys()[m_index]); 154 154 } 155 155 … … 157 157 inline T* ThreadSpecific<T>::get() 158 158 { 159 Data* data = static_cast<Data*>(TlsGetValue( g_tls_keys[m_index]));159 Data* data = static_cast<Data*>(TlsGetValue(tlsKeys()[m_index])); 160 160 return data ? data->value : 0; 161 161 } … … 167 167 Data* data = new Data(ptr, this); 168 168 data->destructor = &ThreadSpecific<T>::destroy; 169 TlsSetValue( g_tls_keys[m_index], data);169 TlsSetValue(tlsKeys()[m_index], data); 170 170 } 171 171 … … 191 191 pthread_setspecific(data->owner->m_key, 0); 192 192 #elif PLATFORM(WIN_OS) 193 TlsSetValue( g_tls_keys[data->owner->m_index], 0);193 TlsSetValue(tlsKeys()[data->owner->m_index], 0); 194 194 #else 195 195 #error ThreadSpecific is not implemented for this platform. -
trunk/JavaScriptCore/wtf/ThreadSpecificWin.cpp
r39708 r41594 30 30 namespace WTF { 31 31 32 long g_tls_key_count = 0; 33 DWORD g_tls_keys[kMaxTlsKeySize]; 32 long& tlsKeyCount() 33 { 34 static long count; 35 return count; 36 } 37 38 DWORD* tlsKeys() 39 { 40 static DWORD keys[kMaxTlsKeySize]; 41 return keys; 42 } 34 43 35 44 void ThreadSpecificThreadExit() 36 45 { 37 for (long i = 0; i < g_tls_key_count; i++) {46 for (long i = 0; i < tlsKeyCount(); i++) { 38 47 // The layout of ThreadSpecific<T>::Data does not depend on T. So we are safe to do the static cast to ThreadSpecific<int> in order to access its data member. 39 ThreadSpecific<int>::Data* data = static_cast<ThreadSpecific<int>::Data*>(TlsGetValue( g_tls_keys[i]));48 ThreadSpecific<int>::Data* data = static_cast<ThreadSpecific<int>::Data*>(TlsGetValue(tlsKeys()[i])); 40 49 if (data) 41 50 data->destructor(data);
Note:
See TracChangeset
for help on using the changeset viewer.