Bug 1302645 - Only relazify functions on shrinking GCs to avoid reparsing too much. r=terrence

This commit is contained in:
Jan de Mooij 2016-09-15 12:58:42 +02:00
Родитель ed2743696a
Коммит 0b8211b299
3 изменённых файлов: 17 добавлений и 7 удалений

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

@ -479,10 +479,15 @@ RelazifyFunctions(JSContext* cx, unsigned argc, Value* vp)
// not active. To aid fuzzing, this testing function allows us to relazify // not active. To aid fuzzing, this testing function allows us to relazify
// even if the compartment is active. // even if the compartment is active.
CallArgs args = CallArgsFromVp(argc, vp);
SetAllowRelazification(cx, true); SetAllowRelazification(cx, true);
bool res = GC(cx, argc, vp);
JS::PrepareForFullGC(cx);
JS::GCForReason(cx, GC_SHRINK, JS::gcreason::API);
SetAllowRelazification(cx, false); SetAllowRelazification(cx, false);
return res; args.rval().setUndefined();
return true;
} }
static bool static bool

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

@ -111,7 +111,7 @@ test = "function f() { }; f();"
+ "assertEq(isLazyFunction(f), false);" + "assertEq(isLazyFunction(f), false);"
+ "var expect = isRelazifiableFunction(f);"; + "var expect = isRelazifiableFunction(f);";
checkAfter = function (ctx) { checkAfter = function (ctx) {
gc(ctx.global.f); // relazify f, if possible. gc(ctx.global.f, "shrinking"); // relazify f, if possible.
evaluate("assertEq(isLazyFunction(f), expect);", ctx); evaluate("assertEq(isLazyFunction(f), expect);", ctx);
}; };
evalWithCache(test, { evalWithCache(test, {
@ -128,7 +128,7 @@ test = "function f() { return isRelazifiableFunction(f) }; var expect = f();"
+ "assertEq(isLazyFunction(f), false);" + "assertEq(isLazyFunction(f), false);"
+ "expect"; + "expect";
checkAfter = function (ctx) { checkAfter = function (ctx) {
gc(ctx.global.f); // relazify f, if possible. gc(ctx.global.f, "shrinking"); // relazify f, if possible.
evaluate("assertEq(isLazyFunction(f), expect);", ctx); evaluate("assertEq(isLazyFunction(f), expect);", ctx);
}; };
evalWithCache(test, { evalWithCache(test, {

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

@ -3841,11 +3841,16 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces
* Relazify functions after discarding JIT code (we can't relazify * Relazify functions after discarding JIT code (we can't relazify
* functions with JIT code) and before the actual mark phase, so that * functions with JIT code) and before the actual mark phase, so that
* the current GC can collect the JSScripts we're unlinking here. * the current GC can collect the JSScripts we're unlinking here.
* We do this only when we're performing a shrinking GC, as too much
* relazification can cause performance issues when we have to reparse
* the same functions over and over.
*/ */
for (GCZonesIter zone(rt); !zone.done(); zone.next()) { if (invocationKind == GC_SHRINK) {
gcstats::AutoPhase ap(stats, gcstats::PHASE_RELAZIFY_FUNCTIONS); gcstats::AutoPhase ap(stats, gcstats::PHASE_RELAZIFY_FUNCTIONS);
RelazifyFunctions(zone, AllocKind::FUNCTION); for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
RelazifyFunctions(zone, AllocKind::FUNCTION_EXTENDED); RelazifyFunctions(zone, AllocKind::FUNCTION);
RelazifyFunctions(zone, AllocKind::FUNCTION_EXTENDED);
}
} }
startNumber = number; startNumber = number;