Changeset 132995 in webkit


Ignore:
Timestamp:
Oct 31, 2012, 1:14:00 AM (13 years ago)
Author:
[email protected]
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):

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r132993 r132995  
     12012-10-31  Eric Seidel  <[email protected]>
     2
     3        Add non-virtual firstChild/lastChild overrides to RenderBlock and RenderTableCol for a > 30% speedup on table from bug 100304
     4        https://bugs.webkit.org/show_bug.cgi?id=100306
     5
     6        Reviewed by Abhishek Arya.
     7
     8        Presumably this is a speedup for other rendering tests as well.  We use firstChild() all over
     9        the rendering code w/o considering that it makes a virtual function call.
     10        Originally I just fixed the one callsite which was showing up on the sample to
     11        use children()->firstChild() directly.  However after further thought, this
     12        broader solution seemed the better way to go.  The first patch was a 15% win for
     13        this large table, this broader solution was a 30%!? win.
     14
     15        The elephant in the room for this table is that we're walking the whole table
     16        for many nextColumn calls.  But that I will solve in a later bug.
     17
     18        * rendering/RenderBlock.h:
     19        (WebCore::RenderBlock::firstChild):
     20        (WebCore::RenderBlock::lastChild):
     21        (RenderBlock):
     22        * rendering/RenderObject.h:
     23        (RenderObject):
     24        * rendering/RenderTableCol.h:
     25        (WebCore::RenderTableCol::firstChild):
     26        (WebCore::RenderTableCol::lastChild):
     27        (RenderTableCol):
     28
    1292012-10-31  Philippe Normand  <[email protected]>
    230
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r132112 r132995  
    8787    virtual ~RenderBlock();
    8888
     89    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
     90    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
     91
    8992    const RenderObjectChildList* children() const { return &m_children; }
    9093    RenderObjectChildList* children() { return &m_children; }
  • trunk/Source/WebCore/rendering/RenderFrameSet.h

    r126859 r132995  
    5858    RenderFrameSet(HTMLFrameSetElement*);
    5959    virtual ~RenderFrameSet();
     60
     61    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
     62    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
    6063
    6164    const RenderObjectChildList* children() const { return &m_children; }
  • trunk/Source/WebCore/rendering/RenderInline.h

    r132112 r132995  
    3535public:
    3636    explicit RenderInline(Node*);
     37
     38    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
     39    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
    3740
    3841    virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
  • trunk/Source/WebCore/rendering/RenderMedia.h

    r115749 r132995  
    4141    virtual ~RenderMedia();
    4242
     43    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
     44    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
     45
    4346    const RenderObjectChildList* children() const { return &m_children; }
    4447    RenderObjectChildList* children() { return &m_children; }
  • trunk/Source/WebCore/rendering/RenderObject.h

    r132503 r132995  
    179179    RenderObject* nextSibling() const { return m_next; }
    180180
     181    // FIXME: These should be renamed slowFirstChild, slowLastChild, etc.
     182    // to discourage their use. The virtualChildren() call inside these
     183    // can be slow for hot code paths.
     184    // Currently, some subclasses like RenderBlock, override these NON-virtual
     185    // functions to make these fast when we already have a more specific pointer type.
    181186    RenderObject* firstChild() const
    182187    {
  • trunk/Source/WebCore/rendering/RenderTableCol.h

    r132764 r132995  
    3737public:
    3838    explicit RenderTableCol(Node*);
     39
     40    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
     41    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
    3942
    4043    const RenderObjectChildList* children() const { return &m_children; }
  • trunk/Source/WebCore/rendering/RenderTableRow.h

    r131050 r132995  
    3636public:
    3737    explicit RenderTableRow(Node*);
     38
     39    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
     40    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
    3841
    3942    const RenderObjectChildList* children() const { return &m_children; }
  • trunk/Source/WebCore/rendering/RenderTableSection.h

    r132112 r132995  
    6666    virtual ~RenderTableSection();
    6767
     68    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
     69    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
     70
    6871    const RenderObjectChildList* children() const { return &m_children; }
    6972    RenderObjectChildList* children() { return &m_children; }
  • trunk/Source/WebCore/rendering/svg/RenderSVGContainer.h

    r118608 r132995  
    3636    explicit RenderSVGContainer(SVGStyledElement*);
    3737    virtual ~RenderSVGContainer();
     38
     39    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
     40    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
    3841
    3942    const RenderObjectChildList* children() const { return &m_children; }
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h

    r131231 r132995  
    4444
    4545    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
     46
     47    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
     48    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
     49
    4650    const RenderObjectChildList* children() const { return &m_children; }
    4751    RenderObjectChildList* children() { return &m_children; }
Note: See TracChangeset for help on using the changeset viewer.