Title: [181543] releases/WebKitGTK/webkit-2.8/Source/WTF
Revision
181543
Author
carlo...@webkit.org
Date
2015-03-16 04:42:44 -0700 (Mon, 16 Mar 2015)

Log Message

Merge r181461 - Change WTF::ByteSpinLock to use std::atomic.
<https://webkit.org/b/142644>

Reviewed by Filip Pizlo.

* wtf/ByteSpinLock.h:
(WTF::ByteSpinLock::ByteSpinLock):
(WTF::ByteSpinLock::lock):
(WTF::ByteSpinLock::unlock):
(WTF::ByteSpinLock::isHeld):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.8/Source/WTF/ChangeLog (181542 => 181543)


--- releases/WebKitGTK/webkit-2.8/Source/WTF/ChangeLog	2015-03-16 11:22:32 UTC (rev 181542)
+++ releases/WebKitGTK/webkit-2.8/Source/WTF/ChangeLog	2015-03-16 11:42:44 UTC (rev 181543)
@@ -1,3 +1,16 @@
+2015-03-12  Mark Lam  <mark....@apple.com>
+
+        Change WTF::ByteSpinLock to use std::atomic.
+        <https://webkit.org/b/142644>
+
+        Reviewed by Filip Pizlo.
+
+        * wtf/ByteSpinLock.h:
+        (WTF::ByteSpinLock::ByteSpinLock):
+        (WTF::ByteSpinLock::lock):
+        (WTF::ByteSpinLock::unlock):
+        (WTF::ByteSpinLock::isHeld):
+
 2015-03-12  Csaba Osztrogonác  <o...@webkit.org>
 
         [ARM][Linux] GC sometimes stuck in an infinite loop if parallel GC is enabled

Modified: releases/WebKitGTK/webkit-2.8/Source/WTF/wtf/ByteSpinLock.h (181542 => 181543)


--- releases/WebKitGTK/webkit-2.8/Source/WTF/wtf/ByteSpinLock.h	2015-03-16 11:22:32 UTC (rev 181542)
+++ releases/WebKitGTK/webkit-2.8/Source/WTF/wtf/ByteSpinLock.h	2015-03-16 11:42:44 UTC (rev 181543)
@@ -26,9 +26,9 @@
 #ifndef ByteSpinLock_h
 #define ByteSpinLock_h
 
+#include <atomic>
 #include <thread>
 #include <wtf/Assertions.h>
-#include <wtf/Atomics.h>
 #include <wtf/Locker.h>
 #include <wtf/Noncopyable.h>
 
@@ -38,27 +38,28 @@
     WTF_MAKE_NONCOPYABLE(ByteSpinLock);
 public:
     ByteSpinLock()
-        : m_lock(0)
+        : m_lock(false)
     {
     }
 
     void lock()
     {
-        while (!weakCompareAndSwap(&m_lock, 0, 1))
+        bool expected = false;
+        while (!m_lock.compare_exchange_weak(expected, true, std::memory_order_acquire)) {
             std::this_thread::yield();
-        memoryBarrierAfterLock();
+            expected = false;
+        }
     }
     
     void unlock()
     {
-        memoryBarrierBeforeUnlock();
-        m_lock = 0;
+        m_lock.store(false, std::memory_order_release);
     }
     
-    bool isHeld() const { return !!m_lock; }
+    bool isHeld() const { return m_lock.load(std::memory_order_acquire); }
     
 private:
-    uint8_t m_lock;
+    std::atomic<bool> m_lock;
 };
 
 typedef Locker<ByteSpinLock> ByteSpinLocker;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to