Ignore:
Timestamp:
May 13, 2009, 3:09:21 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-05-13 Dmitry Titov <[email protected]>

Rubber-stamped by Mark Rowe.

https://bugs.webkit.org/show_bug.cgi?id=25746
Revert http://trac.webkit.org/changeset/43507 which caused crash in PPC nightlies with Safari 4.

  • JavaScriptCore.exp:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def:
  • bytecode/SamplingTool.cpp: (JSC::SamplingThread::start): (JSC::SamplingThread::stop):
  • bytecode/SamplingTool.h:
  • wtf/CrossThreadRefCounted.h: (WTF::CrossThreadRefCounted::CrossThreadRefCounted): (WTF::::ref): (WTF::::deref):
  • wtf/Threading.h:
  • wtf/ThreadingNone.cpp:
  • wtf/ThreadingPthreads.cpp: (WTF::threadMapMutex): (WTF::initializeThreading): (WTF::threadMap): (WTF::identifierByPthreadHandle): (WTF::establishIdentifierForPthreadHandle): (WTF::pthreadHandleForIdentifier): (WTF::clearPthreadHandleForIdentifier): (WTF::createThreadInternal): (WTF::waitForThreadCompletion): (WTF::detachThread): (WTF::currentThread):
  • wtf/ThreadingWin.cpp: (WTF::threadMapMutex): (WTF::initializeThreading): (WTF::threadMap): (WTF::storeThreadHandleByIdentifier): (WTF::threadHandleForIdentifier): (WTF::clearThreadHandleForIdentifier): (WTF::createThreadInternal): (WTF::waitForThreadCompletion): (WTF::detachThread): (WTF::currentThread):
  • wtf/gtk/ThreadingGtk.cpp: (WTF::threadMapMutex): (WTF::initializeThreading): (WTF::threadMap): (WTF::identifierByGthreadHandle): (WTF::establishIdentifierForThread): (WTF::threadForIdentifier): (WTF::clearThreadForIdentifier): (WTF::createThreadInternal): (WTF::waitForThreadCompletion): (WTF::currentThread):
  • wtf/qt/ThreadingQt.cpp: (WTF::threadMapMutex): (WTF::threadMap): (WTF::identifierByQthreadHandle): (WTF::establishIdentifierForThread): (WTF::clearThreadForIdentifier): (WTF::threadForIdentifier): (WTF::initializeThreading): (WTF::createThreadInternal): (WTF::waitForThreadCompletion): (WTF::currentThread):

WebCore:

2009-05-13 Dmitry Titov <[email protected]>

Rubber-stamped by Mark Rowe.

https://bugs.webkit.org/show_bug.cgi?id=25746
Revert http://trac.webkit.org/changeset/43507 which caused crash in PPC nightlies with Safari 4.

  • dom/XMLTokenizerLibxml2.cpp: (WebCore::matchFunc): (WebCore::openFunc): (WebCore::createStringParser): (WebCore::createMemoryParser):
  • loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::open):
  • platform/sql/SQLiteDatabase.cpp: (WebCore::SQLiteDatabase::SQLiteDatabase): (WebCore::SQLiteDatabase::close):
  • storage/DatabaseThread.cpp: (WebCore::DatabaseThread::DatabaseThread): (WebCore::DatabaseThread::start): (WebCore::DatabaseThread::databaseThread):
  • storage/LocalStorageThread.cpp: (WebCore::LocalStorageThread::LocalStorageThread): (WebCore::LocalStorageThread::start): (WebCore::LocalStorageThread::localStorageThread): (WebCore::LocalStorageThread::scheduleImport): (WebCore::LocalStorageThread::scheduleSync): (WebCore::LocalStorageThread::terminate):
  • workers/WorkerThread.cpp: (WebCore::WorkerThread::WorkerThread): (WebCore::WorkerThread::start):

WebKit/win:

2009-05-13 Dmitry Titov <[email protected]>

Rubber-stamped by Mark Rowe.

https://bugs.webkit.org/show_bug.cgi?id=25746
Revert http://trac.webkit.org/changeset/43507 which caused crash in PPC nightlies with Safari 4.

  • WebKit.vcproj/WebKit.def:
  • WebKit.vcproj/WebKit_debug.def:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/qt/ThreadingQt.cpp

    r43637 r43663  
    4242namespace WTF {
    4343
    44 bool ThreadIdentifier::operator==(const ThreadIdentifier& another) const
    45 {
    46     return m_platformId == another.m_platformId;
    47 }
    48 
    49 bool ThreadIdentifier::operator!=(const ThreadIdentifier& another) const
    50 {
    51     return m_platformId != another.m_platformId;
    52 }
    53 
    5444class ThreadPrivate : public QThread {
    5545public:
     
    8070static ThreadIdentifier mainThreadIdentifier;
    8171
     72static Mutex& threadMapMutex()
     73{
     74    static Mutex mutex;
     75    return mutex;
     76}
     77
     78static HashMap<ThreadIdentifier, QThread*>& threadMap()
     79{
     80    static HashMap<ThreadIdentifier, QThread*> map;
     81    return map;
     82}
     83
     84static ThreadIdentifier identifierByQthreadHandle(QThread*& thread)
     85{
     86    MutexLocker locker(threadMapMutex());
     87
     88    HashMap<ThreadIdentifier, QThread*>::iterator i = threadMap().begin();
     89    for (; i != threadMap().end(); ++i) {
     90        if (i->second == thread)
     91            return i->first;
     92    }
     93
     94    return 0;
     95}
     96
     97static ThreadIdentifier establishIdentifierForThread(QThread*& thread)
     98{
     99    ASSERT(!identifierByQthreadHandle(thread));
     100
     101    MutexLocker locker(threadMapMutex());
     102
     103    static ThreadIdentifier identifierCount = 1;
     104
     105    threadMap().add(identifierCount, thread);
     106
     107    return identifierCount++;
     108}
     109
     110static void clearThreadForIdentifier(ThreadIdentifier id)
     111{
     112    MutexLocker locker(threadMapMutex());
     113
     114    ASSERT(threadMap().contains(id));
     115
     116    threadMap().remove(id);
     117}
     118
     119static QThread* threadForIdentifier(ThreadIdentifier id)
     120{
     121    MutexLocker locker(threadMapMutex());
     122
     123    return threadMap().get(id);
     124}
     125
    82126void initializeThreading()
    83127{
    84128    if (!atomicallyInitializedStaticMutex) {
    85129        atomicallyInitializedStaticMutex = new Mutex;
     130        threadMapMutex();
    86131        initializeRandomNumberGenerator();
    87         mainThreadIdentifier = ThreadIdentifier(QCoreApplication::instance()->thread());
     132        QThread* mainThread = QCoreApplication::instance()->thread();
     133        mainThreadIdentifier = identifierByQthreadHandle(mainThread);
     134        if (!mainThreadIdentifier)
     135            mainThreadIdentifier = establishIdentifierForThread(mainThread);
    88136        initializeMainThread();
    89137    }
     
    106154    if (!thread) {
    107155        LOG_ERROR("Failed to create thread at entry point %p with data %p", entryPoint, data);
    108         return ThreadIdentifier();
     156        return 0;
    109157    }
    110158    thread->start();
     
    112160    QThread* threadRef = static_cast<QThread*>(thread);
    113161
    114     return ThreadIdentifier(threadRef);
     162    return establishIdentifierForThread(threadRef);
    115163}
    116164
     
    121169int waitForThreadCompletion(ThreadIdentifier threadID, void** result)
    122170{
    123     ASSERT(threadID.isValid());
    124 
    125     QThread* thread = threadID.platformId();
     171    ASSERT(threadID);
     172
     173    QThread* thread = threadForIdentifier(threadID);
    126174
    127175    bool res = thread->wait();
    128176
     177    clearThreadForIdentifier(threadID);
    129178    if (result)
    130179        *result = static_cast<ThreadPrivate*>(thread)->getReturnValue();
     
    139188ThreadIdentifier currentThread()
    140189{
    141     return ThreadIdentifier(QThread::currentThread());
     190    QThread* currentThread = QThread::currentThread();
     191    if (ThreadIdentifier id = identifierByQthreadHandle(currentThread))
     192        return id;
     193    return establishIdentifierForThread(currentThread);
    142194}
    143195
Note: See TracChangeset for help on using the changeset viewer.