js/src/jit/JitOptions.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=8 sts=4 et sw=4 tw=99:
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "jit/JitOptions.h"
     9 #include "jsscript.h"
    11 using namespace js;
    12 using namespace js::jit;
    14 namespace js {
    15 namespace jit {
    17 JitOptions js_JitOptions;
    19 JitOptions::JitOptions()
    20 {
    21     // Whether to perform expensive graph-consistency DEBUG-only assertions.
    22     // It can be useful to disable this to reduce DEBUG-compile time of large
    23     // asm.js programs.
    24     checkGraphConsistency = true;
    26 #ifdef CHECK_OSIPOINT_REGISTERS
    27     // Emit extra code to verify live regs at the start of a VM call
    28     // are not modified before its OsiPoint.
    29     checkOsiPointRegisters = false;
    30 #endif
    32     // Whether to enable extra code to perform dynamic validation of
    33     // RangeAnalysis results.
    34     checkRangeAnalysis = false;
    36     // Whether Ion should compile try-catch statements.
    37     compileTryCatch = true;
    39     // Toggle whether global value numbering is globally disabled.
    40     disableGvn = false;
    42     // Toggles whether loop invariant code motion is globally disabled.
    43     disableLicm = false;
    45     // Toggles whether inlining is globally disabled.
    46     disableInlining = false;
    48     // Toggles whether Edge Case Analysis is gobally disabled.
    49     disableEdgeCaseAnalysis = false;
    51     // Toggles whether Range Analysis is globally disabled.
    52     disableRangeAnalysis = false;
    54     // Toggles whether Unreachable Code Elimination is globally disabled.
    55     disableUce = false;
    57     // Toggles whether Effective Address Analysis is globally disabled.
    58     disableEaa = false;
    60     // Whether functions are compiled immediately.
    61     eagerCompilation = false;
    63     // Force how many invocation or loop iterations are needed before compiling
    64     // a function with the highest ionmonkey optimization level.
    65     // (i.e. OptimizationLevel_Normal)
    66     forceDefaultIonUsesBeforeCompile = false;
    67     forcedDefaultIonUsesBeforeCompile = 1000;
    69     // Force the GVN kind to be optimistic or pessimistic instead of letting
    70     // the optimization pass decide.
    71     forceGvnKind = false;
    72     forcedGvnKind = GVN_Optimistic;
    74     // Force the used register allocator instead of letting the
    75     // optimization pass decide.
    76     forceRegisterAllocator = false;
    77     forcedRegisterAllocator = RegisterAllocator_LSRA;
    79     // Toggles whether large scripts are rejected.
    80     limitScriptSize = true;
    82     // Toggles whether functions may be entered at loop headers.
    83     osr = true;
    85     // How many invocations or loop iterations are needed before functions
    86     // are compiled with the baseline compiler.
    87     baselineUsesBeforeCompile = 10;
    89     // Number of exception bailouts (resuming into catch/finally block) before
    90     // we invalidate and forbid Ion compilation.
    91     exceptionBailoutThreshold = 10;
    93     // Number of bailouts without invalidation before we set
    94     // JSScript::hadFrequentBailouts and invalidate.
    95     frequentBailoutThreshold = 10;
    97     // How many actual arguments are accepted on the C stack.
    98     maxStackArgs = 4096;
   100     // How many times we will try to enter a script via OSR before
   101     // invalidating the script.
   102     osrPcMismatchesBeforeRecompile = 6000;
   104     // The bytecode length limit for small function.
   105     //
   106     // The default for this was arrived at empirically via benchmarking.
   107     // We may want to tune it further after other optimizations have gone
   108     // in.
   109     smallFunctionMaxBytecodeLength_ = 100;
   111     // How many uses of a parallel kernel before we attempt compilation.
   112     usesBeforeCompilePar = 1;
   114     // Whether to profile inlined functions in Ion or not.
   115     profileInlineFrames = false;
   116 }
   118 bool
   119 JitOptions::isSmallFunction(JSScript *script) const
   120 {
   121     return script->length() <= smallFunctionMaxBytecodeLength_;
   122 }
   124 void
   125 JitOptions::setEagerCompilation()
   126 {
   127     eagerCompilation = true;
   128     baselineUsesBeforeCompile = 0;
   129     forceDefaultIonUsesBeforeCompile = true;
   130     forcedDefaultIonUsesBeforeCompile = 0;
   131 }
   133 void
   134 JitOptions::setUsesBeforeCompile(uint32_t useCount)
   135 {
   136     forceDefaultIonUsesBeforeCompile = true;
   137     forcedDefaultIonUsesBeforeCompile = useCount;
   139     // Undo eager compilation
   140     if (eagerCompilation && useCount != 0) {
   141         jit::JitOptions defaultValues;
   142         eagerCompilation = false;
   143         baselineUsesBeforeCompile = defaultValues.baselineUsesBeforeCompile;
   144     }
   145 }
   147 void
   148 JitOptions::resetUsesBeforeCompile()
   149 {
   150     forceDefaultIonUsesBeforeCompile = false;
   152     // Undo eager compilation
   153     if (eagerCompilation) {
   154         jit::JitOptions defaultValues;
   155         eagerCompilation = false;
   156         baselineUsesBeforeCompile = defaultValues.baselineUsesBeforeCompile;
   157     }
   158 }
   160 } // namespace jit
   161 } // namespace js

mercurial