Changeset 225778 in webkit
- Timestamp:
- Dec 12, 2017 2:35:39 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r225771 r225778 1 2017-12-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [WTF] Thread::create should have Thread::tryCreate 4 https://bugs.webkit.org/show_bug.cgi?id=180333 5 6 Reviewed by Darin Adler. 7 8 * assembler/testmasm.cpp: 9 (JSC::run): 10 * b3/air/testair.cpp: 11 * b3/testb3.cpp: 12 (JSC::B3::run): 13 * jsc.cpp: 14 (functionDollarAgentStart): 15 1 16 2017-12-11 Michael Saboff <msaboff@apple.com> 2 17 -
trunk/Source/JavaScriptCore/assembler/testmasm.cpp
r225536 r225778 809 809 Lock lock; 810 810 811 Vector<Ref Ptr<Thread>> threads;811 Vector<Ref<Thread>> threads; 812 812 for (unsigned i = filter ? 1 : WTF::numberOfProcessorCores(); i--;) { 813 813 threads.append( … … 829 829 } 830 830 831 for ( RefPtr<Thread>thread : threads)831 for (auto& thread : threads) 832 832 thread->waitForCompletion(); 833 833 crashLock.lock(); -
trunk/Source/JavaScriptCore/b3/air/testair.cpp
r224550 r225778 2026 2026 Lock lock; 2027 2027 2028 Vector<Ref Ptr<Thread>> threads;2028 Vector<Ref<Thread>> threads; 2029 2029 for (unsigned i = filter ? 1 : WTF::numberOfProcessorCores(); i--;) { 2030 2030 threads.append( … … 2046 2046 } 2047 2047 2048 for ( RefPtr<Thread>thread : threads)2048 for (auto& thread : threads) 2049 2049 thread->waitForCompletion(); 2050 2050 crashLock.lock(); -
trunk/Source/JavaScriptCore/b3/testb3.cpp
r225659 r225778 17795 17795 Lock lock; 17796 17796 17797 Vector<Ref Ptr<Thread>> threads;17797 Vector<Ref<Thread>> threads; 17798 17798 for (unsigned i = filter ? 1 : WTF::numberOfProcessorCores(); i--;) { 17799 17799 threads.append( … … 17815 17815 } 17816 17816 17817 for ( RefPtr<Thread>thread : threads)17817 for (auto& thread : threads) 17818 17818 thread->waitForCompletion(); 17819 17819 crashLock.lock(); -
trunk/Source/JavaScriptCore/jsc.cpp
r225352 r225778 1561 1561 bool didStart = false; 1562 1562 1563 RefPtr<Thread> thread =Thread::create(1563 Thread::create( 1564 1564 "JSC Agent", 1565 1565 [sourceCode, &didStartLock, &didStartCondition, &didStart] () { … … 1587 1587 return success; 1588 1588 }); 1589 }); 1590 thread->detach(); 1589 })->detach(); 1591 1590 1592 1591 { -
trunk/Source/WTF/ChangeLog
r225764 r225778 1 2017-12-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [WTF] Thread::create should have Thread::tryCreate 4 https://bugs.webkit.org/show_bug.cgi?id=180333 5 6 Reviewed by Darin Adler. 7 8 Many callers of Thread::create assume that it returns non-nullptr Thread. 9 But if the number of threads hits the limit in the system, creating Thread 10 would fail. In that case, it is really difficult to keep WebKit working. 11 12 We introduce Thread::tryCreate, and change the returned value from Thread::create 13 from RefPtr<Thread> to Ref<Thread>. In Thread::create, we ensure thread creation 14 succeeds by RELEASE_ASSERT. And we use Thread::create intentionally if the 15 caller assumes that thread should be created. 16 17 * wtf/AutomaticThread.cpp: 18 (WTF::AutomaticThread::start): 19 * wtf/ParallelJobsGeneric.cpp: 20 (WTF::ParallelEnvironment::ThreadPrivate::tryLockFor): 21 * wtf/Threading.cpp: 22 (WTF::Thread::tryCreate): 23 (WTF::Thread::create): Deleted. 24 * wtf/Threading.h: 25 (WTF::Thread::create): 26 * wtf/WorkQueue.cpp: 27 (WTF::WorkQueue::concurrentApply): 28 1 29 2017-12-11 Eric Carlson <eric.carlson@apple.com> 2 30 -
trunk/Source/WTF/wtf/AutomaticThread.cpp
r219653 r225778 162 162 m_hasUnderlyingThread = true; 163 163 164 RefPtr<Thread> thread =Thread::create(164 Thread::create( 165 165 "WTF::AutomaticThread", 166 166 [=] () { … … 227 227 RELEASE_ASSERT(result == WorkResult::Continue); 228 228 } 229 }); 230 thread->detach(); 229 })->detach(); 231 230 } 232 231 -
trunk/Source/WTF/wtf/ParallelJobsGeneric.cpp
r218816 r225778 95 95 96 96 if (!m_thread) { 97 m_thread = Thread:: create("Parallel worker", [this] {97 m_thread = Thread::tryCreate("Parallel worker", [this] { 98 98 LockHolder lock(m_mutex); 99 99 -
trunk/Source/WTF/wtf/Threading.cpp
r225530 r225778 130 130 } 131 131 132 RefPtr<Thread> Thread:: create(const char* name, Function<void()>&& entryPoint)132 RefPtr<Thread> Thread::tryCreate(const char* name, Function<void()>&& entryPoint) 133 133 { 134 134 WTF::initializeThreading(); -
trunk/Source/WTF/wtf/Threading.h
r225735 r225778 87 87 // Returns nullptr if thread creation failed. 88 88 // The thread name must be a literal since on some platforms it's passed in to the thread. 89 WTF_EXPORT_PRIVATE static RefPtr<Thread> create(const char* threadName, Function<void()>&&); 89 WTF_EXPORT_PRIVATE static RefPtr<Thread> tryCreate(const char* threadName, Function<void()>&&); 90 static inline Ref<Thread> create(const char* threadName, Function<void()>&& function) 91 { 92 auto thread = tryCreate(threadName, WTFMove(function)); 93 RELEASE_ASSERT(thread); 94 return thread.releaseNonNull(); 95 } 90 96 91 97 // Returns Thread object. -
trunk/Source/WTF/wtf/WorkQueue.cpp
r225681 r225778 120 120 Deque<const WTF::Function<void ()>*> m_queue; 121 121 122 Vector<Ref Ptr<Thread>> m_workers;122 Vector<Ref<Thread>> m_workers; 123 123 }; 124 124 -
trunk/Source/WebCore/ChangeLog
r225776 r225778 1 2017-12-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [WTF] Thread::create should have Thread::tryCreate 4 https://bugs.webkit.org/show_bug.cgi?id=180333 5 6 Reviewed by Darin Adler. 7 8 No behavior change. 9 10 * bindings/js/GCController.cpp: 11 (WebCore::GCController::garbageCollectOnAlternateThreadForDebugging): 12 * platform/audio/ReverbConvolver.cpp: 13 (WebCore::ReverbConvolver::ReverbConvolver): 14 * platform/audio/ReverbConvolver.h: 15 * workers/WorkerThread.cpp: 16 (WebCore::WorkerThread::start): 17 1 18 2017-12-11 Manuel Rego Casasnovas <rego@igalia.com> 2 19 -
trunk/Source/WebCore/bindings/js/GCController.cpp
r223476 r225778 102 102 void GCController::garbageCollectOnAlternateThreadForDebugging(bool waitUntilDone) 103 103 { 104 RefPtr<Thread>thread = Thread::create("WebCore: GCController", &collect);104 auto thread = Thread::create("WebCore: GCController", &collect); 105 105 106 106 if (waitUntilDone) { -
trunk/Source/WebCore/platform/audio/ReverbConvolver.cpp
r218816 r225778 62 62 , m_maxFFTSize(maxFFTSize) // until we hit m_maxFFTSize 63 63 , m_useBackgroundThreads(useBackgroundThreads) 64 , m_backgroundThread(0)65 , m_wantsToExit(false)66 , m_moreInputBuffered(false)67 64 { 68 65 // If we are using background threads then don't exceed this FFT size for the -
trunk/Source/WebCore/platform/audio/ReverbConvolver.h
r218816 r225778 85 85 bool m_useBackgroundThreads; 86 86 RefPtr<Thread> m_backgroundThread; 87 bool m_wantsToExit ;88 bool m_moreInputBuffered ;87 bool m_wantsToExit { false }; 88 bool m_moreInputBuffered { false }; 89 89 mutable Lock m_backgroundThreadMutex; 90 90 mutable Condition m_backgroundThreadConditionVariable; -
trunk/Source/WebCore/workers/WorkerThread.cpp
r225343 r225778 141 141 m_evaluateCallback = WTFMove(evaluateCallback); 142 142 143 m_thread = Thread:: create("WebCore: Worker", [this] {143 m_thread = Thread::tryCreate("WebCore: Worker", [this] { 144 144 workerThread(); 145 145 }); -
trunk/Source/WebKit/ChangeLog
r225773 r225778 1 2017-12-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [WTF] Thread::create should have Thread::tryCreate 4 https://bugs.webkit.org/show_bug.cgi?id=180333 5 6 Reviewed by Darin Adler. 7 8 * UIProcess/API/glib/IconDatabase.cpp: 9 (WebKit::IconDatabase::open): 10 * UIProcess/linux/MemoryPressureMonitor.cpp: 11 (WebKit::MemoryPressureMonitor::MemoryPressureMonitor): 12 1 13 2017-12-11 Zan Dobersek <zdobersek@igalia.com> 2 14 -
trunk/Source/WebKit/UIProcess/API/glib/IconDatabase.cpp
r225470 r225778 220 220 // completes and m_syncThreadRunning is properly set 221 221 m_syncLock.lock(); 222 m_syncThread = Thread:: create("WebCore: IconDatabase", [this] {222 m_syncThread = Thread::tryCreate("WebCore: IconDatabase", [this] { 223 223 iconDatabaseSyncThread(); 224 224 }); -
trunk/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp
r215265 r225778 249 249 return; 250 250 251 RefPtr<Thread> thread =Thread::create("MemoryPressureMonitor", [this] {251 Thread::create("MemoryPressureMonitor", [this] { 252 252 double pollInterval = s_maxPollingIntervalInSeconds; 253 253 while (true) { … … 271 271 } 272 272 close(m_eventFD); 273 }); 274 thread->detach(); 273 })->detach(); 275 274 } 276 275 -
trunk/Source/WebKitLegacy/ChangeLog
r225563 r225778 1 2017-12-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [WTF] Thread::create should have Thread::tryCreate 4 https://bugs.webkit.org/show_bug.cgi?id=180333 5 6 Reviewed by Darin Adler. 7 8 * Storage/StorageThread.cpp: 9 (WebCore::StorageThread::start): 10 1 11 2017-12-05 Stephan Szabo <stephan.szabo@sony.com> 2 12 -
trunk/Source/WebKitLegacy/Storage/StorageThread.cpp
r219595 r225778 55 55 ASSERT(isMainThread()); 56 56 if (!m_thread) { 57 m_thread = Thread:: create("WebCore: LocalStorage", [this] {57 m_thread = Thread::tryCreate("WebCore: LocalStorage", [this] { 58 58 threadEntryPoint(); 59 59 }); -
trunk/Source/WebKitLegacy/win/ChangeLog
r225672 r225778 1 2017-12-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [WTF] Thread::create should have Thread::tryCreate 4 https://bugs.webkit.org/show_bug.cgi?id=180333 5 6 Reviewed by Darin Adler. 7 8 * WebKitQuartzCoreAdditions/CVDisplayLink.cpp: 9 (WKQCA::CVDisplayLink::start): 10 1 11 2017-12-08 Yusuke Suzuki <utatane.tea@gmail.com> 2 12 -
trunk/Source/WebKitLegacy/win/WebKitQuartzCoreAdditions/CVDisplayLink.cpp
r224629 r225778 65 65 runIOThread(); 66 66 }); 67 ASSERT(m_ioThread);68 67 } 69 68 -
trunk/Tools/ChangeLog
r225770 r225778 1 2017-12-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [WTF] Thread::create should have Thread::tryCreate 4 https://bugs.webkit.org/show_bug.cgi?id=180333 5 6 Reviewed by Darin Adler. 7 8 * TestWebKitAPI/Tests/WTF/Condition.cpp: 9 * TestWebKitAPI/Tests/WTF/ParkingLot.cpp: 10 * TestWebKitAPI/Tests/WTF/Signals.cpp: 11 (TEST): 12 * TestWebKitAPI/Tests/WTF/ThreadGroup.cpp: 13 (TestWebKitAPI::testThreadGroup): 14 (TestWebKitAPI::TEST): 15 1 16 2017-12-11 Basuke Suzuki <Basuke.Suzuki@sony.com> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WTF/Condition.cpp
r215265 r225778 90 90 Condition fullCondition; 91 91 92 Vector<Ref Ptr<Thread>> consumerThreads;93 Vector<Ref Ptr<Thread>> producerThreads;92 Vector<Ref<Thread>> consumerThreads; 93 Vector<Ref<Thread>> producerThreads; 94 94 95 95 Vector<unsigned> received; … … 97 97 98 98 for (unsigned i = numConsumers; i--;) { 99 RefPtr<Thread> threadIdentifier =Thread::create(99 consumerThreads.append(Thread::create( 100 100 "Consumer thread", 101 101 [&] () { … … 125 125 } 126 126 } 127 }); 128 consumerThreads.append(threadIdentifier); 127 })); 129 128 } 130 129 … … 132 131 133 132 for (unsigned i = numProducers; i--;) { 134 RefPtr<Thread> threadIdentifier =Thread::create(133 producerThreads.append(Thread::create( 135 134 "Producer Thread", 136 135 [&] () { … … 152 151 notify(notifyStyle, emptyCondition, shouldNotify); 153 152 } 154 }); 155 producerThreads.append(threadIdentifier); 156 } 157 158 for (RefPtr<Thread> threadIdentifier : producerThreads) 159 threadIdentifier->waitForCompletion(); 153 })); 154 } 155 156 for (auto& thread : producerThreads) 157 thread->waitForCompletion(); 160 158 161 159 { … … 165 163 emptyCondition.notifyAll(); 166 164 167 for ( RefPtr<Thread> threadIdentifier: consumerThreads)168 thread Identifier->waitForCompletion();165 for (auto& thread : consumerThreads) 166 thread->waitForCompletion(); 169 167 170 168 EXPECT_EQ(numProducers * numMessagesPerProducer, received.size()); -
trunk/Tools/TestWebKitAPI/Tests/WTF/ParkingLot.cpp
r225470 r225778 128 128 } 129 129 130 for ( RefPtr<Thread> threadIdentifier: threads)131 thread Identifier->waitForCompletion();130 for (auto& thread : threads) 131 thread->waitForCompletion(); 132 132 } 133 133 … … 179 179 std::condition_variable condition; 180 180 HashSet<Ref<Thread>> awake; 181 Vector<Ref Ptr<Thread>> threads;181 Vector<Ref<Thread>> threads; 182 182 RefPtr<Thread> lastAwoken; 183 183 }; -
trunk/Tools/TestWebKitAPI/Tests/WTF/Signals.cpp
r220562 r225778 48 48 49 49 Atomic<bool> receiverShouldKeepRunning(true); 50 Ref Ptr<Thread> receiverThread = (Thread::create("ThreadMessage receiver",50 Ref<Thread> receiverThread = (Thread::create("ThreadMessage receiver", 51 51 [&receiverShouldKeepRunning] () { 52 52 while (receiverShouldKeepRunning.load()) { } 53 53 })); 54 ASSERT_TRUE(receiverThread);55 54 56 55 bool signalFired; 57 56 { 58 std::unique_lock<std::mutex> locker(static_cast<ReflectedThread *>(receiverThread.get())->m_mutex);57 std::unique_lock<std::mutex> locker(static_cast<ReflectedThread&>(receiverThread.get()).m_mutex); 59 58 receiverShouldKeepRunning.store(false); 60 EXPECT_FALSE(static_cast<ReflectedThread *>(receiverThread.get())->hasExited());59 EXPECT_FALSE(static_cast<ReflectedThread&>(receiverThread.get()).hasExited()); 61 60 sleep(1); 62 signalFired = !pthread_kill(static_cast<ReflectedThread *>(receiverThread.get())->m_handle, std::get<0>(toSystemSignal(Signal::Usr)));61 signalFired = !pthread_kill(static_cast<ReflectedThread&>(receiverThread.get()).m_handle, std::get<0>(toSystemSignal(Signal::Usr))); 63 62 } 64 63 -
trunk/Tools/TestWebKitAPI/Tests/WTF/ThreadGroup.cpp
r219760 r225778 42 42 Condition condition; 43 43 Condition restartCondition; 44 Vector<Ref Ptr<Thread>> threads;44 Vector<Ref<Thread>> threads; 45 45 46 46 { 47 47 auto locker = holdLock(lock); 48 48 for (unsigned i = 0; i < numberOfThreads; ++i) { 49 Ref Ptr<Thread> thread = Thread::create("ThreadGroupWorker", [&] {49 Ref<Thread> thread = Thread::create("ThreadGroupWorker", [&] { 50 50 auto locker = holdLock(lock); 51 51 if (mode == Mode::AddCurrentThread) … … 58 58 }); 59 59 if (mode == Mode::Add) 60 EXPECT_TRUE(threadGroup->add( *thread) == ThreadGroupAddResult::NewlyAdded);61 threads.append( thread);60 EXPECT_TRUE(threadGroup->add(thread.get()) == ThreadGroupAddResult::NewlyAdded); 61 threads.append(WTFMove(thread)); 62 62 } 63 63 … … 103 103 { 104 104 std::shared_ptr<ThreadGroup> threadGroup = ThreadGroup::create(); 105 Ref Ptr<Thread> thread = Thread::create("ThreadGroupWorker", [&] { });105 Ref<Thread> thread = Thread::create("ThreadGroupWorker", [&] { }); 106 106 thread->waitForCompletion(); 107 EXPECT_TRUE(threadGroup->add( *thread) == ThreadGroupAddResult::NotAdded);107 EXPECT_TRUE(threadGroup->add(thread.get()) == ThreadGroupAddResult::NotAdded); 108 108 109 109 auto threadGroupLocker = holdLock(threadGroup->getLock()); … … 117 117 Condition restartCondition; 118 118 std::shared_ptr<ThreadGroup> threadGroup = ThreadGroup::create(); 119 Ref Ptr<Thread> thread = Thread::create("ThreadGroupWorker", [&] {119 Ref<Thread> thread = Thread::create("ThreadGroupWorker", [&] { 120 120 auto locker = holdLock(lock); 121 121 restartCondition.wait(lock, [&] { … … 123 123 }); 124 124 }); 125 EXPECT_TRUE(threadGroup->add( *thread) == ThreadGroupAddResult::NewlyAdded);126 EXPECT_TRUE(threadGroup->add( *thread) == ThreadGroupAddResult::AlreadyAdded);125 EXPECT_TRUE(threadGroup->add(thread.get()) == ThreadGroupAddResult::NewlyAdded); 126 EXPECT_TRUE(threadGroup->add(thread.get()) == ThreadGroupAddResult::AlreadyAdded); 127 127 128 128 {
Note: See TracChangeset
for help on using the changeset viewer.