Bug 1063816 - Rename usesBefore* to *WarmUpThreshold. r=h4writer

This commit is contained in:
Nicolas B. Pierron 2014-09-10 19:11:20 +02:00
parent 963ce26095
commit 0c46528b5e
10 changed files with 59 additions and 59 deletions

View File

@ -680,8 +680,8 @@ BaselineCompiler::emitWarmUpCounterIncrement(bool allowOsr)
Label skipCall;
const OptimizationInfo *info = js_IonOptimizations.get(js_IonOptimizations.firstLevel());
uint32_t minUses = info->usesBeforeCompile(script, pc);
masm.branch32(Assembler::LessThan, countReg, Imm32(minUses), &skipCall);
uint32_t warmUpThreshold = info->compilerWarmUpThreshold(script, pc);
masm.branch32(Assembler::LessThan, countReg, Imm32(warmUpThreshold), &skipCall);
masm.branchPtr(Assembler::Equal,
Address(scriptReg, JSScript::offsetOfIonScript()),

View File

@ -268,7 +268,7 @@ CanEnterBaselineJIT(JSContext *cx, HandleScript script, bool osr)
if (cx->runtime()->forkJoinWarmup > 0) {
if (osr)
return Method_Skipped;
} else if (script->incWarmUpCounter() <= js_JitOptions.baselineUsesBeforeCompile) {
} else if (script->incWarmUpCounter() <= js_JitOptions.baselineWarmUpThreshold) {
return Method_Skipped;
}

View File

@ -4367,7 +4367,7 @@ IonBuilder::makeInliningDecision(JSFunction *target, CallInfo &callInfo)
// Callee must have been called a few times to have somewhat stable
// type information, except for definite properties analysis,
// as the caller has not run yet.
if (targetScript->getWarmUpCounter() < optimizationInfo().usesBeforeInlining() &&
if (targetScript->getWarmUpCounter() < optimizationInfo().inliningWarmUpThreshold() &&
!targetScript->baselineScript()->ionCompiledOrInlined() &&
info().executionMode() != DefinitePropertiesAnalysis)
{
@ -6385,7 +6385,7 @@ IonBuilder::insertRecompileCheck()
// threshold of the next optimization level.
OptimizationLevel nextLevel = js_IonOptimizations.nextLevel(curLevel);
const OptimizationInfo *info = js_IonOptimizations.get(nextLevel);
uint32_t warmUpCounter = info->usesBeforeCompile(topBuilder->script());
uint32_t warmUpCounter = info->compilerWarmUpThreshold(topBuilder->script());
current->add(MRecompileCheck::New(alloc(), topBuilder->script(), warmUpCounter));
}

View File

@ -41,8 +41,8 @@ OptimizationInfo::initNormalOptimizationInfo()
maxInlineDepth_ = 3;
scalarReplacement_ = true;
smallFunctionMaxInlineDepth_ = 10;
usesBeforeCompile_ = 1000;
usesBeforeInliningFactor_ = 0.125;
compilerWarmUpThreshold_ = 1000;
inliningWarmUpThresholdFactor_ = 0.125;
}
void
@ -63,16 +63,16 @@ OptimizationInfo::initAsmjsOptimizationInfo()
}
uint32_t
OptimizationInfo::usesBeforeCompile(JSScript *script, jsbytecode *pc) const
OptimizationInfo::compilerWarmUpThreshold(JSScript *script, jsbytecode *pc) const
{
JS_ASSERT(pc == nullptr || pc == script->code() || JSOp(*pc) == JSOP_LOOPENTRY);
if (pc == script->code())
pc = nullptr;
uint32_t minUses = usesBeforeCompile_;
if (js_JitOptions.forceDefaultIonUsesBeforeCompile)
minUses = js_JitOptions.forcedDefaultIonUsesBeforeCompile;
uint32_t warmUpThreshold = compilerWarmUpThreshold_;
if (js_JitOptions.forceDefaultIonWarmUpThreshold)
warmUpThreshold = js_JitOptions.forcedDefaultIonWarmUpThreshold;
// If the script is too large to compile on the main thread, we can still
// compile it off thread. In these cases, increase the warm-up counter
@ -80,21 +80,21 @@ OptimizationInfo::usesBeforeCompile(JSScript *script, jsbytecode *pc) const
// avoid later recompilation.
if (script->length() > MAX_MAIN_THREAD_SCRIPT_SIZE)
minUses = minUses * (script->length() / (double) MAX_MAIN_THREAD_SCRIPT_SIZE);
warmUpThreshold *= (script->length() / (double) MAX_MAIN_THREAD_SCRIPT_SIZE);
uint32_t numLocalsAndArgs = NumLocalsAndArgs(script);
if (numLocalsAndArgs > MAX_MAIN_THREAD_LOCALS_AND_ARGS)
minUses = minUses * (numLocalsAndArgs / (double) MAX_MAIN_THREAD_LOCALS_AND_ARGS);
warmUpThreshold *= (numLocalsAndArgs / (double) MAX_MAIN_THREAD_LOCALS_AND_ARGS);
if (!pc || js_JitOptions.eagerCompilation)
return minUses;
return warmUpThreshold;
// It's more efficient to enter outer loops, rather than inner loops, via OSR.
// To accomplish this, we use a slightly higher threshold for inner loops.
// Note that the loop depth is always > 0 so we will prefer non-OSR over OSR.
uint32_t loopDepth = LoopEntryDepthHint(pc);
JS_ASSERT(loopDepth > 0);
return minUses + loopDepth * 100;
return warmUpThreshold + loopDepth * 100;
}
OptimizationInfos::OptimizationInfos()
@ -144,7 +144,7 @@ OptimizationInfos::levelForScript(JSScript *script, jsbytecode *pc) const
while (!isLastLevel(prev)) {
OptimizationLevel level = nextLevel(prev);
const OptimizationInfo *info = get(level);
if (script->getWarmUpCounter() < info->usesBeforeCompile(script, pc))
if (script->getWarmUpCounter() < info->compilerWarmUpThreshold(script, pc))
return prev;
prev = level;

View File

@ -105,11 +105,11 @@ class OptimizationInfo
// How many invocations or loop iterations are needed before functions
// are compiled.
uint32_t usesBeforeCompile_;
uint32_t compilerWarmUpThreshold_;
// How many invocations or loop iterations are needed before calls
// are inlined, as a fraction of usesBeforeCompile.
double usesBeforeInliningFactor_;
// are inlined, as a fraction of compilerWarmUpThreshold.
double inliningWarmUpThresholdFactor_;
OptimizationInfo()
{ }
@ -129,7 +129,7 @@ class OptimizationInfo
return inlineNative_ && !js_JitOptions.disableInlining;
}
uint32_t usesBeforeCompile(JSScript *script, jsbytecode *pc = nullptr) const;
uint32_t compilerWarmUpThreshold(JSScript *script, jsbytecode *pc = nullptr) const;
bool gvnEnabled() const {
return gvn_ && !js_JitOptions.disableGvn;
@ -195,11 +195,11 @@ class OptimizationInfo
return inlineMaxTotalBytecodeLength_;
}
uint32_t usesBeforeInlining() const {
uint32_t usesBeforeCompile = usesBeforeCompile_;
if (js_JitOptions.forceDefaultIonUsesBeforeCompile)
usesBeforeCompile = js_JitOptions.forcedDefaultIonUsesBeforeCompile;
return usesBeforeCompile * usesBeforeInliningFactor_;
uint32_t inliningWarmUpThreshold() const {
uint32_t compilerWarmUpThreshold = compilerWarmUpThreshold_;
if (js_JitOptions.forceDefaultIonWarmUpThreshold)
compilerWarmUpThreshold = js_JitOptions.forcedDefaultIonWarmUpThreshold;
return compilerWarmUpThreshold * inliningWarmUpThresholdFactor_;
}
};

View File

@ -69,8 +69,8 @@ JitOptions::JitOptions()
// Force how many invocation or loop iterations are needed before compiling
// a function with the highest ionmonkey optimization level.
// (i.e. OptimizationLevel_Normal)
forceDefaultIonUsesBeforeCompile = false;
forcedDefaultIonUsesBeforeCompile = 1000;
forceDefaultIonWarmUpThreshold = false;
forcedDefaultIonWarmUpThreshold = 1000;
// Force the used register allocator instead of letting the
// optimization pass decide.
@ -85,7 +85,7 @@ JitOptions::JitOptions()
// How many invocations or loop iterations are needed before functions
// are compiled with the baseline compiler.
baselineUsesBeforeCompile = 10;
baselineWarmUpThreshold = 10;
// Number of exception bailouts (resuming into catch/finally block) before
// we invalidate and forbid Ion compilation.
@ -110,7 +110,7 @@ JitOptions::JitOptions()
smallFunctionMaxBytecodeLength_ = 100;
// How many uses of a parallel kernel before we attempt compilation.
usesBeforeCompilePar = 1;
compilerWarmUpThresholdPar = 1;
}
bool
@ -123,35 +123,35 @@ void
JitOptions::setEagerCompilation()
{
eagerCompilation = true;
baselineUsesBeforeCompile = 0;
forceDefaultIonUsesBeforeCompile = true;
forcedDefaultIonUsesBeforeCompile = 0;
baselineWarmUpThreshold = 0;
forceDefaultIonWarmUpThreshold = true;
forcedDefaultIonWarmUpThreshold = 0;
}
void
JitOptions::setUsesBeforeCompile(uint32_t warmUpCounter)
JitOptions::setCompilerWarmUpThreshold(uint32_t warmUpCounter)
{
forceDefaultIonUsesBeforeCompile = true;
forcedDefaultIonUsesBeforeCompile = warmUpCounter;
forceDefaultIonWarmUpThreshold = true;
forcedDefaultIonWarmUpThreshold = warmUpCounter;
// Undo eager compilation
if (eagerCompilation && warmUpCounter != 0) {
jit::JitOptions defaultValues;
eagerCompilation = false;
baselineUsesBeforeCompile = defaultValues.baselineUsesBeforeCompile;
baselineWarmUpThreshold = defaultValues.baselineWarmUpThreshold;
}
}
void
JitOptions::resetUsesBeforeCompile()
JitOptions::resetCompilerWarmUpThreshold()
{
forceDefaultIonUsesBeforeCompile = false;
forceDefaultIonWarmUpThreshold = false;
// Undo eager compilation
if (eagerCompilation) {
jit::JitOptions defaultValues;
eagerCompilation = false;
baselineUsesBeforeCompile = defaultValues.baselineUsesBeforeCompile;
baselineWarmUpThreshold = defaultValues.baselineWarmUpThreshold;
}
}

View File

@ -43,25 +43,25 @@ struct JitOptions
bool disableUce;
bool disableEaa;
bool eagerCompilation;
bool forceDefaultIonUsesBeforeCompile;
uint32_t forcedDefaultIonUsesBeforeCompile;
bool forceDefaultIonWarmUpThreshold;
uint32_t forcedDefaultIonWarmUpThreshold;
bool forceRegisterAllocator;
IonRegisterAllocator forcedRegisterAllocator;
bool limitScriptSize;
bool osr;
uint32_t baselineUsesBeforeCompile;
uint32_t baselineWarmUpThreshold;
uint32_t exceptionBailoutThreshold;
uint32_t frequentBailoutThreshold;
uint32_t maxStackArgs;
uint32_t osrPcMismatchesBeforeRecompile;
uint32_t smallFunctionMaxBytecodeLength_;
uint32_t usesBeforeCompilePar;
uint32_t compilerWarmUpThresholdPar;
JitOptions();
bool isSmallFunction(JSScript *script) const;
void setEagerCompilation();
void setUsesBeforeCompile(uint32_t warmUpCounter);
void resetUsesBeforeCompile();
void setCompilerWarmUpThreshold(uint32_t warmUpCounter);
void resetCompilerWarmUpThreshold();
};
extern JitOptions js_JitOptions;

View File

@ -6200,16 +6200,16 @@ JS_SetGlobalJitCompilerOption(JSRuntime *rt, JSJitCompilerOption opt, uint32_t v
case JSJITCOMPILER_BASELINE_WARMUP_TRIGGER:
if (value == uint32_t(-1)) {
jit::JitOptions defaultValues;
value = defaultValues.baselineUsesBeforeCompile;
value = defaultValues.baselineWarmUpThreshold;
}
jit::js_JitOptions.baselineUsesBeforeCompile = value;
jit::js_JitOptions.baselineWarmUpThreshold = value;
break;
case JSJITCOMPILER_ION_WARMUP_TRIGGER:
if (value == uint32_t(-1)) {
jit::js_JitOptions.resetUsesBeforeCompile();
jit::js_JitOptions.resetCompilerWarmUpThreshold();
break;
}
jit::js_JitOptions.setUsesBeforeCompile(value);
jit::js_JitOptions.setCompilerWarmUpThreshold(value);
if (value == 0)
jit::js_JitOptions.setEagerCompilation();
break;
@ -6260,9 +6260,9 @@ JS_GetGlobalJitCompilerOption(JSRuntime *rt, JSJitCompilerOption opt)
#ifndef JS_CODEGEN_NONE
switch (opt) {
case JSJITCOMPILER_BASELINE_WARMUP_TRIGGER:
return jit::js_JitOptions.baselineUsesBeforeCompile;
return jit::js_JitOptions.baselineWarmUpThreshold;
case JSJITCOMPILER_ION_WARMUP_TRIGGER:
return jit::js_JitOptions.forcedDefaultIonUsesBeforeCompile;
return jit::js_JitOptions.forcedDefaultIonWarmUpThreshold;
case JSJITCOMPILER_ION_ENABLE:
return JS::RuntimeOptionsRef(rt).ion();
case JSJITCOMPILER_BASELINE_ENABLE:

View File

@ -5807,16 +5807,16 @@ SetRuntimeOptions(JSRuntime *rt, const OptionParser &op)
return OptionFailure("ion-limit-script-size", str);
}
int32_t warmUpCounter = op.getIntOption("ion-uses-before-compile");
int32_t warmUpCounter = op.getIntOption("ion-warmup-threshold");
if (warmUpCounter >= 0)
jit::js_JitOptions.setUsesBeforeCompile(warmUpCounter);
jit::js_JitOptions.setCompilerWarmUpThreshold(warmUpCounter);
warmUpCounter = op.getIntOption("baseline-uses-before-compile");
warmUpCounter = op.getIntOption("baseline-warmup-threshold");
if (warmUpCounter >= 0)
jit::js_JitOptions.baselineUsesBeforeCompile = warmUpCounter;
jit::js_JitOptions.baselineWarmUpThreshold = warmUpCounter;
if (op.getBoolOption("baseline-eager"))
jit::js_JitOptions.baselineUsesBeforeCompile = 0;
jit::js_JitOptions.baselineWarmUpThreshold = 0;
if (const char *str = op.getStringOption("ion-regalloc")) {
if (strcmp(str, "lsra") == 0) {
@ -6054,7 +6054,7 @@ main(int argc, char **argv, char **envp)
"On-Stack Replacement (default: on, off to disable)")
|| !op.addStringOption('\0', "ion-limit-script-size", "on/off",
"Don't compile very large scripts (default: on, off to disable)")
|| !op.addIntOption('\0', "ion-uses-before-compile", "COUNT",
|| !op.addIntOption('\0', "ion-warmup-threshold", "COUNT",
"Wait for COUNT calls or iterations before compiling "
"(default: 1000)", -1)
|| !op.addStringOption('\0', "ion-regalloc", "[mode]",
@ -6071,7 +6071,7 @@ main(int argc, char **argv, char **envp)
|| !op.addBoolOption('\0', "baseline", "Enable baseline compiler (default)")
|| !op.addBoolOption('\0', "no-baseline", "Disable baseline compiler")
|| !op.addBoolOption('\0', "baseline-eager", "Always baseline-compile methods")
|| !op.addIntOption('\0', "baseline-uses-before-compile", "COUNT",
|| !op.addIntOption('\0', "baseline-warmup-threshold", "COUNT",
"Wait for COUNT calls or iterations before baseline-compiling "
"(default: 10)", -1)
|| !op.addBoolOption('\0', "no-fpu", "Pretend CPU does not support floating-point operations "

View File

@ -2284,7 +2284,7 @@ js::ParallelTestsShouldPass(JSContext *cx)
return IsIonEnabled(cx) &&
IsBaselineEnabled(cx) &&
!js_JitOptions.eagerCompilation &&
js_JitOptions.baselineUsesBeforeCompile != 0 &&
js_JitOptions.baselineWarmUpThreshold != 0 &&
cx->runtime()->gcZeal() == 0;
}