WebKit Bugzilla
Attachment 359109 Details for
Bug 193417
: Use MonotonicTime in WorkerRunLoop
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193417-20190114175707.patch (text/plain), 7.35 KB, created by
youenn fablet
on 2019-01-14 17:57:08 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-01-14 17:57:08 PST
Size:
7.35 KB
patch
obsolete
>Subversion Revision: 239787 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 66998e9deeaaf140406089152e88fc41a0816ec3..fcc7c6e2ea5bc9ecdf2fe49330c80272f69232d3 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,14 @@ >+2019-01-14 Youenn Fablet <youenn@apple.com> >+ >+ Use MonotonicTime in WorkerRunLoop >+ https://bugs.webkit.org/show_bug.cgi?id=193417 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/MessageQueue.h: >+ (WTF::MessageQueue<DataType>::waitForMessage): >+ (WTF::MessageQueue<DataType>::waitForMessageFilteredWithTimeout): >+ > 2019-01-09 Mark Lam <mark.lam@apple.com> > > Gigacage disabling checks should handle the GIGACAGE_ALLOCATION_CAN_FAIL case properly. >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 8b9841e8d3709d79bb79ac97235da8724664c8e2..3887a704dd7524be836cbe14e49ec452ebed9cdf 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,17 @@ >+2019-01-14 Youenn Fablet <youenn@apple.com> >+ >+ Use MonotonicTime in WorkerRunLoop >+ https://bugs.webkit.org/show_bug.cgi?id=193417 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Condition is based on MonotonicTime so MessageQueue should also be based on MonotonicTime. >+ Ditto for WorkerRunLoop. >+ No easy way to test the change which should not be easily observable. >+ >+ * workers/WorkerRunLoop.cpp: >+ (WebCore::WorkerRunLoop::runInMode): >+ > 2019-01-14 Youenn Fablet <youenn@apple.com> > > Prevent WorkerRunLoop::runInMode from spinning in nested cases >diff --git a/Source/WTF/wtf/MessageQueue.h b/Source/WTF/wtf/MessageQueue.h >index 04362a33861f5f0bf4e0def9175536a948d0009b..6ad7b6299b37ce06f2ad77c4f92cf2000e965950 100644 >--- a/Source/WTF/wtf/MessageQueue.h >+++ b/Source/WTF/wtf/MessageQueue.h >@@ -35,7 +35,7 @@ > #include <wtf/Deque.h> > #include <wtf/Lock.h> > #include <wtf/Noncopyable.h> >-#include <wtf/WallTime.h> >+#include <wtf/Seconds.h> > > namespace WTF { > >@@ -65,7 +65,7 @@ namespace WTF { > Deque<std::unique_ptr<DataType>> takeAllMessages(); > std::unique_ptr<DataType> tryGetMessageIgnoringKilled(); > template<typename Predicate> >- std::unique_ptr<DataType> waitForMessageFilteredWithTimeout(MessageQueueWaitResult&, Predicate&&, WallTime absoluteTime); >+ std::unique_ptr<DataType> waitForMessageFilteredWithTimeout(MessageQueueWaitResult&, Predicate&&, Seconds relativeTimeout); > > template<typename Predicate> > void removeIf(Predicate&&); >@@ -128,18 +128,19 @@ namespace WTF { > inline auto MessageQueue<DataType>::waitForMessage() -> std::unique_ptr<DataType> > { > MessageQueueWaitResult exitReason; >- std::unique_ptr<DataType> result = waitForMessageFilteredWithTimeout(exitReason, [](const DataType&) { return true; }, WallTime::infinity()); >+ std::unique_ptr<DataType> result = waitForMessageFilteredWithTimeout(exitReason, [](const DataType&) { return true; }, Seconds::infinity()); > ASSERT(exitReason == MessageQueueTerminated || exitReason == MessageQueueMessageReceived); > return result; > } > > template<typename DataType> > template<typename Predicate> >- inline auto MessageQueue<DataType>::waitForMessageFilteredWithTimeout(MessageQueueWaitResult& result, Predicate&& predicate, WallTime absoluteTime) -> std::unique_ptr<DataType> >+ inline auto MessageQueue<DataType>::waitForMessageFilteredWithTimeout(MessageQueueWaitResult& result, Predicate&& predicate, Seconds relativeTimeout) -> std::unique_ptr<DataType> > { > LockHolder lock(m_mutex); > bool timedOut = false; > >+ MonotonicTime absoluteTimeout = MonotonicTime::now() + relativeTimeout; > auto found = m_queue.end(); > while (!m_killed && !timedOut) { > found = m_queue.findIf([&predicate](const std::unique_ptr<DataType>& ptr) -> bool { >@@ -149,10 +150,10 @@ namespace WTF { > if (found != m_queue.end()) > break; > >- timedOut = !m_condition.waitUntil(m_mutex, absoluteTime); >+ timedOut = !m_condition.waitUntil(m_mutex, absoluteTimeout); > } > >- ASSERT(!timedOut || absoluteTime != WallTime::infinity()); >+ ASSERT(!timedOut || absoluteTimeout != MonotonicTime::infinity()); > > if (m_killed) { > result = MessageQueueTerminated; >diff --git a/Source/WebCore/workers/WorkerRunLoop.cpp b/Source/WebCore/workers/WorkerRunLoop.cpp >index a25e07d01c4f0ac15f80933e0d7b68691d1190f1..570e9fa88e267e118c0acdd87a1068f113653c64 100644 >--- a/Source/WebCore/workers/WorkerRunLoop.cpp >+++ b/Source/WebCore/workers/WorkerRunLoop.cpp >@@ -49,17 +49,17 @@ namespace WebCore { > class WorkerSharedTimer final : public SharedTimer { > public: > // SharedTimer interface. >- void setFiredFunction(WTF::Function<void()>&& function) override { m_sharedTimerFunction = WTFMove(function); } >- void setFireInterval(Seconds interval) override { m_nextFireTime = interval + WallTime::now(); } >- void stop() override { m_nextFireTime = WallTime(); } >+ void setFiredFunction(WTF::Function<void()>&& function) final { m_sharedTimerFunction = WTFMove(function); } >+ void setFireInterval(Seconds interval) final { m_nextFireTime = MonotonicTime::now() + interval; } >+ void stop() final { m_nextFireTime = MonotonicTime { }; } > > bool isActive() { return m_sharedTimerFunction && m_nextFireTime; } >- WallTime fireTime() { return m_nextFireTime; } >+ Seconds fireTimeDelay() { return std::max(0_s, m_nextFireTime - MonotonicTime::now()); } > void fire() { m_sharedTimerFunction(); } > > private: > WTF::Function<void()> m_sharedTimerFunction; >- WallTime m_nextFireTime; >+ MonotonicTime m_nextFireTime; > }; > > class ModePredicate { >@@ -174,28 +174,23 @@ MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerGlobalScope* context, cons > g_main_context_iteration(mainContext, FALSE); > #endif > >- WallTime deadline = WallTime::infinity(); >+ Seconds timeoutDelay = Seconds::infinity(); > > #if USE(CF) > CFAbsoluteTime nextCFRunLoopTimerFireDate = CFRunLoopGetNextTimerFireDate(CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); > double timeUntilNextCFRunLoopTimerInSeconds = nextCFRunLoopTimerFireDate - CFAbsoluteTimeGetCurrent(); >- deadline = WallTime::now() + std::max(0_s, Seconds(timeUntilNextCFRunLoopTimerInSeconds)); >+ timeoutDelay = std::max(0_s, Seconds(timeUntilNextCFRunLoopTimerInSeconds)); > #endif > >- WallTime absoluteTime; >- if (waitMode == WaitForMessage) { >- if (predicate.isDefaultMode() && m_sharedTimer->isActive()) >- absoluteTime = std::min(deadline, m_sharedTimer->fireTime()); >- else >- absoluteTime = deadline; >- } >+ if (waitMode == WaitForMessage && predicate.isDefaultMode() && m_sharedTimer->isActive()) >+ timeoutDelay = std::min(timeoutDelay, m_sharedTimer->fireTimeDelay()); > > if (WorkerScriptController* script = context->script()) { > script->releaseHeapAccess(); > script->addTimerSetNotification(timerAddedTask); > } > MessageQueueWaitResult result; >- auto task = m_messageQueue.waitForMessageFilteredWithTimeout(result, predicate, absoluteTime); >+ auto task = m_messageQueue.waitForMessageFilteredWithTimeout(result, predicate, timeoutDelay); > if (WorkerScriptController* script = context->script()) { > script->acquireHeapAccess(); > script->removeTimerSetNotification(timerAddedTask);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193417
:
359109
|
359317
|
359330