Bug 1052042 - Move the pre-pop GC to AutoEntryScript. r=billm

This commit is contained in:
Bobby Holley 2014-08-13 15:36:44 -07:00
parent 8c4bd13859
commit 63bfd2eb94
3 changed files with 10 additions and 9 deletions

View File

@ -348,6 +348,14 @@ AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
MOZ_ASSERT_IF(aCx && aIsMainThread, aCx == FindJSContext(aGlobalObject));
}
AutoEntryScript::~AutoEntryScript()
{
// 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.
JS_MaybeGC(cx());
}
AutoIncumbentScript::AutoIncumbentScript(nsIGlobalObject* aGlobalObject)
: ScriptSettingsStackEntry(aGlobalObject, /* aCandidate = */ false)
, mCallerOverride(nsContentUtils::GetCurrentJSContextForThread())

View File

@ -201,6 +201,8 @@ public:
// Note: aCx is mandatory off-main-thread.
JSContext* aCx = nullptr);
~AutoEntryScript();
void SetWebIDLCallerPrincipal(nsIPrincipal *aPrincipal) {
mWebIDLCallerPrincipal = aPrincipal;
}

View File

@ -51,15 +51,6 @@ AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull)
AutoCxPusher::~AutoCxPusher()
{
// 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.
//
// NB: We need to take care to only do this if we're in a compartment,
// otherwise JS_MaybeGC will segfault.
if (mScx && !mAutoCompartment.empty())
JS_MaybeGC(nsXPConnect::XPConnect()->GetCurrentJSContext());
// Leave the compartment and request before popping.
mAutoCompartment.destroyIfConstructed();
mAutoRequest.destroyIfConstructed();