Bug 1812774: Use AutoTArray to avoid allocation churn in FlattenedDisplayListIterator. r=tnikkel

(This patch doesn't change behavior.)

In addition to the switch-to-AutoTArray, this patch also annotates
FlattenedDisplayListIterator as stack-only, to make it clear that the
AutoTArray buffer won't bloat the size of any long-lived heap-allocated object.

I've chosen 3 as the default size for the AutoTArray based on the observed size
of this member-variable in a run of the Speedometer 3 benchmark, as well as
during a short browsing session. See notes on Bug 1812774 for more details.

Differential Revision: https://phabricator.services.mozilla.com/D168010
This commit is contained in:
Daniel Holbert 2023-01-27 01:33:12 +00:00
parent 98cfeed071
commit baa1300caa

View file

@ -6725,7 +6725,7 @@ class nsDisplayDestination : public nsPaintedDisplayItem {
nsPoint mPosition;
};
class FlattenedDisplayListIterator {
class MOZ_STACK_CLASS FlattenedDisplayListIterator {
public:
FlattenedDisplayListIterator(nsDisplayListBuilder* aBuilder,
nsDisplayList* aList)
@ -6818,7 +6818,8 @@ class FlattenedDisplayListIterator {
nsDisplayListBuilder* mBuilder;
nsDisplayList::iterator mStart;
nsDisplayList::iterator mEnd;
nsTArray<std::pair<nsDisplayList::iterator, nsDisplayList::iterator>> mStack;
AutoTArray<std::pair<nsDisplayList::iterator, nsDisplayList::iterator>, 3>
mStack;
};
class PaintTelemetry {