Changeset 96722 in webkit for trunk/Source/JavaScriptCore/heap


Ignore:
Timestamp:
Oct 5, 2011, 10:44:26 AM (14 years ago)
Author:
Patrick Gansterer
Message:

Get rid of posixThread in MachineStackMarker::Thread
https://bugs.webkit.org/show_bug.cgi?id=54836

Reviewed by Oliver Hunt.

  • heap/MachineStackMarker.cpp:

(JSC::MachineThreads::Thread::Thread):
(JSC::getCurrentPlatformThread):
(JSC::equalThread):
(JSC::MachineThreads::addCurrentThread):
(JSC::MachineThreads::removeCurrentThread):
(JSC::MachineThreads::gatherConservativeRoots):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp

    r95922 r96722  
    112112class MachineThreads::Thread {
    113113public:
    114     Thread(pthread_t pthread, const PlatformThread& platThread, void* base)
    115         : posixThread(pthread)
    116         , platformThread(platThread)
     114    Thread(const PlatformThread& platThread, void* base)
     115        : platformThread(platThread)
    117116        , stackBase(base)
    118117    {
     
    133132
    134133    Thread* next;
    135     pthread_t posixThread;
    136134    PlatformThread platformThread;
    137135    void* stackBase;
     
    165163    return pthread_mach_thread_np(pthread_self());
    166164#elif OS(WINDOWS)
    167     return pthread_getw32threadhandle_np(pthread_self());
     165    return GetCurrentThread();
    168166#elif USE(PTHREADS)
    169167    return pthread_self();
     168#endif
     169}
     170
     171static inline bool equalThread(const PlatformThread& first, const PlatformThread& second)
     172{
     173#if OS(DARWIN) || OS(WINDOWS)
     174    return first == second;
     175#elif USE(PTHREADS)
     176    return !!pthread_equal(first, second);
     177#else
     178#error Need a way to compare threads on this platform
    170179#endif
    171180}
     
    189198
    190199    pthread_setspecific(m_threadSpecific, this);
    191     Thread* thread = new Thread(pthread_self(), getCurrentPlatformThread(), m_heap->globalData()->stack().origin());
     200    Thread* thread = new Thread(getCurrentPlatformThread(), m_heap->globalData()->stack().origin());
    192201
    193202    MutexLocker lock(m_registeredThreadsMutex);
     
    205214void MachineThreads::removeCurrentThread()
    206215{
    207     pthread_t currentPosixThread = pthread_self();
     216    PlatformThread currentPlatformThread = getCurrentPlatformThread();
    208217
    209218    MutexLocker lock(m_registeredThreadsMutex);
    210219
    211     if (pthread_equal(currentPosixThread, m_registeredThreads->posixThread)) {
     220    if (equalThread(currentPlatformThread, m_registeredThreads->platformThread)) {
    212221        Thread* t = m_registeredThreads;
    213222        m_registeredThreads = m_registeredThreads->next;
     
    217226        Thread* t;
    218227        for (t = m_registeredThreads->next; t; t = t->next) {
    219             if (pthread_equal(t->posixThread, currentPosixThread)) {
     228            if (equalThread(t->platformThread, currentPlatformThread)) {
    220229                last->next = t->next;
    221230                break;
     
    468477
    469478    if (m_threadSpecific) {
     479        PlatformThread currentPlatformThread = getCurrentPlatformThread();
    470480
    471481        MutexLocker lock(m_registeredThreadsMutex);
     
    480490        // and since this is a shared heap, they are real locks.
    481491        for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
    482             if (!pthread_equal(thread->posixThread, pthread_self()))
     492            if (!equalThread(thread->platformThread, currentPlatformThread))
    483493                gatherFromOtherThread(conservativeRoots, thread);
    484494        }
Note: See TracChangeset for help on using the changeset viewer.