Changeset 76214 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- Jan 20, 2011, 12:49:00 AM (14 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r76193 r76214 1 2011-01-20 Mark Rowe <[email protected]> 2 3 Reviewed by Maciej Stachowiak. 4 5 Follow-up to r75766 / <rdar://problem/5469576>. 6 7 We were failing to initialize the key, causing all sorts of unexpected behavior. 8 9 * wtf/FastMalloc.cpp: 10 (WTF::setThreadHeap): 11 (WTF::TCMalloc_ThreadCache::GetThreadHeap): 12 (WTF::TCMalloc_ThreadCache::InitTSD): Ensure that the key is initialized. 13 1 14 2011-01-18 Geoffrey Garen <[email protected]> 2 15 -
trunk/Source/JavaScriptCore/wtf/FastMalloc.cpp
r75839 r76214 454 454 #if HAVE(PTHREAD_MACHDEP_H) 455 455 #include <System/pthread_machdep.h> 456 457 #if defined(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0) 458 #define WTF_USE_PTHREAD_GETSPECIFIC_DIRECT 1 459 #endif 456 460 #endif 457 461 … … 464 468 // use a function pointer. But that's not necessarily faster on other platforms, and we had 465 469 // problems with this technique on Windows, so we'll do this only on Mac OS X. 466 #if OS(DARWIN) && !defined(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0) 470 #if OS(DARWIN) 471 #if !USE(PTHREAD_GETSPECIFIC_DIRECT) 467 472 static void* (*pthread_getspecific_function_pointer)(pthread_key_t) = pthread_getspecific; 468 473 #define pthread_getspecific(key) pthread_getspecific_function_pointer(key) 474 #else 475 #define pthread_getspecific(key) _pthread_getspecific_direct(key) 476 #define pthread_setspecific(key, val) _pthread_setspecific_direct(key, (val)) 477 #endif 469 478 #endif 470 479 … … 2520 2529 // Until then, we use a slow path to get the heap object. 2521 2530 static bool tsd_inited = false; 2531 #if USE(PTHREAD_GETSPECIFIC_DIRECT) 2532 static const pthread_key_t heap_key = __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0; 2533 #else 2522 2534 static pthread_key_t heap_key; 2535 #endif 2523 2536 #if OS(WINDOWS) 2524 2537 DWORD tlsIndex = TLS_OUT_OF_INDEXES; … … 2527 2540 static ALWAYS_INLINE void setThreadHeap(TCMalloc_ThreadCache* heap) 2528 2541 { 2542 #if USE(PTHREAD_GETSPECIFIC_DIRECT) 2543 // Can't have two libraries both doing this in the same process, 2544 // so check and make this crash right away. 2545 if (pthread_getspecific(heap_key)) 2546 CRASH(); 2547 #endif 2548 2529 2549 // Still do pthread_setspecific even if there's an alternate form 2530 2550 // of thread-local storage in use, to benefit from the delete callback. … … 2533 2553 #if OS(WINDOWS) 2534 2554 TlsSetValue(tlsIndex, heap); 2535 #elif defined(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0)2536 // Can't have two libraries both doing this in the same process,2537 // so check and make this crash right away.2538 if (_pthread_getspecific_direct(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0))2539 CRASH();2540 _pthread_setspecific_direct(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0, heap);2541 2555 #endif 2542 2556 } … … 3050 3064 #elif OS(WINDOWS) 3051 3065 return static_cast<TCMalloc_ThreadCache*>(TlsGetValue(tlsIndex)); 3052 #elif defined(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0)3053 return static_cast<TCMalloc_ThreadCache*>(_pthread_getspecific_direct(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0));3054 3066 #else 3055 3067 return static_cast<TCMalloc_ThreadCache*>(pthread_getspecific(heap_key)); … … 3079 3091 void TCMalloc_ThreadCache::InitTSD() { 3080 3092 ASSERT(!tsd_inited); 3093 #if USE(PTHREAD_GETSPECIFIC_DIRECT) 3094 pthread_key_init_np(heap_key, DestroyThreadCache); 3095 #else 3081 3096 pthread_key_create(&heap_key, DestroyThreadCache); 3097 #endif 3082 3098 #if OS(WINDOWS) 3083 3099 tlsIndex = TlsAlloc();
Note:
See TracChangeset
for help on using the changeset viewer.