Changeset 214817 in webkit
- Timestamp:
- Apr 3, 2017 10:38:19 AM (7 years ago)
- Location:
- releases/WebKitGTK/webkit-2.16/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.16/Source/JavaScriptCore/ChangeLog
r214815 r214817 1 2017-04-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Share implementation of JSRunLoopTimer::timerDidFire 4 https://bugs.webkit.org/show_bug.cgi?id=170392 5 6 Reviewed by Michael Catanzaro. 7 8 The code is cross-platform but it's duplicated in CF and GLib implementations, it could be shared instead. 9 10 * runtime/JSRunLoopTimer.cpp: 11 (JSC::JSRunLoopTimer::timerDidFire): Move common implementation here. 12 (JSC::JSRunLoopTimer::setRunLoop): Use timerDidFireCallback. 13 (JSC::JSRunLoopTimer::timerDidFireCallback): Call JSRunLoopTimer::timerDidFire(). 14 * runtime/JSRunLoopTimer.h: 15 1 16 2017-04-01 Oleksandr Skachkov <gskachkov@gmail.com> 2 17 -
releases/WebKitGTK/webkit-2.16/Source/JavaScriptCore/heap/HeapTimer.cpp
r212541 r214817 41 41 namespace JSC { 42 42 43 void HeapTimer::timerDidFire() 44 { 45 m_apiLock->lock(); 46 47 RefPtr<VM> vm = m_apiLock->vm(); 48 if (!vm) { 49 // The VM has been destroyed, so we should just give up. 50 m_apiLock->unlock(); 51 return; 52 } 53 54 { 55 JSLockHolder locker(vm.get()); 56 doWork(); 57 } 58 59 m_apiLock->unlock(); 60 } 61 43 62 #if USE(CF) 44 63 … … 65 84 memset(&m_context, 0, sizeof(CFRunLoopTimerContext)); 66 85 m_context.info = this; 67 m_timer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, s_decade, s_decade, 0, 0, HeapTimer::timerDidFire , &m_context));86 m_timer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, s_decade, s_decade, 0, 0, HeapTimer::timerDidFireCallback, &m_context)); 68 87 CFRunLoopAddTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes); 69 88 } … … 75 94 } 76 95 77 void HeapTimer::timerDidFire (CFRunLoopTimerRef, void* contextPtr)96 void HeapTimer::timerDidFireCallback(CFRunLoopTimerRef, void* contextPtr) 78 97 { 79 HeapTimer* timer = static_cast<HeapTimer*>(contextPtr); 80 timer->m_apiLock->lock(); 81 82 RefPtr<VM> vm = timer->m_apiLock->vm(); 83 if (!vm) { 84 // The VM has been destroyed, so we should just give up. 85 timer->m_apiLock->unlock(); 86 return; 87 } 88 89 { 90 JSLockHolder locker(vm.get()); 91 timer->doWork(); 92 } 93 94 timer->m_apiLock->unlock(); 98 static_cast<JSRunLoopTimer*>(contextPtr)->timerDidFire(); 95 99 } 96 100 … … 144 148 } 145 149 146 void HeapTimer::timerDidFire()147 {148 m_apiLock->lock();149 150 if (!m_apiLock->vm()) {151 // The VM has been destroyed, so we should just give up.152 m_apiLock->unlock();153 return;154 }155 156 {157 JSLockHolder locker(m_vm);158 doWork();159 }160 161 m_apiLock->unlock();162 }163 164 150 void HeapTimer::scheduleTimer(double intervalInSeconds) 165 151 { … … 183 169 } 184 170 185 void HeapTimer::invalidate()186 {187 }188 189 171 void HeapTimer::scheduleTimer(double) 190 172 { -
releases/WebKitGTK/webkit-2.16/Source/JavaScriptCore/heap/HeapTimer.h
r212541 r214817 49 49 HeapTimer(VM*); 50 50 #if USE(CF) 51 static void timerDidFire (CFRunLoopTimerRef, void*);51 static void timerDidFireCallback(CFRunLoopTimerRef, void*); 52 52 #endif 53 53 … … 79 79 #elif USE(GLIB) 80 80 static const long s_decade; 81 void timerDidFire();82 81 GRefPtr<GSource> m_timer; 83 82 #endif 84 83 85 84 private: 86 void invalidate();85 void timerDidFire(); 87 86 }; 88 87
Note: See TracChangeset
for help on using the changeset viewer.