Backing out bug 664659 (rev 7b49a2857e18) due to Mac memory regressions.

This commit is contained in:
Justin Lebar 2011-07-19 19:25:19 -04:00
Родитель 1b7adf6bc0
Коммит e28ed030a2
14 изменённых файлов: 93 добавлений и 256 удалений

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

@ -542,54 +542,39 @@ gfxASurface::MovePixels(const nsIntRect& aSourceRect,
/** Memory reporting **/
static const char *sDefaultSurfaceDescription =
"Memory used by gfx surface of the given type.";
struct SurfaceMemoryReporterAttrs {
const char *name;
const char *description;
static const char *sSurfaceNamesForSurfaceType[] = {
"gfx-surface-image",
"gfx-surface-pdf",
"gfx-surface-ps",
"gfx-surface-xlib",
"gfx-surface-xcb",
"gfx-surface-glitz",
"gfx-surface-quartz",
"gfx-surface-win32",
"gfx-surface-beos",
"gfx-surface-directfb",
"gfx-surface-svg",
"gfx-surface-os2",
"gfx-surface-win32printing",
"gfx-surface-quartzimage",
"gfx-surface-script",
"gfx-surface-qpainter",
"gfx-surface-recording",
"gfx-surface-vg",
"gfx-surface-gl",
"gfx-surface-drm",
"gfx-surface-tee",
"gfx-surface-xml",
"gfx-surface-skia",
"gfx-surface-subsurface",
"gfx-surface-d2d"
};
static SurfaceMemoryReporterAttrs sSurfaceMemoryReporterAttrs[] = {
{"gfx-surface-image", nsnull},
{"gfx-surface-pdf", nsnull},
{"gfx-surface-ps", nsnull},
{"gfx-surface-xlib",
"Memory used by xlib surfaces to store pixmaps. This memory lives in "
"the X server's process rather than in this application, so the bytes "
"accounted for here aren't counted in vsize, resident, explicit, or any of "
"the other measurements on this page."},
{"gfx-surface-xcb", nsnull},
{"gfx-surface-glitz", nsnull},
{"gfx-surface-quartz", nsnull},
{"gfx-surface-win32", nsnull},
{"gfx-surface-beos", nsnull},
{"gfx-surface-directfb", nsnull},
{"gfx-surface-svg", nsnull},
{"gfx-surface-os2", nsnull},
{"gfx-surface-win32printing", nsnull},
{"gfx-surface-quartzimage", nsnull},
{"gfx-surface-script", nsnull},
{"gfx-surface-qpainter", nsnull},
{"gfx-surface-recording", nsnull},
{"gfx-surface-vg", nsnull},
{"gfx-surface-gl", nsnull},
{"gfx-surface-drm", nsnull},
{"gfx-surface-tee", nsnull},
{"gfx-surface-xml", nsnull},
{"gfx-surface-skia", nsnull},
{"gfx-surface-subsurface", nsnull},
{"gfx-surface-d2d", nsnull},
};
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sSurfaceMemoryReporterAttrs) ==
gfxASurface::SurfaceTypeMax);
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sSurfaceNamesForSurfaceType) == gfxASurface::SurfaceTypeMax);
#ifdef CAIRO_HAS_D2D_SURFACE
PR_STATIC_ASSERT(PRUint32(CAIRO_SURFACE_TYPE_D2D) ==
PRUint32(gfxASurface::SurfaceTypeD2D));
PR_STATIC_ASSERT(PRUint32(CAIRO_SURFACE_TYPE_D2D) == PRUint32(gfxASurface::SurfaceTypeD2D));
#endif
PR_STATIC_ASSERT(PRUint32(CAIRO_SURFACE_TYPE_SKIA) ==
PRUint32(gfxASurface::SurfaceTypeSkia));
PR_STATIC_ASSERT(PRUint32(CAIRO_SURFACE_TYPE_SKIA) == PRUint32(gfxASurface::SurfaceTypeSkia));
static const char *
SurfaceMemoryReporterPathForType(gfxASurface::gfxSurfaceType aType)
@ -598,17 +583,7 @@ SurfaceMemoryReporterPathForType(gfxASurface::gfxSurfaceType aType)
aType >= gfxASurface::SurfaceTypeMax)
return "gfx-surface-unknown";
return sSurfaceMemoryReporterAttrs[aType].name;
}
static const char *
SurfaceMemoryReporterDescriptionForType(gfxASurface::gfxSurfaceType aType)
{
if (aType >= 0 && aType < gfxASurface::SurfaceTypeMax &&
sSurfaceMemoryReporterAttrs[aType].description)
return sSurfaceMemoryReporterAttrs[aType].description;
return sDefaultSurfaceDescription;
return sSurfaceNamesForSurfaceType[aType];
}
/* Surface size memory reporting */
@ -651,7 +626,7 @@ public:
}
NS_IMETHOD GetDescription(nsACString &desc) {
desc.Assign(SurfaceMemoryReporterDescriptionForType(mType));
desc.AssignLiteral("Memory used by gfx surface of the given type.");
return NS_OK;
}

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

@ -208,23 +208,6 @@ public:
PRInt32 KnownMemoryUsed() { return mBytesRecorded; }
/**
* The memory used by this surface (as reported by KnownMemoryUsed()) can
* either live in this process's heap, in this process but outside the
* heap, or in another process altogether.
*/
enum MemoryLocation {
MEMORY_IN_PROCESS_HEAP,
MEMORY_IN_PROCESS_NONHEAP,
MEMORY_OUT_OF_PROCESS
};
/**
* Where does this surface's memory live? By default, say it's in this
* process's heap.
*/
virtual MemoryLocation GetMemoryLocation() { return MEMORY_IN_PROCESS_HEAP; }
static PRInt32 BytePerPixelFromFormat(gfxImageFormat format);
virtual const gfxIntSize GetSize() const { return gfxIntSize(-1, -1); }

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

@ -98,10 +98,6 @@ public:
FastMovePixels(aSourceRect, aDestTopLeft);
}
// The memory used by this surface lives in this process's address space,
// but not in the heap.
virtual MemoryLocation MemoryLocation() { return MEMORY_IN_PROCESS_NONHEAP; }
private:
PRPackedBool mOwnsDC;
PRPackedBool mForPrinting;

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

@ -104,7 +104,6 @@ gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
gfxXlibSurface::~gfxXlibSurface()
{
// gfxASurface's destructor calls RecordMemoryFreed().
if (mPixmapTaken) {
XFreePixmap (mDisplay, mDrawable);
}
@ -128,26 +127,6 @@ CreatePixmap(Screen *screen, const gfxIntSize& size, unsigned int depth,
depth);
}
void
gfxXlibSurface::TakePixmap()
{
NS_ASSERTION(!mPixmapTaken, "I already own the Pixmap!");
mPixmapTaken = PR_TRUE;
// Divide by 8 because surface_get_depth gives us the number of *bits* per
// pixel.
RecordMemoryUsed(mSize.width * mSize.height *
cairo_xlib_surface_get_depth(CairoSurface()) / 8);
}
Drawable
gfxXlibSurface::ReleasePixmap() {
NS_ASSERTION(mPixmapTaken, "I don't own the Pixmap!");
mPixmapTaken = PR_FALSE;
RecordMemoryFreed();
return mDrawable;
}
/* static */
already_AddRefed<gfxXlibSurface>
gfxXlibSurface::Create(Screen *screen, Visual *visual,

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

@ -90,23 +90,23 @@ public:
// take ownership of a passed-in Pixmap, calling XFreePixmap on it
// when the gfxXlibSurface is destroyed.
void TakePixmap();
void TakePixmap() {
NS_ASSERTION(!mPixmapTaken, "I already own the Pixmap!");
mPixmapTaken = PR_TRUE;
}
// Release ownership of this surface's Pixmap. This is only valid
// on gfxXlibSurfaces for which the user called TakePixmap(), or
// on those created by a Create() factory method.
Drawable ReleasePixmap();
Drawable ReleasePixmap() {
NS_ASSERTION(mPixmapTaken, "I don't own the Pixmap!");
mPixmapTaken = PR_FALSE;
return mDrawable;
}
// Find a visual and colormap pair suitable for rendering to this surface.
PRBool GetColormapAndVisual(Colormap* colormap, Visual **visual);
// This surface is a wrapper around X pixmaps, which are stored in the X
// server, not the main application.
virtual gfxASurface::MemoryLocation MemoryLocation()
{
return MEMORY_OUT_OF_PROCESS;
}
protected:
// if TakePixmap() has been called on this
PRBool mPixmapTaken;

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

@ -63,7 +63,7 @@ Image::GetDataSize()
if (mError)
return 0;
return GetSourceHeapSize() + GetDecodedHeapSize() + GetDecodedNonheapSize();
return GetSourceDataSize() + GetDecodedDataSize();
}
// Translates a mimetype into a concrete decoder

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

@ -102,9 +102,8 @@ public:
/**
* The components that make up GetDataSize().
*/
virtual PRUint32 GetDecodedHeapSize() = 0;
virtual PRUint32 GetDecodedNonheapSize() = 0;
virtual PRUint32 GetSourceHeapSize() = 0;
virtual PRUint32 GetDecodedDataSize() = 0;
virtual PRUint32 GetSourceDataSize() = 0;
// Mimetype translation
enum eDecoderType {

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

@ -739,45 +739,21 @@ RasterImage::GetFrame(PRUint32 aWhichFrame,
return rv;
}
namespace {
enum DecodedSizeType {
DECODED_SIZE_HEAP,
DECODED_SIZE_NONHEAP
};
PRUint32
GetDecodedSize(const nsTArray<imgFrame *> &aFrames, DecodedSizeType aType)
RasterImage::GetDecodedDataSize()
{
PRUint32 val = 0;
for (PRUint32 i = 0; i < aFrames.Length(); ++i) {
imgFrame *frame = aFrames.SafeElementAt(i, nsnull);
for (PRUint32 i = 0; i < mFrames.Length(); ++i) {
imgFrame *frame = mFrames.SafeElementAt(i, nsnull);
NS_ABORT_IF_FALSE(frame, "Null frame in frame array!");
if (aType == DECODED_SIZE_HEAP)
val += frame->EstimateHeapMemoryUsed();
else
val += frame->EstimateNonheapMemoryUsed();
val += frame->EstimateMemoryUsed();
}
return val;
}
} // anonymous namespace
PRUint32
RasterImage::GetDecodedNonheapSize()
{
return GetDecodedSize(mFrames, DECODED_SIZE_NONHEAP);
}
PRUint32
RasterImage::GetDecodedHeapSize()
{
return GetDecodedSize(mFrames, DECODED_SIZE_HEAP);
}
PRUint32
RasterImage::GetSourceHeapSize()
RasterImage::GetSourceDataSize()
{
PRUint32 sourceDataSize = mSourceData.Length();

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

@ -209,9 +209,8 @@ public:
/* The total number of frames in this image. */
PRUint32 GetNumFrames();
virtual PRUint32 GetDecodedHeapSize();
virtual PRUint32 GetDecodedNonheapSize();
virtual PRUint32 GetSourceHeapSize();
PRUint32 GetDecodedDataSize();
PRUint32 GetSourceDataSize();
/* Triggers discarding. */
void Discard(bool force = false);

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

@ -249,20 +249,14 @@ VectorImage::GetCurrentFrameRect(nsIntRect& aRect)
}
PRUint32
VectorImage::GetDecodedHeapSize()
VectorImage::GetDecodedDataSize()
{
// XXXdholbert TODO: return num bytes used by helper SVG doc. (bug 590790)
return sizeof(*this);
}
PRUint32
VectorImage::GetDecodedNonheapSize()
{
return 0;
}
PRUint32
VectorImage::GetSourceHeapSize()
VectorImage::GetSourceDataSize()
{
// We're not storing the source data -- we just feed that directly to
// our helper SVG document as we receive it, for it to parse.

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

@ -87,10 +87,8 @@ public:
const char* aURIString,
PRUint32 aFlags);
void GetCurrentFrameRect(nsIntRect& aRect);
virtual PRUint32 GetDecodedHeapSize();
virtual PRUint32 GetDecodedNonheapSize();
virtual PRUint32 GetSourceHeapSize();
PRUint32 GetDecodedDataSize();
PRUint32 GetSourceDataSize();
// Callback for SVGRootRenderingObserver
void InvalidateObserver();

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

@ -778,7 +778,7 @@ void imgFrame::SetCompositingFailed(PRBool val)
mCompositingFailed = val;
}
PRUint32 imgFrame::EstimateHeapMemoryUsed() const
PRUint32 imgFrame::EstimateMemoryUsed() const
{
PRUint32 size = 0;
@ -791,8 +791,7 @@ PRUint32 imgFrame::EstimateHeapMemoryUsed() const
}
#ifdef USE_WIN_SURFACE
if (mWinSurface && mWinSurface->GetMemoryLocation() ==
gfxASurface::MEMORY_IN_PROCESS_HEAP) {
if (mWinSurface) {
size += mWinSurface->KnownMemoryUsed();
} else
#endif
@ -801,38 +800,18 @@ PRUint32 imgFrame::EstimateHeapMemoryUsed() const
size += mSize.width * mSize.height * 4;
} else
#endif
if (mImageSurface && mImageSurface->GetMemoryLocation() ==
gfxASurface::MEMORY_IN_PROCESS_HEAP) {
if (mImageSurface) {
size += mImageSurface->KnownMemoryUsed();
}
if (mOptSurface && mOptSurface->GetMemoryLocation() ==
gfxASurface::MEMORY_IN_PROCESS_HEAP) {
size += mOptSurface->KnownMemoryUsed();
}
return size;
}
PRUint32 imgFrame::EstimateNonheapMemoryUsed() const
{
PRUint32 size = 0;
#ifdef USE_WIN_SURFACE
if (mWinSurface && mWinSurface->GetMemoryLocation() ==
gfxASurface::MEMORY_IN_PROCESS_NONHEAP) {
size += mWinSurface->KnownMemoryUsed();
} else
#endif
if (mImageSurface && mImageSurface->GetMemoryLocation() ==
gfxASurface::MEMORY_IN_PROCESS_NONHEAP) {
size += mImageSurface->KnownMemoryUsed();
}
if (mOptSurface && mOptSurface->GetMemoryLocation() ==
gfxASurface::MEMORY_IN_PROCESS_NONHEAP) {
if (mOptSurface) {
size += mOptSurface->KnownMemoryUsed();
}
// fall back to pessimistic/approximate size
if (size == 0) {
size = mSize.width * mSize.height * 4;
}
return size;
}

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

@ -135,12 +135,8 @@ public:
return mImageSurface;
}
// These functions estimate how much heap and non-heap memory the imgFrame is
// using. Note that these only report memory within the current process; an
// imgFrame's surface might be using memory outside the current process (e.g.
// gfxXlibSurface).
PRUint32 EstimateHeapMemoryUsed() const;
PRUint32 EstimateNonheapMemoryUsed() const;
// returns an estimate of the memory used by this imgFrame
PRUint32 EstimateMemoryUsed() const;
PRUint8 GetPaletteDepth() const { return mPaletteDepth; }

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

@ -143,30 +143,20 @@ public:
CHROME_BIT = PR_BIT(0),
USED_BIT = PR_BIT(1),
RAW_BIT = PR_BIT(2),
HEAP_BIT = PR_BIT(3),
ChromeUsedRaw = CHROME_BIT | USED_BIT | RAW_BIT | HEAP_BIT,
ChromeUsedUncompressedHeap = CHROME_BIT | USED_BIT | HEAP_BIT,
ChromeUsedUncompressedNonheap = CHROME_BIT | USED_BIT,
ChromeUnusedRaw = CHROME_BIT | RAW_BIT | HEAP_BIT,
ChromeUnusedUncompressedHeap = CHROME_BIT | HEAP_BIT,
ChromeUnusedUncompressedNonheap = CHROME_BIT,
ContentUsedRaw = USED_BIT | RAW_BIT | HEAP_BIT,
ContentUsedUncompressedHeap = USED_BIT | HEAP_BIT,
ContentUsedUncompressedNonheap = USED_BIT,
ContentUnusedRaw = RAW_BIT | HEAP_BIT,
ContentUnusedUncompressedHeap = HEAP_BIT,
ContentUnusedUncompressedNonheap = 0
ChromeUsedRaw = CHROME_BIT | USED_BIT | RAW_BIT,
ChromeUsedUncompressed = CHROME_BIT | USED_BIT,
ChromeUnusedRaw = CHROME_BIT | RAW_BIT,
ChromeUnusedUncompressed = CHROME_BIT,
ContentUsedRaw = USED_BIT | RAW_BIT,
ContentUsedUncompressed = USED_BIT,
ContentUnusedRaw = RAW_BIT,
ContentUnusedUncompressed = 0
};
imgMemoryReporter(ReporterType aType)
: mType(aType)
{
// If the RAW bit is set, HEAP should also be set, because we don't
// currently understand storing compressed image data off the heap.
NS_ASSERTION(!(aType & RAW_BIT) || (aType & HEAP_BIT),
"RAW bit should imply HEAP bit.");
}
{ }
NS_DECL_ISUPPORTS
@ -180,40 +170,27 @@ public:
{
if (mType == ChromeUsedRaw) {
path.AssignLiteral("explicit/images/chrome/used/raw");
} else if (mType == ChromeUsedUncompressedHeap) {
path.AssignLiteral("explicit/images/chrome/used/uncompressed-heap");
} else if (mType == ChromeUsedUncompressedNonheap) {
path.AssignLiteral("explicit/images/chrome/used/uncompressed-nonheap");
} else if (mType == ChromeUsedUncompressed) {
path.AssignLiteral("explicit/images/chrome/used/uncompressed");
} else if (mType == ChromeUnusedRaw) {
path.AssignLiteral("explicit/images/chrome/unused/raw");
} else if (mType == ChromeUnusedUncompressedHeap) {
path.AssignLiteral("explicit/images/chrome/unused/uncompressed-heap");
} else if (mType == ChromeUnusedUncompressedNonheap) {
path.AssignLiteral("explicit/images/chrome/unused/uncompressed-nonheap");
} else if (mType == ChromeUnusedUncompressed) {
path.AssignLiteral("explicit/images/chrome/unused/uncompressed");
} else if (mType == ContentUsedRaw) {
path.AssignLiteral("explicit/images/content/used/raw");
} else if (mType == ContentUsedUncompressedHeap) {
path.AssignLiteral("explicit/images/content/used/uncompressed-heap");
} else if (mType == ContentUsedUncompressedNonheap) {
path.AssignLiteral("explicit/images/content/used/uncompressed-nonheap");
} else if (mType == ContentUsedUncompressed) {
path.AssignLiteral("explicit/images/content/used/uncompressed");
} else if (mType == ContentUnusedRaw) {
path.AssignLiteral("explicit/images/content/unused/raw");
} else if (mType == ContentUnusedUncompressedHeap) {
path.AssignLiteral("explicit/images/content/unused/uncompressed-heap");
} else if (mType == ContentUnusedUncompressedNonheap) {
path.AssignLiteral("explicit/images/content/unused/uncompressed-nonheap");
} else if (mType == ContentUnusedUncompressed) {
path.AssignLiteral("explicit/images/content/unused/uncompressed");
}
return NS_OK;
}
NS_IMETHOD GetKind(PRInt32 *kind)
{
if (mType & HEAP_BIT) {
*kind = KIND_HEAP;
}
else {
*kind = KIND_NONHEAP;
}
*kind = KIND_HEAP;
return NS_OK;
}
@ -253,11 +230,9 @@ public:
return PL_DHASH_NEXT;
if (rtype & RAW_BIT) {
arg->value += image->GetSourceHeapSize();
} else if (rtype & HEAP_BIT) {
arg->value += image->GetDecodedHeapSize();
arg->value += image->GetSourceDataSize();
} else {
arg->value += image->GetDecodedNonheapSize();
arg->value += image->GetDecodedDataSize();
}
return PL_DHASH_NEXT;
@ -280,27 +255,19 @@ public:
{
if (mType == ChromeUsedRaw) {
desc.AssignLiteral("Memory used by in-use chrome images (compressed data).");
} else if (mType == ChromeUsedUncompressedHeap) {
desc.AssignLiteral("Memory used by in-use chrome images (uncompressed data).");
} else if (mType == ChromeUsedUncompressedNonheap) {
} else if (mType == ChromeUsedUncompressed) {
desc.AssignLiteral("Memory used by in-use chrome images (uncompressed data).");
} else if (mType == ChromeUnusedRaw) {
desc.AssignLiteral("Memory used by not in-use chrome images (compressed data).");
} else if (mType == ChromeUnusedUncompressedHeap) {
desc.AssignLiteral("Memory used by not in-use chrome images (uncompressed data).");
} else if (mType == ChromeUnusedUncompressedNonheap) {
} else if (mType == ChromeUnusedUncompressed) {
desc.AssignLiteral("Memory used by not in-use chrome images (uncompressed data).");
} else if (mType == ContentUsedRaw) {
desc.AssignLiteral("Memory used by in-use content images (compressed data).");
} else if (mType == ContentUsedUncompressedHeap) {
desc.AssignLiteral("Memory used by in-use content images (uncompressed data).");
} else if (mType == ContentUsedUncompressedNonheap) {
} else if (mType == ContentUsedUncompressed) {
desc.AssignLiteral("Memory used by in-use content images (uncompressed data).");
} else if (mType == ContentUnusedRaw) {
desc.AssignLiteral("Memory used by not in-use content images (compressed data).");
} else if (mType == ContentUnusedUncompressedHeap) {
desc.AssignLiteral("Memory used by not in-use content images (uncompressed data).");
} else if (mType == ContentUnusedUncompressedNonheap) {
} else if (mType == ContentUnusedUncompressed) {
desc.AssignLiteral("Memory used by not in-use content images (uncompressed data).");
}
return NS_OK;
@ -914,17 +881,13 @@ nsresult imgLoader::InitCache()
sCacheMaxSize = 5 * 1024 * 1024;
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedRaw));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedUncompressedHeap));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedUncompressedNonheap));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUsedUncompressed));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedRaw));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedUncompressedHeap));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedUncompressedNonheap));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ChromeUnusedUncompressed));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedRaw));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedUncompressedHeap));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedUncompressedNonheap));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUsedUncompressed));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedRaw));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedUncompressedHeap));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedUncompressedNonheap));
NS_RegisterMemoryReporter(new imgMemoryReporter(imgMemoryReporter::ContentUnusedUncompressed));
return NS_OK;
}