summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/GCActivityCallback.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-03-14 14:11:02 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-18 17:25:46 +0100
commita2e0d7c96a21cc48aa089938609669502cfdf407 (patch)
tree7b05c790efb1d607cefcd009fffc8055a5320078 /Source/JavaScriptCore/runtime/GCActivityCallback.cpp
parent597984021ca00fd98a0dfe2effd742c6e7bd4190 (diff)
downloadqtwebkit-a2e0d7c96a21cc48aa089938609669502cfdf407.tar.gz
[Qt] Implement GCActivityCallback
https://bugs.webkit.org/show_bug.cgi?id=103998 Reviewed by Simon Hausmann. Source/JavaScriptCore: Implements the activity triggered garbage collector. * runtime/GCActivityCallback.cpp: (JSC::DefaultGCActivityCallback::DefaultGCActivityCallback): (JSC::DefaultGCActivityCallback::scheduleTimer): (JSC::DefaultGCActivityCallback::cancelTimer): * runtime/GCActivityCallback.h: (GCActivityCallback): (DefaultGCActivityCallback): Source/WebCore: Implements the activity triggered garbage collector, and disables the timer based fallback. * bindings/js/GCController.cpp: (WebCore::GCController::GCController): (WebCore::GCController::garbageCollectSoon): * bindings/js/GCController.h: (GCController): Change-Id: Idd8f714e71871b3cc991f8d1866cdd271a47eff4 git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141114 268f45cc-cd09-0410-ab3c-d52691b4dbfc Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'Source/JavaScriptCore/runtime/GCActivityCallback.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/GCActivityCallback.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/Source/JavaScriptCore/runtime/GCActivityCallback.cpp b/Source/JavaScriptCore/runtime/GCActivityCallback.cpp
index 74cbdbaef..0c07b5e02 100644
--- a/Source/JavaScriptCore/runtime/GCActivityCallback.cpp
+++ b/Source/JavaScriptCore/runtime/GCActivityCallback.cpp
@@ -40,14 +40,15 @@
namespace JSC {
-#if USE(CF)
+#if USE(CF) || PLATFORM(QT)
const double gcTimeSlicePerMB = 0.01; // Percentage of CPU time we will spend to reclaim 1 MB
const double maxGCTimeSlice = 0.05; // The maximum amount of CPU time we want to use for opportunistic timer-triggered collections.
const double timerSlop = 2.0; // Fudge factor to avoid performance cost of resetting timer.
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.
-const CFTimeInterval hour = 60 * 60;
+const double hour = 60 * 60;
+#if USE(CF)
DefaultGCActivityCallback::DefaultGCActivityCallback(Heap* heap)
: GCActivityCallback(heap->globalData(), CFRunLoopGetCurrent())
, m_delay(s_decade)
@@ -59,6 +60,13 @@ DefaultGCActivityCallback::DefaultGCActivityCallback(Heap* heap, CFRunLoopRef ru
, m_delay(s_decade)
{
}
+#elif PLATFORM(QT)
+DefaultGCActivityCallback::DefaultGCActivityCallback(Heap* heap)
+ : GCActivityCallback(heap->globalData())
+ , m_delay(hour)
+{
+}
+#endif
void DefaultGCActivityCallback::doWork()
{
@@ -78,6 +86,7 @@ void DefaultGCActivityCallback::doWork()
heap->collect(Heap::DoNotSweep);
}
+#if USE(CF)
void DefaultGCActivityCallback::scheduleTimer(double newDelay)
{
if (newDelay * timerSlop > m_delay)
@@ -92,6 +101,22 @@ void DefaultGCActivityCallback::cancelTimer()
m_delay = s_decade;
CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
}
+#elif PLATFORM(QT)
+
+void DefaultGCActivityCallback::scheduleTimer(double newDelay)
+{
+ if (newDelay * timerSlop > m_delay)
+ return;
+ m_delay = newDelay;
+ m_timer.start(newDelay * 1000, this);
+}
+
+void DefaultGCActivityCallback::cancelTimer()
+{
+ m_delay = hour;
+ m_timer.stop();
+}
+#endif
void DefaultGCActivityCallback::didAllocate(size_t bytes)
{