<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[215228] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/215228">215228</a></dd>
<dt>Author</dt> <dd>utatane.tea@gmail.com</dd>
<dt>Date</dt> <dd>2017-04-11 07:56:21 -0700 (Tue, 11 Apr 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[JSC][GTK] Use RunLoop::Timer in GTK port
https://bugs.webkit.org/show_bug.cgi?id=170723

Reviewed by Carlos Garcia Campos.

Source/JavaScriptCore:

This patch makes GTK port use RunLoop::Timer for JSRunLoopTimer.
Only Cocoa-based ports use platform-specific Timer because it
has additional feature that changes RunLoop to the WebThread one.

And we enable Heap timers in all the ports including JSCOnly port.

* heap/EdenGCActivityCallback.cpp:
(JSC::EdenGCActivityCallback::lastGCLength):
* heap/EdenGCActivityCallback.h:
* heap/FullGCActivityCallback.cpp:
(JSC::FullGCActivityCallback::lastGCLength):
* heap/FullGCActivityCallback.h:
* heap/GCActivityCallback.cpp:
(JSC::GCActivityCallback::GCActivityCallback):
(JSC::GCActivityCallback::doWork):
(JSC::GCActivityCallback::scheduleTimer):
(JSC::GCActivityCallback::cancelTimer):
(JSC::GCActivityCallback::nextFireTime):
(JSC::GCActivityCallback::didAllocate):
* heap/GCActivityCallback.h:
* heap/IncrementalSweeper.cpp:
(JSC::IncrementalSweeper::doWork):
(JSC::IncrementalSweeper::doSweep):
* heap/IncrementalSweeper.h:
* heap/StopIfNecessaryTimer.cpp:
(JSC::StopIfNecessaryTimer::scheduleSoon):
* runtime/JSRunLoopTimer.cpp:
(JSC::JSRunLoopTimer::setRunLoop):
(JSC::JSRunLoopTimer::scheduleTimer):
(JSC::JSRunLoopTimer::cancelTimer):
(JSC::JSRunLoopTimer::JSRunLoopTimer):
(JSC::JSRunLoopTimer::~JSRunLoopTimer):
(JSC::JSRunLoopTimer::timerDidFireCallback):
* runtime/JSRunLoopTimer.h:
* runtime/PromiseDeferredTimer.cpp:
(JSC::PromiseDeferredTimer::scheduleWorkSoon):

Source/WTF:

Add secondsUntilFire method. And add setName and setPriority
for GTK RunLoop::Timer.

* wtf/RunLoop.h:
* wtf/cf/RunLoopCF.cpp:
(WTF::RunLoop::TimerBase::secondsUntilFire):
* wtf/generic/RunLoopGeneric.cpp:
(WTF::RunLoop::TimerBase::secondsUntilFire):
* wtf/glib/RunLoopGLib.cpp:
(WTF::RunLoop::TimerBase::setName):
(WTF::RunLoop::TimerBase::secondsUntilFire):
* wtf/win/RunLoopWin.cpp:
(WTF::RunLoop::TimerBase::timerFired):
(WTF::RunLoop::TimerBase::start):
(WTF::RunLoop::TimerBase::isActive):
(WTF::RunLoop::TimerBase::secondsUntilFire):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapEdenGCActivityCallbackcpp">trunk/Source/JavaScriptCore/heap/EdenGCActivityCallback.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapEdenGCActivityCallbackh">trunk/Source/JavaScriptCore/heap/EdenGCActivityCallback.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapFullGCActivityCallbackcpp">trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapFullGCActivityCallbackh">trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapGCActivityCallbackcpp">trunk/Source/JavaScriptCore/heap/GCActivityCallback.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapGCActivityCallbackh">trunk/Source/JavaScriptCore/heap/GCActivityCallback.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapIncrementalSweepercpp">trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapIncrementalSweeperh">trunk/Source/JavaScriptCore/heap/IncrementalSweeper.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapStopIfNecessaryTimercpp">trunk/Source/JavaScriptCore/heap/StopIfNecessaryTimer.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSRunLoopTimercpp">trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSRunLoopTimerh">trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimePromiseDeferredTimercpp">trunk/Source/JavaScriptCore/runtime/PromiseDeferredTimer.cpp</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfRunLooph">trunk/Source/WTF/wtf/RunLoop.h</a></li>
<li><a href="#trunkSourceWTFwtfcfRunLoopCFcpp">trunk/Source/WTF/wtf/cf/RunLoopCF.cpp</a></li>
<li><a href="#trunkSourceWTFwtfgenericRunLoopGenericcpp">trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp</a></li>
<li><a href="#trunkSourceWTFwtfglibRunLoopGLibcpp">trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp</a></li>
<li><a href="#trunkSourceWTFwtfwinRunLoopWincpp">trunk/Source/WTF/wtf/win/RunLoopWin.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2017-04-11  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        [JSC][GTK] Use RunLoop::Timer in GTK port
+        https://bugs.webkit.org/show_bug.cgi?id=170723
+
+        Reviewed by Carlos Garcia Campos.
+
+        This patch makes GTK port use RunLoop::Timer for JSRunLoopTimer.
+        Only Cocoa-based ports use platform-specific Timer because it
+        has additional feature that changes RunLoop to the WebThread one.
+
+        And we enable Heap timers in all the ports including JSCOnly port.
+
+        * heap/EdenGCActivityCallback.cpp:
+        (JSC::EdenGCActivityCallback::lastGCLength):
+        * heap/EdenGCActivityCallback.h:
+        * heap/FullGCActivityCallback.cpp:
+        (JSC::FullGCActivityCallback::lastGCLength):
+        * heap/FullGCActivityCallback.h:
+        * heap/GCActivityCallback.cpp:
+        (JSC::GCActivityCallback::GCActivityCallback):
+        (JSC::GCActivityCallback::doWork):
+        (JSC::GCActivityCallback::scheduleTimer):
+        (JSC::GCActivityCallback::cancelTimer):
+        (JSC::GCActivityCallback::nextFireTime):
+        (JSC::GCActivityCallback::didAllocate):
+        * heap/GCActivityCallback.h:
+        * heap/IncrementalSweeper.cpp:
+        (JSC::IncrementalSweeper::doWork):
+        (JSC::IncrementalSweeper::doSweep):
+        * heap/IncrementalSweeper.h:
+        * heap/StopIfNecessaryTimer.cpp:
+        (JSC::StopIfNecessaryTimer::scheduleSoon):
+        * runtime/JSRunLoopTimer.cpp:
+        (JSC::JSRunLoopTimer::setRunLoop):
+        (JSC::JSRunLoopTimer::scheduleTimer):
+        (JSC::JSRunLoopTimer::cancelTimer):
+        (JSC::JSRunLoopTimer::JSRunLoopTimer):
+        (JSC::JSRunLoopTimer::~JSRunLoopTimer):
+        (JSC::JSRunLoopTimer::timerDidFireCallback):
+        * runtime/JSRunLoopTimer.h:
+        * runtime/PromiseDeferredTimer.cpp:
+        (JSC::PromiseDeferredTimer::scheduleWorkSoon):
+
</ins><span class="cx"> 2017-04-11  Guillaume Emont  &lt;guijemont@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [jsc][mips] Add missing MacroAssembler functions after r214187
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapEdenGCActivityCallbackcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/EdenGCActivityCallback.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/EdenGCActivityCallback.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/heap/EdenGCActivityCallback.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -31,8 +31,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-#if USE(CF) || USE(GLIB)
-
</del><span class="cx"> EdenGCActivityCallback::EdenGCActivityCallback(Heap* heap)
</span><span class="cx">     : GCActivityCallback(heap)
</span><span class="cx"> {
</span><span class="lines">@@ -43,9 +41,9 @@
</span><span class="cx">     m_vm-&gt;heap.collectAsync(CollectionScope::Eden);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-double EdenGCActivityCallback::lastGCLength()
</del><ins>+Seconds EdenGCActivityCallback::lastGCLength()
</ins><span class="cx"> {
</span><del>-    return m_vm-&gt;heap.lastEdenGCLength().seconds();
</del><ins>+    return m_vm-&gt;heap.lastEdenGCLength();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> double EdenGCActivityCallback::deathRate()
</span><span class="lines">@@ -69,32 +67,4 @@
</span><span class="cx">     return std::min((static_cast&lt;double&gt;(bytes) / MB) * Options::percentCPUPerMBForEdenTimer(), Options::collectionTimerMaxPercentCPU());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#else
-
-EdenGCActivityCallback::EdenGCActivityCallback(Heap* heap)
-    : GCActivityCallback(heap-&gt;vm())
-{
-}
-
-void EdenGCActivityCallback::doCollection()
-{
-}
-
-double EdenGCActivityCallback::lastGCLength()
-{
-    return 0;
-}
-
-double EdenGCActivityCallback::deathRate()
-{
-    return 0;
-}
-
-double EdenGCActivityCallback::gcTimeSlice(size_t)
-{
-    return 0;
-}
-
-#endif // USE(CF) || USE(GLIB)
-
</del><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapEdenGCActivityCallbackh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/EdenGCActivityCallback.h (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/EdenGCActivityCallback.h        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/heap/EdenGCActivityCallback.h        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx">     void doCollection() override;
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><del>-    double lastGCLength() override;
</del><ins>+    Seconds lastGCLength() override;
</ins><span class="cx">     double gcTimeSlice(size_t bytes) override;
</span><span class="cx">     double deathRate() override;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapFullGCActivityCallbackcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -30,8 +30,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-#if USE(CF) || USE(GLIB)
-
</del><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> const double pagingTimeOut = 0.1; // Time in seconds to allow opportunistic timer to iterate over all blocks to see if the Heap is paged out.
</span><span class="cx"> #endif
</span><span class="lines">@@ -58,9 +56,9 @@
</span><span class="cx">     heap.collectAsync(CollectionScope::Full);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-double FullGCActivityCallback::lastGCLength()
</del><ins>+Seconds FullGCActivityCallback::lastGCLength()
</ins><span class="cx"> {
</span><del>-    return m_vm-&gt;heap.lastFullGCLength().seconds();
</del><ins>+    return m_vm-&gt;heap.lastFullGCLength();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> double FullGCActivityCallback::deathRate()
</span><span class="lines">@@ -84,32 +82,4 @@
</span><span class="cx">     return std::min((static_cast&lt;double&gt;(bytes) / MB) * Options::percentCPUPerMBForFullTimer(), Options::collectionTimerMaxPercentCPU());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#else
-
-FullGCActivityCallback::FullGCActivityCallback(Heap* heap)
-    : GCActivityCallback(heap)
-{
-}
-
-void FullGCActivityCallback::doCollection()
-{
-}
-
-double FullGCActivityCallback::lastGCLength()
-{
-    return 0;
-}
-
-double FullGCActivityCallback::deathRate()
-{
-    return 0;
-}
-
-double FullGCActivityCallback::gcTimeSlice(size_t)
-{
-    return 0;
-}
-
-#endif // USE(CF) || USE(GLIB)
-
</del><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapFullGCActivityCallbackh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.h (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.h        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.h        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx">     void setDidSyncGCRecently() { m_didSyncGCRecently = true; }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><del>-    double lastGCLength() override;
</del><ins>+    Seconds lastGCLength() override;
</ins><span class="cx">     double gcTimeSlice(size_t bytes) override;
</span><span class="cx">     double deathRate() override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapGCActivityCallbackcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/GCActivityCallback.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/GCActivityCallback.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/heap/GCActivityCallback.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -34,30 +34,16 @@
</span><span class="cx"> #include &quot;JSObject.h&quot;
</span><span class="cx"> #include &quot;VM.h&quot;
</span><span class="cx"> 
</span><del>-#if USE(GLIB)
-#include &lt;glib.h&gt;
-#endif
-
</del><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="cx"> bool GCActivityCallback::s_shouldCreateGCTimer = true;
</span><span class="cx"> 
</span><del>-#if USE(CF) || USE(GLIB)
-
</del><span class="cx"> const double timerSlop = 2.0; // Fudge factor to avoid performance cost of resetting timer.
</span><span class="cx"> 
</span><del>-#if USE(CF)
</del><span class="cx"> GCActivityCallback::GCActivityCallback(Heap* heap)
</span><span class="cx">     : GCActivityCallback(heap-&gt;vm())
</span><span class="cx"> {
</span><span class="cx"> }
</span><del>-#elif USE(GLIB)
-GCActivityCallback::GCActivityCallback(Heap* heap)
-    : GCActivityCallback(heap-&gt;vm())
-{
-    g_source_set_ready_time(m_timer.get(), g_get_monotonic_time() + s_decade * G_USEC_PER_SEC);
-}
-#endif
</del><span class="cx"> 
</span><span class="cx"> void GCActivityCallback::doWork()
</span><span class="cx"> {
</span><span class="lines">@@ -67,7 +53,7 @@
</span><span class="cx">     
</span><span class="cx">     JSLockHolder locker(m_vm);
</span><span class="cx">     if (heap-&gt;isDeferred()) {
</span><del>-        scheduleTimer(0);
</del><ins>+        scheduleTimer(0_s);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -75,43 +61,49 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(CF)
</span><del>-void GCActivityCallback::scheduleTimer(double newDelay)
</del><ins>+void GCActivityCallback::scheduleTimer(Seconds newDelay)
</ins><span class="cx"> {
</span><span class="cx">     if (newDelay * timerSlop &gt; m_delay)
</span><span class="cx">         return;
</span><del>-    double delta = m_delay - newDelay;
</del><ins>+    Seconds delta = m_delay - newDelay;
</ins><span class="cx">     m_delay = newDelay;
</span><del>-    m_nextFireTime = WTF::currentTime() + newDelay;
-    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFRunLoopTimerGetNextFireDate(m_timer.get()) - delta);
</del><ins>+    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFRunLoopTimerGetNextFireDate(m_timer.get()) - delta.seconds());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GCActivityCallback::cancelTimer()
</span><span class="cx"> {
</span><span class="cx">     m_delay = s_decade;
</span><del>-    m_nextFireTime = 0;
-    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
</del><ins>+    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade.seconds());
</ins><span class="cx"> }
</span><del>-#elif USE(GLIB)
-void GCActivityCallback::scheduleTimer(double newDelay)
</del><ins>+
+double GCActivityCallback::nextFireTime()
</ins><span class="cx"> {
</span><del>-    ASSERT(newDelay &gt;= 0);
</del><ins>+    return CFRunLoopTimerGetNextFireDate(m_timer.get());
+}
+#else
+void GCActivityCallback::scheduleTimer(Seconds newDelay)
+{
</ins><span class="cx">     if (newDelay * timerSlop &gt; m_delay)
</span><span class="cx">         return;
</span><del>-
-    double delta = m_delay - newDelay;
</del><ins>+    Seconds delta = m_delay - newDelay;
</ins><span class="cx">     m_delay = newDelay;
</span><del>-    m_nextFireTime = WTF::currentTime() + newDelay;
</del><span class="cx"> 
</span><del>-    gint64 readyTime = g_source_get_ready_time(m_timer.get());
-    g_source_set_ready_time(m_timer.get(), readyTime - delta * G_USEC_PER_SEC);
</del><ins>+    Seconds secondsUntilFire = m_timer.secondsUntilFire();
+    m_timer.startOneShot(secondsUntilFire - delta);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GCActivityCallback::cancelTimer()
</span><span class="cx"> {
</span><span class="cx">     m_delay = s_decade;
</span><del>-    m_nextFireTime = 0;
-    g_source_set_ready_time(m_timer.get(), g_get_monotonic_time() + s_decade * G_USEC_PER_SEC);
</del><ins>+    m_timer.startOneShot(s_decade);
</ins><span class="cx"> }
</span><ins>+
+double GCActivityCallback::nextFireTime()
+{
+    // FIXME: Should return MonotonicTime.
+    // https://bugs.webkit.org/show_bug.cgi?id=170725
+    return (MonotonicTime::now() + m_timer.secondsUntilFire()).secondsSinceEpoch().value();
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> void GCActivityCallback::didAllocate(size_t bytes)
</span><span class="lines">@@ -121,7 +113,7 @@
</span><span class="cx">     if (!bytes)
</span><span class="cx">         bytes = 1;
</span><span class="cx">     double bytesExpectedToReclaim = static_cast&lt;double&gt;(bytes) * deathRate();
</span><del>-    double newDelay = lastGCLength() / gcTimeSlice(bytesExpectedToReclaim);
</del><ins>+    Seconds newDelay = lastGCLength() / gcTimeSlice(bytesExpectedToReclaim);
</ins><span class="cx">     scheduleTimer(newDelay);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -135,30 +127,5 @@
</span><span class="cx">     cancelTimer();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#else
-
-GCActivityCallback::GCActivityCallback(Heap* heap)
-    : GCActivityCallback(heap-&gt;vm())
-{
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GCActivityCallback::doWork()
-{
-}
-
-void GCActivityCallback::didAllocate(size_t)
-{
-}
-
-void GCActivityCallback::willCollect()
-{
-}
-
-void GCActivityCallback::cancel()
-{
-}
-
-#endif
-
-}
-
</del></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapGCActivityCallbackh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/GCActivityCallback.h (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/GCActivityCallback.h        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/heap/GCActivityCallback.h        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -60,16 +60,13 @@
</span><span class="cx"> 
</span><span class="cx">     static bool s_shouldCreateGCTimer;
</span><span class="cx"> 
</span><del>-#if USE(CF) || USE(GLIB)
-    double nextFireTime() const { return m_nextFireTime; }
-#endif
</del><ins>+    JS_EXPORT_PRIVATE double nextFireTime();
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><del>-    virtual double lastGCLength() = 0;
</del><ins>+    virtual Seconds lastGCLength() = 0;
</ins><span class="cx">     virtual double gcTimeSlice(size_t bytes) = 0;
</span><span class="cx">     virtual double deathRate() = 0;
</span><span class="cx"> 
</span><del>-#if USE(CF)
</del><span class="cx">     GCActivityCallback(VM* vm)
</span><span class="cx">         : Base(vm)
</span><span class="cx">         , m_enabled(true)
</span><span class="lines">@@ -76,32 +73,15 @@
</span><span class="cx">         , m_delay(s_decade)
</span><span class="cx">     {
</span><span class="cx">     }
</span><del>-#elif USE(GLIB)
-    GCActivityCallback(VM* vm)
-        : Base(vm)
-        , m_enabled(true)
-        , m_delay(s_decade)
-    {
-    }
-#else
-    GCActivityCallback(VM* vm)
-        : Base(vm)
-        , m_enabled(true)
-    {
-    }
-#endif
</del><span class="cx"> 
</span><span class="cx">     bool m_enabled;
</span><span class="cx"> 
</span><del>-#if USE(CF) || USE(GLIB)
</del><span class="cx"> protected:
</span><span class="cx">     void cancelTimer();
</span><del>-    void scheduleTimer(double);
</del><ins>+    void scheduleTimer(Seconds);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    double m_delay;
-    double m_nextFireTime { 0 };
-#endif
</del><ins>+    Seconds m_delay;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapIncrementalSweepercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-static const double sweepTimeSlice = .01; // seconds
</del><ins>+static const Seconds sweepTimeSlice = 10_ms; // seconds
</ins><span class="cx"> static const double sweepTimeTotal = .10;
</span><span class="cx"> static const double sweepTimeMultiplier = 1.0 / sweepTimeTotal;
</span><span class="cx"> 
</span><span class="lines">@@ -52,13 +52,13 @@
</span><span class="cx"> 
</span><span class="cx"> void IncrementalSweeper::doWork()
</span><span class="cx"> {
</span><del>-    doSweep(WTF::monotonicallyIncreasingTime());
</del><ins>+    doSweep(MonotonicTime::now());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void IncrementalSweeper::doSweep(double sweepBeginTime)
</del><ins>+void IncrementalSweeper::doSweep(MonotonicTime sweepBeginTime)
</ins><span class="cx"> {
</span><span class="cx">     while (sweepNextBlock()) {
</span><del>-        double elapsedTime = WTF::monotonicallyIncreasingTime() - sweepBeginTime;
</del><ins>+        Seconds elapsedTime = MonotonicTime::now() - sweepBeginTime;
</ins><span class="cx">         if (elapsedTime &lt; sweepTimeSlice)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapIncrementalSweeperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/IncrementalSweeper.h (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/IncrementalSweeper.h        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/heap/IncrementalSweeper.h        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">     JS_EXPORT_PRIVATE void stopSweeping();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void doSweep(double startTime);
</del><ins>+    void doSweep(MonotonicTime startTime);
</ins><span class="cx">     void scheduleTimer();
</span><span class="cx">     
</span><span class="cx">     MarkedAllocator* m_currentAllocator;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapStopIfNecessaryTimercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/StopIfNecessaryTimer.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/StopIfNecessaryTimer.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/heap/StopIfNecessaryTimer.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx">         WTF::loadLoadFence();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    scheduleTimer(0);
</del><ins>+    scheduleTimer(0_s);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSRunLoopTimercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> #include &lt;wtf/MainThread.h&gt;
</span><span class="cx"> #include &lt;wtf/Threading.h&gt;
</span><span class="cx"> 
</span><del>-#if USE(GLIB)
</del><ins>+#if USE(GLIB_EVENT_LOOP)
</ins><span class="cx"> #include &lt;glib.h&gt;
</span><span class="cx"> #include &lt;wtf/glib/RunLoopSourcePriority.h&gt;
</span><span class="cx"> #endif
</span><span class="lines">@@ -42,6 +42,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><ins>+const Seconds JSRunLoopTimer::s_decade { 60 * 60 * 24 * 365 * 10 };
+
</ins><span class="cx"> void JSRunLoopTimer::timerDidFire()
</span><span class="cx"> {
</span><span class="cx">     m_apiLock-&gt;lock();
</span><span class="lines">@@ -63,8 +65,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(CF)
</span><span class="cx"> 
</span><del>-const CFTimeInterval JSRunLoopTimer::s_decade = 60 * 60 * 24 * 365 * 10;
-
</del><span class="cx"> JSRunLoopTimer::JSRunLoopTimer(VM* vm)
</span><span class="cx">     : m_vm(vm)
</span><span class="cx">     , m_apiLock(&amp;vm-&gt;apiLock())
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx">         m_runLoop = runLoop;
</span><span class="cx">         memset(&amp;m_context, 0, sizeof(CFRunLoopTimerContext));
</span><span class="cx">         m_context.info = this;
</span><del>-        m_timer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + s_decade, s_decade, 0, 0, JSRunLoopTimer::timerDidFireCallback, &amp;m_context));
</del><ins>+        m_timer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + s_decade.seconds(), s_decade.seconds(), 0, 0, JSRunLoopTimer::timerDidFireCallback, &amp;m_context));
</ins><span class="cx">         CFRunLoopAddTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes);
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -100,86 +100,44 @@
</span><span class="cx">     static_cast&lt;JSRunLoopTimer*&gt;(contextPtr)-&gt;timerDidFire();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JSRunLoopTimer::scheduleTimer(double intervalInSeconds)
</del><ins>+void JSRunLoopTimer::scheduleTimer(Seconds intervalInSeconds)
</ins><span class="cx"> {
</span><del>-    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + intervalInSeconds);
</del><ins>+    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + intervalInSeconds.seconds());
</ins><span class="cx">     m_isScheduled = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JSRunLoopTimer::cancelTimer()
</span><span class="cx"> {
</span><del>-    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
</del><ins>+    CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade.seconds());
</ins><span class="cx">     m_isScheduled = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#elif USE(GLIB)
</del><ins>+#else
</ins><span class="cx"> 
</span><del>-const long JSRunLoopTimer::s_decade = 60 * 60 * 24 * 365 * 10;
-
-static GSourceFuncs JSRunLoopTimerSourceFunctions = {
-    nullptr, // prepare
-    nullptr, // check
-    // dispatch
-    [](GSource*, GSourceFunc callback, gpointer userData) -&gt; gboolean
-    {
-        return callback(userData);
-    },
-    nullptr, // finalize
-    nullptr, // closure_callback
-    nullptr, // closure_marshall
-};
-
</del><span class="cx"> JSRunLoopTimer::JSRunLoopTimer(VM* vm)
</span><span class="cx">     : m_vm(vm)
</span><span class="cx">     , m_apiLock(&amp;vm-&gt;apiLock())
</span><del>-    , m_timer(adoptGRef(g_source_new(&amp;JSRunLoopTimerSourceFunctions, sizeof(GSource))))
</del><ins>+    , m_timer(RunLoop::current(), this, &amp;JSRunLoopTimer::timerDidFireCallback)
</ins><span class="cx"> {
</span><del>-    g_source_set_priority(m_timer.get(), RunLoopSourcePriority::JavascriptTimer);
-    g_source_set_name(m_timer.get(), &quot;[JavaScriptCore] JSRunLoopTimer&quot;);
-    g_source_set_callback(m_timer.get(), [](gpointer userData) -&gt; gboolean {
-        auto&amp; runLoopTimer = *static_cast&lt;JSRunLoopTimer*&gt;(userData);
-        g_source_set_ready_time(runLoopTimer.m_timer.get(), g_get_monotonic_time() + JSRunLoopTimer::s_decade * G_USEC_PER_SEC);
-        runLoopTimer.timerDidFire();
-        return G_SOURCE_CONTINUE;
-    }, this, nullptr);
-    g_source_attach(m_timer.get(), g_main_context_get_thread_default());
</del><ins>+#if USE(GLIB_EVENT_LOOP)
+    m_timer.setPriority(RunLoopSourcePriority::JavascriptTimer);
+    m_timer.setName(&quot;[JavaScriptCore] JSRunLoopTimer&quot;);
+#endif
+    m_timer.startOneShot(s_decade);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSRunLoopTimer::~JSRunLoopTimer()
</span><span class="cx"> {
</span><del>-    g_source_destroy(m_timer.get());
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JSRunLoopTimer::scheduleTimer(double intervalInSeconds)
</del><ins>+void JSRunLoopTimer::timerDidFireCallback()
</ins><span class="cx"> {
</span><del>-    g_source_set_ready_time(m_timer.get(), g_get_monotonic_time() + intervalInSeconds * G_USEC_PER_SEC);
-    m_isScheduled = true;
-}
-
-void JSRunLoopTimer::cancelTimer()
-{
-    g_source_set_ready_time(m_timer.get(), g_get_monotonic_time() + s_decade * G_USEC_PER_SEC);
-    m_isScheduled = false;
-}
-
-#else
-
-const Seconds JSRunLoopTimer::s_decade { 60 * 60 * 24 * 365 * 10 };
-
-JSRunLoopTimer::JSRunLoopTimer(VM* vm)
-    : m_vm(vm)
-    , m_apiLock(&amp;vm-&gt;apiLock())
-    , m_timer(RunLoop::current(), this, &amp;JSRunLoopTimer::timerDidFire)
-{
</del><span class="cx">     m_timer.startOneShot(s_decade);
</span><ins>+    timerDidFire();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSRunLoopTimer::~JSRunLoopTimer()
</del><ins>+void JSRunLoopTimer::scheduleTimer(Seconds intervalInSeconds)
</ins><span class="cx"> {
</span><del>-}
-
-void JSRunLoopTimer::scheduleTimer(double intervalInSeconds)
-{
</del><span class="cx">     m_timer.startOneShot(intervalInSeconds);
</span><span class="cx">     m_isScheduled = true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSRunLoopTimerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.h (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.h        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.h        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -36,10 +36,6 @@
</span><span class="cx"> #include &lt;CoreFoundation/CoreFoundation.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if USE(GLIB)
-#include &lt;wtf/glib/GRefPtr.h&gt;
-#endif
-
</del><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="cx"> class JSLock;
</span><span class="lines">@@ -50,12 +46,14 @@
</span><span class="cx">     JSRunLoopTimer(VM*);
</span><span class="cx"> #if USE(CF)
</span><span class="cx">     static void timerDidFireCallback(CFRunLoopTimerRef, void*);
</span><ins>+#else
+    void timerDidFireCallback();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     JS_EXPORT_PRIVATE virtual ~JSRunLoopTimer();
</span><span class="cx">     virtual void doWork() = 0;
</span><span class="cx"> 
</span><del>-    void scheduleTimer(double intervalInSeconds);
</del><ins>+    void scheduleTimer(Seconds intervalInSeconds);
</ins><span class="cx">     void cancelTimer();
</span><span class="cx">     bool isScheduled() const { return m_isScheduled; }
</span><span class="cx"> 
</span><span class="lines">@@ -66,11 +64,11 @@
</span><span class="cx"> protected:
</span><span class="cx">     VM* m_vm;
</span><span class="cx"> 
</span><ins>+    static const Seconds s_decade;
+
</ins><span class="cx">     RefPtr&lt;JSLock&gt; m_apiLock;
</span><span class="cx">     bool m_isScheduled { false };
</span><span class="cx"> #if USE(CF)
</span><del>-    static const CFTimeInterval s_decade;
-
</del><span class="cx">     RetainPtr&lt;CFRunLoopTimerRef&gt; m_timer;
</span><span class="cx">     RetainPtr&lt;CFRunLoopRef&gt; m_runLoop;
</span><span class="cx"> 
</span><span class="lines">@@ -77,11 +75,7 @@
</span><span class="cx">     CFRunLoopTimerContext m_context;
</span><span class="cx"> 
</span><span class="cx">     Lock m_shutdownMutex;
</span><del>-#elif USE(GLIB)
-    static const long s_decade;
-    GRefPtr&lt;GSource&gt; m_timer;
</del><span class="cx"> #else
</span><del>-    static const Seconds s_decade;
</del><span class="cx">     RunLoop::Timer&lt;JSRunLoopTimer&gt; m_timer;
</span><span class="cx"> #endif
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimePromiseDeferredTimercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/PromiseDeferredTimer.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/PromiseDeferredTimer.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/JavaScriptCore/runtime/PromiseDeferredTimer.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -134,7 +134,7 @@
</span><span class="cx">     LockHolder locker(m_taskLock);
</span><span class="cx">     m_tasks.append(std::make_tuple(ticket, WTFMove(task)));
</span><span class="cx">     if (!isScheduled() &amp;&amp; !m_currentlyRunningTask)
</span><del>-        scheduleTimer(0);
</del><ins>+        scheduleTimer(0_s);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/WTF/ChangeLog        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -1,5 +1,29 @@
</span><span class="cx"> 2017-04-11  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><ins>+        [JSC][GTK] Use RunLoop::Timer in GTK port
+        https://bugs.webkit.org/show_bug.cgi?id=170723
+
+        Reviewed by Carlos Garcia Campos.
+
+        Add secondsUntilFire method. And add setName and setPriority
+        for GTK RunLoop::Timer.
+
+        * wtf/RunLoop.h:
+        * wtf/cf/RunLoopCF.cpp:
+        (WTF::RunLoop::TimerBase::secondsUntilFire):
+        * wtf/generic/RunLoopGeneric.cpp:
+        (WTF::RunLoop::TimerBase::secondsUntilFire):
+        * wtf/glib/RunLoopGLib.cpp:
+        (WTF::RunLoop::TimerBase::setName):
+        (WTF::RunLoop::TimerBase::secondsUntilFire):
+        * wtf/win/RunLoopWin.cpp:
+        (WTF::RunLoop::TimerBase::timerFired):
+        (WTF::RunLoop::TimerBase::start):
+        (WTF::RunLoop::TimerBase::isActive):
+        (WTF::RunLoop::TimerBase::secondsUntilFire):
+
+2017-04-11  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
</ins><span class="cx">         [JSC] Enable JSRunLoopTimer for JSCOnly and Windows
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=170655
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfRunLooph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/RunLoop.h (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/RunLoop.h        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/WTF/wtf/RunLoop.h        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -93,10 +93,12 @@
</span><span class="cx"> 
</span><span class="cx">         WTF_EXPORT_PRIVATE void stop();
</span><span class="cx">         WTF_EXPORT_PRIVATE bool isActive() const;
</span><ins>+        WTF_EXPORT_PRIVATE Seconds secondsUntilFire() const;
</ins><span class="cx"> 
</span><span class="cx">         virtual void fired() = 0;
</span><span class="cx"> 
</span><span class="cx"> #if USE(GLIB_EVENT_LOOP)
</span><ins>+        void setName(const char*);
</ins><span class="cx">         void setPriority(int);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -106,8 +108,11 @@
</span><span class="cx">         Ref&lt;RunLoop&gt; m_runLoop;
</span><span class="cx"> 
</span><span class="cx"> #if USE(WINDOWS_EVENT_LOOP)
</span><ins>+        bool isActive(const AbstractLocker&amp;) const;
</ins><span class="cx">         static void timerFired(RunLoop*, uint64_t ID);
</span><span class="cx">         uint64_t m_ID;
</span><ins>+        MonotonicTime m_nextFireDate;
+        Seconds m_interval;
</ins><span class="cx">         bool m_isRepeating;
</span><span class="cx"> #elif USE(COCOA_EVENT_LOOP)
</span><span class="cx">         static void timerFired(CFRunLoopTimerRef, void*);
</span></span></pre></div>
<a id="trunkSourceWTFwtfcfRunLoopCFcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/cf/RunLoopCF.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/cf/RunLoopCF.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/WTF/wtf/cf/RunLoopCF.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -119,4 +119,11 @@
</span><span class="cx">     return m_timer &amp;&amp; CFRunLoopTimerIsValid(m_timer.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Seconds RunLoop::TimerBase::secondsUntilFire() const
+{
+    if (isActive())
+        return std::max&lt;Seconds&gt;(Seconds { CFRunLoopTimerGetNextFireDate(m_timer.get()) - CFAbsoluteTimeGetCurrent() }, 0_s);
+    return 0_s;
+}
+
</ins><span class="cx"> } // namespace WTF
</span></span></pre></div>
<a id="trunkSourceWTFwtfgenericRunLoopGenericcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -293,4 +293,12 @@
</span><span class="cx">     return m_scheduledTask;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Seconds RunLoop::TimerBase::secondsUntilFire() const
+{
+    LockHolder locker(m_runLoop-&gt;m_loopLock);
+    if (isActive(locker))
+        return std::max&lt;Seconds&gt;(m_scheduledTask-&gt;scheduledTimePoint() - MonotonicTime::now(), 0_s);
+    return 0_s;
+}
+
</ins><span class="cx"> } // namespace WTF
</span></span></pre></div>
<a id="trunkSourceWTFwtfglibRunLoopGLibcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -176,6 +176,11 @@
</span><span class="cx">     g_source_destroy(m_source.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RunLoop::TimerBase::setName(const char* name)
+{
+    g_source_set_name(m_source.get(), name);
+}
+
</ins><span class="cx"> void RunLoop::TimerBase::setPriority(int priority)
</span><span class="cx"> {
</span><span class="cx">     g_source_set_priority(m_source.get(), priority);
</span><span class="lines">@@ -211,4 +216,9 @@
</span><span class="cx">     return g_source_get_ready_time(m_source.get()) != -1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Seconds RunLoop::TimerBase::secondsUntilFire() const
+{
+    return std::max&lt;Seconds&gt;(Seconds::fromMicroseconds(g_source_get_ready_time(m_source.get()) - g_get_monotonic_time()), 0_s);
+}
+
</ins><span class="cx"> } // namespace WTF
</span></span></pre></div>
<a id="trunkSourceWTFwtfwinRunLoopWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/win/RunLoopWin.cpp (215227 => 215228)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/win/RunLoopWin.cpp        2017-04-11 13:19:21 UTC (rev 215227)
+++ trunk/Source/WTF/wtf/win/RunLoopWin.cpp        2017-04-11 14:56:21 UTC (rev 215228)
</span><span class="lines">@@ -131,7 +131,8 @@
</span><span class="cx">         if (!timer-&gt;m_isRepeating) {
</span><span class="cx">             runLoop-&gt;m_activeTimers.remove(it);
</span><span class="cx">             ::KillTimer(runLoop-&gt;m_runLoopMessageWindow, ID);
</span><del>-        }
</del><ins>+        } else
+            m_nextFireDate = MonotonicTime::now() + m_interval;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     timer-&gt;fired();
</span><span class="lines">@@ -160,6 +161,8 @@
</span><span class="cx">     LockHolder locker(m_runLoop-&gt;m_activeTimersLock);
</span><span class="cx">     m_isRepeating = repeat;
</span><span class="cx">     m_runLoop-&gt;m_activeTimers.set(m_ID, this);
</span><ins>+    m_interval = Seconds(nextFireInterval);
+    m_nextFireDate = MonotonicTime::now() + m_interval;
</ins><span class="cx">     ::SetTimer(m_runLoop-&gt;m_runLoopMessageWindow, m_ID, nextFireInterval * 1000, 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -174,10 +177,24 @@
</span><span class="cx">     ::KillTimer(m_runLoop-&gt;m_runLoopMessageWindow, m_ID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool RunLoop::TimerBase::isActive(const AbstractLocker&amp;) const
+{
+    return m_runLoop-&gt;m_activeTimers.contains(m_ID);
+}
+
</ins><span class="cx"> bool RunLoop::TimerBase::isActive() const
</span><span class="cx"> {
</span><span class="cx">     LockHolder locker(m_runLoop-&gt;m_activeTimersLock);
</span><del>-    return m_runLoop-&gt;m_activeTimers.contains(m_ID);
</del><ins>+    return isActive(locker);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Seconds RunLoop::TimerBase::secondsUntilFire() const
+{
+    LockHolder locker(m_runLoop-&gt;m_activeTimersLock);
+    if (isActive(locker))
+        return std::max&lt;Seconds&gt;(m_nextFireDate - MonotonicTime::now(), 0_s);
+    return 0_s;
+}
+
+
</ins><span class="cx"> } // namespace WTF
</span></span></pre>
</div>
</div>

</body>
</html>