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

Unified Diff: Source/core/dom/QualifiedName.h

Issue 311803003: [oilpan]: Avoid refcounting QualifiedName's nullQName when tracing. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review feedback Created 6 years, 6 months 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 | « Source/core/dom/Element.cpp ('k') | Source/core/dom/QualifiedName.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/QualifiedName.h
diff --git a/Source/core/dom/QualifiedName.h b/Source/core/dom/QualifiedName.h
index b589440d942e0125885430a010aa8ffbec6b18c9..2b1d99304d7561e1688941709f5af70937728621 100644
--- a/Source/core/dom/QualifiedName.h
+++ b/Source/core/dom/QualifiedName.h
@@ -34,32 +34,63 @@ struct QualifiedNameComponents {
StringImpl* m_namespace;
};
+// This struct is used pass data between QualifiedName and the QNameTranslator.
haraken 2014/06/12 10:57:15 is used to pass
wibling-chromium 2014/06/12 11:02:05 Done.
+// For hashing and equality only the QualifiedNameComponents fields are used.
+struct QualifiedNameData {
+ QualifiedNameComponents m_components;
+ bool m_isStatic;
+};
+
class QualifiedName {
WTF_MAKE_FAST_ALLOCATED;
public:
class QualifiedNameImpl : public RefCounted<QualifiedNameImpl> {
public:
- static PassRefPtr<QualifiedNameImpl> create(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI)
+ static PassRefPtr<QualifiedNameImpl> create(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI, bool isStatic)
{
- return adoptRef(new QualifiedNameImpl(prefix, localName, namespaceURI));
+ return adoptRef(new QualifiedNameImpl(prefix, localName, namespaceURI, isStatic));
}
~QualifiedNameImpl();
unsigned computeHash() const;
- mutable unsigned m_existingHash;
+ bool hasOneRef() const
+ {
+ return m_isStatic || RefCounted<QualifiedNameImpl>::hasOneRef();
+ }
+
+ void ref()
+ {
+ if (m_isStatic)
+ return;
+ RefCounted<QualifiedNameImpl>::ref();
+ }
+
+ void deref()
+ {
+ if (m_isStatic)
+ return;
+ RefCounted<QualifiedNameImpl>::deref();
+ }
+
const AtomicString m_prefix;
const AtomicString m_localName;
const AtomicString m_namespace;
mutable AtomicString m_localNameUpper;
+ // We rely on StringHasher's hashMemory clearing out the top 8 bits when
+ // doing hashing and use one of the bits for the m_isStatic value.
+ mutable unsigned m_existingHash : 24;
+ unsigned m_isStatic : 1;
private:
- QualifiedNameImpl(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI)
- : m_existingHash(0)
- , m_prefix(prefix)
+ QualifiedNameImpl(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI, bool isStatic)
+ : m_prefix(prefix)
, m_localName(localName)
, m_namespace(namespaceURI)
+ , m_existingHash(0)
+ , m_isStatic(isStatic)
+
{
ASSERT(!namespaceURI.isEmpty() || namespaceURI.isNull());
}
@@ -102,7 +133,16 @@ public:
// Init routine for globals
static void init();
+ static const QualifiedName& null();
+
+ // The below methods are only for creating static global QNames that need no ref counting.
+ static void createStatic(void* targetAddress, StringImpl* name);
+ static void createStatic(void* targetAddress, StringImpl* name, const AtomicString& nameNamespace);
+
private:
+ // This constructor is used only to create global/static QNames that don't require any ref counting.
+ QualifiedName(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI, bool isStatic);
+
RefPtr<QualifiedNameImpl> m_impl;
};
@@ -111,8 +151,6 @@ extern const QualifiedName anyName;
inline const QualifiedName& anyQName() { return anyName; }
#endif
-const QualifiedName& nullQName();
-
inline bool operator==(const AtomicString& a, const QualifiedName& q) { return a == q.localName(); }
inline bool operator!=(const AtomicString& a, const QualifiedName& q) { return a != q.localName(); }
inline bool operator==(const QualifiedName& q, const AtomicString& a) { return a == q.localName(); }
@@ -139,9 +177,6 @@ struct QualifiedNameHash {
static const bool safeToCompareToEmptyOrDeleted = false;
};
-void createQualifiedName(void* targetAddress, StringImpl* name);
-void createQualifiedName(void* targetAddress, StringImpl* name, const AtomicString& nameNamespace);
-
}
namespace WTF {
@@ -154,7 +189,7 @@ namespace WTF {
template<> struct HashTraits<WebCore::QualifiedName> : SimpleClassHashTraits<WebCore::QualifiedName> {
static const bool emptyValueIsZero = false;
- static WebCore::QualifiedName emptyValue() { return WebCore::nullQName(); }
+ static WebCore::QualifiedName emptyValue() { return WebCore::QualifiedName::null(); }
};
}
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/dom/QualifiedName.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698