Changeset 214817 in webkit


Ignore:
Timestamp:
Apr 3, 2017 10:38:19 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r214732 - Share implementation of JSRunLoopTimer::timerDidFire
https://bugs.webkit.org/show_bug.cgi?id=170392

Reviewed by Michael Catanzaro.

The code is cross-platform but it's duplicated in CF and GLib implementations, it could be shared instead.

  • runtime/JSRunLoopTimer.cpp:

(JSC::JSRunLoopTimer::timerDidFire): Move common implementation here.
(JSC::JSRunLoopTimer::setRunLoop): Use timerDidFireCallback.
(JSC::JSRunLoopTimer::timerDidFireCallback): Call JSRunLoopTimer::timerDidFire().

  • runtime/JSRunLoopTimer.h:
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  
     12017-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
    1162017-04-01  Oleksandr Skachkov  <gskachkov@gmail.com>
    217
  • releases/WebKitGTK/webkit-2.16/Source/JavaScriptCore/heap/HeapTimer.cpp

    r212541 r214817  
    4141namespace JSC {
    4242
     43void 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
    4362#if USE(CF)
    4463   
     
    6584        memset(&m_context, 0, sizeof(CFRunLoopTimerContext));
    6685        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));
    6887        CFRunLoopAddTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes);
    6988    }
     
    7594}
    7695
    77 void HeapTimer::timerDidFire(CFRunLoopTimerRef, void* contextPtr)
     96void HeapTimer::timerDidFireCallback(CFRunLoopTimerRef, void* contextPtr)
    7897{
    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();
    9599}
    96100
     
    144148}
    145149
    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 
    164150void HeapTimer::scheduleTimer(double intervalInSeconds)
    165151{
     
    183169}
    184170
    185 void HeapTimer::invalidate()
    186 {
    187 }
    188 
    189171void HeapTimer::scheduleTimer(double)
    190172{
  • releases/WebKitGTK/webkit-2.16/Source/JavaScriptCore/heap/HeapTimer.h

    r212541 r214817  
    4949    HeapTimer(VM*);
    5050#if USE(CF)
    51     static void timerDidFire(CFRunLoopTimerRef, void*);
     51    static void timerDidFireCallback(CFRunLoopTimerRef, void*);
    5252#endif
    5353   
     
    7979#elif USE(GLIB)
    8080    static const long s_decade;
    81     void timerDidFire();
    8281    GRefPtr<GSource> m_timer;
    8382#endif
    8483   
    8584private:
    86     void invalidate();
     85    void timerDidFire();
    8786};
    8887
Note: See TracChangeset for help on using the changeset viewer.