Skip to content

Commit

Permalink
Add DISABLE_CFI_PERF attribute on the methods with CFI checks disabled.
Browse files Browse the repository at this point in the history
Types converted in this CL:
LayoutBlock, LayoutBlockFlow, InlineFlowBox, InlineBox.

While we have not observed CFI to slowdown real-world use cases,
there are a few blink_perf microbenchmarks, which are somewhat affected
by the change. This change removes CFI protection from the methods
which contribute the most to the slowdown.

Eventually, when proposed optimizations in Clang are implemented
(https://crbug.com/638056, https://crbug.com/638064), these attributes
would be possible to remove from all/most of the methods.

This CL does not in fact change the list of disabled methods, it
just converts them from CFI blacklist entries into attributes.
This should increase visibility, and also serve as a guard against refactoring.

BUG=641536

Review-Url: https://codereview.chromium.org/2304563003
Cr-Commit-Position: refs/heads/master@{#416727}
  • Loading branch information
krasin authored and Commit bot committed Sep 6, 2016
1 parent a408ef7 commit 5e2204a
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 25 deletions.
5 changes: 5 additions & 0 deletions third_party/WebKit/Source/core/layout/LayoutBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ bool LayoutBlock::widthAvailableToChildrenHasChanged()
return widthAvailableToChildrenHasChanged;
}

DISABLE_CFI_PERF
bool LayoutBlock::updateLogicalWidthAndColumnWidth()
{
LayoutUnit oldWidth = logicalWidth();
Expand All @@ -427,6 +428,7 @@ void LayoutBlock::addOverflowFromChildren()
addOverflowFromBlockChildren();
}

DISABLE_CFI_PERF
void LayoutBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool)
{
m_overflow.reset();
Expand Down Expand Up @@ -492,6 +494,7 @@ void LayoutBlock::addVisualOverflowFromTheme()
addSelfVisualOverflow(LayoutRect(inflatedRect));
}

DISABLE_CFI_PERF
bool LayoutBlock::createsNewFormattingContext() const
{
return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItemIncludingDeprecated()
Expand Down Expand Up @@ -1265,6 +1268,7 @@ void LayoutBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay
minLogicalWidth += scrollbarWidth;
}

DISABLE_CFI_PERF
void LayoutBlock::computePreferredLogicalWidths()
{
ASSERT(preferredLogicalWidthsDirty());
Expand Down Expand Up @@ -1396,6 +1400,7 @@ void LayoutBlock::computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth
maxLogicalWidth = std::max(floatLeftWidth + floatRightWidth, maxLogicalWidth);
}

DISABLE_CFI_PERF
void LayoutBlock::computeChildPreferredLogicalWidths(LayoutObject& child, LayoutUnit& minPreferredLogicalWidth, LayoutUnit& maxPreferredLogicalWidth) const
{
if (child.isBox() && child.isHorizontalWritingMode() != isHorizontalWritingMode()) {
Expand Down
8 changes: 4 additions & 4 deletions third_party/WebKit/Source/core/layout/LayoutBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ class CORE_EXPORT LayoutBlock : public LayoutBox {
LayoutUnit logicalHeightForChild(const LayoutBox& child) const { return isHorizontalWritingMode() ? child.size().height() : child.size().width(); }
LayoutSize logicalSizeForChild(const LayoutBox& child) const { return isHorizontalWritingMode() ? child.size() : child.size().transposedSize(); }
LayoutUnit logicalTopForChild(const LayoutBox& child) const { return isHorizontalWritingMode() ? child.location().y() : child.location().x(); }
LayoutUnit marginBeforeForChild(const LayoutBoxModelObject& child) const { return child.marginBefore(style()); }
LayoutUnit marginAfterForChild(const LayoutBoxModelObject& child) const { return child.marginAfter(style()); }
LayoutUnit marginStartForChild(const LayoutBoxModelObject& child) const { return child.marginStart(style()); }
DISABLE_CFI_PERF LayoutUnit marginBeforeForChild(const LayoutBoxModelObject& child) const { return child.marginBefore(style()); }
DISABLE_CFI_PERF LayoutUnit marginAfterForChild(const LayoutBoxModelObject& child) const { return child.marginAfter(style()); }
DISABLE_CFI_PERF LayoutUnit marginStartForChild(const LayoutBoxModelObject& child) const { return child.marginStart(style()); }
LayoutUnit marginEndForChild(const LayoutBoxModelObject& child) const { return child.marginEnd(style()); }
void setMarginStartForChild(LayoutBox& child, LayoutUnit value) const { child.setMarginStart(value, style()); }
void setMarginEndForChild(LayoutBox& child, LayoutUnit value) const { child.setMarginEnd(value, style()); }
Expand All @@ -214,7 +214,7 @@ class CORE_EXPORT LayoutBlock : public LayoutBox {
virtual void scrollbarsChanged(bool /*horizontalScrollbarChanged*/, bool /*verticalScrollbarChanged*/);

LayoutUnit availableLogicalWidthForContent() const { return (logicalRightOffsetForContent() - logicalLeftOffsetForContent()).clampNegativeToZero(); }
LayoutUnit logicalLeftOffsetForContent() const { return isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop(); }
DISABLE_CFI_PERF LayoutUnit logicalLeftOffsetForContent() const { return isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop(); }
LayoutUnit logicalRightOffsetForContent() const { return logicalLeftOffsetForContent() + availableLogicalWidth(); }
LayoutUnit startOffsetForContent() const { return style()->isLeftToRightDirection() ? logicalLeftOffsetForContent() : logicalWidth() - logicalRightOffsetForContent(); }
LayoutUnit endOffsetForContent() const { return !style()->isLeftToRightDirection() ? logicalLeftOffsetForContent() : logicalWidth() - logicalRightOffsetForContent(); }
Expand Down
5 changes: 5 additions & 0 deletions third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ void LayoutBlockFlow::layoutBlock(bool relayoutChildren)
m_isSelfCollapsing = checkIfIsSelfCollapsingBlock();
}

DISABLE_CFI_PERF
inline bool LayoutBlockFlow::layoutBlockFlow(bool relayoutChildren, LayoutUnit &pageLogicalHeight, SubtreeLayoutScope& layoutScope)
{
LayoutUnit oldLeft = logicalLeft();
Expand Down Expand Up @@ -564,6 +565,7 @@ void LayoutBlockFlow::addLowestFloatFromChildren(LayoutBlockFlow* block)
newFloatingObject->setIsLowestNonOverhangingFloatInChild(true);
}

DISABLE_CFI_PERF
void LayoutBlockFlow::determineLogicalLeftPositionForChild(LayoutBox& child)
{
LayoutUnit startPosition = borderStart() + paddingStart();
Expand Down Expand Up @@ -1019,6 +1021,7 @@ LayoutUnit LayoutBlockFlow::adjustForUnsplittableChild(LayoutBox& child, LayoutU
return logicalOffset + paginationStrut;
}

DISABLE_CFI_PERF
void LayoutBlockFlow::rebuildFloatsFromIntruding()
{
if (m_floatingObjects)
Expand Down Expand Up @@ -1576,6 +1579,7 @@ void LayoutBlockFlow::setCollapsedBottomMargin(const MarginInfo& marginInfo)
}
}

DISABLE_CFI_PERF
void LayoutBlockFlow::marginBeforeEstimateForChild(LayoutBox& child, LayoutUnit& positiveMarginBefore, LayoutUnit& negativeMarginBefore, bool& discardMarginBefore) const
{
// Give up if in quirks mode and we're a body/table cell and the top margin of the child box is quirky.
Expand Down Expand Up @@ -2261,6 +2265,7 @@ void LayoutBlockFlow::styleWillChange(StyleDifference diff, const ComputedStyle&
LayoutBlock::styleWillChange(diff, newStyle);
}

DISABLE_CFI_PERF
void LayoutBlockFlow::styleDidChange(StyleDifference diff, const ComputedStyle* oldStyle)
{
bool hadSelfPaintingLayer = hasSelfPaintingLayer();
Expand Down
1 change: 1 addition & 0 deletions third_party/WebKit/Source/core/layout/LayoutBlockFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class CORE_EXPORT LayoutBlockFlow : public LayoutBlock {
return child.x() + marginBeforeForChild(*child.layoutObject());
}

DISABLE_CFI_PERF
LayoutUnit yPositionForFloatIncludingMargin(const FloatingObject& child) const
{
if (isHorizontalWritingMode())
Expand Down
2 changes: 2 additions & 0 deletions third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,7 @@ static inline void adjustMarginForInlineReplaced(LayoutObject* child,

// FIXME: This function should be broken into something less monolithic.
// FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. They can probably reuse code.
DISABLE_CFI_PERF
void LayoutBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth)
{
LayoutUnit inlineMax;
Expand Down Expand Up @@ -1585,6 +1586,7 @@ static inline bool shouldTruncateOverflowingText(const LayoutBlockFlow* block)
return objectToCheck->hasOverflowClip() && objectToCheck->style()->getTextOverflow();
}

DISABLE_CFI_PERF
void LayoutBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit afterEdge)
{
// Figure out if we should clear out our line boxes.
Expand Down
1 change: 1 addition & 0 deletions third_party/WebKit/Source/core/layout/line/InlineBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ InlineBox::~InlineBox()

#endif

DISABLE_CFI_PERF
void InlineBox::destroy()
{
// We do not need to issue invalidations if the page is being destroyed
Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/core/layout/line/InlineBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CORE_EXPORT InlineBox : public DisplayItemClient {
// The implementation should update the position of the whole subtree (e.g. position of descendants and overflow etc.
// should also be moved accordingly).
virtual void move(const LayoutSize& delta);
void moveInLogicalDirection(const LayoutSize& deltaInLogicalDirection) { move(isHorizontal() ? deltaInLogicalDirection : deltaInLogicalDirection.transposedSize()); }
DISABLE_CFI_PERF void moveInLogicalDirection(const LayoutSize& deltaInLogicalDirection) { move(isHorizontal() ? deltaInLogicalDirection : deltaInLogicalDirection.transposedSize()); }
void moveInInlineDirection(LayoutUnit delta) { moveInLogicalDirection(LayoutSize(delta, LayoutUnit())); }
void moveInBlockDirection(LayoutUnit delta) { moveInLogicalDirection(LayoutSize(LayoutUnit(), delta)); }

Expand Down
1 change: 1 addition & 0 deletions third_party/WebKit/Source/core/layout/line/InlineFlowBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class InlineFlowBox : public InlineBox {
typedef void (*CustomInlineBoxRangeReverse)(Vector<InlineBox*>::iterator first, Vector<InlineBox*>::iterator last);
void collectLeafBoxesInLogicalOrder(Vector<InlineBox*>&, CustomInlineBoxRangeReverse customReverseImplementation = 0) const;

DISABLE_CFI_PERF
void setConstructed() final
{
InlineBox::setConstructed();
Expand Down
20 changes: 0 additions & 20 deletions tools/cfi/blacklist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,26 +133,6 @@ fun:*LayoutTreeBuilderForElement*shouldCreateLayoutObject*
fun:*LayoutTreeBuilderForElement*createLayoutObject*
fun:*EventTarget*hasEventListeners*
fun:*HTMLCollection*invalidateCacheForAttribute*
fun:*InlineBox*destroy*
fun:*InlineBox*moveInLogicalDirection*
fun:*InlineFlowBox*setConstructed*
fun:*LayoutBlock*createsNewFormattingContext*
fun:*LayoutBlock*computeChildPreferredLogicalWidth*
fun:*LayoutBlock*computePreferredLogicalWidths*
fun:*LayoutBlock*computeOverflow*
fun:*LayoutBlock*logicalLeftOffsetForContent*
fun:*LayoutBlock*marginAfterForChild*
fun:*LayoutBlock*marginBeforeForChild*
fun:*LayoutBlock*marginStartForChild*
fun:*LayoutBlock*updateLogicalWidthAndColumnWidth*
fun:*LayoutBlockFlow*computeInlinePreferredLogicalWidths*
fun:*LayoutBlockFlow*determineLogicalLeftPositionForChild*
fun:*LayoutBlockFlow*layoutBlockFlow*
fun:*LayoutBlockFlow*layoutInlineChildren*
fun:*LayoutBlockFlow*marginBeforeEstimateForChild*
fun:*LayoutBlockFlow*rebuildFloatsFromIntruding*
fun:*LayoutBlockFlow*yPositionForFloatIncludingMargin*
fun:*LayoutBlockFlow*styleDidChange*
fun:*LayoutBoxModelObject*borderAndPaddingHeight*
fun:*LayoutBoxModelObject*borderAndPaddingWidth*
fun:*LayoutBoxModelObject*borderAndPaddingBefore*
Expand Down

0 comments on commit 5e2204a

Please sign in to comment.