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

Side by Side Diff: Source/core/dom/QualifiedName.cpp

Issue 311803003: [oilpan]: Avoid refcounting QualifiedName's nullQName when tracing. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/QualifiedName.h ('k') | Source/core/dom/custom/CustomElementRegistry.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 static QualifiedNameCache& qualifiedNameCache() 54 static QualifiedNameCache& qualifiedNameCache()
55 { 55 {
56 // This code is lockless and thus assumes it all runs on one thread! 56 // This code is lockless and thus assumes it all runs on one thread!
57 ASSERT(isMainThread()); 57 ASSERT(isMainThread());
58 static QualifiedNameCache* gNameCache = new QualifiedNameCache; 58 static QualifiedNameCache* gNameCache = new QualifiedNameCache;
59 return *gNameCache; 59 return *gNameCache;
60 } 60 }
61 61
62 struct QNameComponentsTranslator { 62 struct QNameComponentsTranslator {
63 static unsigned hash(const QualifiedNameComponents& components) 63 static unsigned hash(const QualifiedNameData& data)
64 { 64 {
65 return hashComponents(components); 65 return hashComponents(data.m_components);
66 } 66 }
67 static bool equal(QualifiedName::QualifiedNameImpl* name, const QualifiedNam eComponents& c) 67 static bool equal(QualifiedName::QualifiedNameImpl* name, const QualifiedNam eData& data)
68 { 68 {
69 return c.m_prefix == name->m_prefix.impl() && c.m_localName == name->m_l ocalName.impl() && c.m_namespace == name->m_namespace.impl(); 69 return data.m_components.m_prefix == name->m_prefix.impl()
70 && data.m_components.m_localName == name->m_localName.impl()
71 && data.m_components.m_namespace == name->m_namespace.impl();
70 } 72 }
71 static void translate(QualifiedName::QualifiedNameImpl*& location, const Qua lifiedNameComponents& components, unsigned) 73 static void translate(QualifiedName::QualifiedNameImpl*& location, const Qua lifiedNameData& data, unsigned)
72 { 74 {
73 location = QualifiedName::QualifiedNameImpl::create(AtomicString(compone nts.m_prefix), AtomicString(components.m_localName), AtomicString(components.m_n amespace)).leakRef(); 75 const QualifiedNameComponents& components = data.m_components;
76 location = QualifiedName::QualifiedNameImpl::create(AtomicString(compone nts.m_prefix), AtomicString(components.m_localName), AtomicString(components.m_n amespace), data.m_isStatic).leakRef();
74 } 77 }
75 }; 78 };
76 79
77 QualifiedName::QualifiedName(const AtomicString& p, const AtomicString& l, const AtomicString& n) 80 QualifiedName::QualifiedName(const AtomicString& p, const AtomicString& l, const AtomicString& n)
78 { 81 {
79 QualifiedNameComponents components = { p.impl(), l.impl(), n.isEmpty() ? nul lAtom.impl() : n.impl() }; 82 QualifiedNameData data = { { p.impl(), l.impl(), n.isEmpty() ? nullAtom.impl () : n.impl() }, false };
80 QualifiedNameCache::AddResult addResult = qualifiedNameCache().add<QNameComp onentsTranslator>(components); 83 QualifiedNameCache::AddResult addResult = qualifiedNameCache().add<QNameComp onentsTranslator>(data);
81 m_impl = addResult.isNewEntry ? adoptRef(*addResult.storedValue) : *addResul t.storedValue; 84 m_impl = addResult.isNewEntry ? adoptRef(*addResult.storedValue) : *addResul t.storedValue;
82 } 85 }
83 86
87 QualifiedName::QualifiedName(const AtomicString& p, const AtomicString& l, const AtomicString& n, bool isStatic)
88 {
89 QualifiedNameData data = { { p.impl(), l.impl(), n.impl() }, isStatic };
90 QualifiedNameCache::AddResult addResult = qualifiedNameCache().add<QNameComp onentsTranslator>(data);
91 m_impl = addResult.isNewEntry ? adoptRef(*addResult.storedValue) : *addResul t.storedValue;
92 }
93
84 QualifiedName::~QualifiedName() 94 QualifiedName::~QualifiedName()
85 { 95 {
86 } 96 }
87 97
88 QualifiedName::QualifiedNameImpl::~QualifiedNameImpl() 98 QualifiedName::QualifiedNameImpl::~QualifiedNameImpl()
89 { 99 {
90 qualifiedNameCache().remove(this); 100 qualifiedNameCache().remove(this);
91 } 101 }
92 102
93 String QualifiedName::toString() const 103 String QualifiedName::toString() const
94 { 104 {
95 String local = localName(); 105 String local = localName();
96 if (hasPrefix()) 106 if (hasPrefix())
97 return prefix().string() + ":" + local; 107 return prefix().string() + ":" + local;
98 return local; 108 return local;
99 } 109 }
100 110
101 // Global init routines 111 // Global init routines
102 DEFINE_GLOBAL(QualifiedName, anyName, nullAtom, starAtom, starAtom) 112 DEFINE_GLOBAL(QualifiedName, anyName, nullAtom, starAtom, starAtom)
103 113
104 void QualifiedName::init() 114 void QualifiedName::init()
105 { 115 {
106 ASSERT(starAtom.impl()); 116 ASSERT(starAtom.impl());
107 new ((void*)&anyName) QualifiedName(nullAtom, starAtom, starAtom); 117 new ((void*)&anyName) QualifiedName(nullAtom, starAtom, starAtom, true );
108 } 118 }
109 119
110 const QualifiedName& nullQName() 120 const QualifiedName& QualifiedName::null()
111 { 121 {
112 DEFINE_STATIC_LOCAL(QualifiedName, nullName, (nullAtom, nullAtom, nullAtom)) ; 122 DEFINE_STATIC_LOCAL(QualifiedName, nullName, (nullAtom, nullAtom, nullAtom, true));
113 return nullName; 123 return nullName;
114 } 124 }
115 125
116 const AtomicString& QualifiedName::localNameUpper() const 126 const AtomicString& QualifiedName::localNameUpper() const
117 { 127 {
118 if (!m_impl->m_localNameUpper) 128 if (!m_impl->m_localNameUpper)
119 m_impl->m_localNameUpper = m_impl->m_localName.upper(); 129 m_impl->m_localNameUpper = m_impl->m_localName.upper();
120 return m_impl->m_localNameUpper; 130 return m_impl->m_localNameUpper;
121 } 131 }
122 132
123 unsigned QualifiedName::QualifiedNameImpl::computeHash() const 133 unsigned QualifiedName::QualifiedNameImpl::computeHash() const
124 { 134 {
125 QualifiedNameComponents components = { m_prefix.impl(), m_localName.impl(), m_namespace.impl() }; 135 QualifiedNameComponents components = { m_prefix.impl(), m_localName.impl(), m_namespace.impl() };
126 return hashComponents(components); 136 return hashComponents(components);
127 } 137 }
128 138
129 void createQualifiedName(void* targetAddress, StringImpl* name, const AtomicStri ng& nameNamespace) 139 void QualifiedName::createStatic(void* targetAddress, StringImpl* name, const At omicString& nameNamespace)
130 { 140 {
131 new (targetAddress) QualifiedName(nullAtom, AtomicString(name), nameNamespac e); 141 new (targetAddress) QualifiedName(nullAtom, AtomicString(name), nameNamespac e, true);
132 } 142 }
133 143
134 void createQualifiedName(void* targetAddress, StringImpl* name) 144 void QualifiedName::createStatic(void* targetAddress, StringImpl* name)
135 { 145 {
136 new (targetAddress) QualifiedName(nullAtom, AtomicString(name), nullAtom); 146 new (targetAddress) QualifiedName(nullAtom, AtomicString(name), nullAtom, tr ue);
137 } 147 }
138 148
139 } 149 }
OLDNEW
« no previous file with comments | « Source/core/dom/QualifiedName.h ('k') | Source/core/dom/custom/CustomElementRegistry.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698