Changeset 26760 in webkit


Ignore:
Timestamp:
Oct 18, 2007 7:14:09 PM (17 years ago)
Author:
mjs
Message:

Reviewed by Adam.


  • use declspec(thread) for fast thread-local storage on Windows


  • 2.2% speedup on sunspider (on Windows)
  • 7% speedup on the string section
  • 6% speedup on JS iBench


  • fixed <rdar://problem/5473084> PLT on Windows got 2.5% slower between r25406 and r25422
  • fixed at least some of <rdar://5527965? i-Bench JS was 14% slower in 310A11 than 310A10



  • wtf/FastMalloc.cpp: (WTF::getThreadHeap): (WTF::setThreadHeap): (WTF::TCMalloc_ThreadCache::GetCache): (WTF::TCMalloc_ThreadCache::GetCacheIfPresent): (WTF::TCMalloc_ThreadCache::CreateCacheIfNecessary):
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r26720 r26760  
     12007-10-18  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Adam.
     4       
     5        - use __declspec(thread) for fast thread-local storage on Windows
     6       
     7        - 2.2% speedup on sunspider (on Windows)
     8        - 7% speedup on the string section
     9        - 6% speedup on JS iBench
     10       
     11        - fixed <rdar://problem/5473084> PLT on Windows got 2.5% slower between r25406 and r25422
     12        - fixed at least some of <rdar://5527965? i-Bench JS was 14% slower in 310A11 than 310A10
     13       
     14       
     15        * wtf/FastMalloc.cpp:
     16        (WTF::getThreadHeap):
     17        (WTF::setThreadHeap):
     18        (WTF::TCMalloc_ThreadCache::GetCache):
     19        (WTF::TCMalloc_ThreadCache::GetCacheIfPresent):
     20        (WTF::TCMalloc_ThreadCache::CreateCacheIfNecessary):
     21
    1222007-10-17  Darin Adler  <darin@apple.com>
    223
  • trunk/JavaScriptCore/wtf/FastMalloc.cpp

    r25637 r26760  
    11851185  static TCMalloc_ThreadCache* GetCache();
    11861186  static TCMalloc_ThreadCache* GetCacheIfPresent();
    1187   static void*                CreateCacheIfNecessary();
     1187  static TCMalloc_ThreadCache* CreateCacheIfNecessary();
    11881188  static void                  DeleteCache(void* ptr);
    11891189  static void                  RecomputeThreadCacheSize();
     
    12931293static bool tsd_inited = false;
    12941294static pthread_key_t heap_key;
     1295#if COMPILER(MSVC)
     1296__declspec(thread) TCMalloc_ThreadCache* threadHeap;
     1297#endif
     1298
     1299static ALWAYS_INLINE TCMalloc_ThreadCache* getThreadHeap()
     1300{
     1301#if COMPILER(MSVC)
     1302    return threadHeap;
     1303#else
     1304    return static_cast<TCMalloc_ThreadCache*>(pthread_getspecific(heap_key));
     1305#endif
     1306}
     1307
     1308static ALWAYS_INLINE void setThreadHeap(TCMalloc_ThreadCache* heap)
     1309{
     1310    // still do pthread_setspecific when using MSVC fast TLS to
     1311    // benefit from the delete callback.
     1312    pthread_setspecific(heap_key, heap);
     1313#if COMPILER(MSVC)
     1314    threadHeap = heap;
     1315#endif
     1316}
    12951317
    12961318// Allocator for thread heaps
     
    15581580
    15591581ALWAYS_INLINE TCMalloc_ThreadCache* TCMalloc_ThreadCache::GetCache() {
    1560   void* ptr = NULL;
     1582  TCMalloc_ThreadCache* ptr = NULL;
    15611583  if (!tsd_inited) {
    15621584    InitModule();
    15631585  } else {
    1564     ptr = pthread_getspecific(heap_key);
     1586      ptr = getThreadHeap();
    15651587  }
    15661588  if (ptr == NULL) ptr = CreateCacheIfNecessary();
    1567   return static_cast<TCMalloc_ThreadCache*>(ptr);
     1589  return ptr;
    15681590}
    15691591
     
    15731595inline TCMalloc_ThreadCache* TCMalloc_ThreadCache::GetCacheIfPresent() {
    15741596  if (!tsd_inited) return NULL;
    1575   return static_cast<TCMalloc_ThreadCache*>(pthread_getspecific(heap_key));
     1597  return getThreadHeap();
    15761598}
    15771599
     
    16381660}
    16391661
    1640 void* TCMalloc_ThreadCache::CreateCacheIfNecessary() {
     1662TCMalloc_ThreadCache* TCMalloc_ThreadCache::CreateCacheIfNecessary() {
    16411663  // Initialize per-thread data if necessary
    16421664  TCMalloc_ThreadCache* heap = NULL;
     
    16811703  if (!heap->setspecific_ && tsd_inited) {
    16821704    heap->setspecific_ = true;
    1683     pthread_setspecific(heap_key, heap);
     1705    setThreadHeap(heap);
    16841706  }
    16851707  return heap;
Note: See TracChangeset for help on using the changeset viewer.