js/src/jit/IonOptimizationLevels.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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 #ifndef jit_IonOptimizationLevels_h
     8 #define jit_IonOptimizationLevels_h
    10 #include "jsbytecode.h"
    11 #include "jstypes.h"
    13 #include "jit/JitOptions.h"
    14 #include "js/TypeDecls.h"
    16 namespace js {
    17 namespace jit {
    19 enum OptimizationLevel
    20 {
    21     Optimization_DontCompile,
    22     Optimization_Normal,
    23     Optimization_AsmJS,
    24     Optimization_Count
    25 };
    27 #ifdef JS_ION
    29 #ifdef DEBUG
    30 inline const char *
    31 OptimizationLevelString(OptimizationLevel level)
    32 {
    33     switch (level) {
    34       case Optimization_DontCompile:
    35         return "Optimization_DontCompile";
    36       case Optimization_Normal:
    37         return "Optimization_Normal";
    38       case Optimization_AsmJS:
    39         return "Optimization_AsmJS";
    40       default:
    41         MOZ_ASSUME_UNREACHABLE("Invalid OptimizationLevel");
    42     }
    43 }
    44 #endif
    46 class OptimizationInfo
    47 {
    48   public:
    49     OptimizationLevel level_;
    51     // Toggles whether Effective Address Analysis is performed.
    52     bool eaa_;
    54     // Toggles whether Edge Case Analysis is used.
    55     bool edgeCaseAnalysis_;
    57     // Toggles whether redundant checks get removed.
    58     bool eliminateRedundantChecks_;
    60     // Toggles whether interpreted scripts get inlined.
    61     bool inlineInterpreted_;
    63     // Toggles whether native scripts get inlined.
    64     bool inlineNative_;
    66     // Toggles whether global value numbering is used.
    67     bool gvn_;
    69     // Toggles whether global value numbering is optimistic or pessimistic.
    70     IonGvnKind gvnKind_;
    72     // Toggles whether loop invariant code motion is performed.
    73     bool licm_;
    75     // Toggles whether Unreachable Code Elimination is performed.
    76     bool uce_;
    78     // Toggles whether Range Analysis is used.
    79     bool rangeAnalysis_;
    81     // Describes which register allocator to use.
    82     IonRegisterAllocator registerAllocator_;
    84     // The maximum total bytecode size of an inline call site.
    85     uint32_t inlineMaxTotalBytecodeLength_;
    87     // The maximum bytecode length the caller may have,
    88     // before we stop inlining large functions in that caller.
    89     uint32_t inliningMaxCallerBytecodeLength_;
    91     // The maximum inlining depth.
    92     uint32_t maxInlineDepth_;
    94     // The maximum inlining depth for functions.
    95     //
    96     // Inlining small functions has almost no compiling overhead
    97     // and removes the otherwise needed call overhead.
    98     // The value is currently very low.
    99     // Actually it is only needed to make sure we don't blow out the stack.
   100     uint32_t smallFunctionMaxInlineDepth_;
   102     // How many invocations or loop iterations are needed before functions
   103     // are compiled.
   104     uint32_t usesBeforeCompile_;
   106     // How many invocations or loop iterations are needed before calls
   107     // are inlined, as a fraction of usesBeforeCompile.
   108     double usesBeforeInliningFactor_;
   110     OptimizationInfo()
   111     { }
   113     void initNormalOptimizationInfo();
   114     void initAsmjsOptimizationInfo();
   116     OptimizationLevel level() const {
   117         return level_;
   118     }
   120     bool inlineInterpreted() const {
   121         return inlineInterpreted_ && !js_JitOptions.disableInlining;
   122     }
   124     bool inlineNative() const {
   125         return inlineNative_ && !js_JitOptions.disableInlining;
   126     }
   128     uint32_t usesBeforeCompile(JSScript *script, jsbytecode *pc = nullptr) const;
   130     bool gvnEnabled() const {
   131         return gvn_ && !js_JitOptions.disableGvn;
   132     }
   134     bool licmEnabled() const {
   135         return licm_ && !js_JitOptions.disableLicm;
   136     }
   138     bool uceEnabled() const {
   139         return uce_ && !js_JitOptions.disableUce;
   140     }
   142     bool rangeAnalysisEnabled() const {
   143         return rangeAnalysis_ && !js_JitOptions.disableRangeAnalysis;
   144     }
   146     bool eaaEnabled() const {
   147         return eaa_ && !js_JitOptions.disableEaa;
   148     }
   150     bool edgeCaseAnalysisEnabled() const {
   151         return edgeCaseAnalysis_ && !js_JitOptions.disableEdgeCaseAnalysis;
   152     }
   154     bool eliminateRedundantChecksEnabled() const {
   155         return eliminateRedundantChecks_;
   156     }
   158     IonGvnKind gvnKind() const {
   159         if (!js_JitOptions.forceGvnKind)
   160             return gvnKind_;
   161         return js_JitOptions.forcedGvnKind;
   162     }
   164     IonRegisterAllocator registerAllocator() const {
   165         if (!js_JitOptions.forceRegisterAllocator)
   166             return registerAllocator_;
   167         return js_JitOptions.forcedRegisterAllocator;
   168     }
   170     uint32_t smallFunctionMaxInlineDepth() const {
   171         return smallFunctionMaxInlineDepth_;
   172     }
   174     bool isSmallFunction(JSScript *script) const;
   176     uint32_t maxInlineDepth() const {
   177         return maxInlineDepth_;
   178     }
   180     uint32_t inlineMaxTotalBytecodeLength() const {
   181         return inlineMaxTotalBytecodeLength_;
   182     }
   184     uint32_t inliningMaxCallerBytecodeLength() const {
   185         return inlineMaxTotalBytecodeLength_;
   186     }
   188     uint32_t usesBeforeInlining() const {
   189         uint32_t usesBeforeCompile = usesBeforeCompile_;
   190         if (js_JitOptions.forceDefaultIonUsesBeforeCompile)
   191             usesBeforeCompile = js_JitOptions.forcedDefaultIonUsesBeforeCompile;
   192         return usesBeforeCompile * usesBeforeInliningFactor_;
   193     }
   194 };
   196 class OptimizationInfos
   197 {
   198   private:
   199     OptimizationInfo infos_[Optimization_Count - 1];
   201   public:
   202     OptimizationInfos();
   204     const OptimizationInfo *get(OptimizationLevel level) const {
   205         JS_ASSERT(level < Optimization_Count);
   206         JS_ASSERT(level != Optimization_DontCompile);
   208         return &infos_[level - 1];
   209     }
   211     OptimizationLevel nextLevel(OptimizationLevel level) const;
   212     OptimizationLevel firstLevel() const;
   213     bool isLastLevel(OptimizationLevel level) const;
   214     OptimizationLevel levelForScript(JSScript *script, jsbytecode *pc = nullptr) const;
   215 };
   217 extern OptimizationInfos js_IonOptimizations;
   219 #endif // JS_ION
   221 } // namespace jit
   222 } // namespace js
   224 #endif /* jit_IonOptimizationLevels_h */

mercurial