Backed out changeset a57d8f30d1bf (bug 1383982) for build bustage at nsGlobalWindow.cpp:13826: 'class nsWindowSizes' has no member named 'mMallocSizeOf'. r=backout

This commit is contained in:
Sebastian Hengst 2017-07-28 09:50:48 +02:00
Родитель 28bdd40776
Коммит 9077ac8886
33 изменённых файлов: 102 добавлений и 203 удалений

Просмотреть файл

@ -67,7 +67,6 @@
#include "mozilla/EventStates.h"
#include "mozilla/InternalMutationEvent.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/SizeOfState.h"
#include "mozilla/TextEditor.h"
#include "mozilla/TextEvents.h"
#include "nsNodeUtils.h"
@ -4138,14 +4137,3 @@ Element::SetCustomElementData(CustomElementData* aData)
MOZ_ASSERT(!slots->mCustomElementData, "Custom element data may not be changed once set.");
slots->mCustomElementData = aData;
}
size_t
Element::SizeOfExcludingThis(SizeOfState& aState) const
{
size_t n = FragmentOrElement::SizeOfExcludingThis(aState);
// XXX: measure mServoData.
return n;
}

Просмотреть файл

@ -205,8 +205,6 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ELEMENT_IID)
NS_DECL_SIZEOF_EXCLUDING_THIS
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
/**

Просмотреть файл

@ -2497,15 +2497,15 @@ FragmentOrElement::FireNodeRemovedForChildren()
}
size_t
FragmentOrElement::SizeOfExcludingThis(SizeOfState& aState) const
FragmentOrElement::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = 0;
n += nsIContent::SizeOfExcludingThis(aState);
n += mAttrsAndChildren.SizeOfExcludingThis(aState.mMallocSizeOf);
n += nsIContent::SizeOfExcludingThis(aMallocSizeOf);
n += mAttrsAndChildren.SizeOfExcludingThis(aMallocSizeOf);
nsDOMSlots* slots = GetExistingDOMSlots();
if (slots) {
n += slots->SizeOfIncludingThis(aState.mMallocSizeOf);
n += slots->SizeOfIncludingThis(aMallocSizeOf);
}
return n;

Просмотреть файл

@ -830,14 +830,14 @@ Link::SetHrefAttribute(nsIURI *aURI)
}
size_t
Link::SizeOfExcludingThis(mozilla::SizeOfState& aState) const
Link::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
size_t n = 0;
if (mCachedURI) {
nsCOMPtr<nsISizeOf> iface = do_QueryInterface(mCachedURI);
if (iface) {
n += iface->SizeOfIncludingThis(aState.mMallocSizeOf);
n += iface->SizeOfIncludingThis(aMallocSizeOf);
}
}

Просмотреть файл

@ -114,7 +114,7 @@ public:
virtual bool HasDeferredDNSPrefetchRequest() { return true; }
virtual size_t
SizeOfExcludingThis(mozilla::SizeOfState& aState) const;
SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
virtual bool ElementHasHref() const;

Просмотреть файл

@ -12332,10 +12332,10 @@ nsDocument::GetVisibilityState(nsAString& aState)
nsIDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
{
aWindowSizes->mDOMOtherSize +=
nsINode::SizeOfExcludingThis(aWindowSizes->mState);
nsINode::SizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
if (mPresShell) {
mPresShell->AddSizeOfIncludingThis(aWindowSizes->mState.mMallocSizeOf,
mPresShell->AddSizeOfIncludingThis(aWindowSizes->mMallocSizeOf,
&aWindowSizes->mArenaStats,
&aWindowSizes->mLayoutPresShellSize,
&aWindowSizes->mLayoutStyleSetsSize,
@ -12345,12 +12345,11 @@ nsIDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
}
aWindowSizes->mPropertyTablesSize +=
mPropertyTable.SizeOfExcludingThis(aWindowSizes->mState.mMallocSizeOf);
mPropertyTable.SizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
for (uint32_t i = 0, count = mExtraPropertyTables.Length();
i < count; ++i) {
aWindowSizes->mPropertyTablesSize +=
mExtraPropertyTables[i]->SizeOfIncludingThis(
aWindowSizes->mState.mMallocSizeOf);
mExtraPropertyTables[i]->SizeOfIncludingThis(aWindowSizes->mMallocSizeOf);
}
if (EventListenerManager* elm = GetExistingListenerManager()) {
@ -12365,7 +12364,7 @@ nsIDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
void
nsIDocument::DocAddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
{
aWindowSizes->mDOMOtherSize += aWindowSizes->mState.mMallocSizeOf(this);
aWindowSizes->mDOMOtherSize += aWindowSizes->mMallocSizeOf(this);
DocAddSizeOfExcludingThis(aWindowSizes);
}
@ -12386,7 +12385,7 @@ SizeOfOwnedSheetArrayExcludingThis(const nsTArray<RefPtr<StyleSheet>>& aSheets,
}
size_t
nsDocument::SizeOfExcludingThis(SizeOfState& aState) const
nsDocument::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
// This SizeOfExcludingThis() overrides the one from nsINode. But
// nsDocuments can only appear at the top of the DOM tree, and we use the
@ -12404,7 +12403,7 @@ nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
node;
node = node->GetNextNode(this))
{
size_t nodeSize = node->SizeOfIncludingThis(aWindowSizes->mState);
size_t nodeSize = node->SizeOfIncludingThis(aWindowSizes->mMallocSizeOf);
size_t* p;
switch (node->NodeType()) {
@ -12434,34 +12433,33 @@ nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
aWindowSizes->mStyleSheetsSize +=
SizeOfOwnedSheetArrayExcludingThis(mStyleSheets,
aWindowSizes->mState.mMallocSizeOf);
aWindowSizes->mMallocSizeOf);
// Note that we do not own the sheets pointed to by mOnDemandBuiltInUASheets
// (the nsLayoutStyleSheetCache singleton does).
aWindowSizes->mStyleSheetsSize +=
mOnDemandBuiltInUASheets.ShallowSizeOfExcludingThis(
aWindowSizes->mState.mMallocSizeOf);
aWindowSizes->mMallocSizeOf);
for (auto& sheetArray : mAdditionalSheets) {
aWindowSizes->mStyleSheetsSize +=
SizeOfOwnedSheetArrayExcludingThis(sheetArray,
aWindowSizes->mState.mMallocSizeOf);
aWindowSizes->mMallocSizeOf);
}
// Lumping in the loader with the style-sheets size is not ideal,
// but most of the things in there are in fact stylesheets, so it
// doesn't seem worthwhile to separate it out.
aWindowSizes->mStyleSheetsSize +=
CSSLoader()->SizeOfIncludingThis(aWindowSizes->mState.mMallocSizeOf);
aWindowSizes->mDOMOtherSize += mAttrStyleSheet
? mAttrStyleSheet->DOMSizeOfIncludingThis(
aWindowSizes->mState.mMallocSizeOf)
: 0;
CSSLoader()->SizeOfIncludingThis(aWindowSizes->mMallocSizeOf);
aWindowSizes->mDOMOtherSize +=
mStyledLinks.ShallowSizeOfExcludingThis(
aWindowSizes->mState.mMallocSizeOf);
mAttrStyleSheet ?
mAttrStyleSheet->DOMSizeOfIncludingThis(aWindowSizes->mMallocSizeOf) :
0;
aWindowSizes->mDOMOtherSize +=
mIdentifierMap.SizeOfExcludingThis(aWindowSizes->mState.mMallocSizeOf);
mStyledLinks.ShallowSizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
aWindowSizes->mDOMOtherSize +=
mIdentifierMap.SizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
// Measurement of the following members may be added later if DMD finds it
// is worthwhile:

Просмотреть файл

@ -1110,10 +1110,10 @@ nsGenericDOMDataNode::GetAttributeChangeHint(const nsIAtom* aAttribute,
}
size_t
nsGenericDOMDataNode::SizeOfExcludingThis(SizeOfState& aState) const
nsGenericDOMDataNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = nsIContent::SizeOfExcludingThis(aState);
n += mText.SizeOfExcludingThis(aState.mMallocSizeOf);
size_t n = nsIContent::SizeOfExcludingThis(aMallocSizeOf);
n += mText.SizeOfExcludingThis(aMallocSizeOf);
return n;
}

Просмотреть файл

@ -13778,13 +13778,13 @@ nsGlobalWindow::DisableTimeChangeNotifications()
void
nsGlobalWindow::AddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
{
aWindowSizes->mDOMOtherSize += aWindowSizes->mState.mMallocSizeOf(this);
aWindowSizes->mDOMOtherSize += aWindowSizes->mMallocSizeOf(this);
if (IsInnerWindow()) {
EventListenerManager* elm = GetExistingListenerManager();
if (elm) {
aWindowSizes->mDOMOtherSize +=
elm->SizeOfIncludingThis(aWindowSizes->mState.mMallocSizeOf);
elm->SizeOfIncludingThis(aWindowSizes->mMallocSizeOf);
aWindowSizes->mDOMEventListenersCount +=
elm->ListenerCount();
}
@ -13801,19 +13801,17 @@ nsGlobalWindow::AddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
if (mNavigator) {
aWindowSizes->mDOMOtherSize +=
mNavigator->SizeOfIncludingThis(aWindowSizes->mState.mMallocSizeOf);
mNavigator->SizeOfIncludingThis(aWindowSizes->mMallocSizeOf);
}
aWindowSizes->mDOMEventTargetsSize +=
mEventTargetObjects.ShallowSizeOfExcludingThis(
aWindowSizes->mState.mMallocSizeOf);
mEventTargetObjects.ShallowSizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
for (auto iter = mEventTargetObjects.ConstIter(); !iter.Done(); iter.Next()) {
DOMEventTargetHelper* et = iter.Get()->GetKey();
if (nsCOMPtr<nsISizeOfEventTarget> iSizeOf = do_QueryObject(et)) {
aWindowSizes->mDOMEventTargetsSize +=
iSizeOf->SizeOfEventTargetIncludingThis(
aWindowSizes->mState.mMallocSizeOf);
iSizeOf->SizeOfEventTargetIncludingThis(aWindowSizes->mMallocSizeOf);
}
if (EventListenerManager* elm = et->GetExistingListenerManager()) {
aWindowSizes->mDOMEventListenersCount += elm->ListenerCount();

Просмотреть файл

@ -2579,12 +2579,12 @@ nsINode::GetAccessibleNode()
}
size_t
nsINode::SizeOfExcludingThis(SizeOfState& aState) const
nsINode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = 0;
EventListenerManager* elm = GetExistingListenerManager();
if (elm) {
n += elm->SizeOfIncludingThis(aState.mMallocSizeOf);
n += elm->SizeOfIncludingThis(aMallocSizeOf);
}
// Measurement of the following members may be added later if DMD finds it is

Просмотреть файл

@ -19,7 +19,6 @@
#include "nsTObserverArray.h" // for member
#include "mozilla/ErrorResult.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/SizeOfState.h" // for SizeOfState
#include "mozilla/dom/EventTarget.h" // for base class
#include "js/TypeDecls.h" // for Handle, Value, JSObject, JSContext
#include "mozilla/dom/DOMString.h"
@ -269,8 +268,7 @@ private:
// defined, it is inherited from nsINode.
// This macro isn't actually specific to nodes, and bug 956400 will move it into MFBT.
#define NS_DECL_SIZEOF_EXCLUDING_THIS \
virtual size_t SizeOfExcludingThis(mozilla::SizeOfState& aState) \
const override;
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
// Categories of node properties
// 0 is global.
@ -328,15 +326,15 @@ public:
// The following members don't need to be measured:
// - nsIContent: mPrimaryFrame, because it's non-owning and measured elsewhere
//
virtual size_t SizeOfExcludingThis(mozilla::SizeOfState& aState) const;
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
// SizeOfIncludingThis doesn't need to be overridden by sub-classes because
// sub-classes of nsINode are guaranteed to be laid out in memory in such a
// way that |this| points to the start of the allocated object, even in
// methods of nsINode's sub-classes, so aState.mMallocSizeOf(this) is always
// methods of nsINode's sub-classes, and so |aMallocSizeOf(this)| is always
// safe to call no matter which object it was invoked on.
virtual size_t SizeOfIncludingThis(mozilla::SizeOfState& aState) const {
return aState.mMallocSizeOf(this) + SizeOfExcludingThis(aState);
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
friend class nsNodeUtils;

Просмотреть файл

@ -52,19 +52,19 @@ AddNonJSSizeOfWindowAndItsDescendents(nsGlobalWindow* aWindow,
nsTabSizes* aSizes)
{
// Measure the window.
SizeOfState state(moz_malloc_size_of);
nsWindowSizes windowSizes(state);
nsWindowSizes windowSizes(moz_malloc_size_of);
aWindow->AddSizeOfIncludingThis(&windowSizes);
windowSizes.addToTabSizes(aSizes);
// Measure the inner window, if there is one.
nsWindowSizes innerWindowSizes(moz_malloc_size_of);
nsGlobalWindow* inner = aWindow->IsOuterWindow() ? aWindow->GetCurrentInnerWindowInternal()
: nullptr;
if (inner) {
inner->AddSizeOfIncludingThis(&windowSizes);
inner->AddSizeOfIncludingThis(&innerWindowSizes);
innerWindowSizes.addToTabSizes(aSizes);
}
windowSizes.addToTabSizes(aSizes);
nsCOMPtr<nsIDOMWindowCollection> frames = aWindow->GetFrames();
uint32_t length;
@ -309,10 +309,7 @@ CollectWindowReports(nsGlobalWindow *aWindow,
ReportCount(censusWindowPath, _pathTail, _amount, NS_LITERAL_CSTRING(_desc), \
aHandleReport, aData);
// This SizeOfState contains the SeenPtrs used for all memory reporting of
// this window.
SizeOfState state(WindowsMallocSizeOf);
nsWindowSizes windowSizes(state);
nsWindowSizes windowSizes(WindowsMallocSizeOf);
aWindow->AddSizeOfIncludingThis(&windowSizes);
REPORT_SIZE("/dom/element-nodes", windowSizes.mDOMElementNodesSize,
@ -521,8 +518,7 @@ nsWindowMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
WindowPaths topWindowPaths;
// Collect window memory usage.
SizeOfState fakeState(nullptr); // this won't be used
nsWindowSizes windowTotalSizes(fakeState);
nsWindowSizes windowTotalSizes(nullptr);
nsCOMPtr<amIAddonManager> addonManager;
if (XRE_IsParentProcess()) {
// Only try to access the service from the main process.

Просмотреть файл

@ -39,7 +39,7 @@ class nsWindowSizes {
macro(Other, mPropertyTablesSize) \
public:
explicit nsWindowSizes(mozilla::SizeOfState& aState)
explicit nsWindowSizes(mozilla::MallocSizeOf aMallocSizeOf)
:
#define ZERO_SIZE(kind, mSize) mSize(0),
FOR_EACH_SIZE(ZERO_SIZE)
@ -47,7 +47,7 @@ public:
mDOMEventTargetsCount(0),
mDOMEventListenersCount(0),
mArenaStats(),
mState(aState)
mMallocSizeOf(aMallocSizeOf)
{}
void addToTabSizes(nsTabSizes *sizes) const {
@ -75,7 +75,7 @@ public:
uint32_t mDOMEventListenersCount;
nsArenaMemoryStats mArenaStats;
mozilla::SizeOfState& mState;
mozilla::MallocSizeOf mMallocSizeOf;
#undef FOR_EACH_SIZE
};

Просмотреть файл

@ -406,10 +406,10 @@ HTMLAnchorElement::IntrinsicState() const
}
size_t
HTMLAnchorElement::SizeOfExcludingThis(mozilla::SizeOfState& aState) const
HTMLAnchorElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
return nsGenericHTMLElement::SizeOfExcludingThis(aState) +
Link::SizeOfExcludingThis(aState);
return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) +
Link::SizeOfExcludingThis(aMallocSizeOf);
}
} // namespace dom

Просмотреть файл

@ -220,10 +220,10 @@ HTMLAreaElement::IntrinsicState() const
}
size_t
HTMLAreaElement::SizeOfExcludingThis(mozilla::SizeOfState& aState) const
HTMLAreaElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
return nsGenericHTMLElement::SizeOfExcludingThis(aState) +
Link::SizeOfExcludingThis(aState);
return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) +
Link::SizeOfExcludingThis(aMallocSizeOf);
}
JSObject*

Просмотреть файл

@ -509,10 +509,10 @@ HTMLLinkElement::IntrinsicState() const
}
size_t
HTMLLinkElement::SizeOfExcludingThis(mozilla::SizeOfState& aState) const
HTMLLinkElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
return nsGenericHTMLElement::SizeOfExcludingThis(aState) +
Link::SizeOfExcludingThis(aState);
return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) +
Link::SizeOfExcludingThis(aMallocSizeOf);
}
JSObject*

Просмотреть файл

@ -46,10 +46,10 @@ SVGPathElement::SVGPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeIn
// memory reporting methods
size_t
SVGPathElement::SizeOfExcludingThis(mozilla::SizeOfState& aState) const
SVGPathElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
return SVGPathElementBase::SizeOfExcludingThis(aState) +
mD.SizeOfExcludingThis(aState.mMallocSizeOf);
return SVGPathElementBase::SizeOfExcludingThis(aMallocSizeOf) +
mD.SizeOfExcludingThis(aMallocSizeOf);
}
//----------------------------------------------------------------------

Просмотреть файл

@ -32,7 +32,7 @@ DynamicImage::GetProgressTracker()
}
size_t
DynamicImage::SizeOfSourceWithComputedFallback(SizeOfState& aState) const
DynamicImage::SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf) const
{
return 0;
}

Просмотреть файл

@ -34,7 +34,7 @@ public:
nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) const override;
virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
virtual size_t SizeOfSourceWithComputedFallback(
SizeOfState& aState) const override;
MallocSizeOf aMallocSizeOf) const override;
virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
MallocSizeOf aMallocSizeOf) const override;

Просмотреть файл

@ -15,7 +15,7 @@ namespace image {
///////////////////////////////////////////////////////////////////////////////
ImageMemoryCounter::ImageMemoryCounter(Image* aImage,
SizeOfState& aState,
MallocSizeOf aMallocSizeOf,
bool aIsUsed)
: mIsUsed(aIsUsed)
{
@ -36,8 +36,8 @@ ImageMemoryCounter::ImageMemoryCounter(Image* aImage,
mType = aImage->GetType();
// Populate memory counters for source and decoded data.
mValues.SetSource(aImage->SizeOfSourceWithComputedFallback(aState));
aImage->CollectSizeOfSurfaces(mSurfaces, aState.mMallocSizeOf);
mValues.SetSource(aImage->SizeOfSourceWithComputedFallback(aMallocSizeOf));
aImage->CollectSizeOfSurfaces(mSurfaces, aMallocSizeOf);
// Compute totals.
for (const SurfaceMemoryCounter& surfaceCounter : mSurfaces) {

Просмотреть файл

@ -94,7 +94,9 @@ private:
struct ImageMemoryCounter
{
ImageMemoryCounter(Image* aImage, SizeOfState& aState, bool aIsUsed);
ImageMemoryCounter(Image* aImage,
MallocSizeOf aMallocSizeOf,
bool aIsUsed);
nsCString& URI() { return mURI; }
const nsCString& URI() const { return mURI; }
@ -165,7 +167,7 @@ public:
* ensure that something reasonable is always returned.
*/
virtual size_t
SizeOfSourceWithComputedFallback(SizeOfState& aState) const = 0;
SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf) const = 0;
/**
* Collect an accounting of the memory occupied by the image's surfaces (which

Просмотреть файл

@ -30,9 +30,9 @@ ImageWrapper::GetProgressTracker()
}
size_t
ImageWrapper::SizeOfSourceWithComputedFallback(SizeOfState& aState) const
ImageWrapper::SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf) const
{
return mInnerImage->SizeOfSourceWithComputedFallback(aState);
return mInnerImage->SizeOfSourceWithComputedFallback(aMallocSizeOf);
}
void

Просмотреть файл

@ -26,7 +26,7 @@ public:
virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
virtual size_t
SizeOfSourceWithComputedFallback(SizeOfState& aState) const override;
SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf) const override;
virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
MallocSizeOf aMallocSizeOf) const override;

Просмотреть файл

@ -705,10 +705,9 @@ RasterImage::UpdateImageContainer()
}
size_t
RasterImage::SizeOfSourceWithComputedFallback(SizeOfState& aState) const
RasterImage::SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf) const
{
return mSourceBuffer->SizeOfIncludingThisWithComputedFallback(
aState.mMallocSizeOf);
return mSourceBuffer->SizeOfIncludingThisWithComputedFallback(aMallocSizeOf);
}
void

Просмотреть файл

@ -167,7 +167,7 @@ public:
// Methods inherited from Image
virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override;
virtual size_t SizeOfSourceWithComputedFallback(SizeOfState& aState)
virtual size_t SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf)
const override;
virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
MallocSizeOf aMallocSizeOf) const override;

Просмотреть файл

@ -380,7 +380,7 @@ VectorImage::Init(const char* aMimeType,
}
size_t
VectorImage::SizeOfSourceWithComputedFallback(SizeOfState& aState) const
VectorImage::SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf) const
{
if (!mSVGDocumentWrapper) {
return 0; // No document, so no memory used for the document.
@ -391,7 +391,7 @@ VectorImage::SizeOfSourceWithComputedFallback(SizeOfState& aState) const
return 0; // No document, so no memory used for the document.
}
nsWindowSizes windowSizes(aState);
nsWindowSizes windowSizes(aMallocSizeOf);
doc->DocAddSizeOfIncludingThis(&windowSizes);
if (windowSizes.getTotalSize() == 0) {

Просмотреть файл

@ -35,7 +35,7 @@ public:
// Methods inherited from Image
nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) const override;
virtual size_t SizeOfSourceWithComputedFallback(SizeOfState& aState)
virtual size_t SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf)
const override;
virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
MallocSizeOf aMallocSizeOf) const override;

Просмотреть файл

@ -140,8 +140,7 @@ public:
// memory. This function's measurement is secondary -- the result doesn't
// go in the "explicit" tree -- so we use moz_malloc_size_of instead of
// ImagesMallocSizeOf to prevent DMD from seeing it reported twice.
SizeOfState state(moz_malloc_size_of);
ImageMemoryCounter counter(image, state, /* aIsUsed = */ true);
ImageMemoryCounter counter(image, moz_malloc_size_of, /* aIsUsed = */ true);
n += counter.Values().DecodedHeap();
n += counter.Values().DecodedNonHeap();
@ -410,8 +409,7 @@ private:
return;
}
SizeOfState state(ImagesMallocSizeOf);
ImageMemoryCounter counter(image, state, aIsUsed);
ImageMemoryCounter counter(image, ImagesMallocSizeOf, aIsUsed);
aArray->AppendElement(Move(counter));
}

Просмотреть файл

@ -617,8 +617,7 @@ imgRequest::UpdateCacheEntrySize()
}
RefPtr<Image> image = GetImage();
SizeOfState state(moz_malloc_size_of);
size_t size = image->SizeOfSourceWithComputedFallback(state);
size_t size = image->SizeOfSourceWithComputedFallback(moz_malloc_size_of);
mCacheEntry->SetDataSize(size);
}

Просмотреть файл

@ -2119,11 +2119,11 @@ MOZ_DEFINE_MALLOC_SIZE_OF(OrphanMallocSizeOf)
namespace xpc {
static size_t
SizeOfTreeIncludingThis(nsINode* tree, SizeOfState& aState)
SizeOfTreeIncludingThis(nsINode* tree)
{
size_t n = tree->SizeOfIncludingThis(aState);
size_t n = tree->SizeOfIncludingThis(OrphanMallocSizeOf);
for (nsIContent* child = tree->GetFirstChild(); child; child = child->GetNextNode(tree))
n += child->SizeOfIncludingThis(aState);
n += child->SizeOfIncludingThis(OrphanMallocSizeOf);
return n;
}
@ -2133,11 +2133,10 @@ class OrphanReporter : public JS::ObjectPrivateVisitor
public:
explicit OrphanReporter(GetISupportsFun aGetISupports)
: JS::ObjectPrivateVisitor(aGetISupports)
, mState(OrphanMallocSizeOf)
{}
virtual size_t sizeOfIncludingThis(nsISupports* aSupports) override
{
}
virtual size_t sizeOfIncludingThis(nsISupports* aSupports) override {
size_t n = 0;
nsCOMPtr<nsINode> node = do_QueryInterface(aSupports);
// https://bugzilla.mozilla.org/show_bug.cgi?id=773533#c11 explains
@ -2150,15 +2149,21 @@ class OrphanReporter : public JS::ObjectPrivateVisitor
// sub-tree that this node belongs to, measure the sub-tree's size
// and then record its root so we don't measure it again.
nsCOMPtr<nsINode> orphanTree = node->SubtreeRoot();
if (orphanTree && !mState.HaveSeenPtr(orphanTree.get())) {
n += SizeOfTreeIncludingThis(orphanTree, mState);
if (orphanTree &&
!mAlreadyMeasuredOrphanTrees.Contains(orphanTree)) {
// If PutEntry() fails we don't measure this tree, which could
// lead to under-measurement. But that's better than the
// alternatives, which are over-measurement or an OOM abort.
if (mAlreadyMeasuredOrphanTrees.PutEntry(orphanTree, fallible)) {
n += SizeOfTreeIncludingThis(orphanTree);
}
}
}
return n;
}
private:
SizeOfState mState;
nsTHashtable <nsISupportsHashKey> mAlreadyMeasuredOrphanTrees;
};
#ifdef DEBUG

Просмотреть файл

@ -42,8 +42,7 @@ public:
mDeathGrip = nullptr;
}
virtual size_t SizeOfExcludingThis(mozilla::SizeOfState& aState)
const override
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override
{
return 0; // the value shouldn't matter
}

Просмотреть файл

@ -1,73 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef SizeOfState_h
#define SizeOfState_h
#include "mozilla/fallible.h"
#include "mozilla/Maybe.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Unused.h"
#include "nsTHashtable.h"
#include "nsHashKeys.h"
// This file includes types that are useful during memory reporting, but which
// cannot be put into mfbt/MemoryReporting.h because they depend on things that
// are not in MFBT.
namespace mozilla {
// A table of seen pointers. Useful when measuring structures that contain
// nodes that may be pointed to from multiple places, e.g. via RefPtr (in C++
// code) or Arc (in Rust code).
class SeenPtrs : public nsTHashtable<nsPtrHashKey<const void>>
{
public:
// Returns true if we have seen this pointer before, false otherwise. Also
// remembers this pointer for later queries.
bool HaveSeenPtr(const void* aPtr)
{
uint32_t oldCount = Count();
mozilla::Unused << PutEntry(aPtr, fallible);
// If the counts match, there are two possibilities.
//
// - Lookup succeeded: we've seen the pointer before, and didn't need to
// add a new entry.
//
// - PutEntry() tried to add the entry and failed due to lack of memory. In
// this case we can't tell if this pointer has been seen before (because
// the table is in an unreliable state and may have dropped previous
// insertions). When doing memory reporting it's better to err on the
// side of under-reporting rather than over-reporting, so we assume we've
// seen the pointer before.
//
return oldCount == Count();
}
};
// Memory reporting state. Some memory measuring functions
// (SizeOfIncludingThis(), etc.) just need a MallocSizeOf parameter, but some
// also need a record of pointers that have been seen and should not be
// re-measured. This class encapsulates both of those things.
class SizeOfState
{
public:
explicit SizeOfState(MallocSizeOf aMallocSizeOf)
: mMallocSizeOf(aMallocSizeOf)
{}
bool HaveSeenPtr(const void* aPtr) { return mSeenPtrs.HaveSeenPtr(aPtr); }
MallocSizeOf mMallocSizeOf;
SeenPtrs mSeenPtrs;
};
} // namespace mozilla
#endif // SizeOfState_h

Просмотреть файл

@ -111,7 +111,6 @@ EXPORTS.mozilla += [
'nsMemoryInfoDumper.h',
'NSPRLogModulesParser.h',
'OwningNonNull.h',
'SizeOfState.h',
'StaticMutex.h',
'StaticPtr.h',
'SystemMemoryReporter.h',

Просмотреть файл

@ -144,9 +144,10 @@ public:
bool Contains(KeyType aKey) const { return !!GetEntry(aKey); }
/**
* Infallibly get the entry associated with a key, or create a new entry,
* Get the entry associated with a key, or create a new entry,
* @param aKey the key to retrieve
* @return pointer to the entry retrieved; never nullptr
* @return pointer to the entry class retreived; nullptr only if memory
can't be allocated
*/
EntryType* PutEntry(KeyType aKey)
{
@ -154,12 +155,6 @@ public:
return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey)));
}
/**
* Fallibly get the entry associated with a key, or create a new entry,
* @param aKey the key to retrieve
* @return pointer to the entry retrieved; nullptr only if memory can't
* be allocated
*/
MOZ_MUST_USE
EntryType* PutEntry(KeyType aKey, const fallible_t&)
{