michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "jit/JitOptions.h" michael@0: michael@0: #include "jsscript.h" michael@0: michael@0: using namespace js; michael@0: using namespace js::jit; michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: JitOptions js_JitOptions; michael@0: michael@0: JitOptions::JitOptions() michael@0: { michael@0: // Whether to perform expensive graph-consistency DEBUG-only assertions. michael@0: // It can be useful to disable this to reduce DEBUG-compile time of large michael@0: // asm.js programs. michael@0: checkGraphConsistency = true; michael@0: michael@0: #ifdef CHECK_OSIPOINT_REGISTERS michael@0: // Emit extra code to verify live regs at the start of a VM call michael@0: // are not modified before its OsiPoint. michael@0: checkOsiPointRegisters = false; michael@0: #endif michael@0: michael@0: // Whether to enable extra code to perform dynamic validation of michael@0: // RangeAnalysis results. michael@0: checkRangeAnalysis = false; michael@0: michael@0: // Whether Ion should compile try-catch statements. michael@0: compileTryCatch = true; michael@0: michael@0: // Toggle whether global value numbering is globally disabled. michael@0: disableGvn = false; michael@0: michael@0: // Toggles whether loop invariant code motion is globally disabled. michael@0: disableLicm = false; michael@0: michael@0: // Toggles whether inlining is globally disabled. michael@0: disableInlining = false; michael@0: michael@0: // Toggles whether Edge Case Analysis is gobally disabled. michael@0: disableEdgeCaseAnalysis = false; michael@0: michael@0: // Toggles whether Range Analysis is globally disabled. michael@0: disableRangeAnalysis = false; michael@0: michael@0: // Toggles whether Unreachable Code Elimination is globally disabled. michael@0: disableUce = false; michael@0: michael@0: // Toggles whether Effective Address Analysis is globally disabled. michael@0: disableEaa = false; michael@0: michael@0: // Whether functions are compiled immediately. michael@0: eagerCompilation = false; michael@0: michael@0: // Force how many invocation or loop iterations are needed before compiling michael@0: // a function with the highest ionmonkey optimization level. michael@0: // (i.e. OptimizationLevel_Normal) michael@0: forceDefaultIonUsesBeforeCompile = false; michael@0: forcedDefaultIonUsesBeforeCompile = 1000; michael@0: michael@0: // Force the GVN kind to be optimistic or pessimistic instead of letting michael@0: // the optimization pass decide. michael@0: forceGvnKind = false; michael@0: forcedGvnKind = GVN_Optimistic; michael@0: michael@0: // Force the used register allocator instead of letting the michael@0: // optimization pass decide. michael@0: forceRegisterAllocator = false; michael@0: forcedRegisterAllocator = RegisterAllocator_LSRA; michael@0: michael@0: // Toggles whether large scripts are rejected. michael@0: limitScriptSize = true; michael@0: michael@0: // Toggles whether functions may be entered at loop headers. michael@0: osr = true; michael@0: michael@0: // How many invocations or loop iterations are needed before functions michael@0: // are compiled with the baseline compiler. michael@0: baselineUsesBeforeCompile = 10; michael@0: michael@0: // Number of exception bailouts (resuming into catch/finally block) before michael@0: // we invalidate and forbid Ion compilation. michael@0: exceptionBailoutThreshold = 10; michael@0: michael@0: // Number of bailouts without invalidation before we set michael@0: // JSScript::hadFrequentBailouts and invalidate. michael@0: frequentBailoutThreshold = 10; michael@0: michael@0: // How many actual arguments are accepted on the C stack. michael@0: maxStackArgs = 4096; michael@0: michael@0: // How many times we will try to enter a script via OSR before michael@0: // invalidating the script. michael@0: osrPcMismatchesBeforeRecompile = 6000; michael@0: michael@0: // The bytecode length limit for small function. michael@0: // michael@0: // The default for this was arrived at empirically via benchmarking. michael@0: // We may want to tune it further after other optimizations have gone michael@0: // in. michael@0: smallFunctionMaxBytecodeLength_ = 100; michael@0: michael@0: // How many uses of a parallel kernel before we attempt compilation. michael@0: usesBeforeCompilePar = 1; michael@0: michael@0: // Whether to profile inlined functions in Ion or not. michael@0: profileInlineFrames = false; michael@0: } michael@0: michael@0: bool michael@0: JitOptions::isSmallFunction(JSScript *script) const michael@0: { michael@0: return script->length() <= smallFunctionMaxBytecodeLength_; michael@0: } michael@0: michael@0: void michael@0: JitOptions::setEagerCompilation() michael@0: { michael@0: eagerCompilation = true; michael@0: baselineUsesBeforeCompile = 0; michael@0: forceDefaultIonUsesBeforeCompile = true; michael@0: forcedDefaultIonUsesBeforeCompile = 0; michael@0: } michael@0: michael@0: void michael@0: JitOptions::setUsesBeforeCompile(uint32_t useCount) michael@0: { michael@0: forceDefaultIonUsesBeforeCompile = true; michael@0: forcedDefaultIonUsesBeforeCompile = useCount; michael@0: michael@0: // Undo eager compilation michael@0: if (eagerCompilation && useCount != 0) { michael@0: jit::JitOptions defaultValues; michael@0: eagerCompilation = false; michael@0: baselineUsesBeforeCompile = defaultValues.baselineUsesBeforeCompile; michael@0: } michael@0: } michael@0: michael@0: void michael@0: JitOptions::resetUsesBeforeCompile() michael@0: { michael@0: forceDefaultIonUsesBeforeCompile = false; michael@0: michael@0: // Undo eager compilation michael@0: if (eagerCompilation) { michael@0: jit::JitOptions defaultValues; michael@0: eagerCompilation = false; michael@0: baselineUsesBeforeCompile = defaultValues.baselineUsesBeforeCompile; michael@0: } michael@0: } michael@0: michael@0: } // namespace jit michael@0: } // namespace js