Changeset 219260 in webkit
- Timestamp:
- Jul 7, 2017 11:30:09 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 deleted
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp
r219238 r219260 37 37 #include <wtf/CurrentTime.h> 38 38 #include <wtf/Lock.h> 39 #include <wtf/Threading.h>40 39 #include <wtf/text/StringBuilder.h> 41 40 -
trunk/Source/JavaScriptCore/ChangeLog
r219241 r219260 1 2017-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 1 23 2017-07-06 Yusuke Suzuki <utatane.tea@gmail.com> 2 24 -
trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp
r219241 r219260 24 24 25 25 #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" 27 33 #include <setjmp.h> 28 34 #include <stdlib.h> 29 #include <wtf/ BitVector.h>30 #include <wtf/ PageBlock.h>35 #include <wtf/MainThread.h> 36 #include <wtf/NeverDestroyed.h> 31 37 #include <wtf/StdLibExtras.h> 32 38 … … 35 41 namespace JSC { 36 42 43 class ActiveMachineThreadsManager; 44 static ActiveMachineThreadsManager& activeMachineThreadsManager(); 45 46 class ActiveMachineThreadsManager { 47 WTF_MAKE_NONCOPYABLE(ActiveMachineThreadsManager); 48 public: 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 79 private: 80 typedef HashSet<MachineThreads*> MachineThreadsSet; 81 82 ActiveMachineThreadsManager() { } 83 84 Lock m_lock; 85 MachineThreadsSet m_set; 86 87 friend ActiveMachineThreadsManager& activeMachineThreadsManager(); 88 }; 89 90 static 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 37 134 MachineThreads::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 145 MachineThreads::~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 158 void 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 176 auto 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 189 void 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 215 void 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 } 40 225 } 41 226 … … 51 236 conservativeRoots.add(currentThreadState.stackTop, currentThreadState.stackOrigin, jitStubRoutines, codeBlocks); 52 237 } 238 239 MachineThreads::MachineThread::MachineThread() 240 : m_thread(WTF::Thread::current()) 241 { 242 } 243 244 size_t MachineThreads::MachineThread::getRegisters(MachineThread::Registers& registers) 245 { 246 WTF::PlatformRegisters& regs = registers.regs; 247 return m_thread->getRegisters(regs); 248 } 249 250 void* MachineThreads::MachineThread::Registers::stackPointer() const 251 { 252 return MachineContext::stackPointer(regs); 253 } 254 255 #if ENABLE(SAMPLING_PROFILER) 256 void* 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 265 void* 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 274 void* 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) 53 284 54 285 static inline int osRedZoneAdjustment() … … 67 298 } 68 299 69 st atic std::pair<void*, size_t> captureStack(Thread& thread,void* stackTop)70 { 71 char* begin = reinterpret_cast_ptr<char*>( thread.stack().origin());300 std::pair<void*, size_t> MachineThreads::MachineThread::captureStack(void* stackTop) 301 { 302 char* begin = reinterpret_cast_ptr<char*>(stackBase()); 72 303 char* end = bitwise_cast<char*>(WTF::roundUpToMultipleOf<sizeof(void*)>(reinterpret_cast<uintptr_t>(stackTop))); 73 304 ASSERT(begin >= end); … … 76 307 ASSERT(WTF::roundUpToMultipleOf<sizeof(void*)>(reinterpret_cast<uintptr_t>(endWithRedZone)) == reinterpret_cast<uintptr_t>(endWithRedZone)); 77 308 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()); 80 311 81 312 std::swap(begin, endWithRedZone); … … 110 341 // operation. As the heap is generally much larger than the stack the performance hit is minimal. 111 342 // 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);343 void MachineThreads::tryCopyOtherThreadStack(MachineThread* thread, void* buffer, size_t capacity, size_t* size) 344 { 345 MachineThread::Registers registers; 346 size_t registersSize = thread->getRegisters(registers); 116 347 117 348 // This is a workaround for <rdar://problem/27607384>. libdispatch recycles work 118 349 // queue threads without running pthread exit destructors. This can cause us to scan a 119 350 // thread during work queue initialization, when the stack pointer is null. 120 if (UNLIKELY(! MachineContext::stackPointer(registers))) {351 if (UNLIKELY(!registers.stackPointer())) { 121 352 *size = 0; 122 353 return; 123 354 } 124 355 125 std::pair<void*, size_t> stack = captureStack(thread, MachineContext::stackPointer(registers));356 std::pair<void*, size_t> stack = thread->captureStack(registers.stackPointer()); 126 357 127 358 bool canCopy = *size + registersSize + stack.second <= capacity; … … 136 367 } 137 368 138 bool MachineThreads::tryCopyOtherThreadStacks(const AbstractLocker& locker, void* buffer, size_t capacity, size_t* size)369 bool MachineThreads::tryCopyOtherThreadStacks(const AbstractLocker&, void* buffer, size_t capacity, size_t* size) 139 370 { 140 371 // Prevent two VMs from suspending each other's threads at the same time, … … 145 376 *size = 0; 146 377 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(); 159 386 #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; 167 407 } 168 ++index; 408 #else 409 UNUSED_PARAM(numberOfThreads); 410 ASSERT_UNUSED(result, result); 411 #endif 169 412 } 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 190 432 return *size <= capacity; 191 433 } … … 208 450 size_t capacity = 0; 209 451 void* buffer = nullptr; 210 auto locker = holdLock(m_threadGroup->getLock());211 while (!tryCopyOtherThreadStacks(lock er, buffer, capacity, &size))452 LockHolder lock(m_registeredThreadsMutex); 453 while (!tryCopyOtherThreadStacks(lock, buffer, capacity, &size)) 212 454 growBuffer(size, &buffer, &capacity); 213 455 -
trunk/Source/JavaScriptCore/heap/MachineStackMarker.h
r219238 r219260 22 22 #pragma once 23 23 24 #include "MachineContext.h" 24 25 #include "RegisterState.h" 26 #include <wtf/DoublyLinkedList.h> 25 27 #include <wtf/Lock.h> 26 28 #include <wtf/ScopedLambda.h> 27 #include <wtf/Thread Group.h>29 #include <wtf/ThreadSpecific.h> 28 30 29 31 namespace JSC { … … 44 46 public: 45 47 MachineThreads(); 48 ~MachineThreads(); 46 49 47 50 void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, CurrentThreadState*); 48 51 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. 51 53 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(); 54 86 55 87 private: 56 88 void gatherFromCurrentThread(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, CurrentThreadState&); 57 89 58 void tryCopyOtherThreadStack( Thread&, void*, size_t capacity, size_t*);90 void tryCopyOtherThreadStack(MachineThread*, void*, size_t capacity, size_t*); 59 91 bool tryCopyOtherThreadStacks(const AbstractLocker&, void*, size_t capacity, size_t*); 60 92 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; 62 100 }; 63 101 -
trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp
r219238 r219260 40 40 #include "JSFunction.h" 41 41 #include "LLIntPCRanges.h" 42 #include "MachineContext.h"43 42 #include "MarkedBlock.h" 44 43 #include "MarkedBlockSet.h" … … 167 166 { 168 167 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()); 172 172 RELEASE_ASSERT(stackBase); 173 173 RELEASE_ASSERT(stackLimit); … … 279 279 , m_stopwatch(WTFMove(stopwatch)) 280 280 , m_timingInterval(std::chrono::microseconds(Options::sampleInterval())) 281 , m_jscExecutionThread(nullptr) 281 282 , m_isPaused(false) 282 283 , m_isShutDown(false) … … 338 339 double nowTime = m_stopwatch->elapsedTime(); 339 340 340 auto machineThreadsLocker = holdLock(m_vm.heap.machineThreads().getLock());341 LockHolder machineThreadsLocker(m_vm.heap.machineThreads().getLock()); 341 342 LockHolder codeBlockSetLocker(m_vm.heap.codeBlockSet().getLock()); 342 343 LockHolder executableAllocatorLocker(ExecutableAllocator::singleton().getLock()); … … 352 353 void* llintPC; 353 354 { 354 PlatformRegisters registers;355 MachineThreads::MachineThread::Registers registers; 355 356 m_jscExecutionThread->getRegisters(registers); 356 machineFrame = MachineContext::framePointer(registers);357 machineFrame = registers.framePointer(); 357 358 callFrame = static_cast<ExecState*>(machineFrame); 358 machinePC = MachineContext::instructionPointer(registers);359 llintPC = MachineContext::llintInstructionPointer(registers);359 machinePC = registers.instructionPointer(); 360 llintPC = registers.llintPC(); 360 361 } 361 362 // FIXME: Lets have a way of detecting when we're parsing code. … … 678 679 { 679 680 ASSERT(m_lock.isLocked()); 680 m_jscExecutionThread = &Thread::current();681 m_jscExecutionThread = m_vm.heap.machineThreads().machineThreadForCurrentThread(); 681 682 } 682 683 -
trunk/Source/JavaScriptCore/runtime/SamplingProfiler.h
r219238 r219260 197 197 Lock m_lock; 198 198 RefPtr<Thread> m_thread; 199 RefPtr<Thread>m_jscExecutionThread;199 MachineThreads::MachineThread* m_jscExecutionThread; 200 200 bool m_isPaused; 201 201 bool m_isShutDown; -
trunk/Source/JavaScriptCore/wasm/WasmMachineThreads.cpp
r219238 r219260 56 56 { 57 57 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&) { 60 62 // It's likely that the signal handler will already reset the instruction cache but we might as well be sure. 61 63 WTF::crossModifyingCodeFence(); -
trunk/Source/WTF/ChangeLog
r219250 r219260 1 2017-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 1 23 2017-07-07 Yusuke Suzuki <utatane.tea@gmail.com> 2 24 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r219238 r219260 132 132 DCEE22031CEA7551000C2396 /* PlatformUserPreferredLanguagesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = DCEE21FF1CEA7551000C2396 /* PlatformUserPreferredLanguagesMac.mm */; }; 133 133 E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */; }; 134 E311FB171F0A568B003C08DE /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E311FB151F0A568B003C08DE /* ThreadGroup.cpp */; };135 134 E3200AB81E9A536D003B59D2 /* ThreadHolder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3200AB51E9A536D003B59D2 /* ThreadHolder.cpp */; }; 136 135 E38C41251EB4E04C0042957D /* CPUTimeCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = E38C41241EB4E04C0042957D /* CPUTimeCocoa.mm */; }; … … 541 540 E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptographicUtilities.cpp; sourceTree = "<group>"; }; 542 541 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>"; };545 542 E3200AB41E9A536D003B59D2 /* PlatformRegisters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformRegisters.h; sourceTree = "<group>"; }; 546 543 E3200AB51E9A536D003B59D2 /* ThreadHolder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadHolder.cpp; sourceTree = "<group>"; }; … … 960 957 0FB317C31C488001007E395A /* SystemTracing.h */, 961 958 A8A4732F151A825B004123FF /* ThreadFunctionInvocation.h */, 962 E311FB151F0A568B003C08DE /* ThreadGroup.cpp */,963 E311FB161F0A568B003C08DE /* ThreadGroup.h */,964 959 E3200AB51E9A536D003B59D2 /* ThreadHolder.cpp */, 965 960 E3200AB61E9A536D003B59D2 /* ThreadHolder.h */, … … 1394 1389 A8A4744A151A825B004123FF /* Threading.cpp in Sources */, 1395 1390 A8A4744E151A825B004123FF /* ThreadingPthreads.cpp in Sources */, 1396 E311FB171F0A568B003C08DE /* ThreadGroup.cpp in Sources */,1397 1391 5311BD5C1EA822F900525281 /* ThreadMessage.cpp in Sources */, 1398 1392 0F66B2901DC97BAB004A1D3F /* TimeWithDynamicClockType.cpp in Sources */, -
trunk/Source/WTF/wtf/AutomaticThread.cpp
r219238 r219260 28 28 29 29 #include "DataLog.h" 30 #include "Threading.h"31 30 32 31 namespace WTF { -
trunk/Source/WTF/wtf/CMakeLists.txt
r219238 r219260 133 133 SystemFree.h 134 134 SystemTracing.h 135 ThreadGroup.h136 135 ThreadHolder.cpp 137 136 ThreadMessage.h … … 248 247 StackTrace.cpp 249 248 StringPrintStream.cpp 250 ThreadGroup.cpp251 249 ThreadMessage.cpp 252 250 Threading.cpp -
trunk/Source/WTF/wtf/CrossThreadCopier.h
r219238 r219260 36 36 #include <wtf/HashSet.h> 37 37 #include <wtf/RefPtr.h> 38 #include <wtf/ThreadSafeRefCounted.h>39 38 #include <wtf/text/WTFString.h> 40 39 -
trunk/Source/WTF/wtf/ParkingLot.h
r219238 r219260 29 29 #include <wtf/Atomics.h> 30 30 #include <wtf/ScopedLambda.h> 31 #include <wtf/Threading.h> 31 32 #include <wtf/TimeWithDynamicClockType.h> 32 33 33 34 namespace WTF { 34 35 class Thread;36 35 37 36 class ParkingLot { -
trunk/Source/WTF/wtf/Threading.cpp
r219239 r219260 27 27 #include "Threading.h" 28 28 29 #include "dtoa.h" 30 #include "dtoa/cached-powers.h" 29 31 #include <algorithm> 30 32 #include <cmath> … … 33 35 #include <wtf/PrintStream.h> 34 36 #include <wtf/RandomNumberSeed.h> 35 #include <wtf/ThreadGroup.h>36 37 #include <wtf/ThreadHolder.h> 37 38 #include <wtf/ThreadMessage.h> … … 130 131 } 131 132 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&) 133 void Thread::didExit() 147 134 { 148 135 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);160 136 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);172 137 } 173 138 -
trunk/Source/WTF/wtf/Threading.h
r219238 r219260 37 37 #include <wtf/Expected.h> 38 38 #include <wtf/Function.h> 39 #include <wtf/HashSet.h>40 39 #include <wtf/PlatformRegisters.h> 41 40 #include <wtf/RefPtr.h> … … 50 49 namespace WTF { 51 50 52 class AbstractLocker;53 51 class ThreadMessageData; 54 52 … … 56 54 typedef void (*ThreadFunction)(void* argument); 57 55 58 class ThreadGroup;59 56 class ThreadHolder; 60 57 class PrintStream; … … 62 59 class Thread : public ThreadSafeRefCounted<Thread> { 63 60 public: 64 friend class ThreadGroup;65 61 friend class ThreadHolder; 66 62 … … 180 176 bool hasExited() { return m_didExit; } 181 177 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 187 178 // WordLock & Lock rely on ThreadSpecific. But Thread object can be destroyed even after ThreadSpecific things are destroyed. 188 179 std::mutex m_mutex; … … 190 181 JoinableState m_joinableState { Joinable }; 191 182 StackBounds m_stack { StackBounds::emptyBounds() }; 192 HashSet<ThreadGroup*> m_threadGroups;193 183 bool m_didExit { false }; 194 184 #if USE(PTHREADS) -
trunk/Source/WebCore/ChangeLog
r219257 r219260 1 2017-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 1 23 2017-05-24 Sergio Villar Senin <svillar@igalia.com> 2 24 -
trunk/Source/WebCore/page/ResourceUsageThread.h
r219238 r219260 36 36 #include <wtf/NeverDestroyed.h> 37 37 #include <wtf/Noncopyable.h> 38 #include <wtf/Threading.h>39 38 40 39 namespace JSC { -
trunk/Source/WebKit2/ChangeLog
r219249 r219260 1 2017-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 1 23 2017-07-07 Antti Koivisto <antti@apple.com> 2 24 -
trunk/Source/WebKit2/Shared/AsyncRequest.h
r219238 r219260 28 28 #define AsyncRequest_h 29 29 30 #include <wtf/Function.h>31 30 #include <wtf/HashMap.h> 32 31 #include <wtf/RefCounted.h> -
trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h
r219242 r219260 30 30 #include <wtf/HashSet.h> 31 31 #include <wtf/MonotonicTime.h> 32 #include <wtf/ThreadSafeRefCounted.h>33 32 #include <wtf/WallTime.h> 34 33 #include <wtf/text/WTFString.h> -
trunk/Tools/ChangeLog
r219255 r219260 1 2017-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 1 23 2017-07-07 Yusuke Suzuki <utatane.tea@gmail.com> 2 24 -
trunk/Tools/TestWebKitAPI/CMakeLists.txt
r219238 r219260 82 82 ${TESTWEBKITAPI_DIR}/Tests/WTF/StringView.cpp 83 83 ${TESTWEBKITAPI_DIR}/Tests/WTF/TextBreakIterator.cpp 84 ${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadGroup.cpp85 84 ${TESTWEBKITAPI_DIR}/Tests/WTF/Time.cpp 86 85 ${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueRef.cpp -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r219238 r219260 632 632 E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; }; 633 633 E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; }; 634 E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */; };635 634 ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = ECA680CD1E68CC0900731D20 /* StringUtilities.mm */; }; 636 635 F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F415086C1DA040C10044BE9B /* play-audio-on-click.html */; }; … … 1611 1610 E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = StopLoadingFromDidReceiveResponse.html; sourceTree = "<group>"; }; 1612 1611 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>"; };1614 1612 E40019301ACE9B5C001B0A2A /* BloomFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BloomFilter.cpp; sourceTree = "<group>"; }; 1615 1613 E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TypingStyleCrash.mm; sourceTree = "<group>"; }; … … 2394 2392 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */, 2395 2393 9329AA281DE3F81E003ABD07 /* TextBreakIterator.cpp */, 2396 E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */,2397 2394 5311BD5D1EA9490D00525281 /* ThreadMessages.cpp */, 2398 2395 0F2C20B71DCD544800542D9E /* Time.cpp */, … … 2894 2891 buildActionMask = 2147483647; 2895 2892 files = ( 2896 E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */,2897 2893 7C83DE991D0A590C00FEBCF3 /* AtomicString.cpp in Sources */, 2898 2894 1ADAD1501D77A9F600212586 /* BlockPtr.mm in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.