Bug 1359436 - Add leak checking to CycleCollectedJSContext and related classes. r=mccr8

This commit is contained in:
kedziorski.lukasz@gmail.com
2017-05-09 13:59:00 +02:00
parent cbcc5a9be1
commit af7965b07d
5 changed files with 12 additions and 0 deletions

View File

@@ -1056,6 +1056,7 @@ public:
: CycleCollectedJSRuntime(aCx)
, mWorkerPrivate(aWorkerPrivate)
{
MOZ_COUNT_CTOR_INHERITED(WorkerJSRuntime, CycleCollectedJSRuntime);
MOZ_ASSERT(aWorkerPrivate);
}
@@ -1068,6 +1069,7 @@ public:
~WorkerJSRuntime()
{
MOZ_COUNT_DTOR_INHERITED(WorkerJSRuntime, CycleCollectedJSRuntime);
}
virtual void
@@ -1120,11 +1122,13 @@ public:
explicit WorkerJSContext(WorkerPrivate* aWorkerPrivate)
: mWorkerPrivate(aWorkerPrivate)
{
MOZ_COUNT_CTOR_INHERITED(WorkerJSContext, CycleCollectedJSContext);
MOZ_ASSERT(aWorkerPrivate);
}
~WorkerJSContext()
{
MOZ_COUNT_DTOR_INHERITED(WorkerJSContext, CycleCollectedJSContext);
JSContext* cx = MaybeContext();
if (!cx) {
return; // Initialize() must have failed

View File

@@ -581,6 +581,7 @@ XPCJSContext::InterruptCallback(JSContext* cx)
XPCJSContext::~XPCJSContext()
{
MOZ_COUNT_DTOR_INHERITED(XPCJSContext, CycleCollectedJSContext);
// Elsewhere we abort immediately if XPCJSContext initialization fails.
// Therefore the context must be non-null.
MOZ_ASSERT(MaybeContext());
@@ -620,6 +621,7 @@ XPCJSContext::XPCJSContext()
mTimeoutAccumulated(false),
mPendingResult(NS_OK)
{
MOZ_COUNT_CTOR_INHERITED(XPCJSContext, CycleCollectedJSContext);
MOZ_RELEASE_ASSERT(!gTlsContext.get());
gTlsContext.set(this);
}

View File

@@ -1221,6 +1221,7 @@ XPCJSRuntime::Shutdown(JSContext* cx)
XPCJSRuntime::~XPCJSRuntime()
{
MOZ_COUNT_DTOR_INHERITED(XPCJSRuntime, CycleCollectedJSRuntime);
}
// If |*anonymizeID| is non-zero and this is a user compartment, the name will
@@ -2952,6 +2953,7 @@ XPCJSRuntime::XPCJSRuntime(JSContext* aCx)
mObjectHolderRoots(nullptr),
mAsyncSnowWhiteFreer(new AsyncFreeSnowWhite())
{
MOZ_COUNT_CTOR_INHERITED(XPCJSRuntime, CycleCollectedJSRuntime);
}
/* static */

View File

@@ -62,6 +62,7 @@ CycleCollectedJSContext::CycleCollectedJSContext()
, mDoingStableStates(false)
, mDisableMicroTaskCheckpoint(false)
{
MOZ_COUNT_CTOR(CycleCollectedJSContext);
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
mOwningThread = thread.forget().downcast<nsThread>().take();
MOZ_RELEASE_ASSERT(mOwningThread);
@@ -69,6 +70,7 @@ CycleCollectedJSContext::CycleCollectedJSContext()
CycleCollectedJSContext::~CycleCollectedJSContext()
{
MOZ_COUNT_DTOR(CycleCollectedJSContext);
// If the allocation failed, here we are.
if (!mJSContext) {
return;

View File

@@ -511,6 +511,7 @@ CycleCollectedJSRuntime::CycleCollectedJSRuntime(JSContext* aCx)
, mOutOfMemoryState(OOMState::OK)
, mLargeAllocationFailureState(OOMState::OK)
{
MOZ_COUNT_CTOR(CycleCollectedJSRuntime);
MOZ_ASSERT(aCx);
MOZ_ASSERT(mJSRuntime);
@@ -561,6 +562,7 @@ CycleCollectedJSRuntime::Shutdown(JSContext* cx)
CycleCollectedJSRuntime::~CycleCollectedJSRuntime()
{
MOZ_COUNT_DTOR(CycleCollectedJSRuntime);
MOZ_ASSERT(!mDeferredFinalizerTable.Count());
}