Ignore:
Timestamp:
Sep 4, 2007, 10:15:06 PM (18 years ago)
Author:
mjs
Message:

Back out accidentally committed change.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/collector.cpp: (KJS::Collector::registerThread):
  • wtf/FastMalloc.cpp: (WTF::fastMallocSetIsMultiThreaded): (WTF::TCMalloc_ThreadCache::GetCache): (WTF::TCMalloc_ThreadCache::GetCacheIfPresent): (WTF::TCMalloc_ThreadCache::CreateCacheIfNecessary): (WTF::do_malloc):
  • wtf/FastMallocInternal.h: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/FastMalloc.cpp

    r25365 r25366  
    161161}
    162162
     163void fastMallocSetIsMultiThreaded()
     164{
     165}
     166
    163167} // namespace WTF
    164168
     
    15471551}
    15481552
     1553#ifdef WTF_CHANGES
     1554bool isMultiThreaded;
     1555TCMalloc_ThreadCache *mainThreadCache;
     1556
     1557void fastMallocSetIsMultiThreaded()
     1558{
     1559    // We lock when writing mainThreadCache but not when reading it. It's OK if
     1560    // the main thread reads a stale, non-NULL value for mainThreadCache because
     1561    // mainThreadCache is the same as the main thread's thread-specific cache.
     1562    // Other threads can't read a stale, non-NULL value for mainThreadCache because
     1563    // clients must call this function before allocating on other threads, so they'll
     1564    // have synchronized before reading mainThreadCache.
     1565   
     1566    // A similar principle applies to isMultiThreaded. It's OK for the main thread
     1567    // in GetCache() to read a stale, false value for isMultiThreaded because
     1568    // doing so will just cause it to make an unnecessary call to InitModule(),
     1569    // which will synchronize it.
     1570
     1571    // To save a branch in some cases, mainThreadCache is only set when
     1572    // isMultiThreaded is false.
     1573
     1574    {
     1575        SpinLockHolder lock(&pageheap_lock);
     1576        isMultiThreaded = true;
     1577        mainThreadCache = 0;
     1578    }
     1579
     1580    TCMalloc_ThreadCache::InitModule();
     1581}
     1582#endif
     1583
    15491584ALWAYS_INLINE TCMalloc_ThreadCache* TCMalloc_ThreadCache::GetCache() {
    15501585  void* ptr = NULL;
     1586#ifndef WTF_CHANGES
    15511587  if (!tsd_inited) {
    15521588    InitModule();
     
    15541590    ptr = pthread_getspecific(heap_key);
    15551591  }
     1592#else
     1593  if (mainThreadCache) // fast path for single-threaded mode
     1594    return mainThreadCache;
     1595
     1596  if (isMultiThreaded) // fast path for multi-threaded mode -- heap_key already initialized
     1597    ptr = pthread_getspecific(heap_key);
     1598  else // slow path for possible first-time init
     1599    InitModule();
     1600#endif
    15561601  if (ptr == NULL) ptr = CreateCacheIfNecessary();
    15571602  return reinterpret_cast<TCMalloc_ThreadCache*>(ptr);
     
    15621607// already cleaned up the cache for this thread.
    15631608inline TCMalloc_ThreadCache* TCMalloc_ThreadCache::GetCacheIfPresent() {
     1609  if (mainThreadCache)
     1610      return mainThreadCache;
    15641611  if (!tsd_inited) return NULL;
    15651612  return reinterpret_cast<TCMalloc_ThreadCache*>
     
    16631710      thread_heap_count++;
    16641711      RecomputeThreadCacheSize();
     1712      if (!isMultiThreaded)
     1713        mainThreadCache = heap;
    16651714    }
    16661715  }
     
    19932042
    19942043#ifdef WTF_CHANGES
     2044    ASSERT(isMultiThreaded || pthread_main_np());
    19952045    ASSERT(!isForbidden());
    19962046#endif
Note: See TracChangeset for help on using the changeset viewer.