Bug 903212 - Add a GC when popping a script entry point. r=mrbkap

I think that this is more or less isomorphic with the MaybeGC we do in
ScriptEvaluated in the cases that matter. And doing it in a spec-defined
place is helpful in getting rid of spec-nonsensical machinery.
This commit is contained in:
Bobby Holley 2013-08-14 14:00:02 -07:00
Родитель 4c9559f8e1
Коммит 0a570c79b5
1 изменённых файлов: 9 добавлений и 0 удалений

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

@ -146,6 +146,15 @@ AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull) : mScriptIsRunning(fal
NS_EXPORT
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();