<!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>[195046] releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore</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/195046">195046</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-14 05:22:14 -0800 (Thu, 14 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/192773">r192773</a> - [GLIB] Implement garbage collector timers
https://bugs.webkit.org/show_bug.cgi?id=151391

Reviewed by Žan Doberšek.

Add GLib implementation using GSource.

* heap/EdenGCActivityCallback.cpp:
* heap/FullGCActivityCallback.cpp:
* heap/GCActivityCallback.cpp:
(JSC::GCActivityCallback::GCActivityCallback):
(JSC::GCActivityCallback::scheduleTimer):
(JSC::GCActivityCallback::cancelTimer):
* heap/GCActivityCallback.h:
* heap/Heap.cpp:
(JSC::Heap::Heap):
* heap/HeapTimer.cpp:
(JSC::HeapTimer::HeapTimer):
(JSC::HeapTimer::~HeapTimer):
(JSC::HeapTimer::timerDidFire):
* heap/HeapTimer.h:
* heap/IncrementalSweeper.cpp:
(JSC::IncrementalSweeper::IncrementalSweeper):
(JSC::IncrementalSweeper::scheduleTimer):
(JSC::IncrementalSweeper::cancelTimer):
* heap/IncrementalSweeper.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreChangeLog">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreheapEdenGCActivityCallbackcpp">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/EdenGCActivityCallback.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreheapFullGCActivityCallbackcpp">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreheapGCActivityCallbackcpp">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/GCActivityCallback.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreheapGCActivityCallbackh">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/GCActivityCallback.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreheapHeapcpp">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/Heap.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreheapHeapTimercpp">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/HeapTimer.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreheapHeapTimerh">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/HeapTimer.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreheapIncrementalSweepercpp">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/IncrementalSweeper.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreheapIncrementalSweeperh">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/IncrementalSweeper.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/ChangeLog (195045 => 195046)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/ChangeLog        2016-01-14 13:17:53 UTC (rev 195045)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/ChangeLog        2016-01-14 13:22:14 UTC (rev 195046)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2015-11-26  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GLIB] Implement garbage collector timers
+        https://bugs.webkit.org/show_bug.cgi?id=151391
+
+        Reviewed by Žan Doberšek.
+
+        Add GLib implementation using GSource.
+
+        * heap/EdenGCActivityCallback.cpp:
+        * heap/FullGCActivityCallback.cpp:
+        * heap/GCActivityCallback.cpp:
+        (JSC::GCActivityCallback::GCActivityCallback):
+        (JSC::GCActivityCallback::scheduleTimer):
+        (JSC::GCActivityCallback::cancelTimer):
+        * heap/GCActivityCallback.h:
+        * heap/Heap.cpp:
+        (JSC::Heap::Heap):
+        * heap/HeapTimer.cpp:
+        (JSC::HeapTimer::HeapTimer):
+        (JSC::HeapTimer::~HeapTimer):
+        (JSC::HeapTimer::timerDidFire):
+        * heap/HeapTimer.h:
+        * heap/IncrementalSweeper.cpp:
+        (JSC::IncrementalSweeper::IncrementalSweeper):
+        (JSC::IncrementalSweeper::scheduleTimer):
+        (JSC::IncrementalSweeper::cancelTimer):
+        * heap/IncrementalSweeper.h:
+
</ins><span class="cx"> 2015-11-20  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         GC timers should carry on gracefully when Heap claims it grew from GC.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreheapEdenGCActivityCallbackcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/EdenGCActivityCallback.cpp (195045 => 195046)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/EdenGCActivityCallback.cpp        2016-01-14 13:17:53 UTC (rev 195045)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/EdenGCActivityCallback.cpp        2016-01-14 13:22:14 UTC (rev 195046)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-#if USE(CF) || PLATFORM(EFL)
</del><ins>+#if USE(CF) || USE(GLIB)
</ins><span class="cx"> 
</span><span class="cx"> EdenGCActivityCallback::EdenGCActivityCallback(Heap* heap)
</span><span class="cx">     : GCActivityCallback(heap)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreheapFullGCActivityCallbackcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp (195045 => 195046)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp        2016-01-14 13:17:53 UTC (rev 195045)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp        2016-01-14 13:22:14 UTC (rev 195046)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-#if USE(CF) || PLATFORM(EFL)
</del><ins>+#if USE(CF) || USE(GLIB)
</ins><span class="cx"> 
</span><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></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreheapGCActivityCallbackcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/GCActivityCallback.cpp (195045 => 195046)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/GCActivityCallback.cpp        2016-01-14 13:17:53 UTC (rev 195045)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/GCActivityCallback.cpp        2016-01-14 13:22:14 UTC (rev 195046)
</span><span class="lines">@@ -39,13 +39,15 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(EFL)
</span><span class="cx"> #include &lt;wtf/MainThread.h&gt;
</span><ins>+#elif USE(GLIB)
+#include &lt;glib.h&gt;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><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) || PLATFORM(EFL)
</del><ins>+#if USE(CF) || USE(GLIB)
</ins><span class="cx"> 
</span><span class="cx"> const double timerSlop = 2.0; // Fudge factor to avoid performance cost of resetting timer.
</span><span class="cx"> 
</span><span class="lines">@@ -64,6 +66,11 @@
</span><span class="cx">     : GCActivityCallback(heap-&gt;vm(), WTF::isMainThread())
</span><span class="cx"> {
</span><span class="cx"> }
</span><ins>+#elif USE(GLIB)
+GCActivityCallback::GCActivityCallback(Heap* heap)
+    : GCActivityCallback(heap-&gt;vm())
+{
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> void GCActivityCallback::doWork()
</span><span class="lines">@@ -114,6 +121,34 @@
</span><span class="cx">     m_delay = s_hour;
</span><span class="cx">     stop();
</span><span class="cx"> }
</span><ins>+#elif USE(GLIB)
+void GCActivityCallback::scheduleTimer(double newDelay)
+{
+    ASSERT(newDelay &gt;= 0);
+    if (m_delay != -1 &amp;&amp; newDelay * timerSlop &gt; m_delay)
+        return;
+
+    m_delay = newDelay;
+    if (!m_delay) {
+        g_source_set_ready_time(m_timer.get(), 0);
+        return;
+    }
+
+    auto delayDuration = std::chrono::duration&lt;double&gt;(m_delay);
+    auto safeDelayDuration = std::chrono::microseconds::max();
+    if (delayDuration &lt; safeDelayDuration)
+        safeDelayDuration = std::chrono::duration_cast&lt;std::chrono::microseconds&gt;(delayDuration);
+    gint64 currentTime = g_get_monotonic_time();
+    gint64 targetTime = currentTime + std::min&lt;gint64&gt;(G_MAXINT64 - currentTime, safeDelayDuration.count());
+    ASSERT(targetTime &gt;= currentTime);
+    g_source_set_ready_time(m_timer.get(), targetTime);
+}
+
+void GCActivityCallback::cancelTimer()
+{
+    m_delay = -1;
+    g_source_set_ready_time(m_timer.get(), -1);
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> void GCActivityCallback::didAllocate(size_t bytes)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreheapGCActivityCallbackh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/GCActivityCallback.h (195045 => 195046)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/GCActivityCallback.h        2016-01-14 13:17:53 UTC (rev 195045)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/GCActivityCallback.h        2016-01-14 13:22:14 UTC (rev 195046)
</span><span class="lines">@@ -81,6 +81,13 @@
</span><span class="cx">         , m_delay(s_hour)
</span><span class="cx">     {
</span><span class="cx">     }
</span><ins>+#elif USE(GLIB)
+    GCActivityCallback(VM* vm)
+        : HeapTimer(vm)
+        , m_enabled(true)
+        , m_delay(-1)
+    {
+    }
</ins><span class="cx"> #else
</span><span class="cx">     GCActivityCallback(VM* vm)
</span><span class="cx">         : HeapTimer(vm)
</span><span class="lines">@@ -95,7 +102,7 @@
</span><span class="cx"> protected:
</span><span class="cx">     GCActivityCallback(Heap*, CFRunLoopRef);
</span><span class="cx"> #endif
</span><del>-#if USE(CF) || PLATFORM(EFL)
</del><ins>+#if USE(CF) || USE(GLIB)
</ins><span class="cx"> protected:
</span><span class="cx">     void cancelTimer();
</span><span class="cx">     void scheduleTimer(double);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreheapHeapcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/Heap.cpp (195045 => 195046)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/Heap.cpp        2016-01-14 13:17:53 UTC (rev 195045)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/Heap.cpp        2016-01-14 13:22:14 UTC (rev 195046)
</span><span class="lines">@@ -356,7 +356,7 @@
</span><span class="cx"> #if USE(CF)
</span><span class="cx">     , m_sweeper(std::make_unique&lt;IncrementalSweeper&gt;(this, CFRunLoopGetCurrent()))
</span><span class="cx"> #else
</span><del>-    , m_sweeper(std::make_unique&lt;IncrementalSweeper&gt;(this-&gt;vm()))
</del><ins>+    , m_sweeper(std::make_unique&lt;IncrementalSweeper&gt;(this))
</ins><span class="cx"> #endif
</span><span class="cx">     , m_deferralDepth(0)
</span><span class="cx"> #if USE(CF)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreheapHeapTimercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/HeapTimer.cpp (195045 => 195046)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/HeapTimer.cpp        2016-01-14 13:17:53 UTC (rev 195045)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/HeapTimer.cpp        2016-01-14 13:22:14 UTC (rev 195046)
</span><span class="lines">@@ -36,6 +36,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(EFL)
</span><span class="cx"> #include &lt;Ecore.h&gt;
</span><ins>+#elif USE(GLIB)
+#include &lt;glib.h&gt;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="lines">@@ -140,6 +142,61 @@
</span><span class="cx">     
</span><span class="cx">     return ECORE_CALLBACK_CANCEL;
</span><span class="cx"> }
</span><ins>+
+#elif USE(GLIB)
+
+static GSourceFuncs heapTimerSourceFunctions = {
+    nullptr, // prepare
+    nullptr, // check
+    // dispatch
+    [](GSource* source, GSourceFunc callback, gpointer userData) -&gt; gboolean
+    {
+        if (g_source_get_ready_time(source) == -1)
+            return G_SOURCE_CONTINUE;
+        g_source_set_ready_time(source, -1);
+        return callback(userData);
+    },
+    nullptr, // finalize
+    nullptr, // closure_callback
+    nullptr, // closure_marshall
+};
+
+HeapTimer::HeapTimer(VM* vm)
+    : m_vm(vm)
+    , m_apiLock(&amp;vm-&gt;apiLock())
+    , m_timer(adoptGRef(g_source_new(&amp;heapTimerSourceFunctions, sizeof(GSource))))
+{
+    g_source_set_name(m_timer.get(), &quot;[JavaScriptCore] HeapTimer&quot;);
+    g_source_set_callback(m_timer.get(), [](gpointer userData) -&gt; gboolean {
+        static_cast&lt;HeapTimer*&gt;(userData)-&gt;timerDidFire();
+        return G_SOURCE_CONTINUE;
+    }, this, nullptr);
+    g_source_attach(m_timer.get(), g_main_context_get_thread_default());
+}
+
+HeapTimer::~HeapTimer()
+{
+    g_source_destroy(m_timer.get());
+}
+
+void HeapTimer::timerDidFire()
+{
+    m_apiLock-&gt;lock();
+
+    if (!m_apiLock-&gt;vm()) {
+        // The VM has been destroyed, so we should just give up.
+        m_apiLock-&gt;unlock();
+        return;
+    }
+
+    {
+        JSLockHolder locker(m_vm);
+        doWork();
+    }
+
+    m_apiLock-&gt;unlock();
+}
+
</ins><span class="cx"> #else
</span><span class="cx"> HeapTimer::HeapTimer(VM* vm)
</span><span class="cx">     : m_vm(vm)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreheapHeapTimerh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/HeapTimer.h (195045 => 195046)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/HeapTimer.h        2016-01-14 13:17:53 UTC (rev 195045)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/HeapTimer.h        2016-01-14 13:22:14 UTC (rev 195046)
</span><span class="lines">@@ -34,8 +34,13 @@
</span><span class="cx"> #include &lt;CoreFoundation/CoreFoundation.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(GLIB) &amp;&amp; !PLATFORM(EFL)
+#include &lt;wtf/glib/GRefPtr.h&gt;
+#endif
+
</ins><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><ins>+class JSLock;
</ins><span class="cx"> class VM;
</span><span class="cx"> 
</span><span class="cx"> class HeapTimer {
</span><span class="lines">@@ -66,6 +71,10 @@
</span><span class="cx">     Ecore_Timer* add(double delay, void* agent);
</span><span class="cx">     void stop();
</span><span class="cx">     Ecore_Timer* m_timer;
</span><ins>+#elif USE(GLIB)
+    void timerDidFire();
+    RefPtr&lt;JSLock&gt; m_apiLock;
+    GRefPtr&lt;GSource&gt; m_timer;
</ins><span class="cx"> #endif
</span><span class="cx">     
</span><span class="cx"> private:
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreheapIncrementalSweepercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/IncrementalSweeper.cpp (195045 => 195046)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/IncrementalSweeper.cpp        2016-01-14 13:17:53 UTC (rev 195045)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/IncrementalSweeper.cpp        2016-01-14 13:22:14 UTC (rev 195046)
</span><span class="lines">@@ -35,14 +35,19 @@
</span><span class="cx"> #include &lt;wtf/HashSet.h&gt;
</span><span class="cx"> #include &lt;wtf/WTFThreadData.h&gt;
</span><span class="cx"> 
</span><ins>+#if USE(GLIB) &amp;&amp; !PLATFORM(EFL)
+#include &lt;glib.h&gt;
+#endif
+
</ins><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-#if USE(CF)
</del><ins>+#if USE(CF) || (USE(GLIB) &amp;&amp; !PLATFORM(EFL))
</ins><span class="cx"> 
</span><span class="cx"> static const double sweepTimeSlice = .01; // seconds
</span><span class="cx"> static const double sweepTimeTotal = .10;
</span><span class="cx"> static const double sweepTimeMultiplier = 1.0 / sweepTimeTotal;
</span><span class="cx"> 
</span><ins>+#if USE(CF)
</ins><span class="cx"> IncrementalSweeper::IncrementalSweeper(Heap* heap, CFRunLoopRef runLoop)
</span><span class="cx">     : HeapTimer(heap-&gt;vm(), runLoop)
</span><span class="cx">     , m_blocksToSweep(heap-&gt;m_blockSnapshot)
</span><span class="lines">@@ -58,7 +63,28 @@
</span><span class="cx"> {
</span><span class="cx">     CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
</span><span class="cx"> }
</span><ins>+#elif USE(GLIB)
+IncrementalSweeper::IncrementalSweeper(Heap* heap)
+    : HeapTimer(heap-&gt;vm())
+    , m_blocksToSweep(heap-&gt;m_blockSnapshot)
+{
+}
</ins><span class="cx"> 
</span><ins>+void IncrementalSweeper::scheduleTimer()
+{
+    auto delayDuration = std::chrono::duration_cast&lt;std::chrono::microseconds&gt;(std::chrono::duration&lt;double&gt;(sweepTimeSlice * sweepTimeMultiplier));
+    gint64 currentTime = g_get_monotonic_time();
+    gint64 targetTime = currentTime + std::min&lt;gint64&gt;(G_MAXINT64 - currentTime, delayDuration.count());
+    ASSERT(targetTime &gt;= currentTime);
+    g_source_set_ready_time(m_timer.get(), targetTime);
+}
+
+void IncrementalSweeper::cancelTimer()
+{
+    g_source_set_ready_time(m_timer.get(), -1);
+}
+#endif
+
</ins><span class="cx"> void IncrementalSweeper::doWork()
</span><span class="cx"> {
</span><span class="cx">     doSweep(WTF::monotonicallyIncreasingTime());
</span><span class="lines">@@ -110,8 +136,8 @@
</span><span class="cx"> 
</span><span class="cx"> #else
</span><span class="cx"> 
</span><del>-IncrementalSweeper::IncrementalSweeper(VM* vm)
-    : HeapTimer(vm)
</del><ins>+IncrementalSweeper::IncrementalSweeper(Heap* heap)
+    : HeapTimer(heap-&gt;vm())
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreheapIncrementalSweeperh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/IncrementalSweeper.h (195045 => 195046)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/IncrementalSweeper.h        2016-01-14 13:17:53 UTC (rev 195045)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/heap/IncrementalSweeper.h        2016-01-14 13:22:14 UTC (rev 195046)
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx"> #if USE(CF)
</span><span class="cx">     JS_EXPORT_PRIVATE IncrementalSweeper(Heap*, CFRunLoopRef);
</span><span class="cx"> #else
</span><del>-    explicit IncrementalSweeper(VM*);
</del><ins>+    explicit IncrementalSweeper(Heap*);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     void startSweeping();
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx">     bool sweepNextBlock();
</span><span class="cx">     void willFinishSweeping();
</span><span class="cx"> 
</span><del>-#if USE(CF)
</del><ins>+#if USE(CF) || (USE(GLIB) &amp;&amp; !PLATFORM(EFL))
</ins><span class="cx"> private:
</span><span class="cx">     void doSweep(double startTime);
</span><span class="cx">     void scheduleTimer();
</span></span></pre>
</div>
</div>

</body>
</html>