Bug 1368654 - pt 1 - Implement memory reporter support for FrameProperties. r=mats

This commit is contained in:
Jonathan Kew 2017-05-31 19:52:47 +01:00
parent 28e4ba1a1b
commit 20b8376ffd
9 changed files with 62 additions and 16 deletions

View File

@ -12338,7 +12338,8 @@ nsIDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
&aWindowSizes->mLayoutPresShellSize,
&aWindowSizes->mLayoutStyleSetsSize,
&aWindowSizes->mLayoutTextRunsSize,
&aWindowSizes->mLayoutPresContextSize);
&aWindowSizes->mLayoutPresContextSize,
&aWindowSizes->mLayoutFramePropertiesSize);
}
aWindowSizes->mPropertyTablesSize +=

View File

@ -400,6 +400,12 @@ CollectWindowReports(nsGlobalWindow *aWindow,
aWindowTotalSizes->mLayoutPresContextSize +=
windowSizes.mLayoutPresContextSize;
REPORT_SIZE("/layout/frame-properties", windowSizes.mLayoutFramePropertiesSize,
"Memory used for frame properties attached to frames "
"within a window.");
aWindowTotalSizes->mLayoutFramePropertiesSize +=
windowSizes.mLayoutFramePropertiesSize;
// There are many different kinds of frames, but it is very likely
// that only a few matter. Implement a cutoff so we don't bloat
// about:memory with many uninteresting entries.
@ -565,6 +571,9 @@ nsWindowMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
REPORT("window-objects/layout/pres-contexts", windowTotalSizes.mLayoutPresContextSize,
"This is the sum of all windows' 'layout/pres-contexts' numbers.");
REPORT("window-objects/layout/frame-properties", windowTotalSizes.mLayoutFramePropertiesSize,
"This is the sum of all windows' 'layout/frame-properties' numbers.");
size_t frameTotal = 0;
#define FRAME_ID(classname, ...) \
frameTotal += windowTotalSizes.mArenaStats.FRAME_ID_STAT_FIELD(classname);

View File

@ -33,6 +33,7 @@ class nsWindowSizes {
macro(Style, mLayoutStyleSetsSize) \
macro(Other, mLayoutTextRunsSize) \
macro(Other, mLayoutPresContextSize) \
macro(Other, mLayoutFramePropertiesSize) \
macro(Other, mPropertyTablesSize) \
public:

View File

@ -268,6 +268,9 @@ public:
void DeleteAll(const nsIFrame* aFrame);
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
private:
friend class ::nsIFrame;

View File

@ -10957,11 +10957,12 @@ PresShell::GetRootPresShell()
void
PresShell::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
nsArenaMemoryStats *aArenaObjectsSize,
size_t *aPresShellSize,
size_t *aStyleSetsSize,
size_t *aTextRunsSize,
size_t *aPresContextSize)
nsArenaMemoryStats* aArenaObjectsSize,
size_t* aPresShellSize,
size_t* aStyleSetsSize,
size_t* aTextRunsSize,
size_t* aPresContextSize,
size_t* aFramePropertiesSize)
{
mFrameArena.AddSizeOfExcludingThis(aMallocSizeOf, aArenaObjectsSize);
*aPresShellSize += aMallocSizeOf(this);
@ -10983,6 +10984,12 @@ PresShell::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
*aTextRunsSize += SizeOfTextRuns(aMallocSizeOf);
*aPresContextSize += mPresContext->SizeOfIncludingThis(aMallocSizeOf);
nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
if (rootFrame) {
*aFramePropertiesSize +=
rootFrame->SizeOfFramePropertiesForTree(aMallocSizeOf);
}
}
size_t

View File

@ -370,11 +370,12 @@ public:
virtual void LoadComplete() override;
void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
nsArenaMemoryStats *aArenaObjectsSize,
size_t *aPresShellSize,
size_t *aStyleSetsSize,
size_t *aTextRunsSize,
size_t *aPresContextSize) override;
nsArenaMemoryStats* aArenaObjectsSize,
size_t* aPresShellSize,
size_t* aStyleSetsSize,
size_t* aTextRunsSize,
size_t* aPresContextSize,
size_t* aFramePropertiesSize) override;
size_t SizeOfTextRuns(mozilla::MallocSizeOf aMallocSizeOf) const;
// This data is stored as a content property (nsGkAtoms::scrolling) on

View File

@ -1590,11 +1590,12 @@ public:
bool aFlushOnHoverChange) = 0;
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
nsArenaMemoryStats *aArenaObjectsSize,
size_t *aPresShellSize,
size_t *aStyleSetsSize,
size_t *aTextRunsSize,
size_t *aPresContextSize) = 0;
nsArenaMemoryStats* aArenaObjectsSize,
size_t* aPresShellSize,
size_t* aStyleSetsSize,
size_t* aTextRunsSize,
size_t* aPresContextSize,
size_t* aFramePropertiesSize) = 0;
/**
* Methods that retrieve the cached font inflation preferences.

View File

@ -10549,6 +10549,26 @@ nsFrame::HasCSSTransitions()
return collection && collection->mAnimations.Length() > 0;
}
size_t
nsIFrame::SizeOfFramePropertiesForTree(MallocSizeOf aMallocSizeOf) const
{
size_t result = 0;
if (mProperties) {
result += mProperties->SizeOfIncludingThis(aMallocSizeOf);
}
FrameChildListIterator iter(this);
while (!iter.IsDone()) {
for (const nsIFrame* f : iter.CurrentList()) {
result += f->SizeOfFramePropertiesForTree(aMallocSizeOf);
}
iter.Next();
}
return result;
}
// Box layout debugging
#ifdef DEBUG_REFLOW
int32_t gIndent2 = 0;

View File

@ -3460,6 +3460,9 @@ public:
}
}
// Reports size of the FrameProperties for this frame and its descendants
size_t SizeOfFramePropertiesForTree(mozilla::MallocSizeOf aMallocSizeOf) const;
/**
* Return true if and only if this frame obeys visibility:hidden.
* if it does not, then nsContainerFrame will hide its view even though