js/src/jit/JitOptions.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit/JitOptions.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,161 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "jit/JitOptions.h"
    1.11 +
    1.12 +#include "jsscript.h"
    1.13 +
    1.14 +using namespace js;
    1.15 +using namespace js::jit;
    1.16 +
    1.17 +namespace js {
    1.18 +namespace jit {
    1.19 +
    1.20 +JitOptions js_JitOptions;
    1.21 +
    1.22 +JitOptions::JitOptions()
    1.23 +{
    1.24 +    // Whether to perform expensive graph-consistency DEBUG-only assertions.
    1.25 +    // It can be useful to disable this to reduce DEBUG-compile time of large
    1.26 +    // asm.js programs.
    1.27 +    checkGraphConsistency = true;
    1.28 +
    1.29 +#ifdef CHECK_OSIPOINT_REGISTERS
    1.30 +    // Emit extra code to verify live regs at the start of a VM call
    1.31 +    // are not modified before its OsiPoint.
    1.32 +    checkOsiPointRegisters = false;
    1.33 +#endif
    1.34 +
    1.35 +    // Whether to enable extra code to perform dynamic validation of
    1.36 +    // RangeAnalysis results.
    1.37 +    checkRangeAnalysis = false;
    1.38 +
    1.39 +    // Whether Ion should compile try-catch statements.
    1.40 +    compileTryCatch = true;
    1.41 +
    1.42 +    // Toggle whether global value numbering is globally disabled.
    1.43 +    disableGvn = false;
    1.44 +
    1.45 +    // Toggles whether loop invariant code motion is globally disabled.
    1.46 +    disableLicm = false;
    1.47 +
    1.48 +    // Toggles whether inlining is globally disabled.
    1.49 +    disableInlining = false;
    1.50 +
    1.51 +    // Toggles whether Edge Case Analysis is gobally disabled.
    1.52 +    disableEdgeCaseAnalysis = false;
    1.53 +
    1.54 +    // Toggles whether Range Analysis is globally disabled.
    1.55 +    disableRangeAnalysis = false;
    1.56 +
    1.57 +    // Toggles whether Unreachable Code Elimination is globally disabled.
    1.58 +    disableUce = false;
    1.59 +
    1.60 +    // Toggles whether Effective Address Analysis is globally disabled.
    1.61 +    disableEaa = false;
    1.62 +
    1.63 +    // Whether functions are compiled immediately.
    1.64 +    eagerCompilation = false;
    1.65 +
    1.66 +    // Force how many invocation or loop iterations are needed before compiling
    1.67 +    // a function with the highest ionmonkey optimization level.
    1.68 +    // (i.e. OptimizationLevel_Normal)
    1.69 +    forceDefaultIonUsesBeforeCompile = false;
    1.70 +    forcedDefaultIonUsesBeforeCompile = 1000;
    1.71 +
    1.72 +    // Force the GVN kind to be optimistic or pessimistic instead of letting
    1.73 +    // the optimization pass decide.
    1.74 +    forceGvnKind = false;
    1.75 +    forcedGvnKind = GVN_Optimistic;
    1.76 +
    1.77 +    // Force the used register allocator instead of letting the
    1.78 +    // optimization pass decide.
    1.79 +    forceRegisterAllocator = false;
    1.80 +    forcedRegisterAllocator = RegisterAllocator_LSRA;
    1.81 +
    1.82 +    // Toggles whether large scripts are rejected.
    1.83 +    limitScriptSize = true;
    1.84 +
    1.85 +    // Toggles whether functions may be entered at loop headers.
    1.86 +    osr = true;
    1.87 +
    1.88 +    // How many invocations or loop iterations are needed before functions
    1.89 +    // are compiled with the baseline compiler.
    1.90 +    baselineUsesBeforeCompile = 10;
    1.91 +
    1.92 +    // Number of exception bailouts (resuming into catch/finally block) before
    1.93 +    // we invalidate and forbid Ion compilation.
    1.94 +    exceptionBailoutThreshold = 10;
    1.95 +
    1.96 +    // Number of bailouts without invalidation before we set
    1.97 +    // JSScript::hadFrequentBailouts and invalidate.
    1.98 +    frequentBailoutThreshold = 10;
    1.99 +
   1.100 +    // How many actual arguments are accepted on the C stack.
   1.101 +    maxStackArgs = 4096;
   1.102 +
   1.103 +    // How many times we will try to enter a script via OSR before
   1.104 +    // invalidating the script.
   1.105 +    osrPcMismatchesBeforeRecompile = 6000;
   1.106 +
   1.107 +    // The bytecode length limit for small function.
   1.108 +    //
   1.109 +    // The default for this was arrived at empirically via benchmarking.
   1.110 +    // We may want to tune it further after other optimizations have gone
   1.111 +    // in.
   1.112 +    smallFunctionMaxBytecodeLength_ = 100;
   1.113 +
   1.114 +    // How many uses of a parallel kernel before we attempt compilation.
   1.115 +    usesBeforeCompilePar = 1;
   1.116 +
   1.117 +    // Whether to profile inlined functions in Ion or not.
   1.118 +    profileInlineFrames = false;
   1.119 +}
   1.120 +
   1.121 +bool
   1.122 +JitOptions::isSmallFunction(JSScript *script) const
   1.123 +{
   1.124 +    return script->length() <= smallFunctionMaxBytecodeLength_;
   1.125 +}
   1.126 +
   1.127 +void
   1.128 +JitOptions::setEagerCompilation()
   1.129 +{
   1.130 +    eagerCompilation = true;
   1.131 +    baselineUsesBeforeCompile = 0;
   1.132 +    forceDefaultIonUsesBeforeCompile = true;
   1.133 +    forcedDefaultIonUsesBeforeCompile = 0;
   1.134 +}
   1.135 +
   1.136 +void
   1.137 +JitOptions::setUsesBeforeCompile(uint32_t useCount)
   1.138 +{
   1.139 +    forceDefaultIonUsesBeforeCompile = true;
   1.140 +    forcedDefaultIonUsesBeforeCompile = useCount;
   1.141 +
   1.142 +    // Undo eager compilation
   1.143 +    if (eagerCompilation && useCount != 0) {
   1.144 +        jit::JitOptions defaultValues;
   1.145 +        eagerCompilation = false;
   1.146 +        baselineUsesBeforeCompile = defaultValues.baselineUsesBeforeCompile;
   1.147 +    }
   1.148 +}
   1.149 +
   1.150 +void
   1.151 +JitOptions::resetUsesBeforeCompile()
   1.152 +{
   1.153 +    forceDefaultIonUsesBeforeCompile = false;
   1.154 +
   1.155 +    // Undo eager compilation
   1.156 +    if (eagerCompilation) {
   1.157 +        jit::JitOptions defaultValues;
   1.158 +        eagerCompilation = false;
   1.159 +        baselineUsesBeforeCompile = defaultValues.baselineUsesBeforeCompile;
   1.160 +    }
   1.161 +}
   1.162 +
   1.163 +} // namespace jit
   1.164 +} // namespace js

mercurial