Skip to content

Commit

Permalink
Back out 4537337759b7 (bug 910517) because nobody expects the talos i…
Browse files Browse the repository at this point in the history
…nquisition

--HG--
rename : content/canvas/src/WebGLMemoryReporterWrapper.h => content/canvas/src/WebGLMemoryMultiReporterWrapper.h
  • Loading branch information
philor committed Sep 5, 2013
1 parent e6e55b7 commit 26ceee4
Show file tree
Hide file tree
Showing 67 changed files with 1,292 additions and 852 deletions.
12 changes: 8 additions & 4 deletions addon-sdk/source/lib/sdk/test/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ function reportMemoryUsage() {
var mgr = Cc["@mozilla.org/memory-reporter-manager;1"]
.getService(Ci.nsIMemoryReporterManager);

// XXX: this code is *so* bogus -- nsIMemoryReporter changed its |memoryUsed|
// field to |amount| *years* ago, and even bigger changes have happened
// since -- that it must just never be run.
var reporters = mgr.enumerateReporters();
if (reporters.hasMoreElements())
print("\n");
Expand Down Expand Up @@ -379,7 +376,14 @@ function getPotentialLeaks() {

let enm = mgr.enumerateReporters();
while (enm.hasMoreElements()) {
let mr = enm.getNext().QueryInterface(Ci.nsIMemoryReporter);
let reporter = enm.getNext().QueryInterface(Ci.nsIMemoryReporter);
logReporter(reporter.process, reporter.path, reporter.kind, reporter.units,
reporter.amount, reporter.description);
}

let enm = mgr.enumerateMultiReporters();
while (enm.hasMoreElements()) {
let mr = enm.getNext().QueryInterface(Ci.nsIMemoryMultiReporter);
mr.collectReports(logReporter, null);
}

Expand Down
4 changes: 2 additions & 2 deletions content/base/src/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);

static PLDHashTable sEventListenerManagersHash;

class DOMEventListenerManagersHashReporter MOZ_FINAL : public MemoryUniReporter
class DOMEventListenerManagersHashReporter MOZ_FINAL : public MemoryReporterBase
{
public:
DOMEventListenerManagersHashReporter()
: MemoryUniReporter(
: MemoryReporterBase(
"explicit/dom/event-listener-managers-hash",
KIND_HEAP,
UNITS_BYTES,
Expand Down
8 changes: 4 additions & 4 deletions content/base/src/nsDOMFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ nsDOMMemoryFile::DataOwner::sMemoryReporterRegistered;
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(DOMMemoryFileDataOwnerMallocSizeOf)

class nsDOMMemoryFileDataOwnerMemoryReporter MOZ_FINAL
: public nsIMemoryReporter
: public nsIMemoryMultiReporter
{
NS_DECL_THREADSAFE_ISUPPORTS

Expand All @@ -651,7 +651,7 @@ class nsDOMMemoryFileDataOwnerMemoryReporter MOZ_FINAL
return NS_OK;
}

NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCallback,
NS_IMETHOD CollectReports(nsIMemoryMultiReporterCallback *aCallback,
nsISupports *aClosure)
{
typedef nsDOMMemoryFile::DataOwner DataOwner;
Expand Down Expand Up @@ -725,7 +725,7 @@ class nsDOMMemoryFileDataOwnerMemoryReporter MOZ_FINAL
};

NS_IMPL_ISUPPORTS1(nsDOMMemoryFileDataOwnerMemoryReporter,
nsIMemoryReporter)
nsIMemoryMultiReporter)

/* static */ void
nsDOMMemoryFile::DataOwner::EnsureMemoryReporterRegistered()
Expand All @@ -737,7 +737,7 @@ nsDOMMemoryFile::DataOwner::EnsureMemoryReporterRegistered()

nsRefPtr<nsDOMMemoryFileDataOwnerMemoryReporter> reporter = new
nsDOMMemoryFileDataOwnerMemoryReporter();
NS_RegisterMemoryReporter(reporter);
NS_RegisterMemoryMultiReporter(reporter);

sMemoryReporterRegistered = true;
}
Expand Down
4 changes: 2 additions & 2 deletions content/canvas/src/CanvasRenderingContext2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ static int64_t gCanvasAzureMemoryUsed = 0;
// This is KIND_OTHER because it's not always clear where in memory the pixels
// of a canvas are stored. Furthermore, this memory will be tracked by the
// underlying surface implementations. See bug 655638 for details.
class Canvas2dPixelsReporter MOZ_FINAL : public MemoryUniReporter
class Canvas2dPixelsReporter MOZ_FINAL : public MemoryReporterBase
{
public:
Canvas2dPixelsReporter()
: MemoryUniReporter("canvas-2d-pixels", KIND_OTHER, UNITS_BYTES,
: MemoryReporterBase("canvas-2d-pixels", KIND_OTHER, UNITS_BYTES,
"Memory used by 2D canvases. Each canvas requires (width * height * 4) bytes.")
{}
private:
Expand Down
10 changes: 5 additions & 5 deletions content/canvas/src/WebGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "WebGLContextUtils.h"
#include "WebGLBuffer.h"
#include "WebGLVertexAttribData.h"
#include "WebGLMemoryReporterWrapper.h"
#include "WebGLMemoryMultiReporterWrapper.h"
#include "WebGLFramebuffer.h"
#include "WebGLVertexArray.h"
#include "WebGLQuery.h"
Expand Down Expand Up @@ -179,7 +179,7 @@ WebGLContext::WebGLContext()
mPixelStorePackAlignment = 4;
mPixelStoreUnpackAlignment = 4;

WebGLMemoryReporterWrapper::AddWebGLContext(this);
WebGLMemoryMultiReporterWrapper::AddWebGLContext(this);

mAllowRestore = true;
mContextLossTimerRunning = false;
Expand Down Expand Up @@ -213,7 +213,7 @@ WebGLContext::WebGLContext()
WebGLContext::~WebGLContext()
{
DestroyResourcesAndContext();
WebGLMemoryReporterWrapper::RemoveWebGLContext(this);
WebGLMemoryMultiReporterWrapper::RemoveWebGLContext(this);
TerminateContextLossTimer();
mContextRestorer = nullptr;
}
Expand Down Expand Up @@ -653,8 +653,8 @@ void WebGLContext::LoseOldestWebGLContextIfLimitExceeded()
// when choosing which one to lose first.
UpdateLastUseIndex();

WebGLMemoryReporterWrapper::ContextsArrayType &contexts
= WebGLMemoryReporterWrapper::Contexts();
WebGLMemoryMultiReporterWrapper::ContextsArrayType &contexts
= WebGLMemoryMultiReporterWrapper::Contexts();

// quick exit path, should cover a majority of cases
if (contexts.Length() <= kMaxWebGLContextsPerPrincipal) {
Expand Down
2 changes: 1 addition & 1 deletion content/canvas/src/WebGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class WebGLContext :
{
friend class WebGLContextUserData;
friend class WebGLMemoryPressureObserver;
friend class WebGLMemoryReporterWrapper;
friend class WebGLMemoryMultiReporterWrapper;
friend class WebGLExtensionLoseContext;
friend class WebGLExtensionCompressedTextureS3TC;
friend class WebGLExtensionCompressedTextureATC;
Expand Down
80 changes: 40 additions & 40 deletions content/canvas/src/WebGLContextReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "WebGLContext.h"
#include "WebGLMemoryReporterWrapper.h"
#include "WebGLMemoryMultiReporterWrapper.h"
#include "nsIMemoryReporter.h"

using namespace mozilla;

NS_IMPL_ISUPPORTS1(WebGLMemoryPressureObserver, nsIObserver)

class WebGLMemoryReporter MOZ_FINAL : public nsIMemoryReporter
class WebGLMemoryMultiReporter MOZ_FINAL : public nsIMemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER
NS_DECL_NSIMEMORYMULTIREPORTER
};

NS_IMPL_ISUPPORTS1(WebGLMemoryReporter, nsIMemoryReporter)
NS_IMPL_ISUPPORTS1(WebGLMemoryMultiReporter, nsIMemoryMultiReporter)

NS_IMETHODIMP
WebGLMemoryReporter::GetName(nsACString &aName)
WebGLMemoryMultiReporter::GetName(nsACString &aName)
{
aName.AssignLiteral("webgl");
return NS_OK;
}

NS_IMETHODIMP
WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
nsISupports* aClosure)
WebGLMemoryMultiReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb,
nsISupports* aClosure)
{
#define REPORT(_path, _kind, _units, _amount, _desc) \
do { \
Expand All @@ -42,21 +42,21 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,

REPORT("webgl-texture-memory",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetTextureMemoryUsed(),
WebGLMemoryMultiReporterWrapper::GetTextureMemoryUsed(),
"Memory used by WebGL textures.The OpenGL"
" implementation is free to store these textures in either video"
" memory or main memory. This measurement is only a lower bound,"
" actual memory usage may be higher for example if the storage"
" actual memory usage may be higher for example if the storage"
" is strided.");

REPORT("webgl-texture-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetTextureCount(),
WebGLMemoryMultiReporterWrapper::GetTextureCount(),
"Number of WebGL textures.");

REPORT("webgl-buffer-memory",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetBufferMemoryUsed(),
WebGLMemoryMultiReporterWrapper::GetBufferMemoryUsed(),
"Memory used by WebGL buffers. The OpenGL"
" implementation is free to store these buffers in either video"
" memory or main memory. This measurement is only a lower bound,"
Expand All @@ -65,7 +65,7 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,

REPORT("explicit/webgl/buffer-cache-memory",
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetBufferCacheMemoryUsed(),
WebGLMemoryMultiReporterWrapper::GetBufferCacheMemoryUsed(),
"Memory used by WebGL buffer caches. The WebGL"
" implementation caches the contents of element array buffers"
" only.This adds up with the webgl-buffer-memory value, but"
Expand All @@ -74,69 +74,69 @@ WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,

REPORT("webgl-buffer-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetBufferCount(),
"Number of WebGL buffers.");

WebGLMemoryMultiReporterWrapper::GetBufferCount(),
"Number of WebGL buffers.");
REPORT("webgl-renderbuffer-memory",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetRenderbufferMemoryUsed(),
WebGLMemoryMultiReporterWrapper::GetRenderbufferMemoryUsed(),
"Memory used by WebGL renderbuffers. The OpenGL"
" implementation is free to store these renderbuffers in either"
" video memory or main memory. This measurement is only a lower"
" bound, actual memory usage may be higher for example if the"
" storage is strided.");

REPORT("webgl-renderbuffer-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetRenderbufferCount(),
WebGLMemoryMultiReporterWrapper::GetRenderbufferCount(),
"Number of WebGL renderbuffers.");

REPORT("explicit/webgl/shader",
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
WebGLMemoryReporterWrapper::GetShaderSize(),
WebGLMemoryMultiReporterWrapper::GetShaderSize(),
"Combined size of WebGL shader ASCII sources and translation"
" logs cached on the heap.");
" logs cached on the heap.");

REPORT("webgl-shader-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetShaderCount(),
"Number of WebGL shaders.");
WebGLMemoryMultiReporterWrapper::GetShaderCount(),
"Number of WebGL shaders.");

REPORT("webgl-context-count",
nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT,
WebGLMemoryReporterWrapper::GetContextCount(),
"Number of WebGL contexts.");
WebGLMemoryMultiReporterWrapper::GetContextCount(),
"Number of WebGL contexts.");

#undef REPORT

return NS_OK;
}

WebGLMemoryReporterWrapper* WebGLMemoryReporterWrapper::sUniqueInstance = nullptr;
WebGLMemoryMultiReporterWrapper* WebGLMemoryMultiReporterWrapper::sUniqueInstance = nullptr;

WebGLMemoryReporterWrapper* WebGLMemoryReporterWrapper::UniqueInstance()
WebGLMemoryMultiReporterWrapper* WebGLMemoryMultiReporterWrapper::UniqueInstance()
{
if (!sUniqueInstance) {
sUniqueInstance = new WebGLMemoryReporterWrapper;
sUniqueInstance = new WebGLMemoryMultiReporterWrapper;
}
return sUniqueInstance;
return sUniqueInstance;
}

WebGLMemoryReporterWrapper::WebGLMemoryReporterWrapper()
{
mReporter = new WebGLMemoryReporter;
NS_RegisterMemoryReporter(mReporter);
WebGLMemoryMultiReporterWrapper::WebGLMemoryMultiReporterWrapper()
{
mReporter = new WebGLMemoryMultiReporter;
NS_RegisterMemoryMultiReporter(mReporter);
}

WebGLMemoryReporterWrapper::~WebGLMemoryReporterWrapper()
WebGLMemoryMultiReporterWrapper::~WebGLMemoryMultiReporterWrapper()
{
NS_UnregisterMemoryReporter(mReporter);
NS_UnregisterMemoryMultiReporter(mReporter);
}

NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(WebGLBufferMallocSizeOf)

int64_t
WebGLMemoryReporterWrapper::GetBufferCacheMemoryUsed() {
int64_t
WebGLMemoryMultiReporterWrapper::GetBufferCacheMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
Expand All @@ -153,8 +153,8 @@ WebGLMemoryReporterWrapper::GetBufferCacheMemoryUsed() {

NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(WebGLShaderMallocSizeOf)

int64_t
WebGLMemoryReporterWrapper::GetShaderSize() {
int64_t
WebGLMemoryMultiReporterWrapper::GetShaderSize() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* 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 WEBGLMEMORYREPORTWRAPER_H_
#define WEBGLMEMORYREPORTWRAPER_H_
#ifndef WEBGLMEMORYMULTIREPORTWRAPER_H_
#define WEBGLMEMORYMULTIREPORTWRAPER_H_

#include "WebGLContext.h"
#include "WebGLBuffer.h"
Expand All @@ -17,21 +17,21 @@

namespace mozilla {

class WebGLMemoryReporterWrapper
class WebGLMemoryMultiReporterWrapper
{
WebGLMemoryReporterWrapper();
~WebGLMemoryReporterWrapper();
static WebGLMemoryReporterWrapper* sUniqueInstance;
WebGLMemoryMultiReporterWrapper();
~WebGLMemoryMultiReporterWrapper();
static WebGLMemoryMultiReporterWrapper* sUniqueInstance;

// here we store plain pointers, not RefPtrs: we don't want the
// WebGLMemoryReporterWrapper unique instance to keep alive all
// here we store plain pointers, not RefPtrs: we don't want the
// WebGLMemoryMultiReporterWrapper unique instance to keep alive all
// WebGLContexts ever created.
typedef nsTArray<const WebGLContext*> ContextsArrayType;
ContextsArrayType mContexts;

nsCOMPtr<nsIMemoryReporter> mReporter;
nsCOMPtr<nsIMemoryMultiReporter> mReporter;

static WebGLMemoryReporterWrapper* UniqueInstance();
static WebGLMemoryMultiReporterWrapper* UniqueInstance();

static ContextsArrayType & Contexts() { return UniqueInstance()->mContexts; }

Expand Down
Loading

0 comments on commit 26ceee4

Please sign in to comment.