Changeset 141089 in webkit
- Timestamp:
- Jan 29, 2013 2:51:39 AM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r141069 r141089 1 2013-01-29 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 3 [Qt] Implement IncrementalSweeper and HeapTimer 4 https://bugs.webkit.org/show_bug.cgi?id=103996 5 6 Reviewed by Simon Hausmann. 7 8 Implements the incremental sweeping garbage collection for the Qt platform. 9 10 * heap/HeapTimer.cpp: 11 (JSC::HeapTimer::HeapTimer): 12 (JSC::HeapTimer::~HeapTimer): 13 (JSC::HeapTimer::timerEvent): 14 (JSC::HeapTimer::synchronize): 15 (JSC::HeapTimer::invalidate): 16 (JSC::HeapTimer::didStartVMShutdown): 17 * heap/HeapTimer.h: 18 (HeapTimer): 19 * heap/IncrementalSweeper.cpp: 20 (JSC::IncrementalSweeper::IncrementalSweeper): 21 (JSC::IncrementalSweeper::scheduleTimer): 22 * heap/IncrementalSweeper.h: 23 (IncrementalSweeper): 24 1 25 2013-01-28 Filip Pizlo <fpizlo@apple.com> 2 26 -
trunk/Source/JavaScriptCore/heap/HeapTimer.cpp
r127202 r141089 34 34 #include <wtf/Threading.h> 35 35 36 #if PLATFORM(QT) 37 #include <QCoreApplication> 38 #include <QMutexLocker> 39 #include <QThread> 40 #include <QTimerEvent> 41 #endif 42 36 43 namespace JSC { 37 44 … … 133 140 } 134 141 142 #elif PLATFORM(QT) 143 144 HeapTimer::HeapTimer(JSGlobalData* globalData) 145 : m_globalData(globalData) 146 , m_newThread(0) 147 , m_mutex(QMutex::NonRecursive) 148 { 149 // The HeapTimer might be created before the runLoop is started, 150 // but we need to ensure the thread has an eventDispatcher already. 151 QEventLoop fakeLoop(this); 152 } 153 154 HeapTimer::~HeapTimer() 155 { 156 } 157 158 void HeapTimer::timerEvent(QTimerEvent*) 159 { 160 QMutexLocker lock(&m_mutex); 161 if (m_newThread) { 162 // We need to wait with processing until we are on the right thread. 163 return; 164 } 165 166 APIEntryShim shim(m_globalData, APIEntryShimWithoutLock::DontRefGlobalData); 167 doWork(); 168 } 169 170 void HeapTimer::customEvent(QEvent*) 171 { 172 ASSERT(m_newThread); 173 QMutexLocker lock(&m_mutex); 174 moveToThread(m_newThread); 175 m_newThread = 0; 176 } 177 178 void HeapTimer::synchronize() 179 { 180 if (thread() != QThread::currentThread()) { 181 // We can only move from the objects own thread to another, so we fire an 182 // event into the owning thread to trigger the move. 183 // This must be processed before any timerEvents so giving it high priority. 184 QMutexLocker lock(&m_mutex); 185 m_newThread = QThread::currentThread(); 186 QCoreApplication::postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority); 187 } 188 } 189 190 void HeapTimer::invalidate() 191 { 192 QMutexLocker lock(&m_mutex); 193 m_timer.stop(); 194 } 195 196 void HeapTimer::didStartVMShutdown() 197 { 198 invalidate(); 199 if (thread() == QThread::currentThread()) 200 delete this; 201 else 202 deleteLater(); 203 } 204 135 205 #else 136 137 206 HeapTimer::HeapTimer(JSGlobalData* globalData) 138 207 : m_globalData(globalData) -
trunk/Source/JavaScriptCore/heap/HeapTimer.h
r122624 r141089 34 34 #elif PLATFORM(BLACKBERRY) 35 35 #include <BlackBerryPlatformTimer.h> 36 #elif PLATFORM(QT) 37 #include <QBasicTimer> 38 #include <QMutex> 39 #include <QObject> 40 #include <QThread> 36 41 #endif 37 42 … … 39 44 40 45 class JSGlobalData; 41 46 47 #if PLATFORM(QT) 48 class HeapTimer : public QObject { 49 #else 42 50 class HeapTimer { 51 #endif 43 52 public: 44 53 #if USE(CF) … … 70 79 71 80 BlackBerry::Platform::Timer<HeapTimer> m_timer; 81 #elif PLATFORM(QT) 82 void timerEvent(QTimerEvent*); 83 void customEvent(QEvent*); 84 QBasicTimer m_timer; 85 QThread* m_newThread; 86 QMutex m_mutex; 72 87 #endif 73 88 -
trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp
r131213 r141089 38 38 namespace JSC { 39 39 40 #if USE(CF) || PLATFORM(BLACKBERRY) 40 #if USE(CF) || PLATFORM(BLACKBERRY) || PLATFORM(QT) 41 41 42 42 static const double sweepTimeSlice = .01; // seconds … … 68 68 } 69 69 70 #elif PLATFORM(BLACKBERRY) 70 #elif PLATFORM(BLACKBERRY) || PLATFORM(QT) 71 71 72 72 IncrementalSweeper::IncrementalSweeper(Heap* heap) 73 73 : HeapTimer(heap->globalData()) 74 74 , m_currentBlockToSweepIndex(0) 75 , m_blocksToSweep(heap->m_blockSnapshot) 75 76 { 76 77 } … … 83 84 void IncrementalSweeper::scheduleTimer() 84 85 { 86 #if PLATFORM(QT) 87 m_timer.start(sweepTimeSlice * sweepTimeMultiplier * 1000, this); 88 #else 85 89 m_timer.start(sweepTimeSlice * sweepTimeMultiplier); 90 #endif 86 91 } 87 92 -
trunk/Source/JavaScriptCore/heap/IncrementalSweeper.h
r131213 r141089 47 47 48 48 private: 49 #if USE(CF) || PLATFORM(BLACKBERRY) 49 #if USE(CF) || PLATFORM(BLACKBERRY) || PLATFORM(QT) 50 50 #if USE(CF) 51 51 IncrementalSweeper(Heap*, CFRunLoopRef);
Note: See TracChangeset
for help on using the changeset viewer.