Title: [188914] releases/WebKitGTK/webkit-2.10/Source
Revision
188914
Author
[email protected]
Date
2015-08-25 10:35:41 -0700 (Tue, 25 Aug 2015)

Log Message

Merge r188677 - Remove WTF::SpinLock
https://bugs.webkit.org/show_bug.cgi?id=148208

Reviewed by Geoffrey Garen.

Source/_javascript_Core:

Remove the one remaining use of SpinLock.

* API/JSValue.mm:
(handerForStructTag):

Source/WTF:

Remove the SpinLock.h file and remove references to the SpinLock class. Put the old SpinLock
algorithm in LockSpeedTest.cpp - which isn't compiled as part of a WTF or WebKit build - just
so we can still benchmark our locking algorithms against a spinlock baseline.

* WTF.vcxproj/WTF.vcxproj:
* WTF.xcodeproj/project.pbxproj:
* benchmarks/LockSpeedTest.cpp:
* wtf/CMakeLists.txt:
* wtf/Lock.h:
* wtf/SpinLock.h: Removed.
* wtf/WordLock.h:

Modified Paths

Removed Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/API/JSValue.mm (188913 => 188914)


--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/API/JSValue.mm	2015-08-25 17:04:47 UTC (rev 188913)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/API/JSValue.mm	2015-08-25 17:35:41 UTC (rev 188914)
@@ -41,8 +41,8 @@
 #import "StrongInlines.h"
 #import <wtf/HashMap.h>
 #import <wtf/HashSet.h>
+#import <wtf/Lock.h>
 #import <wtf/ObjcRuntimeExtras.h>
-#import <wtf/SpinLock.h>
 #import <wtf/Vector.h>
 #import <wtf/text/WTFString.h>
 #import <wtf/text/StringHash.h>
@@ -1114,8 +1114,8 @@
 
 static StructTagHandler* handerForStructTag(const char* encodedType)
 {
-    static StaticSpinLock handerForStructTagLock;
-    SpinLockHolder lockHolder(&handerForStructTagLock);
+    static StaticLock handerForStructTagLock;
+    LockHolder lockHolder(&handerForStructTagLock);
 
     static StructHandlers* structHandlers = createStructHandlerMap();
 

Modified: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/ChangeLog (188913 => 188914)


--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/ChangeLog	2015-08-25 17:04:47 UTC (rev 188913)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/ChangeLog	2015-08-25 17:35:41 UTC (rev 188914)
@@ -1,3 +1,15 @@
+2015-08-19  Filip Pizlo  <[email protected]>
+
+        Remove WTF::SpinLock
+        https://bugs.webkit.org/show_bug.cgi?id=148208
+
+        Reviewed by Geoffrey Garen.
+
+        Remove the one remaining use of SpinLock.
+
+        * API/JSValue.mm:
+        (handerForStructTag):
+
 2015-08-18  Filip Pizlo  <[email protected]>
 
         Replace all uses of std::mutex/std::condition_variable with WTF::Lock/WTF::Condition

Modified: releases/WebKitGTK/webkit-2.10/Source/WTF/ChangeLog (188913 => 188914)


--- releases/WebKitGTK/webkit-2.10/Source/WTF/ChangeLog	2015-08-25 17:04:47 UTC (rev 188913)
+++ releases/WebKitGTK/webkit-2.10/Source/WTF/ChangeLog	2015-08-25 17:35:41 UTC (rev 188914)
@@ -1,3 +1,22 @@
+2015-08-19  Filip Pizlo  <[email protected]>
+
+        Remove WTF::SpinLock
+        https://bugs.webkit.org/show_bug.cgi?id=148208
+
+        Reviewed by Geoffrey Garen.
+
+        Remove the SpinLock.h file and remove references to the SpinLock class. Put the old SpinLock
+        algorithm in LockSpeedTest.cpp - which isn't compiled as part of a WTF or WebKit build - just
+        so we can still benchmark our locking algorithms against a spinlock baseline.
+
+        * WTF.vcxproj/WTF.vcxproj:
+        * WTF.xcodeproj/project.pbxproj:
+        * benchmarks/LockSpeedTest.cpp:
+        * wtf/CMakeLists.txt:
+        * wtf/Lock.h:
+        * wtf/SpinLock.h: Removed.
+        * wtf/WordLock.h:
+
 2015-08-18  Filip Pizlo  <[email protected]>
 
         Replace all uses of std::mutex/std::condition_variable with WTF::Lock/WTF::Condition

Modified: releases/WebKitGTK/webkit-2.10/Source/WTF/WTF.vcxproj/WTF.vcxproj (188913 => 188914)


--- releases/WebKitGTK/webkit-2.10/Source/WTF/WTF.vcxproj/WTF.vcxproj	2015-08-25 17:04:47 UTC (rev 188913)
+++ releases/WebKitGTK/webkit-2.10/Source/WTF/WTF.vcxproj/WTF.vcxproj	2015-08-25 17:35:41 UTC (rev 188914)
@@ -270,7 +270,6 @@
     <ClInclude Include="..\wtf\SHA1.h" />
     <ClInclude Include="..\wtf\SinglyLinkedList.h" />
     <ClInclude Include="..\wtf\SixCharacterHash.h" />
-    <ClInclude Include="..\wtf\SpinLock.h" />
     <ClInclude Include="..\wtf\StackBounds.h" />
     <ClInclude Include="..\wtf\StaticConstructors.h" />
     <ClInclude Include="..\wtf\StdLibExtras.h" />

Modified: releases/WebKitGTK/webkit-2.10/Source/WTF/benchmarks/LockSpeedTest.cpp (188913 => 188914)


--- releases/WebKitGTK/webkit-2.10/Source/WTF/benchmarks/LockSpeedTest.cpp	2015-08-25 17:04:47 UTC (rev 188913)
+++ releases/WebKitGTK/webkit-2.10/Source/WTF/benchmarks/LockSpeedTest.cpp	2015-08-25 17:35:41 UTC (rev 188914)
@@ -31,7 +31,6 @@
 #include <unistd.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/Lock.h>
-#include <wtf/SpinLock.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/Threading.h>
 #include <wtf/ThreadingPrimitives.h>
@@ -39,6 +38,35 @@
 
 namespace {
 
+// This is the old WTF::SpinLock class, included here so that we can still compare our new locks to a
+// spinlock baseline.
+class SpinLock {
+public:
+    SpinLock()
+    {
+        m_lock.store(0, std::memory_order_relaxed);
+    }
+
+    void lock()
+    {
+        while (!m_lock.compareExchangeWeak(0, 1, std::memory_order_acquire))
+            std::this_thread::yield();
+    }
+
+    void unlock()
+    {
+        m_lock.store(0, std::memory_order_release);
+    }
+
+    bool isLocked() const
+    {
+        return m_lock.load(std::memory_order_acquire);
+    }
+
+private:
+    Atomic<unsigned> m_lock;
+};
+
 unsigned numThreadGroups;
 unsigned numThreadsPerGroup;
 unsigned workPerCriticalSection;

Modified: releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/CMakeLists.txt (188913 => 188914)


--- releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/CMakeLists.txt	2015-08-25 17:04:47 UTC (rev 188913)
+++ releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/CMakeLists.txt	2015-08-25 17:35:41 UTC (rev 188914)
@@ -83,7 +83,6 @@
     SHA1.h
     SaturatedArithmetic.h
     SegmentedVector.h
-    SpinLock.h
     StackBounds.h
     StackStats.h
     StaticConstructors.h

Modified: releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/Lock.h (188913 => 188914)


--- releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/Lock.h	2015-08-25 17:04:47 UTC (rev 188913)
+++ releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/Lock.h	2015-08-25 17:35:41 UTC (rev 188914)
@@ -38,10 +38,10 @@
 namespace WTF {
 
 // This is a fully adaptive mutex that only requires 1 byte of storage. It has fast paths that are
-// competetive to SpinLock (uncontended locking is inlined and is just a CAS, microcontention is
-// handled by spinning and yielding), and a slow path that is competetive to Mutex (if a lock cannot
-// be acquired in a short period of time, the thread is put to sleep until the lock is available
-// again). It uses less memory than either SpinLock or Mutex.
+// competetive to a spinlock (uncontended locking is inlined and is just a CAS, microcontention is
+// handled by spinning and yielding), and a slow path that is competetive to std::mutex (if a lock
+// cannot be acquired in a short period of time, the thread is put to sleep until the lock is available
+// again). It uses less memory than a std::mutex.
 
 // This is a struct without a constructor or destructor so that it can be statically initialized.
 // Use Lock in instance variables.

Deleted: releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/SpinLock.h (188913 => 188914)


--- releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/SpinLock.h	2015-08-25 17:04:47 UTC (rev 188913)
+++ releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/SpinLock.h	2015-08-25 17:35:41 UTC (rev 188914)
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SpinLock_h
-#define SpinLock_h
-
-#include <thread>
-#include <wtf/Atomics.h>
-#include <wtf/Locker.h>
-
-namespace WTF {
-
-// SpinLock is a very simple lock implementation that has extremely fast lock/unlock for very small
-// uncontended critical sections. However, it will exhibit bad performance degradation when the lock
-// becomes contended: the thread trying to acquire the lock will simply waste CPU cycles.
-//
-// For most (all?) locking use cases, it's better to use Lock (see wtf/Lock.h). That uses only a bit
-// more memory (8 bytes instead of 4 on 64-bit), and is only a bit slower in the uncontended case
-// (Lock needs CAS to unlock, while SpinLock doesn't), but will burn a lot less CPU time - for 10
-// threads acquiring a 50 microsecond critical section, Lock will use up to 100x less kernel CPU time
-// than SpinLock.
-
-// SpinLockBase is a struct without an explicitly defined constructors so that
-// it can be initialized at compile time. See StaticSpinLock below.
-struct SpinLockBase {
-
-    void lock()
-    {
-        while (!m_lock.compareExchangeWeak(0, 1, std::memory_order_acquire))
-            std::this_thread::yield();
-    }
-
-    void unlock()
-    {
-        m_lock.store(0, std::memory_order_release);
-    }
-
-    bool isLocked() const
-    {
-        return m_lock.load(std::memory_order_acquire);
-    }
-    
-    Atomic<unsigned> m_lock;
-};
-
-// SpinLock is for use as instance variables in structs and classes, not as
-// statics and globals.
-struct SpinLock : public SpinLockBase {
-    SpinLock()
-    {
-        m_lock.store(0, std::memory_order_relaxed);
-    }
-};
-
-// StaticSpinLock is for use as statics and globals, not as instance variables.
-typedef SpinLockBase StaticSpinLock;
-typedef Locker<SpinLockBase> SpinLockHolder;
-
-} // namespace WTF
-
-using WTF::StaticSpinLock;
-using WTF::SpinLock;
-using WTF::SpinLockHolder;
-
-#endif // SpinLock_h

Modified: releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/WordLock.h (188913 => 188914)


--- releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/WordLock.h	2015-08-25 17:04:47 UTC (rev 188913)
+++ releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/WordLock.h	2015-08-25 17:35:41 UTC (rev 188914)
@@ -38,8 +38,8 @@
 namespace WTF {
 
 // A WordLock is a fully adaptive mutex that uses sizeof(void*) storage. It has a fast path that is
-// similar to SpinLock, and a slow path that is similar to Mutex. In most cases, you should use Lock
-// instead. WordLock sits lower in the stack and is used to implement Lock, so Lock is the main
+// similar to a spinlock, and a slow path that is similar to std::mutex. In most cases, you should use
+// Lock instead. WordLock sits lower in the stack and is used to implement Lock, so Lock is the main
 // client of WordLock.
 
 class WordLock {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to