Title: [149110] trunk/Source/WebCore
Revision
149110
Author
[email protected]
Date
2013-04-25 07:33:54 -0700 (Thu, 25 Apr 2013)

Log Message

Add FINAL decorators to the InlineBox class hierarchy.
<http://webkit.org/b/115177>

Reviewed by Antti Koivisto.

>From Blink r148628 by <[email protected]>:

FINAL is a macro in wtf/Compiler.h that does the correct thing if the compiler does not support "final")
The approach used is as simple as possible whilst being thorough.
So, leaf classes have FINAL applied to the whole class whereas intermediary classes have FINAL applied to relevant methods.

FINAL allows a compiler to devirtualize call sites and turn them into direct calls. As you might expect, this is perf positive:
(clang on Linux):
- line_layout.html goes from 120 runs/s -> 123 runs/2, +2.5%
- html5-full-render.html goes from 3176ms -> 3162ms, +0.4%

I have confidence that the former result is statistically significant (as the numbers are very very stable) but not the latter.

* rendering/EllipsisBox.h:
* rendering/InlineFlowBox.h:
* rendering/InlineTextBox.h:
* rendering/RootInlineBox.h:
* rendering/TrailingFloatsRootInlineBox.h:
* rendering/svg/SVGInlineFlowBox.h:
* rendering/svg/SVGInlineTextBox.h:
* rendering/svg/SVGRootInlineBox.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (149109 => 149110)


--- trunk/Source/WebCore/ChangeLog	2013-04-25 14:19:40 UTC (rev 149109)
+++ trunk/Source/WebCore/ChangeLog	2013-04-25 14:33:54 UTC (rev 149110)
@@ -1,5 +1,34 @@
 2013-04-25  Andreas Kling  <[email protected]>
 
+        Add FINAL decorators to the InlineBox class hierarchy.
+        <http://webkit.org/b/115177>
+
+        Reviewed by Antti Koivisto.
+
+        From Blink r148628 by <[email protected]>:
+
+        FINAL is a macro in wtf/Compiler.h that does the correct thing if the compiler does not support "final")
+        The approach used is as simple as possible whilst being thorough.
+        So, leaf classes have FINAL applied to the whole class whereas intermediary classes have FINAL applied to relevant methods.
+
+        FINAL allows a compiler to devirtualize call sites and turn them into direct calls. As you might expect, this is perf positive:
+        (clang on Linux):
+        - line_layout.html goes from 120 runs/s -> 123 runs/2, +2.5%
+        - html5-full-render.html goes from 3176ms -> 3162ms, +0.4%
+
+        I have confidence that the former result is statistically significant (as the numbers are very very stable) but not the latter.
+
+        * rendering/EllipsisBox.h:
+        * rendering/InlineFlowBox.h:
+        * rendering/InlineTextBox.h:
+        * rendering/RootInlineBox.h:
+        * rendering/TrailingFloatsRootInlineBox.h:
+        * rendering/svg/SVGInlineFlowBox.h:
+        * rendering/svg/SVGInlineTextBox.h:
+        * rendering/svg/SVGRootInlineBox.h:
+
+2013-04-25  Andreas Kling  <[email protected]>
+
         CSS parser: Add error recovery while parsing @-webkit-keyframes key values.
         <http://webkit.org/b/115175>
 

Modified: trunk/Source/WebCore/rendering/EllipsisBox.h (149109 => 149110)


--- trunk/Source/WebCore/rendering/EllipsisBox.h	2013-04-25 14:19:40 UTC (rev 149109)
+++ trunk/Source/WebCore/rendering/EllipsisBox.h	2013-04-25 14:33:54 UTC (rev 149110)
@@ -27,7 +27,7 @@
 class HitTestRequest;
 class HitTestResult;
 
-class EllipsisBox : public InlineBox {
+class EllipsisBox FINAL : public InlineBox {
 public:
     EllipsisBox(RenderObject* obj, const AtomicString& ellipsisStr, InlineFlowBox* parent,
                 int width, int height, int y, bool firstLine, bool isVertical, InlineBox* markupBox)

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.h (149109 => 149110)


--- trunk/Source/WebCore/rendering/InlineFlowBox.h	2013-04-25 14:19:40 UTC (rev 149109)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.h	2013-04-25 14:33:54 UTC (rev 149110)
@@ -80,7 +80,7 @@
     InlineBox* firstChild() const { checkConsistency(); return m_firstChild; }
     InlineBox* lastChild() const { checkConsistency(); return m_lastChild; }
 
-    virtual bool isLeaf() const { return false; }
+    virtual bool isLeaf() const FINAL { return false; }
     
     InlineBox* firstLeafChild() const;
     InlineBox* lastLeafChild() const;
@@ -88,7 +88,7 @@
     typedef void (*CustomInlineBoxRangeReverse)(void* userData, Vector<InlineBox*>::iterator first, Vector<InlineBox*>::iterator last);
     void collectLeafBoxesInLogicalOrder(Vector<InlineBox*>&, CustomInlineBoxRangeReverse customReverseImplementation = 0, void* userData = 0) const;
 
-    virtual void setConstructed()
+    virtual void setConstructed() FINAL
     {
         InlineBox::setConstructed();
         for (InlineBox* child = firstChild(); child; child = child->nextOnLine())
@@ -96,9 +96,9 @@
     }
 
     void addToLine(InlineBox* child);
-    virtual void deleteLine(RenderArena*);
-    virtual void extractLine();
-    virtual void attachLine();
+    virtual void deleteLine(RenderArena*) FINAL;
+    virtual void extractLine() FINAL;
+    virtual void attachLine() FINAL;
     virtual void adjustPosition(float dx, float dy);
 
     virtual void extractLineBoxFromRenderObject();
@@ -109,8 +109,8 @@
 
     IntRect roundedFrameRect() const;
     
-    virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
-    virtual void paintMask(PaintInfo&, const LayoutPoint&);
+    virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&) FINAL;
+    virtual void paintMask(PaintInfo&, const LayoutPoint&) FINAL;
     void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, CompositeOperator = CompositeSourceOver);
     void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, CompositeOperator = CompositeSourceOver);
     void paintBoxShadow(const PaintInfo&, RenderStyle*, ShadowStyle, const LayoutRect&);
@@ -201,7 +201,7 @@
 
     virtual RenderObject::SelectionState selectionState();
 
-    virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) const OVERRIDE;
+    virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) const OVERRIDE FINAL;
     virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool&) OVERRIDE;
 
     bool hasTextChildren() const { return m_hasTextChildren; }
@@ -309,7 +309,7 @@
 protected:
     OwnPtr<RenderOverflow> m_overflow;
 
-    virtual bool isInlineFlowBox() const { return true; }
+    virtual bool isInlineFlowBox() const FINAL { return true; }
 
     InlineBox* m_firstChild;
     InlineBox* m_lastChild;

Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (149109 => 149110)


--- trunk/Source/WebCore/rendering/InlineTextBox.h	2013-04-25 14:19:40 UTC (rev 149109)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h	2013-04-25 14:33:54 UTC (rev 149110)
@@ -57,7 +57,7 @@
     {
     }
 
-    virtual void destroy(RenderArena*);
+    virtual void destroy(RenderArena*) FINAL;
 
     InlineTextBox* prevTextBox() const { return m_prevTextBox; }
     InlineTextBox* nextTextBox() const { return m_nextTextBox; }
@@ -76,7 +76,7 @@
 
     unsigned short truncation() { return m_truncation; }
 
-    virtual void markDirty(bool dirty = true) OVERRIDE;
+    virtual void markDirty(bool dirty = true) OVERRIDE FINAL;
 
     using InlineBox::hasHyphen;
     using InlineBox::setHasHyphen;
@@ -85,8 +85,8 @@
 
     static inline bool compareByStart(const InlineTextBox* first, const InlineTextBox* second) { return first->start() < second->start(); }
 
-    virtual int baselinePosition(FontBaseline) const;
-    virtual LayoutUnit lineHeight() const;
+    virtual int baselinePosition(FontBaseline) const FINAL;
+    virtual LayoutUnit lineHeight() const FINAL;
 
     bool getEmphasisMarkPosition(RenderStyle*, TextEmphasisPosition&) const;
 
@@ -125,19 +125,19 @@
     RenderText* textRenderer() const;
 
 private:
-    virtual void deleteLine(RenderArena*);
-    virtual void extractLine();
-    virtual void attachLine();
+    virtual void deleteLine(RenderArena*) FINAL;
+    virtual void extractLine() FINAL;
+    virtual void attachLine() FINAL;
 
 public:
-    virtual RenderObject::SelectionState selectionState();
+    virtual RenderObject::SelectionState selectionState() FINAL;
 
 private:
-    virtual void clearTruncation() { m_truncation = cNoTruncation; }
-    virtual float placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) OVERRIDE;
+    virtual void clearTruncation() FINAL { m_truncation = cNoTruncation; }
+    virtual float placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) OVERRIDE FINAL;
 
 public:
-    virtual bool isLineBreak() const;
+    virtual bool isLineBreak() const FINAL;
 
     void setExpansion(int newExpansion)
     {
@@ -147,11 +147,11 @@
     }
 
 private:
-    virtual bool isInlineTextBox() const { return true; }    
+    virtual bool isInlineTextBox() const FINAL { return true; }
 
 public:
-    virtual int caretMinOffset() const;
-    virtual int caretMaxOffset() const;
+    virtual int caretMinOffset() const FINAL;
+    virtual int caretMaxOffset() const FINAL;
 
 private:
     float textPos() const; // returns the x position relative to the left start of the text line.

Modified: trunk/Source/WebCore/rendering/RootInlineBox.h (149109 => 149110)


--- trunk/Source/WebCore/rendering/RootInlineBox.h	2013-04-25 14:19:40 UTC (rev 149109)
+++ trunk/Source/WebCore/rendering/RootInlineBox.h	2013-04-25 14:33:54 UTC (rev 149110)
@@ -38,16 +38,16 @@
 public:
     explicit RootInlineBox(RenderBlock*);
 
-    virtual void destroy(RenderArena*);
+    virtual void destroy(RenderArena*) FINAL;
 
-    virtual bool isRootInlineBox() const { return true; }
+    virtual bool isRootInlineBox() const FINAL { return true; }
 
     void detachEllipsisBox(RenderArena*);
 
     RootInlineBox* nextRootBox() const { return static_cast<RootInlineBox*>(m_nextLineBox); }
     RootInlineBox* prevRootBox() const { return static_cast<RootInlineBox*>(m_prevLineBox); }
 
-    virtual void adjustPosition(float dx, float dy);
+    virtual void adjustPosition(float dx, float dy) FINAL;
 
     LayoutUnit lineTop() const { return m_lineTop; }
     LayoutUnit lineBottom() const { return m_lineBottom; }
@@ -85,7 +85,7 @@
         m_lineBottomWithLeading = bottomWithLeading;
     }
 
-    virtual RenderLineBoxList* rendererLineBoxes() const;
+    virtual RenderLineBoxList* rendererLineBoxes() const FINAL;
 
     RenderObject* lineBreakObj() const { return m_lineBreakObj; }
     BidiStatus lineBreakBidiStatus() const;
@@ -103,19 +103,19 @@
     // Return the truncatedWidth, the width of the truncated text + ellipsis.
     float placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, InlineBox* markupBox = 0);
     // Return the position of the EllipsisBox or -1.
-    virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) OVERRIDE;
+    virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) OVERRIDE FINAL;
 
     using InlineBox::hasEllipsisBox;
     EllipsisBox* ellipsisBox() const;
 
     void paintEllipsisBox(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) const;
 
-    virtual void clearTruncation() OVERRIDE;
+    virtual void clearTruncation() OVERRIDE FINAL;
 
     bool isHyphenated() const;
 
-    virtual int baselinePosition(FontBaseline baselineType) const;
-    virtual LayoutUnit lineHeight() const;
+    virtual int baselinePosition(FontBaseline baselineType) const FINAL;
+    virtual LayoutUnit lineHeight() const FINAL;
 
 #if PLATFORM(MAC)
     void addHighlightOverflow();
@@ -123,12 +123,12 @@
 #endif
 
     virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom);
-    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) OVERRIDE;
+    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) OVERRIDE FINAL;
 
     using InlineBox::hasSelectedChildren;
     using InlineBox::setHasSelectedChildren;
 
-    virtual RenderObject::SelectionState selectionState();
+    virtual RenderObject::SelectionState selectionState() FINAL;
     InlineBox* firstSelectedBox();
     InlineBox* lastSelectedBox();
 
@@ -151,9 +151,9 @@
 
     Vector<RenderBox*>* floatsPtr() { ASSERT(!isDirty()); return m_floats.get(); }
 
-    virtual void extractLineBoxFromRenderObject();
-    virtual void attachLineBoxToRenderObject();
-    virtual void removeLineBoxFromRenderObject();
+    virtual void extractLineBoxFromRenderObject() FINAL;
+    virtual void attachLineBoxToRenderObject() FINAL;
+    virtual void removeLineBoxFromRenderObject() FINAL;
     
     FontBaseline baselineType() const { return static_cast<FontBaseline>(m_baselineType); }
 

Modified: trunk/Source/WebCore/rendering/TrailingFloatsRootInlineBox.h (149109 => 149110)


--- trunk/Source/WebCore/rendering/TrailingFloatsRootInlineBox.h	2013-04-25 14:19:40 UTC (rev 149109)
+++ trunk/Source/WebCore/rendering/TrailingFloatsRootInlineBox.h	2013-04-25 14:33:54 UTC (rev 149110)
@@ -30,7 +30,7 @@
 
 namespace WebCore {
 
-class TrailingFloatsRootInlineBox : public RootInlineBox {
+class TrailingFloatsRootInlineBox FINAL : public RootInlineBox {
 public:
     TrailingFloatsRootInlineBox(RenderBlock* block)
         : RootInlineBox(block)

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.h (149109 => 149110)


--- trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.h	2013-04-25 14:19:40 UTC (rev 149109)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.h	2013-04-25 14:33:54 UTC (rev 149110)
@@ -28,7 +28,7 @@
 
 class RenderSVGInlineText;
 
-class SVGInlineFlowBox : public InlineFlowBox {
+class SVGInlineFlowBox FINAL : public InlineFlowBox {
 public:
     SVGInlineFlowBox(RenderObject* obj)
         : InlineFlowBox(obj)

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h (149109 => 149110)


--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h	2013-04-25 14:19:40 UTC (rev 149109)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h	2013-04-25 14:33:54 UTC (rev 149110)
@@ -31,7 +31,7 @@
 class RenderSVGResource;
 class SVGRootInlineBox;
 
-class SVGInlineTextBox : public InlineTextBox {
+class SVGInlineTextBox FINAL : public InlineTextBox {
 public:
     SVGInlineTextBox(RenderObject*);
 
@@ -57,7 +57,7 @@
     Vector<SVGTextFragment>& textFragments() { return m_textFragments; }
     const Vector<SVGTextFragment>& textFragments() const { return m_textFragments; }
 
-    void dirtyLineBoxes() OVERRIDE;
+    virtual void dirtyLineBoxes() OVERRIDE;
 
     bool startsNewTextChunk() const { return m_startsNewTextChunk; }
     void setStartsNewTextChunk(bool newTextChunk) { m_startsNewTextChunk = newTextChunk; }

Modified: trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h (149109 => 149110)


--- trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h	2013-04-25 14:19:40 UTC (rev 149109)
+++ trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h	2013-04-25 14:33:54 UTC (rev 149110)
@@ -32,7 +32,7 @@
 
 class SVGInlineTextBox;
 
-class SVGRootInlineBox : public RootInlineBox {
+class SVGRootInlineBox FINAL : public RootInlineBox {
 public:
     SVGRootInlineBox(RenderBlock* block)
         : RootInlineBox(block)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to