Changeset 163685 in webkit


Ignore:
Timestamp:
Feb 7, 2014 6:52:05 PM (10 years ago)
Author:
mark.lam@apple.com
Message:

Unify JSLock implementation for iOS and non-iOS ports.
<https://webkit.org/b/128409>

Reviewed by Michael Saboff.

The iOS and non-iOS implementations of dropAllLocks(),
dropAllLocksUnconditionally(), and grabAllLocks() effectively do the
same work. The main difference is that the iOS implementation acquires
the JSLock spin lock in the DropAllLocks class while the other ports
acquire it when it calls JSLock::lock() and unlock().

The other difference is that the iOS implementation will only increment
m_locksDropDepth if it actually drops locks, whereas other ports will
increment it unconditionally. Analogously, iOS decrements the depth only
when needed while other ports will decrement it unconditionally when
re-grabbing locks.

We can unify the 2 implementations by having both use the iOS
implementation for a start.

  • runtime/JSLock.cpp:

(JSC::JSLock::dropAllLocks):
(JSC::JSLock::dropAllLocksUnconditionally):
(JSC::JSLock::grabAllLocks):
(JSC::JSLock::DropAllLocks::DropAllLocks):
(JSC::JSLock::DropAllLocks::~DropAllLocks):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r163674 r163685  
     12014-02-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Unify JSLock implementation for iOS and non-iOS ports.
     4        <https://webkit.org/b/128409>
     5
     6        Reviewed by Michael Saboff.
     7
     8        The iOS and non-iOS implementations of dropAllLocks(),
     9        dropAllLocksUnconditionally(), and grabAllLocks() effectively do the
     10        same work. The main difference is that the iOS implementation acquires
     11        the JSLock spin lock in the DropAllLocks class while the other ports
     12        acquire it when it calls JSLock::lock() and unlock().
     13
     14        The other difference is that the iOS implementation will only increment
     15        m_locksDropDepth if it actually drops locks, whereas other ports will
     16        increment it unconditionally. Analogously, iOS decrements the depth only
     17        when needed while other ports will decrement it unconditionally when
     18        re-grabbing locks.
     19
     20        We can unify the 2 implementations by having both use the iOS
     21        implementation for a start.
     22
     23        * runtime/JSLock.cpp:
     24        (JSC::JSLock::dropAllLocks):
     25        (JSC::JSLock::dropAllLocksUnconditionally):
     26        (JSC::JSLock::grabAllLocks):
     27        (JSC::JSLock::DropAllLocks::DropAllLocks):
     28        (JSC::JSLock::DropAllLocks::~DropAllLocks):
     29
    1302014-02-06  Filip Pizlo  <fpizlo@apple.com>
    231
  • trunk/Source/JavaScriptCore/runtime/JSLock.cpp

    r163672 r163685  
    209209unsigned JSLock::dropAllLocks(SpinLock& spinLock)
    210210{
    211 #if PLATFORM(IOS)
    212211    ASSERT_UNUSED(spinLock, spinLock.IsHeld());
    213212    // Check if this thread is currently holding the lock.
     
    232231    m_lock.unlock();
    233232    return lockCount;
    234 #else
    235     if (m_lockDropDepth++)
    236         return 0;
    237 
    238     return dropAllLocksUnconditionally(spinLock);
    239 #endif
    240233}
    241234
    242235unsigned JSLock::dropAllLocksUnconditionally(SpinLock& spinLock)
    243236{
    244 #if PLATFORM(IOS)
    245237    ASSERT_UNUSED(spinLock, spinLock.IsHeld());
    246238    // Check if this thread is currently holding the lock.
     
    259251    m_lock.unlock();
    260252    return lockCount;
    261 #else
    262     UNUSED_PARAM(spinLock);
    263     unsigned lockCount = m_lockCount;
    264     for (unsigned i = 0; i < lockCount; ++i)
    265         unlock();
    266 
    267     return lockCount;
    268 #endif
    269253}
    270254
    271255void JSLock::grabAllLocks(unsigned lockCount, SpinLock& spinLock)
    272256{
    273 #if PLATFORM(IOS)
    274257    ASSERT(spinLock.IsHeld());
    275258    // If no locks were dropped, nothing to do!
     
    294277    m_lockCount = lockCount;
    295278    --m_lockDropDepth;
    296 #else
    297     UNUSED_PARAM(spinLock);
    298     for (unsigned i = 0; i < lockCount; ++i)
    299         lock();
    300 
    301     --m_lockDropDepth;
    302 #endif
    303279}
    304280
     
    310286        return;
    311287    SpinLock& spinLock = m_vm->apiLock().m_spinLock;
    312 #if PLATFORM(IOS)
    313288    SpinLockHolder holder(&spinLock);
    314 #endif
    315289
    316290    WTFThreadData& threadData = wtfThreadData();
     
    333307        return;
    334308    SpinLock& spinLock = m_vm->apiLock().m_spinLock;
    335 #if PLATFORM(IOS)
    336309    SpinLockHolder holder(&spinLock);
    337 #endif
    338310
    339311    WTFThreadData& threadData = wtfThreadData();
     
    354326        return;
    355327    SpinLock& spinLock = m_vm->apiLock().m_spinLock;
    356 #if PLATFORM(IOS)
    357328    SpinLockHolder holder(&spinLock);
    358 #endif
    359329    m_vm->apiLock().grabAllLocks(m_lockCount, spinLock);
    360330
Note: See TracChangeset for help on using the changeset viewer.