Bug 1276477, make document update less malloc heavy, r=baku

--HG--
extra : rebase_source : 5cf067fb8a874c144fcf7c1f85210a944ed75878
This commit is contained in:
Olli Pettay 2016-05-30 18:47:32 +03:00
Родитель 231fa73ee9
Коммит dfb20cda68
4 изменённых файлов: 18 добавлений и 5 удалений

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

@ -250,7 +250,7 @@ nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nullptr;
uint32_t nsContentUtils::sScriptBlockerCount = 0;
uint32_t nsContentUtils::sDOMNodeRemovedSuppressCount = 0;
uint32_t nsContentUtils::sMicroTaskLevel = 0;
nsTArray< nsCOMPtr<nsIRunnable> >* nsContentUtils::sBlockedScriptRunners = nullptr;
AutoTArray<nsCOMPtr<nsIRunnable>, 8>* nsContentUtils::sBlockedScriptRunners = nullptr;
uint32_t nsContentUtils::sRunnersCountAtFirstBlocker = 0;
nsIInterfaceRequestor* nsContentUtils::sSameOriginChecker = nullptr;
@ -534,7 +534,7 @@ nsContentUtils::Init()
RegisterStrongMemoryReporter(new DOMEventListenerManagersHashReporter());
}
sBlockedScriptRunners = new nsTArray< nsCOMPtr<nsIRunnable> >;
sBlockedScriptRunners = new AutoTArray<nsCOMPtr<nsIRunnable>, 8>;
Preferences::AddBoolVarCache(&sAllowXULXBL_for_file,
"dom.allow_XUL_XBL_for_file");

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

@ -2658,7 +2658,7 @@ private:
static uint32_t sDOMNodeRemovedSuppressCount;
static uint32_t sMicroTaskLevel;
// Not an nsCOMArray because removing elements from those is slower
static nsTArray< nsCOMPtr<nsIRunnable> >* sBlockedScriptRunners;
static AutoTArray<nsCOMPtr<nsIRunnable>, 8>* sBlockedScriptRunners;
static uint32_t sRunnersCountAtFirstBlocker;
static uint32_t sScriptBlockerCountWhereRunnersPrevented;

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

@ -1809,6 +1809,13 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
return NS_SUCCESS_INTERRUPTED_TRAVERSE;
}
if (tmp->mMaybeEndOutermostXBLUpdateRunner) {
// The cached runnable keeps a reference to the document object..
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
"mMaybeEndOutermostXBLUpdateRunner.mObj");
cb.NoteXPCOMChild(ToSupports(tmp));
}
for (auto iter = tmp->mIdentifierMap.ConstIter(); !iter.Done();
iter.Next()) {
iter.Get()->Traverse(&cb);
@ -1959,6 +1966,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
tmp->mCachedRootElement = nullptr; // Avoid a dangling pointer
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDisplayDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFirstBaseNodeWithHref)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMaybeEndOutermostXBLUpdateRunner)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDOMImplementation)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mImageMaps)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedEncoder)
@ -4981,8 +4989,11 @@ nsDocument::MaybeEndOutermostXBLUpdate()
mInXBLUpdate = false;
BindingManager()->EndOutermostUpdate();
} else if (!mInDestructor) {
nsContentUtils::AddScriptRunner(
NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate));
if (!mMaybeEndOutermostXBLUpdateRunner) {
mMaybeEndOutermostXBLUpdateRunner =
NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate);
}
nsContentUtils::AddScriptRunner(mMaybeEndOutermostXBLUpdateRunner);
}
}
}

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

@ -1789,6 +1789,8 @@ private:
nsTArray<nsCOMPtr<nsIRunnable> > mFrameLoaderFinalizers;
RefPtr<nsRunnableMethod<nsDocument> > mFrameLoaderRunner;
nsCOMPtr<nsIRunnable> mMaybeEndOutermostXBLUpdateRunner;
nsRevocableEventPtr<nsRunnableMethod<nsDocument, void, false> >
mPendingTitleChangeEvent;