Title: [141089] trunk/Source/_javascript_Core
- Revision
- 141089
- Author
- allan.jen...@digia.com
- Date
- 2013-01-29 02:51:39 -0800 (Tue, 29 Jan 2013)
Log Message
[Qt] Implement IncrementalSweeper and HeapTimer
https://bugs.webkit.org/show_bug.cgi?id=103996
Reviewed by Simon Hausmann.
Implements the incremental sweeping garbage collection for the Qt platform.
* heap/HeapTimer.cpp:
(JSC::HeapTimer::HeapTimer):
(JSC::HeapTimer::~HeapTimer):
(JSC::HeapTimer::timerEvent):
(JSC::HeapTimer::synchronize):
(JSC::HeapTimer::invalidate):
(JSC::HeapTimer::didStartVMShutdown):
* heap/HeapTimer.h:
(HeapTimer):
* heap/IncrementalSweeper.cpp:
(JSC::IncrementalSweeper::IncrementalSweeper):
(JSC::IncrementalSweeper::scheduleTimer):
* heap/IncrementalSweeper.h:
(IncrementalSweeper):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (141088 => 141089)
--- trunk/Source/_javascript_Core/ChangeLog 2013-01-29 10:15:06 UTC (rev 141088)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-01-29 10:51:39 UTC (rev 141089)
@@ -1,3 +1,27 @@
+2013-01-29 Allan Sandfeld Jensen <allan.jen...@digia.com>
+
+ [Qt] Implement IncrementalSweeper and HeapTimer
+ https://bugs.webkit.org/show_bug.cgi?id=103996
+
+ Reviewed by Simon Hausmann.
+
+ Implements the incremental sweeping garbage collection for the Qt platform.
+
+ * heap/HeapTimer.cpp:
+ (JSC::HeapTimer::HeapTimer):
+ (JSC::HeapTimer::~HeapTimer):
+ (JSC::HeapTimer::timerEvent):
+ (JSC::HeapTimer::synchronize):
+ (JSC::HeapTimer::invalidate):
+ (JSC::HeapTimer::didStartVMShutdown):
+ * heap/HeapTimer.h:
+ (HeapTimer):
+ * heap/IncrementalSweeper.cpp:
+ (JSC::IncrementalSweeper::IncrementalSweeper):
+ (JSC::IncrementalSweeper::scheduleTimer):
+ * heap/IncrementalSweeper.h:
+ (IncrementalSweeper):
+
2013-01-28 Filip Pizlo <fpi...@apple.com>
DFG should not use a graph that is a vector, Nodes shouldn't move after allocation, and we should always refer to nodes by Node*
Modified: trunk/Source/_javascript_Core/heap/HeapTimer.cpp (141088 => 141089)
--- trunk/Source/_javascript_Core/heap/HeapTimer.cpp 2013-01-29 10:15:06 UTC (rev 141088)
+++ trunk/Source/_javascript_Core/heap/HeapTimer.cpp 2013-01-29 10:51:39 UTC (rev 141089)
@@ -33,6 +33,13 @@
#include <wtf/MainThread.h>
#include <wtf/Threading.h>
+#if PLATFORM(QT)
+#include <QCoreApplication>
+#include <QMutexLocker>
+#include <QThread>
+#include <QTimerEvent>
+#endif
+
namespace JSC {
#if USE(CF)
@@ -132,19 +139,81 @@
delete this;
}
-#else
+#elif PLATFORM(QT)
HeapTimer::HeapTimer(JSGlobalData* globalData)
: m_globalData(globalData)
+ , m_newThread(0)
+ , m_mutex(QMutex::NonRecursive)
{
+ // The HeapTimer might be created before the runLoop is started,
+ // but we need to ensure the thread has an eventDispatcher already.
+ QEventLoop fakeLoop(this);
}
HeapTimer::~HeapTimer()
{
}
+void HeapTimer::timerEvent(QTimerEvent*)
+{
+ QMutexLocker lock(&m_mutex);
+ if (m_newThread) {
+ // We need to wait with processing until we are on the right thread.
+ return;
+ }
+
+ APIEntryShim shim(m_globalData, APIEntryShimWithoutLock::DontRefGlobalData);
+ doWork();
+}
+
+void HeapTimer::customEvent(QEvent*)
+{
+ ASSERT(m_newThread);
+ QMutexLocker lock(&m_mutex);
+ moveToThread(m_newThread);
+ m_newThread = 0;
+}
+
+void HeapTimer::synchronize()
+{
+ if (thread() != QThread::currentThread()) {
+ // We can only move from the objects own thread to another, so we fire an
+ // event into the owning thread to trigger the move.
+ // This must be processed before any timerEvents so giving it high priority.
+ QMutexLocker lock(&m_mutex);
+ m_newThread = QThread::currentThread();
+ QCoreApplication::postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority);
+ }
+}
+
+void HeapTimer::invalidate()
+{
+ QMutexLocker lock(&m_mutex);
+ m_timer.stop();
+}
+
void HeapTimer::didStartVMShutdown()
{
+ invalidate();
+ if (thread() == QThread::currentThread())
+ delete this;
+ else
+ deleteLater();
+}
+
+#else
+HeapTimer::HeapTimer(JSGlobalData* globalData)
+ : m_globalData(globalData)
+{
+}
+
+HeapTimer::~HeapTimer()
+{
+}
+
+void HeapTimer::didStartVMShutdown()
+{
delete this;
}
Modified: trunk/Source/_javascript_Core/heap/HeapTimer.h (141088 => 141089)
--- trunk/Source/_javascript_Core/heap/HeapTimer.h 2013-01-29 10:15:06 UTC (rev 141088)
+++ trunk/Source/_javascript_Core/heap/HeapTimer.h 2013-01-29 10:51:39 UTC (rev 141089)
@@ -33,13 +33,22 @@
#include <CoreFoundation/CoreFoundation.h>
#elif PLATFORM(BLACKBERRY)
#include <BlackBerryPlatformTimer.h>
+#elif PLATFORM(QT)
+#include <QBasicTimer>
+#include <QMutex>
+#include <QObject>
+#include <QThread>
#endif
namespace JSC {
class JSGlobalData;
-
+
+#if PLATFORM(QT)
+class HeapTimer : public QObject {
+#else
class HeapTimer {
+#endif
public:
#if USE(CF)
HeapTimer(JSGlobalData*, CFRunLoopRef);
@@ -69,6 +78,12 @@
void timerDidFire();
BlackBerry::Platform::Timer<HeapTimer> m_timer;
+#elif PLATFORM(QT)
+ void timerEvent(QTimerEvent*);
+ void customEvent(QEvent*);
+ QBasicTimer m_timer;
+ QThread* m_newThread;
+ QMutex m_mutex;
#endif
private:
Modified: trunk/Source/_javascript_Core/heap/IncrementalSweeper.cpp (141088 => 141089)
--- trunk/Source/_javascript_Core/heap/IncrementalSweeper.cpp 2013-01-29 10:15:06 UTC (rev 141088)
+++ trunk/Source/_javascript_Core/heap/IncrementalSweeper.cpp 2013-01-29 10:51:39 UTC (rev 141089)
@@ -37,7 +37,7 @@
namespace JSC {
-#if USE(CF) || PLATFORM(BLACKBERRY)
+#if USE(CF) || PLATFORM(BLACKBERRY) || PLATFORM(QT)
static const double sweepTimeSlice = .01; // seconds
static const double sweepTimeTotal = .10;
@@ -67,11 +67,12 @@
CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
}
-#elif PLATFORM(BLACKBERRY)
+#elif PLATFORM(BLACKBERRY) || PLATFORM(QT)
IncrementalSweeper::IncrementalSweeper(Heap* heap)
: HeapTimer(heap->globalData())
, m_currentBlockToSweepIndex(0)
+ , m_blocksToSweep(heap->m_blockSnapshot)
{
}
@@ -82,7 +83,11 @@
void IncrementalSweeper::scheduleTimer()
{
+#if PLATFORM(QT)
+ m_timer.start(sweepTimeSlice * sweepTimeMultiplier * 1000, this);
+#else
m_timer.start(sweepTimeSlice * sweepTimeMultiplier);
+#endif
}
void IncrementalSweeper::cancelTimer()
Modified: trunk/Source/_javascript_Core/heap/IncrementalSweeper.h (141088 => 141089)
--- trunk/Source/_javascript_Core/heap/IncrementalSweeper.h 2013-01-29 10:15:06 UTC (rev 141088)
+++ trunk/Source/_javascript_Core/heap/IncrementalSweeper.h 2013-01-29 10:51:39 UTC (rev 141089)
@@ -46,7 +46,7 @@
void willFinishSweeping();
private:
-#if USE(CF) || PLATFORM(BLACKBERRY)
+#if USE(CF) || PLATFORM(BLACKBERRY) || PLATFORM(QT)
#if USE(CF)
IncrementalSweeper(Heap*, CFRunLoopRef);
#else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes