Bug 1081038 - part1: Microtask in AutoEntryScript. r=bholley

This commit is contained in:
Gabor Krizsanits 2014-11-14 16:46:26 +01:00
parent 3c4d8f8870
commit 69f651a9d6
2 changed files with 10 additions and 0 deletions

View File

@ -517,10 +517,14 @@ AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
, ScriptSettingsStackEntry(aGlobalObject, /* aCandidate = */ true)
, mWebIDLCallerPrincipal(nullptr)
, mDocShellForJSRunToCompletion(nullptr)
, mIsMainThread(aIsMainThread)
{
MOZ_ASSERT(aGlobalObject);
MOZ_ASSERT_IF(!aCx, aIsMainThread); // cx is mandatory off-main-thread.
MOZ_ASSERT_IF(aCx && aIsMainThread, aCx == FindJSContext(aGlobalObject));
if (aIsMainThread) {
nsContentUtils::EnterMicroTask();
}
if (aIsMainThread && gRunToCompletionListeners > 0) {
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobalObject);
@ -540,6 +544,10 @@ AutoEntryScript::~AutoEntryScript()
mDocShellForJSRunToCompletion->NotifyJSRunToCompletionStop();
}
if (mIsMainThread) {
nsContentUtils::LeaveMicroTask();
}
// GC when we pop a script entry point. This is a useful heuristic that helps
// us out on certain (flawed) benchmarks like sunspider, because it lets us
// avoid GCing during the timing loop.

View File

@ -344,6 +344,8 @@ private:
friend nsIPrincipal* GetWebIDLCallerPrincipal();
nsIDocShell* mDocShellForJSRunToCompletion;
bool mIsMainThread;
};
/*