Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2243)

Unified Diff: Source/wtf/text/StringImpl.h

Issue 751553004: CL for perf tryjob ThreadSafeRefCountedStringImpl Linux blink_perf.dom Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Tools/run-perf-test.cfg » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/text/StringImpl.h
diff --git a/Source/wtf/text/StringImpl.h b/Source/wtf/text/StringImpl.h
index 4c5fb01607778ad77ea6c7e7dec8cba0de257cd2..1682171712bf672c9520d02193ebcdee0ec5c3eb 100644
--- a/Source/wtf/text/StringImpl.h
+++ b/Source/wtf/text/StringImpl.h
@@ -25,6 +25,7 @@
#include <limits.h>
#include "wtf/ASCIICType.h"
+#include "wtf/DynamicAnnotations.h"
#include "wtf/Forward.h"
#include "wtf/HashMap.h"
#include "wtf/StringHasher.h"
@@ -283,24 +284,28 @@ public:
return hashSlowCase();
}
+ ALWAYS_INLINE unsigned refCount() const
+ {
+ return static_cast<int const volatile &>(m_refCount);
+ }
+
ALWAYS_INLINE bool hasOneRef() const
{
- return m_refCount == 1;
+ return refCount() == 1;
}
ALWAYS_INLINE void ref()
{
- ++m_refCount;
+ atomicIncrement(&m_refCount);
}
ALWAYS_INLINE void deref()
{
- if (hasOneRef()) {
+ WTF_ANNOTATE_HAPPENS_BEFORE(&m_refCount);
+ if (atomicDecrement(&m_refCount) <= 0) {
+ WTF_ANNOTATE_HAPPENS_AFTER(&m_refCount);
Alexander Potapenko 2014/12/08 11:46:57 Please do not use WTF_ANNOTATE_HAPPENS_AFTER. They
destroyIfNotStatic();
- return;
}
-
- --m_refCount;
}
static StringImpl* empty();
@@ -448,7 +453,7 @@ private:
#endif
private:
- unsigned m_refCount;
+ int m_refCount;
unsigned m_length;
mutable unsigned m_hash : 24;
unsigned m_isAtomic : 1;
« no previous file with comments | « no previous file | Tools/run-perf-test.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698