Bug 765325 - Inline small functions more aggressively, turn off insertRecompileCheck for inliningDepth > 0. (r=sstangl)

This commit is contained in:
Kannan Vijayan 2012-06-20 11:45:45 -04:00
parent 235798a626
commit c26f2e16bd
2 changed files with 52 additions and 3 deletions

View File

@ -119,6 +119,24 @@ struct IonOptions
// Default: 4,096
uint32 maxStackArgs;
// The bytecode length limit for small function.
//
// The default for this was arrived at empirically via benchmarking.
// We may want to tune it further after other optimizations have gone
// in.
//
// Default: 100
uint32 smallFunctionMaxBytecodeLength;
// The inlining limit for small functions.
//
// This value has been arrived at empirically via benchmarking.
// We may want to revisit this tuning after other optimizations have
// gone in.
//
// Default: usesBeforeInlining / 4
uint32 smallFunctionUsesBeforeInlining;
void setEagerCompilation() {
usesBeforeCompile = usesBeforeCompileNoJaeger = 0;
@ -138,7 +156,9 @@ struct IonOptions
usesBeforeCompile(10240),
usesBeforeCompileNoJaeger(40),
usesBeforeInlining(usesBeforeCompile),
maxStackArgs(4096)
maxStackArgs(4096),
smallFunctionMaxBytecodeLength(100),
smallFunctionUsesBeforeInlining(usesBeforeInlining / 4)
{ }
};

View File

@ -2846,13 +2846,39 @@ class AutoAccumulateExits
}
};
static bool IsSmallFunction(JSFunction *target) {
if (!target->isInterpreted())
return false;
JSScript *script = target->script();
if(script->length > js_IonOptions.smallFunctionMaxBytecodeLength)
return false;
return true;
}
bool
IonBuilder::makeInliningDecision(JSFunction *target)
{
if (inliningDepth >= 3)
static const size_t INLINING_LIMIT = 3;
if (inliningDepth >= INLINING_LIMIT)
return false;
if (script->getUseCount() < js_IonOptions.usesBeforeInlining) {
// For "small" functions, we should be more aggressive about inlining.
// This is based on the following intuition:
// 1. The call overhead for a small function will likely be a much
// higher proportion of the runtime of the function than for larger
// functions.
// 2. The cost of inlining (in terms of size expansion of the SSA graph),
// and size expansion of the ultimately generated code, will be
// less significant.
uint32 checkUses = js_IonOptions.usesBeforeInlining;
if (IsSmallFunction(target))
checkUses = js_IonOptions.smallFunctionUsesBeforeInlining;
if (script->getUseCount() < checkUses) {
IonSpew(IonSpew_Inlining, "Not inlining, caller is not hot");
return false;
}
@ -3605,6 +3631,9 @@ IonBuilder::insertRecompileCheck()
if (!inliningEnabled())
return;
if (inliningDepth > 0)
return;
// Don't recompile if we are already inlining.
if (script->getUseCount() >= js_IonOptions.usesBeforeInlining)
return;