Bug 1081038 - part 1: Microtask in AutoEntryScript. r=bholley

This commit is contained in:
Gabor Krizsanits 2014-11-13 09:50:12 +01:00
parent 23f75ef94e
commit 54bff82eea
2 changed files with 9 additions and 0 deletions

View File

@ -463,14 +463,22 @@ AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
aCx ? aCx : FindJSContext(aGlobalObject))
, ScriptSettingsStackEntry(aGlobalObject, /* aCandidate = */ true)
, mWebIDLCallerPrincipal(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();
}
}
AutoEntryScript::~AutoEntryScript()
{
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

@ -330,6 +330,7 @@ private:
// bit up the stack, and which will outlive us. So we know the principal
// can't go away until then either.
nsIPrincipal* mWebIDLCallerPrincipal;
bool mIsMainThread;
friend nsIPrincipal* GetWebIDLCallerPrincipal();
};