Inline Node's rare data getters.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Jul 2014 18:01:06 +0000 (18:01 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Jul 2014 18:01:06 +0000 (18:01 +0000)
<https://webkit.org/b/134652>

There was a fair bit of overhead when calling Node::ensureRareData()
from Document's collection getters. This patch inlines the case where
we've already materialized the rare data.

Reviewed by Antti Koivisto.

* dom/Node.cpp:
(WebCore::Node::materializeRareData):
(WebCore::Node::rareData): Deleted.
(WebCore::Node::ensureRareData): Deleted.
* dom/Node.h:
* dom/NodeRareData.h:
(WebCore::Node::rareData):
(WebCore::Node::ensureRareData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170828 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/NodeRareData.h

index 4b1a25a..f0801b4 100644 (file)
@@ -1,3 +1,23 @@
+2014-07-06  Andreas Kling  <akling@apple.com>
+
+        Inline Node's rare data getters.
+        <https://webkit.org/b/134652>
+
+        There was a fair bit of overhead when calling Node::ensureRareData()
+        from Document's collection getters. This patch inlines the case where
+        we've already materialized the rare data.
+
+        Reviewed by Antti Koivisto.
+
+        * dom/Node.cpp:
+        (WebCore::Node::materializeRareData):
+        (WebCore::Node::rareData): Deleted.
+        (WebCore::Node::ensureRareData): Deleted.
+        * dom/Node.h:
+        * dom/NodeRareData.h:
+        (WebCore::Node::rareData):
+        (WebCore::Node::ensureRareData):
+
 2014-07-05  Dean Jackson  <dino@apple.com>
 
         [iOS] MediaDocument should set a viewport
index 28eaa2c..f177779 100644 (file)
@@ -325,17 +325,8 @@ void Node::willBeDeletedFrom(Document& document)
         cache->remove(this);
 }
 
-NodeRareData* Node::rareData() const
+void Node::materializeRareData()
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(hasRareData());
-    return static_cast<NodeRareData*>(m_data.m_rareData);
-}
-
-NodeRareData& Node::ensureRareData()
-{
-    if (hasRareData())
-        return *rareData();
-
     NodeRareData* data;
     if (isElementNode())
         data = ElementRareData::create(toRenderElement(m_data.m_renderer)).leakPtr();
@@ -345,7 +336,6 @@ NodeRareData& Node::ensureRareData()
 
     m_data.m_rareData = data;
     setFlag(HasRareDataFlag);
-    return *data;
 }
 
 void Node::clearRareData()
index 2603352..195e5b2 100644 (file)
@@ -691,6 +691,7 @@ private:
     Element* ancestorElement() const;
 
     void trackForDebugging();
+    void materializeRareData();
 
     Vector<OwnPtr<MutationObserverRegistration>>* mutationObserverRegistry();
     HashSet<MutationObserverRegistration*>* transientMutationObserverRegistry();
index 6d02231..a35ebe0 100644 (file)
@@ -356,6 +356,19 @@ inline bool NodeListsNodeData::deleteThisAndUpdateNodeRareDataIfAboutToRemoveLas
     return true;
 }
 
+inline NodeRareData* Node::rareData() const
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(hasRareData());
+    return static_cast<NodeRareData*>(m_data.m_rareData);
+}
+
+inline NodeRareData& Node::ensureRareData()
+{
+    if (!hasRareData())
+        materializeRareData();
+    return *rareData();
+}
+
 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow
 COMPILE_ASSERT(Page::maxNumberOfFrames < 1024, Frame_limit_should_fit_in_rare_data_count);