Title: [132995] trunk/Source/WebCore
Revision
132995
Author
[email protected]
Date
2012-10-31 01:14:00 -0700 (Wed, 31 Oct 2012)

Log Message

Add non-virtual firstChild/lastChild overrides to RenderBlock and RenderTableCol for a > 30% speedup on table from bug 100304
https://bugs.webkit.org/show_bug.cgi?id=100306

Reviewed by Abhishek Arya.

Presumably this is a speedup for other rendering tests as well.  We use firstChild() all over
the rendering code w/o considering that it makes a virtual function call.
Originally I just fixed the one callsite which was showing up on the sample to
use children()->firstChild() directly.  However after further thought, this
broader solution seemed the better way to go.  The first patch was a 15% win for
this large table, this broader solution was a 30%!? win.

The elephant in the room for this table is that we're walking the whole table
for many nextColumn calls.  But that I will solve in a later bug.

* rendering/RenderBlock.h:
(WebCore::RenderBlock::firstChild):
(WebCore::RenderBlock::lastChild):
(RenderBlock):
* rendering/RenderObject.h:
(RenderObject):
* rendering/RenderTableCol.h:
(WebCore::RenderTableCol::firstChild):
(WebCore::RenderTableCol::lastChild):
(RenderTableCol):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132994 => 132995)


--- trunk/Source/WebCore/ChangeLog	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/ChangeLog	2012-10-31 08:14:00 UTC (rev 132995)
@@ -1,3 +1,31 @@
+2012-10-31  Eric Seidel  <[email protected]>
+
+        Add non-virtual firstChild/lastChild overrides to RenderBlock and RenderTableCol for a > 30% speedup on table from bug 100304
+        https://bugs.webkit.org/show_bug.cgi?id=100306
+
+        Reviewed by Abhishek Arya.
+
+        Presumably this is a speedup for other rendering tests as well.  We use firstChild() all over
+        the rendering code w/o considering that it makes a virtual function call.
+        Originally I just fixed the one callsite which was showing up on the sample to
+        use children()->firstChild() directly.  However after further thought, this
+        broader solution seemed the better way to go.  The first patch was a 15% win for
+        this large table, this broader solution was a 30%!? win.
+
+        The elephant in the room for this table is that we're walking the whole table
+        for many nextColumn calls.  But that I will solve in a later bug.
+
+        * rendering/RenderBlock.h:
+        (WebCore::RenderBlock::firstChild):
+        (WebCore::RenderBlock::lastChild):
+        (RenderBlock):
+        * rendering/RenderObject.h:
+        (RenderObject):
+        * rendering/RenderTableCol.h:
+        (WebCore::RenderTableCol::firstChild):
+        (WebCore::RenderTableCol::lastChild):
+        (RenderTableCol):
+
 2012-10-31  Philippe Normand  <[email protected]>
 
         Spatialized panning renders incorrectly with USE_CONCATENATED_IMPULSE_RESPONSES

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (132994 => 132995)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2012-10-31 08:14:00 UTC (rev 132995)
@@ -86,6 +86,9 @@
     RenderBlock(Node*);
     virtual ~RenderBlock();
 
+    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
+    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
+
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 

Modified: trunk/Source/WebCore/rendering/RenderFrameSet.h (132994 => 132995)


--- trunk/Source/WebCore/rendering/RenderFrameSet.h	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/rendering/RenderFrameSet.h	2012-10-31 08:14:00 UTC (rev 132995)
@@ -58,6 +58,9 @@
     RenderFrameSet(HTMLFrameSetElement*);
     virtual ~RenderFrameSet();
 
+    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
+    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
+
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 

Modified: trunk/Source/WebCore/rendering/RenderInline.h (132994 => 132995)


--- trunk/Source/WebCore/rendering/RenderInline.h	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/rendering/RenderInline.h	2012-10-31 08:14:00 UTC (rev 132995)
@@ -35,6 +35,9 @@
 public:
     explicit RenderInline(Node*);
 
+    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
+    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
+
     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
 
     virtual LayoutUnit marginLeft() const;

Modified: trunk/Source/WebCore/rendering/RenderMedia.h (132994 => 132995)


--- trunk/Source/WebCore/rendering/RenderMedia.h	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/rendering/RenderMedia.h	2012-10-31 08:14:00 UTC (rev 132995)
@@ -40,6 +40,9 @@
     RenderMedia(HTMLMediaElement*, const IntSize& intrinsicSize);
     virtual ~RenderMedia();
 
+    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
+    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
+
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 

Modified: trunk/Source/WebCore/rendering/RenderObject.h (132994 => 132995)


--- trunk/Source/WebCore/rendering/RenderObject.h	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/rendering/RenderObject.h	2012-10-31 08:14:00 UTC (rev 132995)
@@ -178,6 +178,11 @@
     RenderObject* previousSibling() const { return m_previous; }
     RenderObject* nextSibling() const { return m_next; }
 
+    // FIXME: These should be renamed slowFirstChild, slowLastChild, etc.
+    // to discourage their use. The virtualChildren() call inside these
+    // can be slow for hot code paths.
+    // Currently, some subclasses like RenderBlock, override these NON-virtual
+    // functions to make these fast when we already have a more specific pointer type.
     RenderObject* firstChild() const
     {
         if (const RenderObjectChildList* children = virtualChildren())

Modified: trunk/Source/WebCore/rendering/RenderTableCol.h (132994 => 132995)


--- trunk/Source/WebCore/rendering/RenderTableCol.h	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/rendering/RenderTableCol.h	2012-10-31 08:14:00 UTC (rev 132995)
@@ -37,6 +37,9 @@
 public:
     explicit RenderTableCol(Node*);
 
+    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
+    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
+
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 

Modified: trunk/Source/WebCore/rendering/RenderTableRow.h (132994 => 132995)


--- trunk/Source/WebCore/rendering/RenderTableRow.h	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/rendering/RenderTableRow.h	2012-10-31 08:14:00 UTC (rev 132995)
@@ -36,6 +36,9 @@
 public:
     explicit RenderTableRow(Node*);
 
+    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
+    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
+
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 

Modified: trunk/Source/WebCore/rendering/RenderTableSection.h (132994 => 132995)


--- trunk/Source/WebCore/rendering/RenderTableSection.h	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/rendering/RenderTableSection.h	2012-10-31 08:14:00 UTC (rev 132995)
@@ -65,6 +65,9 @@
     RenderTableSection(Node*);
     virtual ~RenderTableSection();
 
+    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
+    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
+
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGContainer.h (132994 => 132995)


--- trunk/Source/WebCore/rendering/svg/RenderSVGContainer.h	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGContainer.h	2012-10-31 08:14:00 UTC (rev 132995)
@@ -36,6 +36,9 @@
     explicit RenderSVGContainer(SVGStyledElement*);
     virtual ~RenderSVGContainer();
 
+    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
+    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
+
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h (132994 => 132995)


--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h	2012-10-31 08:07:57 UTC (rev 132994)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h	2012-10-31 08:14:00 UTC (rev 132995)
@@ -43,6 +43,10 @@
     bool isEmbeddedThroughFrameContainingSVGDocument() const;
 
     virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
+
+    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
+    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
+
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to