Title: [143983] trunk/Source/WebCore
Revision
143983
Author
aba...@webkit.org
Date
2013-02-25 16:12:53 -0800 (Mon, 25 Feb 2013)

Log Message

6% regression in intl1 page cycler on chromium-mac
https://bugs.webkit.org/show_bug.cgi?id=110784

Reviewed by Eric Seidel.

This patch reverts http://trac.webkit.org/changeset/143014 to see if
that's the cause of the PLT regression. If it's not the cause, I'll
roll it back in.

* dom/Element.cpp:
(WebCore::Element::addAttributeInternal):
(WebCore::ShareableElementData::ShareableElementData):
(WebCore::UniqueElementData::makeShareableCopy):
(WebCore::ElementData::addAttribute):
(WebCore::ElementData::removeAttribute):
(WebCore::ElementData::reportMemoryUsage):
* dom/Element.h:
(ElementData):
(UniqueElementData):
(WebCore::ElementData::mutableAttributeVector):
(WebCore):
(WebCore::ElementData::immutableAttributeArray):
(WebCore::ElementData::length):
(WebCore::ElementData::getAttributeItem):
(WebCore::ElementData::attributeItem):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143982 => 143983)


--- trunk/Source/WebCore/ChangeLog	2013-02-25 23:48:24 UTC (rev 143982)
+++ trunk/Source/WebCore/ChangeLog	2013-02-26 00:12:53 UTC (rev 143983)
@@ -1,3 +1,31 @@
+2013-02-25  Adam Barth  <aba...@webkit.org>
+
+        6% regression in intl1 page cycler on chromium-mac
+        https://bugs.webkit.org/show_bug.cgi?id=110784
+
+        Reviewed by Eric Seidel.
+
+        This patch reverts http://trac.webkit.org/changeset/143014 to see if
+        that's the cause of the PLT regression. If it's not the cause, I'll
+        roll it back in.
+
+        * dom/Element.cpp:
+        (WebCore::Element::addAttributeInternal):
+        (WebCore::ShareableElementData::ShareableElementData):
+        (WebCore::UniqueElementData::makeShareableCopy):
+        (WebCore::ElementData::addAttribute):
+        (WebCore::ElementData::removeAttribute):
+        (WebCore::ElementData::reportMemoryUsage):
+        * dom/Element.h:
+        (ElementData):
+        (UniqueElementData):
+        (WebCore::ElementData::mutableAttributeVector):
+        (WebCore):
+        (WebCore::ElementData::immutableAttributeArray):
+        (WebCore::ElementData::length):
+        (WebCore::ElementData::getAttributeItem):
+        (WebCore::ElementData::attributeItem):
+
 2013-02-25  Tim Horton  <timothy_hor...@apple.com>
 
         Page::m_isInWindow is uninitialized

Modified: trunk/Source/WebCore/dom/Element.cpp (143982 => 143983)


--- trunk/Source/WebCore/dom/Element.cpp	2013-02-25 23:48:24 UTC (rev 143982)
+++ trunk/Source/WebCore/dom/Element.cpp	2013-02-26 00:12:53 UTC (rev 143983)
@@ -1820,7 +1820,7 @@
 {
     if (!inSynchronizationOfLazyAttribute)
         willModifyAttribute(name, nullAtom, value);
-    ensureUniqueElementData()->addAttribute(name, value);
+    ensureUniqueElementData()->addAttribute(Attribute(name, value));
     if (!inSynchronizationOfLazyAttribute)
         didAddAttribute(name, value);
 }
@@ -2969,7 +2969,7 @@
     }
 
     for (unsigned i = 0; i < m_arraySize; ++i)
-        new (&m_attributeArray[i]) Attribute(other.m_attributeVector.at(i));
+        new (&reinterpret_cast<Attribute*>(&m_attributeArray)[i]) Attribute(*other.attributeItem(i));
 }
 
 ElementData::ElementData(const ElementData& other, bool isUnique)
@@ -3019,19 +3019,21 @@
 
 PassRefPtr<ShareableElementData> UniqueElementData::makeShareableCopy() const
 {
-    void* slot = WTF::fastMalloc(sizeForShareableElementDataWithAttributeCount(m_attributeVector.size()));
+    void* slot = WTF::fastMalloc(sizeForShareableElementDataWithAttributeCount(mutableAttributeVector().size()));
     return adoptRef(new (slot) ShareableElementData(*this));
 }
 
-void UniqueElementData::addAttribute(const QualifiedName& attributeName, const AtomicString& value)
+void ElementData::addAttribute(const Attribute& attribute)
 {
-    m_attributeVector.append(Attribute(attributeName, value));
+    ASSERT(isUnique());
+    mutableAttributeVector().append(attribute);
 }
 
-void UniqueElementData::removeAttribute(size_t index)
+void ElementData::removeAttribute(size_t index)
 {
+    ASSERT(isUnique());
     ASSERT_WITH_SECURITY_IMPLICATION(index < length());
-    m_attributeVector.remove(index);
+    mutableAttributeVector().remove(index);
 }
 
 bool ElementData::isEquivalent(const ElementData* other) const
@@ -3061,9 +3063,8 @@
     info.addMember(m_classNames, "classNames");
     info.addMember(m_idForStyleResolution, "idForStyleResolution");
     if (m_isUnique) {
-        const UniqueElementData* uniqueThis = static_cast<const UniqueElementData*>(this);
-        info.addMember(uniqueThis->m_presentationAttributeStyle, "presentationAttributeStyle");
-        info.addMember(uniqueThis->m_attributeVector, "attributeVector");
+        info.addMember(presentationAttributeStyle(), "presentationAttributeStyle()");
+        info.addMember(mutableAttributeVector(), "mutableAttributeVector");
     }
     for (unsigned i = 0, len = length(); i < len; i++)
         info.addMember(*attributeItem(i), "*attributeItem");
@@ -3088,19 +3089,4 @@
     return notFound;
 }
 
-Attribute* UniqueElementData::getAttributeItem(const QualifiedName& name)
-{
-    for (unsigned i = 0; i < length(); ++i) {
-        if (m_attributeVector.at(i).name().matches(name))
-            return &m_attributeVector.at(i);
-    }
-    return 0;
-}
-
-Attribute* UniqueElementData::attributeItem(unsigned index)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(index < length());
-    return &m_attributeVector.at(index);
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/Element.h (143982 => 143983)


--- trunk/Source/WebCore/dom/Element.h	2013-02-25 23:48:24 UTC (rev 143982)
+++ trunk/Source/WebCore/dom/Element.h	2013-02-26 00:12:53 UTC (rev 143983)
@@ -75,9 +75,15 @@
 
     const Attribute* attributeItem(unsigned index) const;
     const Attribute* getAttributeItem(const QualifiedName&) const;
+    Attribute* attributeItem(unsigned index);
+    Attribute* getAttributeItem(const QualifiedName&);
     size_t getAttributeItemIndex(const QualifiedName&) const;
     size_t getAttributeItemIndex(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
 
+    // These functions do no error checking.
+    void addAttribute(const Attribute&);
+    void removeAttribute(size_t index);
+
     bool hasID() const { return !m_idForStyleResolution.isNull(); }
     bool hasClass() const { return !m_classNames.isNull(); }
 
@@ -86,6 +92,7 @@
     void reportMemoryUsage(MemoryObjectInfo*) const;
 
     bool isUnique() const { return m_isUnique; }
+    const Attribute* immutableAttributeArray() const;
 
 protected:
     ElementData();
@@ -113,10 +120,14 @@
     friend class SVGElement;
 #endif
 
+    Attribute* getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase);
     const Attribute* getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
     size_t getAttributeItemIndexSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
 
     PassRefPtr<UniqueElementData> makeUniqueCopy() const;
+
+    Vector<Attribute, 4>& mutableAttributeVector();
+    const Vector<Attribute, 4>& mutableAttributeVector() const;
 };
 
 #if COMPILER(MSVC)
@@ -144,13 +155,6 @@
     static PassRefPtr<UniqueElementData> create();
     PassRefPtr<ShareableElementData> makeShareableCopy() const;
 
-    // These functions do no error/duplicate checking.
-    void addAttribute(const QualifiedName&, const AtomicString&);
-    void removeAttribute(size_t index);
-
-    Attribute* attributeItem(unsigned index);
-    Attribute* getAttributeItem(const QualifiedName&);
-
     UniqueElementData();
     explicit UniqueElementData(const ShareableElementData&);
     explicit UniqueElementData(const UniqueElementData&);
@@ -898,11 +902,28 @@
 {
     return node && node->isElementNode() && toElement(node)->shadow();
 }
+inline Vector<Attribute, 4>& ElementData::mutableAttributeVector()
+{
+    ASSERT(m_isUnique);
+    return static_cast<UniqueElementData*>(this)->m_attributeVector;
+}
 
+inline const Vector<Attribute, 4>& ElementData::mutableAttributeVector() const
+{
+    ASSERT(m_isUnique);
+    return static_cast<const UniqueElementData*>(this)->m_attributeVector;
+}
+
+inline const Attribute* ElementData::immutableAttributeArray() const
+{
+    ASSERT(!m_isUnique);
+    return reinterpret_cast<const Attribute*>(&static_cast<const ShareableElementData*>(this)->m_attributeArray);
+}
+
 inline size_t ElementData::length() const
 {
     if (isUnique())
-        return static_cast<const UniqueElementData*>(this)->m_attributeVector.size();
+        return mutableAttributeVector().size();
     return m_arraySize;
 }
 
@@ -913,6 +934,14 @@
     return static_cast<const UniqueElementData*>(this)->m_presentationAttributeStyle.get();
 }
 
+inline Attribute* ElementData::getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase)
+{
+    size_t index = getAttributeItemIndex(name, shouldIgnoreAttributeCase);
+    if (index != notFound)
+        return attributeItem(index);
+    return 0;
+}
+
 inline const Attribute* ElementData::getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase) const
 {
     size_t index = getAttributeItemIndex(name, shouldIgnoreAttributeCase);
@@ -961,14 +990,29 @@
     return 0;
 }
 
+inline Attribute* ElementData::getAttributeItem(const QualifiedName& name)
+{
+    for (unsigned i = 0; i < length(); ++i) {
+        if (attributeItem(i)->name().matches(name))
+            return attributeItem(i);
+    }
+    return 0;
+}
+
 inline const Attribute* ElementData::attributeItem(unsigned index) const
 {
     ASSERT_WITH_SECURITY_IMPLICATION(index < length());
     if (m_isUnique)
-        return &static_cast<const UniqueElementData*>(this)->m_attributeVector.at(index);
-    return &static_cast<const ShareableElementData*>(this)->m_attributeArray[index];
+        return &mutableAttributeVector().at(index);
+    return &immutableAttributeArray()[index];
 }
 
+inline Attribute* ElementData::attributeItem(unsigned index)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(index < length());
+    return &mutableAttributeVector().at(index);
+}
+
 } // namespace
 
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to