Changeset 219260 in webkit


Ignore:
Timestamp:
Jul 7, 2017 11:30:09 AM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r219238, r219239, and r219241.
https://bugs.webkit.org/show_bug.cgi?id=174265

"fast/workers/dedicated-worker-lifecycle.html is flaky"
(Requested by yusukesuzuki on #webkit).

Reverted changesets:

"[WTF] Implement WTF::ThreadGroup"
https://bugs.webkit.org/show_bug.cgi?id=174081
http://trac.webkit.org/changeset/219238

"Unreviewed, build fix after r219238"
https://bugs.webkit.org/show_bug.cgi?id=174081
http://trac.webkit.org/changeset/219239

"Unreviewed, CLoop build fix after r219238"
https://bugs.webkit.org/show_bug.cgi?id=174081
http://trac.webkit.org/changeset/219241

Location:
trunk
Files:
3 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp

    r219238 r219260  
    3737#include <wtf/CurrentTime.h>
    3838#include <wtf/Lock.h>
    39 #include <wtf/Threading.h>
    4039#include <wtf/text/StringBuilder.h>
    4140
  • trunk/Source/JavaScriptCore/ChangeLog

    r219241 r219260  
     12017-07-07  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r219238, r219239, and r219241.
     4        https://bugs.webkit.org/show_bug.cgi?id=174265
     5
     6        "fast/workers/dedicated-worker-lifecycle.html is flaky"
     7        (Requested by yusukesuzuki on #webkit).
     8
     9        Reverted changesets:
     10
     11        "[WTF] Implement WTF::ThreadGroup"
     12        https://bugs.webkit.org/show_bug.cgi?id=174081
     13        http://trac.webkit.org/changeset/219238
     14
     15        "Unreviewed, build fix after r219238"
     16        https://bugs.webkit.org/show_bug.cgi?id=174081
     17        http://trac.webkit.org/changeset/219239
     18
     19        "Unreviewed, CLoop build fix after r219238"
     20        https://bugs.webkit.org/show_bug.cgi?id=174081
     21        http://trac.webkit.org/changeset/219241
     22
    1232017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
    224
  • trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp

    r219241 r219260  
    2424
    2525#include "ConservativeRoots.h"
    26 #include "MachineContext.h"
     26#include "GPRInfo.h"
     27#include "Heap.h"
     28#include "JSArray.h"
     29#include "JSCInlines.h"
     30#include "LLIntPCRanges.h"
     31#include "MacroAssembler.h"
     32#include "VM.h"
    2733#include <setjmp.h>
    2834#include <stdlib.h>
    29 #include <wtf/BitVector.h>
    30 #include <wtf/PageBlock.h>
     35#include <wtf/MainThread.h>
     36#include <wtf/NeverDestroyed.h>
    3137#include <wtf/StdLibExtras.h>
    3238
     
    3541namespace JSC {
    3642
     43class ActiveMachineThreadsManager;
     44static ActiveMachineThreadsManager& activeMachineThreadsManager();
     45
     46class ActiveMachineThreadsManager {
     47    WTF_MAKE_NONCOPYABLE(ActiveMachineThreadsManager);
     48public:
     49
     50    class Locker {
     51    public:
     52        Locker(ActiveMachineThreadsManager& manager)
     53            : m_locker(manager.m_lock)
     54        {
     55        }
     56
     57    private:
     58        LockHolder m_locker;
     59    };
     60
     61    void add(MachineThreads* machineThreads)
     62    {
     63        LockHolder managerLock(m_lock);
     64        m_set.add(machineThreads);
     65    }
     66
     67    void THREAD_SPECIFIC_CALL remove(MachineThreads* machineThreads)
     68    {
     69        LockHolder managerLock(m_lock);
     70        auto recordedMachineThreads = m_set.take(machineThreads);
     71        RELEASE_ASSERT(recordedMachineThreads == machineThreads);
     72    }
     73
     74    bool contains(MachineThreads* machineThreads)
     75    {
     76        return m_set.contains(machineThreads);
     77    }
     78
     79private:
     80    typedef HashSet<MachineThreads*> MachineThreadsSet;
     81
     82    ActiveMachineThreadsManager() { }
     83   
     84    Lock m_lock;
     85    MachineThreadsSet m_set;
     86
     87    friend ActiveMachineThreadsManager& activeMachineThreadsManager();
     88};
     89
     90static ActiveMachineThreadsManager& activeMachineThreadsManager()
     91{
     92    static std::once_flag initializeManagerOnceFlag;
     93    static ActiveMachineThreadsManager* manager = nullptr;
     94
     95    std::call_once(initializeManagerOnceFlag, [] {
     96        manager = new ActiveMachineThreadsManager();
     97    });
     98    return *manager;
     99}
     100
     101#if CPU(X86_64) && OS(DARWIN)
     102#define FILL_CALLEE_SAVES_FOR_CRASH_INFO(number)     \
     103    asm volatile(                                    \
     104        "movq $0xc0defefe000000" number ", %%rbx;" \
     105        "movq $0xc0defefe000000" number ", %%r12;" \
     106        "movq $0xc0defefe000000" number ", %%r13;" \
     107        "movq $0xc0defefe000000" number ", %%r14;" \
     108        "movq $0xc0defefe000000" number ", %%r15;" \
     109        :                                            \
     110        :                                            \
     111        : "%rbx", "%r12", "%r13", "%r14", "%r15"     \
     112    );
     113
     114#define FILL_CALLER_SAVES_FOR_CRASH_INFO(number)     \
     115    asm volatile(                                    \
     116        "movq $0xc0defefe000000" number ", %%rax;" \
     117        "movq $0xc0defefe000000" number ", %%rdi;" \
     118        "movq $0xc0defefe000000" number ", %%rsi;" \
     119        "movq $0xc0defefe000000" number ", %%rdx;" \
     120        "movq $0xc0defefe000000" number ", %%rcx;" \
     121        "movq $0xc0defefe000000" number ", %%r8;"  \
     122        "movq $0xc0defefe000000" number ", %%r9;"  \
     123        "movq $0xc0defefe000000" number ", %%r10;" \
     124        "movq $0xc0defefe000000" number ", %%r11;" \
     125        :                                            \
     126        :                                            \
     127        : "%rax", "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9", "%r10", "%r11" \
     128    );
     129#else
     130#define FILL_CALLEE_SAVES_FOR_CRASH_INFO(number)
     131#define FILL_CALLER_SAVES_FOR_CRASH_INFO(number)
     132#endif
     133
    37134MachineThreads::MachineThreads()
    38     : m_threadGroup(ThreadGroup::create())
    39 {
     135    : m_registeredThreads()
     136    , m_threadSpecificForMachineThreads(0)
     137{
     138    FILL_CALLEE_SAVES_FOR_CRASH_INFO("01");
     139    threadSpecificKeyCreate(&m_threadSpecificForMachineThreads, removeThread);
     140    FILL_CALLEE_SAVES_FOR_CRASH_INFO("02");
     141    activeMachineThreadsManager().add(this);
     142    FILL_CALLER_SAVES_FOR_CRASH_INFO("03");
     143}
     144
     145MachineThreads::~MachineThreads()
     146{
     147    activeMachineThreadsManager().remove(this);
     148    threadSpecificKeyDelete(m_threadSpecificForMachineThreads);
     149
     150    LockHolder registeredThreadsLock(m_registeredThreadsMutex);
     151    for (MachineThread* current = m_registeredThreads.head(); current;) {
     152        MachineThread* next = current->next();
     153        delete current;
     154        current = next;
     155    }
     156}
     157
     158void MachineThreads::addCurrentThread()
     159{
     160    if (threadSpecificGet(m_threadSpecificForMachineThreads)) {
     161#ifndef NDEBUG
     162        LockHolder lock(m_registeredThreadsMutex);
     163        ASSERT(threadSpecificGet(m_threadSpecificForMachineThreads) == this);
     164#endif
     165        return;
     166    }
     167
     168    MachineThread* thread = new MachineThread();
     169    threadSpecificSet(m_threadSpecificForMachineThreads, this);
     170
     171    LockHolder lock(m_registeredThreadsMutex);
     172
     173    m_registeredThreads.append(thread);
     174}
     175
     176auto MachineThreads::machineThreadForCurrentThread() -> MachineThread*
     177{
     178    LockHolder lock(m_registeredThreadsMutex);
     179    ThreadIdentifier id = currentThread();
     180    for (MachineThread* thread = m_registeredThreads.head(); thread; thread = thread->next()) {
     181        if (thread->threadID() == id)
     182            return thread;
     183    }
     184
     185    RELEASE_ASSERT_NOT_REACHED();
     186    return nullptr;
     187}
     188
     189void THREAD_SPECIFIC_CALL MachineThreads::removeThread(void* p)
     190{
     191    auto& manager = activeMachineThreadsManager();
     192    ActiveMachineThreadsManager::Locker lock(manager);
     193    auto machineThreads = static_cast<MachineThreads*>(p);
     194    if (manager.contains(machineThreads)) {
     195        // There's a chance that the MachineThreads registry that this thread
     196        // was registered with was already destructed, and another one happened
     197        // to be instantiated at the same address. Hence, this thread may or
     198        // may not be found in this MachineThreads registry. We only need to
     199        // do a removal if this thread is found in it.
     200
     201#if OS(WINDOWS)
     202        // On Windows the thread specific destructor is also called when the
     203        // main thread is exiting. This may lead to the main thread waiting
     204        // forever for the machine thread lock when exiting, if the sampling
     205        // profiler thread was terminated by the system while holding the
     206        // machine thread lock.
     207        if (WTF::isMainThread())
     208            return;
     209#endif
     210
     211        machineThreads->removeThreadIfFound(currentThread());
     212    }
     213}
     214
     215void MachineThreads::removeThreadIfFound(ThreadIdentifier id)
     216{
     217    LockHolder lock(m_registeredThreadsMutex);
     218    for (MachineThread* current = m_registeredThreads.head(); current; current = current->next()) {
     219        if (current->threadID() == id) {
     220            m_registeredThreads.remove(current);
     221            delete current;
     222            break;
     223        }
     224    }
    40225}
    41226
     
    51236    conservativeRoots.add(currentThreadState.stackTop, currentThreadState.stackOrigin, jitStubRoutines, codeBlocks);
    52237}
     238
     239MachineThreads::MachineThread::MachineThread()
     240    : m_thread(WTF::Thread::current())
     241{
     242}
     243
     244size_t MachineThreads::MachineThread::getRegisters(MachineThread::Registers& registers)
     245{
     246    WTF::PlatformRegisters& regs = registers.regs;
     247    return m_thread->getRegisters(regs);
     248}
     249
     250void* MachineThreads::MachineThread::Registers::stackPointer() const
     251{
     252    return MachineContext::stackPointer(regs);
     253}
     254
     255#if ENABLE(SAMPLING_PROFILER)
     256void* MachineThreads::MachineThread::Registers::framePointer() const
     257{
     258#if OS(WINDOWS) || HAVE(MACHINE_CONTEXT)
     259    return MachineContext::framePointer(regs);
     260#else
     261#error Need a way to get the frame pointer for another thread on this platform
     262#endif
     263}
     264
     265void* MachineThreads::MachineThread::Registers::instructionPointer() const
     266{
     267#if OS(WINDOWS) || HAVE(MACHINE_CONTEXT)
     268    return MachineContext::instructionPointer(regs);
     269#else
     270#error Need a way to get the instruction pointer for another thread on this platform
     271#endif
     272}
     273
     274void* MachineThreads::MachineThread::Registers::llintPC() const
     275{
     276    // LLInt uses regT4 as PC.
     277#if OS(WINDOWS) || HAVE(MACHINE_CONTEXT)
     278    return MachineContext::llintInstructionPointer(regs);
     279#else
     280#error Need a way to get the LLIntPC for another thread on this platform
     281#endif
     282}
     283#endif // ENABLE(SAMPLING_PROFILER)
    53284
    54285static inline int osRedZoneAdjustment()
     
    67298}
    68299
    69 static std::pair<void*, size_t> captureStack(Thread& thread, void* stackTop)
    70 {
    71     char* begin = reinterpret_cast_ptr<char*>(thread.stack().origin());
     300std::pair<void*, size_t> MachineThreads::MachineThread::captureStack(void* stackTop)
     301{
     302    char* begin = reinterpret_cast_ptr<char*>(stackBase());
    72303    char* end = bitwise_cast<char*>(WTF::roundUpToMultipleOf<sizeof(void*)>(reinterpret_cast<uintptr_t>(stackTop)));
    73304    ASSERT(begin >= end);
     
    76307    ASSERT(WTF::roundUpToMultipleOf<sizeof(void*)>(reinterpret_cast<uintptr_t>(endWithRedZone)) == reinterpret_cast<uintptr_t>(endWithRedZone));
    77308
    78     if (endWithRedZone < thread.stack().end())
    79         endWithRedZone = reinterpret_cast_ptr<char*>(thread.stack().end());
     309    if (endWithRedZone < stackEnd())
     310        endWithRedZone = reinterpret_cast_ptr<char*>(stackEnd());
    80311
    81312    std::swap(begin, endWithRedZone);
     
    110341// operation. As the heap is generally much larger than the stack the performance hit is minimal.
    111342// See: https://bugs.webkit.org/show_bug.cgi?id=146297
    112 void MachineThreads::tryCopyOtherThreadStack(Thread& thread, void* buffer, size_t capacity, size_t* size)
    113 {
    114     PlatformRegisters registers;
    115     size_t registersSize = thread.getRegisters(registers);
     343void MachineThreads::tryCopyOtherThreadStack(MachineThread* thread, void* buffer, size_t capacity, size_t* size)
     344{
     345    MachineThread::Registers registers;
     346    size_t registersSize = thread->getRegisters(registers);
    116347
    117348    // This is a workaround for <rdar://problem/27607384>. libdispatch recycles work
    118349    // queue threads without running pthread exit destructors. This can cause us to scan a
    119350    // thread during work queue initialization, when the stack pointer is null.
    120     if (UNLIKELY(!MachineContext::stackPointer(registers))) {
     351    if (UNLIKELY(!registers.stackPointer())) {
    121352        *size = 0;
    122353        return;
    123354    }
    124355
    125     std::pair<void*, size_t> stack = captureStack(thread, MachineContext::stackPointer(registers));
     356    std::pair<void*, size_t> stack = thread->captureStack(registers.stackPointer());
    126357
    127358    bool canCopy = *size + registersSize + stack.second <= capacity;
     
    136367}
    137368
    138 bool MachineThreads::tryCopyOtherThreadStacks(const AbstractLocker& locker, void* buffer, size_t capacity, size_t* size)
     369bool MachineThreads::tryCopyOtherThreadStacks(const AbstractLocker&, void* buffer, size_t capacity, size_t* size)
    139370{
    140371    // Prevent two VMs from suspending each other's threads at the same time,
     
    145376    *size = 0;
    146377
    147     Thread& currentThread = Thread::current();
    148     const auto& threads = m_threadGroup->threads(locker);
    149     BitVector isSuspended(threads.size());
    150 
    151     {
    152         unsigned index = 0;
    153         for (auto* thread : threads) {
    154             if (*thread != currentThread) {
    155                 auto result = thread->suspend();
    156                 if (result)
    157                     isSuspended.set(index);
    158                 else {
     378    ThreadIdentifier id = currentThread();
     379    int numberOfThreads = 0; // Using 0 to denote that we haven't counted the number of threads yet.
     380    int index = 1;
     381    DoublyLinkedList<MachineThread> threadsToBeDeleted;
     382
     383    for (MachineThread* thread = m_registeredThreads.head(); thread; index++) {
     384        if (thread->threadID() != id) {
     385            auto result = thread->suspend();
    159386#if OS(DARWIN)
    160                     // These threads will be removed from the ThreadGroup. Thus, we do not do anything here except for reporting.
    161                     ASSERT(result.error() != KERN_SUCCESS);
    162                     WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION,
    163                         "JavaScript garbage collection encountered an invalid thread (err 0x%x): Thread [%d/%d: %p] id %u.",
    164                         result.error(), index, threads.size(), thread, thread->id());
    165 #endif
    166                 }
     387            if (!result) {
     388                if (!numberOfThreads)
     389                    numberOfThreads = m_registeredThreads.size();
     390
     391                ASSERT(result.error() != KERN_SUCCESS);
     392
     393                WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION,
     394                    "JavaScript garbage collection encountered an invalid thread (err 0x%x): Thread [%d/%d: %p] id %u.",
     395                    result.error(), index, numberOfThreads, thread, thread->threadID());
     396
     397                // Put the invalid thread on the threadsToBeDeleted list.
     398                // We can't just delete it here because we have suspended other
     399                // threads, and they may still be holding the C heap lock which
     400                // we need for deleting the invalid thread. Hence, we need to
     401                // defer the deletion till after we have resumed all threads.
     402                MachineThread* nextThread = thread->next();
     403                m_registeredThreads.remove(thread);
     404                threadsToBeDeleted.append(thread);
     405                thread = nextThread;
     406                continue;
    167407            }
    168             ++index;
     408#else
     409            UNUSED_PARAM(numberOfThreads);
     410            ASSERT_UNUSED(result, result);
     411#endif
    169412        }
    170     }
    171 
    172     {
    173         unsigned index = 0;
    174         for (auto* thread : threads) {
    175             if (isSuspended.get(index))
    176                 tryCopyOtherThreadStack(*thread, buffer, capacity, size);
    177             ++index;
    178         }
    179     }
    180 
    181     {
    182         unsigned index = 0;
    183         for (auto* thread : threads) {
    184             if (isSuspended.get(index))
    185                 thread->resume();
    186             ++index;
    187         }
    188     }
    189 
     413        thread = thread->next();
     414    }
     415
     416    for (MachineThread* thread = m_registeredThreads.head(); thread; thread = thread->next()) {
     417        if (thread->threadID() != id)
     418            tryCopyOtherThreadStack(thread, buffer, capacity, size);
     419    }
     420
     421    for (MachineThread* thread = m_registeredThreads.head(); thread; thread = thread->next()) {
     422        if (thread->threadID() != id)
     423            thread->resume();
     424    }
     425
     426    for (MachineThread* thread = threadsToBeDeleted.head(); thread; ) {
     427        MachineThread* nextThread = thread->next();
     428        delete thread;
     429        thread = nextThread;
     430    }
     431   
    190432    return *size <= capacity;
    191433}
     
    208450    size_t capacity = 0;
    209451    void* buffer = nullptr;
    210     auto locker = holdLock(m_threadGroup->getLock());
    211     while (!tryCopyOtherThreadStacks(locker, buffer, capacity, &size))
     452    LockHolder lock(m_registeredThreadsMutex);
     453    while (!tryCopyOtherThreadStacks(lock, buffer, capacity, &size))
    212454        growBuffer(size, &buffer, &capacity);
    213455
  • trunk/Source/JavaScriptCore/heap/MachineStackMarker.h

    r219238 r219260  
    2222#pragma once
    2323
     24#include "MachineContext.h"
    2425#include "RegisterState.h"
     26#include <wtf/DoublyLinkedList.h>
    2527#include <wtf/Lock.h>
    2628#include <wtf/ScopedLambda.h>
    27 #include <wtf/ThreadGroup.h>
     29#include <wtf/ThreadSpecific.h>
    2830
    2931namespace JSC {
     
    4446public:
    4547    MachineThreads();
     48    ~MachineThreads();
    4649
    4750    void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, CurrentThreadState*);
    4851
    49     // Only needs to be called by clients that can use the same heap from multiple threads.
    50     void addCurrentThread() { m_threadGroup->addCurrentThread(); }
     52    JS_EXPORT_PRIVATE void addCurrentThread(); // Only needs to be called by clients that can use the same heap from multiple threads.
    5153
    52     std::mutex& getLock() { return m_threadGroup->getLock(); }
    53     const ListHashSet<Thread*>& threads(const AbstractLocker& locker) const { return m_threadGroup->threads(locker); }
     54    class MachineThread : public DoublyLinkedListNode<MachineThread> {
     55        WTF_MAKE_FAST_ALLOCATED;
     56    public:
     57        MachineThread();
     58
     59        struct Registers {
     60            void* stackPointer() const;
     61#if ENABLE(SAMPLING_PROFILER)
     62            void* framePointer() const;
     63            void* instructionPointer() const;
     64            void* llintPC() const;
     65#endif // ENABLE(SAMPLING_PROFILER)
     66            PlatformRegisters regs;
     67        };
     68
     69        Expected<void, Thread::PlatformSuspendError> suspend() { return m_thread->suspend(); }
     70        void resume() { m_thread->resume(); }
     71        size_t getRegisters(Registers& regs);
     72        std::pair<void*, size_t> captureStack(void* stackTop);
     73
     74        WTF::ThreadIdentifier threadID() const { return m_thread->id(); }
     75        void* stackBase() const { return m_thread->stack().origin(); }
     76        void* stackEnd() const { return m_thread->stack().end(); }
     77
     78        Ref<WTF::Thread> m_thread;
     79        MachineThread* m_next { nullptr };
     80        MachineThread* m_prev { nullptr };
     81    };
     82
     83    Lock& getLock() { return m_registeredThreadsMutex; }
     84    const DoublyLinkedList<MachineThread>& threadsListHead(const AbstractLocker&) const { ASSERT(m_registeredThreadsMutex.isLocked()); return m_registeredThreads; }
     85    MachineThread* machineThreadForCurrentThread();
    5486
    5587private:
    5688    void gatherFromCurrentThread(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, CurrentThreadState&);
    5789
    58     void tryCopyOtherThreadStack(Thread&, void*, size_t capacity, size_t*);
     90    void tryCopyOtherThreadStack(MachineThread*, void*, size_t capacity, size_t*);
    5991    bool tryCopyOtherThreadStacks(const AbstractLocker&, void*, size_t capacity, size_t*);
    6092
    61     Ref<ThreadGroup> m_threadGroup;
     93    static void THREAD_SPECIFIC_CALL removeThread(void*);
     94
     95    void removeThreadIfFound(ThreadIdentifier);
     96
     97    Lock m_registeredThreadsMutex;
     98    DoublyLinkedList<MachineThread> m_registeredThreads;
     99    WTF::ThreadSpecificKey m_threadSpecificForMachineThreads;
    62100};
    63101
  • trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp

    r219238 r219260  
    4040#include "JSFunction.h"
    4141#include "LLIntPCRanges.h"
    42 #include "MachineContext.h"
    4342#include "MarkedBlock.h"
    4443#include "MarkedBlockSet.h"
     
    167166    {
    168167        uint8_t* fpCast = bitwise_cast<uint8_t*>(exec);
    169         for (auto* thread : m_vm.heap.machineThreads().threads(m_machineThreadsLocker)) {
    170             uint8_t* stackBase = static_cast<uint8_t*>(thread->stack().origin());
    171             uint8_t* stackLimit = static_cast<uint8_t*>(thread->stack().end());
     168        const auto& threadList = m_vm.heap.machineThreads().threadsListHead(m_machineThreadsLocker);
     169        for (MachineThreads::MachineThread* thread = threadList.head(); thread; thread = thread->next()) {
     170            uint8_t* stackBase = static_cast<uint8_t*>(thread->stackBase());
     171            uint8_t* stackLimit = static_cast<uint8_t*>(thread->stackEnd());
    172172            RELEASE_ASSERT(stackBase);
    173173            RELEASE_ASSERT(stackLimit);
     
    279279    , m_stopwatch(WTFMove(stopwatch))
    280280    , m_timingInterval(std::chrono::microseconds(Options::sampleInterval()))
     281    , m_jscExecutionThread(nullptr)
    281282    , m_isPaused(false)
    282283    , m_isShutDown(false)
     
    338339        double nowTime = m_stopwatch->elapsedTime();
    339340
    340         auto machineThreadsLocker = holdLock(m_vm.heap.machineThreads().getLock());
     341        LockHolder machineThreadsLocker(m_vm.heap.machineThreads().getLock());
    341342        LockHolder codeBlockSetLocker(m_vm.heap.codeBlockSet().getLock());
    342343        LockHolder executableAllocatorLocker(ExecutableAllocator::singleton().getLock());
     
    352353            void* llintPC;
    353354            {
    354                 PlatformRegisters registers;
     355                MachineThreads::MachineThread::Registers registers;
    355356                m_jscExecutionThread->getRegisters(registers);
    356                 machineFrame = MachineContext::framePointer(registers);
     357                machineFrame = registers.framePointer();
    357358                callFrame = static_cast<ExecState*>(machineFrame);
    358                 machinePC = MachineContext::instructionPointer(registers);
    359                 llintPC = MachineContext::llintInstructionPointer(registers);
     359                machinePC = registers.instructionPointer();
     360                llintPC = registers.llintPC();
    360361            }
    361362            // FIXME: Lets have a way of detecting when we're parsing code.
     
    678679{
    679680    ASSERT(m_lock.isLocked());
    680     m_jscExecutionThread = &Thread::current();
     681    m_jscExecutionThread = m_vm.heap.machineThreads().machineThreadForCurrentThread();
    681682}
    682683
  • trunk/Source/JavaScriptCore/runtime/SamplingProfiler.h

    r219238 r219260  
    197197    Lock m_lock;
    198198    RefPtr<Thread> m_thread;
    199     RefPtr<Thread> m_jscExecutionThread;
     199    MachineThreads::MachineThread* m_jscExecutionThread;
    200200    bool m_isPaused;
    201201    bool m_isShutDown;
  • trunk/Source/JavaScriptCore/wasm/WasmMachineThreads.cpp

    r219238 r219260  
    5656{
    5757    auto locker = holdLock(wasmThreads().getLock());
    58     for (auto* thread : wasmThreads().threads(locker)) {
    59         sendMessage(*thread, [] (const PlatformRegisters&) {
     58
     59    const DoublyLinkedList<MachineThreads::MachineThread>& threads = wasmThreads().threadsListHead(locker);
     60    for (const auto* thread = threads.head(); thread; thread = thread->next()) {
     61        sendMessage(thread->m_thread.get(), [] (const PlatformRegisters&) {
    6062            // It's likely that the signal handler will already reset the instruction cache but we might as well be sure.
    6163            WTF::crossModifyingCodeFence();
  • trunk/Source/WTF/ChangeLog

    r219250 r219260  
     12017-07-07  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r219238, r219239, and r219241.
     4        https://bugs.webkit.org/show_bug.cgi?id=174265
     5
     6        "fast/workers/dedicated-worker-lifecycle.html is flaky"
     7        (Requested by yusukesuzuki on #webkit).
     8
     9        Reverted changesets:
     10
     11        "[WTF] Implement WTF::ThreadGroup"
     12        https://bugs.webkit.org/show_bug.cgi?id=174081
     13        http://trac.webkit.org/changeset/219238
     14
     15        "Unreviewed, build fix after r219238"
     16        https://bugs.webkit.org/show_bug.cgi?id=174081
     17        http://trac.webkit.org/changeset/219239
     18
     19        "Unreviewed, CLoop build fix after r219238"
     20        https://bugs.webkit.org/show_bug.cgi?id=174081
     21        http://trac.webkit.org/changeset/219241
     22
    1232017-07-07  Yusuke Suzuki  <utatane.tea@gmail.com>
    224
  • trunk/Source/WTF/WTF.xcodeproj/project.pbxproj

    r219238 r219260  
    132132                DCEE22031CEA7551000C2396 /* PlatformUserPreferredLanguagesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = DCEE21FF1CEA7551000C2396 /* PlatformUserPreferredLanguagesMac.mm */; };
    133133                E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */; };
    134                 E311FB171F0A568B003C08DE /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E311FB151F0A568B003C08DE /* ThreadGroup.cpp */; };
    135134                E3200AB81E9A536D003B59D2 /* ThreadHolder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3200AB51E9A536D003B59D2 /* ThreadHolder.cpp */; };
    136135                E38C41251EB4E04C0042957D /* CPUTimeCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = E38C41241EB4E04C0042957D /* CPUTimeCocoa.mm */; };
     
    541540                E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptographicUtilities.cpp; sourceTree = "<group>"; };
    542541                E15556F418A0CC18006F48FB /* CryptographicUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptographicUtilities.h; sourceTree = "<group>"; };
    543                 E311FB151F0A568B003C08DE /* ThreadGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGroup.cpp; sourceTree = "<group>"; };
    544                 E311FB161F0A568B003C08DE /* ThreadGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadGroup.h; sourceTree = "<group>"; };
    545542                E3200AB41E9A536D003B59D2 /* PlatformRegisters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformRegisters.h; sourceTree = "<group>"; };
    546543                E3200AB51E9A536D003B59D2 /* ThreadHolder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadHolder.cpp; sourceTree = "<group>"; };
     
    960957                                0FB317C31C488001007E395A /* SystemTracing.h */,
    961958                                A8A4732F151A825B004123FF /* ThreadFunctionInvocation.h */,
    962                                 E311FB151F0A568B003C08DE /* ThreadGroup.cpp */,
    963                                 E311FB161F0A568B003C08DE /* ThreadGroup.h */,
    964959                                E3200AB51E9A536D003B59D2 /* ThreadHolder.cpp */,
    965960                                E3200AB61E9A536D003B59D2 /* ThreadHolder.h */,
     
    13941389                                A8A4744A151A825B004123FF /* Threading.cpp in Sources */,
    13951390                                A8A4744E151A825B004123FF /* ThreadingPthreads.cpp in Sources */,
    1396                                 E311FB171F0A568B003C08DE /* ThreadGroup.cpp in Sources */,
    13971391                                5311BD5C1EA822F900525281 /* ThreadMessage.cpp in Sources */,
    13981392                                0F66B2901DC97BAB004A1D3F /* TimeWithDynamicClockType.cpp in Sources */,
  • trunk/Source/WTF/wtf/AutomaticThread.cpp

    r219238 r219260  
    2828
    2929#include "DataLog.h"
    30 #include "Threading.h"
    3130
    3231namespace WTF {
  • trunk/Source/WTF/wtf/CMakeLists.txt

    r219238 r219260  
    133133    SystemFree.h
    134134    SystemTracing.h
    135     ThreadGroup.h
    136135    ThreadHolder.cpp
    137136    ThreadMessage.h
     
    248247    StackTrace.cpp
    249248    StringPrintStream.cpp
    250     ThreadGroup.cpp
    251249    ThreadMessage.cpp
    252250    Threading.cpp
  • trunk/Source/WTF/wtf/CrossThreadCopier.h

    r219238 r219260  
    3636#include <wtf/HashSet.h>
    3737#include <wtf/RefPtr.h>
    38 #include <wtf/ThreadSafeRefCounted.h>
    3938#include <wtf/text/WTFString.h>
    4039
  • trunk/Source/WTF/wtf/ParkingLot.h

    r219238 r219260  
    2929#include <wtf/Atomics.h>
    3030#include <wtf/ScopedLambda.h>
     31#include <wtf/Threading.h>
    3132#include <wtf/TimeWithDynamicClockType.h>
    3233
    3334namespace WTF {
    34 
    35 class Thread;
    3635
    3736class ParkingLot {
  • trunk/Source/WTF/wtf/Threading.cpp

    r219239 r219260  
    2727#include "Threading.h"
    2828
     29#include "dtoa.h"
     30#include "dtoa/cached-powers.h"
    2931#include <algorithm>
    3032#include <cmath>
     
    3335#include <wtf/PrintStream.h>
    3436#include <wtf/RandomNumberSeed.h>
    35 #include <wtf/ThreadGroup.h>
    3637#include <wtf/ThreadHolder.h>
    3738#include <wtf/ThreadMessage.h>
     
    130131}
    131132
    132 static bool shouldRemoveThreadFromThreadGroup()
    133 {
    134 #if OS(WINDOWS)
    135     // On Windows the thread specific destructor is also called when the
    136     // main thread is exiting. This may lead to the main thread waiting
    137     // forever for the thread group lock when exiting, if the sampling
    138     // profiler thread was terminated by the system while holding the
    139     // thread group lock.
    140     if (WTF::isMainThread())
    141         return false;
    142 #endif
    143     return true;
    144 }
    145 
    146 bool Thread::canAddToThreadGroup(const AbstractLocker&)
     133void Thread::didExit()
    147134{
    148135    std::lock_guard<std::mutex> locker(m_mutex);
    149     return !m_didExit;
    150 }
    151 
    152 void Thread::didExit()
    153 {
    154     auto destructionMutexLocker = holdLock(ThreadGroup::destructionMutex());
    155     if (shouldRemoveThreadFromThreadGroup()) {
    156         for (auto* threadGroup : m_threadGroups)
    157             threadGroup->removeCurrentThread(destructionMutexLocker, *this);
    158     }
    159     std::lock_guard<std::mutex> locker(m_mutex);
    160136    m_didExit = true;
    161 }
    162 
    163 void Thread::addToThreadGroup(const AbstractLocker& destructionMutexLocker, ThreadGroup& threadGroup)
    164 {
    165     ASSERT_UNUSED(destructionMutexLocker, canAddToThreadGroup(destructionMutexLocker));
    166     m_threadGroups.add(&threadGroup);
    167 }
    168 
    169 void Thread::removeFromThreadGroup(const AbstractLocker&, ThreadGroup& threadGroup)
    170 {
    171     m_threadGroups.remove(&threadGroup);
    172137}
    173138
  • trunk/Source/WTF/wtf/Threading.h

    r219238 r219260  
    3737#include <wtf/Expected.h>
    3838#include <wtf/Function.h>
    39 #include <wtf/HashSet.h>
    4039#include <wtf/PlatformRegisters.h>
    4140#include <wtf/RefPtr.h>
     
    5049namespace WTF {
    5150
    52 class AbstractLocker;
    5351class ThreadMessageData;
    5452
     
    5654typedef void (*ThreadFunction)(void* argument);
    5755
    58 class ThreadGroup;
    5956class ThreadHolder;
    6057class PrintStream;
     
    6259class Thread : public ThreadSafeRefCounted<Thread> {
    6360public:
    64     friend class ThreadGroup;
    6561    friend class ThreadHolder;
    6662
     
    180176    bool hasExited() { return m_didExit; }
    181177
    182     // These functions are only called from ThreadGroup.
    183     bool canAddToThreadGroup(const AbstractLocker& destructionMutexLocker);
    184     void addToThreadGroup(const AbstractLocker& destructionMutexLocker, ThreadGroup&);
    185     void removeFromThreadGroup(const AbstractLocker& destructionMutexLocker, ThreadGroup&);
    186 
    187178    // WordLock & Lock rely on ThreadSpecific. But Thread object can be destroyed even after ThreadSpecific things are destroyed.
    188179    std::mutex m_mutex;
     
    190181    JoinableState m_joinableState { Joinable };
    191182    StackBounds m_stack { StackBounds::emptyBounds() };
    192     HashSet<ThreadGroup*> m_threadGroups;
    193183    bool m_didExit { false };
    194184#if USE(PTHREADS)
  • trunk/Source/WebCore/ChangeLog

    r219257 r219260  
     12017-07-07  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r219238, r219239, and r219241.
     4        https://bugs.webkit.org/show_bug.cgi?id=174265
     5
     6        "fast/workers/dedicated-worker-lifecycle.html is flaky"
     7        (Requested by yusukesuzuki on #webkit).
     8
     9        Reverted changesets:
     10
     11        "[WTF] Implement WTF::ThreadGroup"
     12        https://bugs.webkit.org/show_bug.cgi?id=174081
     13        http://trac.webkit.org/changeset/219238
     14
     15        "Unreviewed, build fix after r219238"
     16        https://bugs.webkit.org/show_bug.cgi?id=174081
     17        http://trac.webkit.org/changeset/219239
     18
     19        "Unreviewed, CLoop build fix after r219238"
     20        https://bugs.webkit.org/show_bug.cgi?id=174081
     21        http://trac.webkit.org/changeset/219241
     22
    1232017-05-24  Sergio Villar Senin  <svillar@igalia.com>
    224
  • trunk/Source/WebCore/page/ResourceUsageThread.h

    r219238 r219260  
    3636#include <wtf/NeverDestroyed.h>
    3737#include <wtf/Noncopyable.h>
    38 #include <wtf/Threading.h>
    3938
    4039namespace JSC {
  • trunk/Source/WebKit2/ChangeLog

    r219249 r219260  
     12017-07-07  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r219238, r219239, and r219241.
     4        https://bugs.webkit.org/show_bug.cgi?id=174265
     5
     6        "fast/workers/dedicated-worker-lifecycle.html is flaky"
     7        (Requested by yusukesuzuki on #webkit).
     8
     9        Reverted changesets:
     10
     11        "[WTF] Implement WTF::ThreadGroup"
     12        https://bugs.webkit.org/show_bug.cgi?id=174081
     13        http://trac.webkit.org/changeset/219238
     14
     15        "Unreviewed, build fix after r219238"
     16        https://bugs.webkit.org/show_bug.cgi?id=174081
     17        http://trac.webkit.org/changeset/219239
     18
     19        "Unreviewed, CLoop build fix after r219238"
     20        https://bugs.webkit.org/show_bug.cgi?id=174081
     21        http://trac.webkit.org/changeset/219241
     22
    1232017-07-07  Antti Koivisto  <antti@apple.com>
    224
  • trunk/Source/WebKit2/Shared/AsyncRequest.h

    r219238 r219260  
    2828#define AsyncRequest_h
    2929
    30 #include <wtf/Function.h>
    3130#include <wtf/HashMap.h>
    3231#include <wtf/RefCounted.h>
  • trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h

    r219242 r219260  
    3030#include <wtf/HashSet.h>
    3131#include <wtf/MonotonicTime.h>
    32 #include <wtf/ThreadSafeRefCounted.h>
    3332#include <wtf/WallTime.h>
    3433#include <wtf/text/WTFString.h>
  • trunk/Tools/ChangeLog

    r219255 r219260  
     12017-07-07  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r219238, r219239, and r219241.
     4        https://bugs.webkit.org/show_bug.cgi?id=174265
     5
     6        "fast/workers/dedicated-worker-lifecycle.html is flaky"
     7        (Requested by yusukesuzuki on #webkit).
     8
     9        Reverted changesets:
     10
     11        "[WTF] Implement WTF::ThreadGroup"
     12        https://bugs.webkit.org/show_bug.cgi?id=174081
     13        http://trac.webkit.org/changeset/219238
     14
     15        "Unreviewed, build fix after r219238"
     16        https://bugs.webkit.org/show_bug.cgi?id=174081
     17        http://trac.webkit.org/changeset/219239
     18
     19        "Unreviewed, CLoop build fix after r219238"
     20        https://bugs.webkit.org/show_bug.cgi?id=174081
     21        http://trac.webkit.org/changeset/219241
     22
    1232017-07-07  Yusuke Suzuki  <utatane.tea@gmail.com>
    224
  • trunk/Tools/TestWebKitAPI/CMakeLists.txt

    r219238 r219260  
    8282    ${TESTWEBKITAPI_DIR}/Tests/WTF/StringView.cpp
    8383    ${TESTWEBKITAPI_DIR}/Tests/WTF/TextBreakIterator.cpp
    84     ${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadGroup.cpp
    8584    ${TESTWEBKITAPI_DIR}/Tests/WTF/Time.cpp
    8685    ${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueRef.cpp
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r219238 r219260  
    632632                E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
    633633                E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
    634                 E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */; };
    635634                ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = ECA680CD1E68CC0900731D20 /* StringUtilities.mm */; };
    636635                F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F415086C1DA040C10044BE9B /* play-audio-on-click.html */; };
     
    16111610                E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = StopLoadingFromDidReceiveResponse.html; sourceTree = "<group>"; };
    16121611                E19DB9781B32137C00DB38D4 /* NavigatorLanguage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NavigatorLanguage.mm; sourceTree = "<group>"; };
    1613                 E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGroup.cpp; sourceTree = "<group>"; };
    16141612                E40019301ACE9B5C001B0A2A /* BloomFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BloomFilter.cpp; sourceTree = "<group>"; };
    16151613                E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TypingStyleCrash.mm; sourceTree = "<group>"; };
     
    23942392                                5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */,
    23952393                                9329AA281DE3F81E003ABD07 /* TextBreakIterator.cpp */,
    2396                                 E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */,
    23972394                                5311BD5D1EA9490D00525281 /* ThreadMessages.cpp */,
    23982395                                0F2C20B71DCD544800542D9E /* Time.cpp */,
     
    28942891                        buildActionMask = 2147483647;
    28952892                        files = (
    2896                                 E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */,
    28972893                                7C83DE991D0A590C00FEBCF3 /* AtomicString.cpp in Sources */,
    28982894                                1ADAD1501D77A9F600212586 /* BlockPtr.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.