WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
the patch
blah.patch (text/plain), 3.71 KB, created by
Filip Pizlo
on 2013-08-31 17:47:21 PDT
(
hide
)
Description:
the patch
Filename:
MIME Type:
Creator:
Filip Pizlo
Created:
2013-08-31 17:47:21 PDT
Size:
3.71 KB
patch
obsolete
>Index: Source/WTF/ChangeLog >=================================================================== >--- Source/WTF/ChangeLog (revision 154934) >+++ Source/WTF/ChangeLog (working copy) >@@ -1,3 +1,18 @@ >+2013-08-31 Filip Pizlo <fpizlo@apple.com> >+ >+ DeferredRefCounted should be thread-safe >+ https://bugs.webkit.org/show_bug.cgi?id=120568 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This makes the class more general. It also happens that this doesn't hurt >+ performance for current users of DeferredRefCounted (i.e. ArrayBuffers). >+ >+ * wtf/DeferrableRefCounted.h: >+ (WTF::DeferrableRefCountedBase::ref): >+ (WTF::DeferrableRefCountedBase::derefBase): >+ (WTF::DeferrableRefCountedBase::setIsDeferredBase): >+ > 2013-08-30 Oliver Hunt <oliver@apple.com> > > Make JSValue bool conversion less dangerous >Index: Source/WTF/wtf/DeferrableRefCounted.h >=================================================================== >--- Source/WTF/wtf/DeferrableRefCounted.h (revision 154933) >+++ Source/WTF/wtf/DeferrableRefCounted.h (working copy) >@@ -27,8 +27,10 @@ > #define DeferrableRefCounted_h > > #include <wtf/Assertions.h> >+#include <wtf/Atomics.h> > #include <wtf/FastAllocBase.h> > #include <wtf/Noncopyable.h> >+#include <wtf/ThreadingPrimitives.h> > > namespace WTF { > >@@ -38,6 +40,10 @@ namespace WTF { > // specifically happened - this can be useful either for debugging, or > // sometimes even for some additional functionality. > >+// Note, this is always thread-safe ref-counted - this works out fine >+// because the users of this class either have low refCount churn, or >+// need thread-safe reference counting, or both. >+ > class DeferrableRefCountedBase { > static const unsigned deferredFlag = 1; > static const unsigned normalIncrement = 2; >@@ -45,7 +51,15 @@ class DeferrableRefCountedBase { > public: > void ref() > { >+#if ENABLE(COMPARE_AND_SWAP) >+ unsigned oldValue; >+ do >+ oldValue = m_refCount; >+ while (!weakCompareAndSwap(&m_refCount, oldValue, oldValue + normalIncrement)); >+#else // ENABLE(COMPARE_AND_SWAP) >+ MutexLocker locker(m_lock); > m_refCount += normalIncrement; >+#endif // ENABLE(COMPARE_AND_SWAP) > } > > bool hasOneRef() const >@@ -75,22 +89,55 @@ protected: > > bool derefBase() > { >+#if ENABLE(COMPARE_AND_SWAP) >+ unsigned oldValue; >+ unsigned newValue; >+ do { >+ oldValue = m_refCount; >+ newValue = oldValue - normalIncrement; >+ } while (!weakCompareAndSwap(&m_refCount, oldValue, newValue)); >+ return !newValue; >+#else // ENABLE(COMPARE_AND_SWAP) >+ MutexLocker locker(m_lock); > m_refCount -= normalIncrement; > return !m_refCount; >+#endif // ENABLE(COMPARE_AND_SWAP) > } > > bool setIsDeferredBase(bool value) > { >+#if ENABLE(COMPARE_AND_SWAP) >+ unsigned oldValue; >+ unsigned newValue; >+ bool result; >+ do { >+ oldValue = m_refCount; >+ if (value) { >+ newValue = oldValue | deferredFlag; >+ result = false; >+ } else { >+ newValue = oldValue & ~deferredFlag; >+ result = !newValue; >+ } >+ } while (!weakCompareAndSwap(&m_refCount, oldValue, newValue)); >+ return result; >+#else // ENABLE(COMPARE_AND_SWAP) >+ MutexLocker locker(m_lock); > if (value) { > m_refCount |= deferredFlag; > return false; > } > m_refCount &= ~deferredFlag; > return !m_refCount; >+#endif // ENABLE(COMPARE_AND_SWAP) > } > > private: > unsigned m_refCount; >+ >+#if !ENABLE(COMPARE_AND_SWAP) >+ Mutex m_lock; >+#endif // !ENABLE(COMPARE_AND_SWAP) > }; > > template<typename T>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 120568
:
210221
|
210223