Title: [163685] trunk/Source/_javascript_Core
Revision
163685
Author
mark....@apple.com
Date
2014-02-07 18:52:05 -0800 (Fri, 07 Feb 2014)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (163684 => 163685)


--- trunk/Source/_javascript_Core/ChangeLog	2014-02-08 02:51:15 UTC (rev 163684)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-02-08 02:52:05 UTC (rev 163685)
@@ -1,3 +1,32 @@
+2014-02-07  Mark Lam  <mark....@apple.com>
+
+        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):
+
 2014-02-06  Filip Pizlo  <fpi...@apple.com>
 
         More FTL build scaffolding

Modified: trunk/Source/_javascript_Core/runtime/JSLock.cpp (163684 => 163685)


--- trunk/Source/_javascript_Core/runtime/JSLock.cpp	2014-02-08 02:51:15 UTC (rev 163684)
+++ trunk/Source/_javascript_Core/runtime/JSLock.cpp	2014-02-08 02:52:05 UTC (rev 163685)
@@ -208,7 +208,6 @@
 // This function returns the number of locks that were dropped.
 unsigned JSLock::dropAllLocks(SpinLock& spinLock)
 {
-#if PLATFORM(IOS)
     ASSERT_UNUSED(spinLock, spinLock.IsHeld());
     // Check if this thread is currently holding the lock.
     // FIXME: Maybe we want to require this, guard with an ASSERT?
@@ -231,17 +230,10 @@
     }
     m_lock.unlock();
     return lockCount;
-#else
-    if (m_lockDropDepth++)
-        return 0;
-
-    return dropAllLocksUnconditionally(spinLock);
-#endif
 }
 
 unsigned JSLock::dropAllLocksUnconditionally(SpinLock& spinLock)
 {
-#if PLATFORM(IOS)
     ASSERT_UNUSED(spinLock, spinLock.IsHeld());
     // Check if this thread is currently holding the lock.
     // FIXME: Maybe we want to require this, guard with an ASSERT?
@@ -258,19 +250,10 @@
     }
     m_lock.unlock();
     return lockCount;
-#else
-    UNUSED_PARAM(spinLock);
-    unsigned lockCount = m_lockCount;
-    for (unsigned i = 0; i < lockCount; ++i)
-        unlock();
-
-    return lockCount;
-#endif
 }
 
 void JSLock::grabAllLocks(unsigned lockCount, SpinLock& spinLock)
 {
-#if PLATFORM(IOS)
     ASSERT(spinLock.IsHeld());
     // If no locks were dropped, nothing to do!
     if (!lockCount)
@@ -293,13 +276,6 @@
     ASSERT(!m_lockCount);
     m_lockCount = lockCount;
     --m_lockDropDepth;
-#else
-    UNUSED_PARAM(spinLock);
-    for (unsigned i = 0; i < lockCount; ++i)
-        lock();
-
-    --m_lockDropDepth;
-#endif
 }
 
 JSLock::DropAllLocks::DropAllLocks(ExecState* exec, AlwaysDropLocksTag alwaysDropLocks)
@@ -309,9 +285,7 @@
     if (!m_vm)
         return;
     SpinLock& spinLock = m_vm->apiLock().m_spinLock;
-#if PLATFORM(IOS)
     SpinLockHolder holder(&spinLock);
-#endif
 
     WTFThreadData& threadData = wtfThreadData();
     
@@ -332,9 +306,7 @@
     if (!m_vm)
         return;
     SpinLock& spinLock = m_vm->apiLock().m_spinLock;
-#if PLATFORM(IOS)
     SpinLockHolder holder(&spinLock);
-#endif
 
     WTFThreadData& threadData = wtfThreadData();
     
@@ -353,9 +325,7 @@
     if (!m_vm)
         return;
     SpinLock& spinLock = m_vm->apiLock().m_spinLock;
-#if PLATFORM(IOS)
     SpinLockHolder holder(&spinLock);
-#endif
     m_vm->apiLock().grabAllLocks(m_lockCount, spinLock);
 
     WTFThreadData& threadData = wtfThreadData();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to