js/src/jit/IonOptimizationLevels.h

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.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef jit_IonOptimizationLevels_h
michael@0 8 #define jit_IonOptimizationLevels_h
michael@0 9
michael@0 10 #include "jsbytecode.h"
michael@0 11 #include "jstypes.h"
michael@0 12
michael@0 13 #include "jit/JitOptions.h"
michael@0 14 #include "js/TypeDecls.h"
michael@0 15
michael@0 16 namespace js {
michael@0 17 namespace jit {
michael@0 18
michael@0 19 enum OptimizationLevel
michael@0 20 {
michael@0 21 Optimization_DontCompile,
michael@0 22 Optimization_Normal,
michael@0 23 Optimization_AsmJS,
michael@0 24 Optimization_Count
michael@0 25 };
michael@0 26
michael@0 27 #ifdef JS_ION
michael@0 28
michael@0 29 #ifdef DEBUG
michael@0 30 inline const char *
michael@0 31 OptimizationLevelString(OptimizationLevel level)
michael@0 32 {
michael@0 33 switch (level) {
michael@0 34 case Optimization_DontCompile:
michael@0 35 return "Optimization_DontCompile";
michael@0 36 case Optimization_Normal:
michael@0 37 return "Optimization_Normal";
michael@0 38 case Optimization_AsmJS:
michael@0 39 return "Optimization_AsmJS";
michael@0 40 default:
michael@0 41 MOZ_ASSUME_UNREACHABLE("Invalid OptimizationLevel");
michael@0 42 }
michael@0 43 }
michael@0 44 #endif
michael@0 45
michael@0 46 class OptimizationInfo
michael@0 47 {
michael@0 48 public:
michael@0 49 OptimizationLevel level_;
michael@0 50
michael@0 51 // Toggles whether Effective Address Analysis is performed.
michael@0 52 bool eaa_;
michael@0 53
michael@0 54 // Toggles whether Edge Case Analysis is used.
michael@0 55 bool edgeCaseAnalysis_;
michael@0 56
michael@0 57 // Toggles whether redundant checks get removed.
michael@0 58 bool eliminateRedundantChecks_;
michael@0 59
michael@0 60 // Toggles whether interpreted scripts get inlined.
michael@0 61 bool inlineInterpreted_;
michael@0 62
michael@0 63 // Toggles whether native scripts get inlined.
michael@0 64 bool inlineNative_;
michael@0 65
michael@0 66 // Toggles whether global value numbering is used.
michael@0 67 bool gvn_;
michael@0 68
michael@0 69 // Toggles whether global value numbering is optimistic or pessimistic.
michael@0 70 IonGvnKind gvnKind_;
michael@0 71
michael@0 72 // Toggles whether loop invariant code motion is performed.
michael@0 73 bool licm_;
michael@0 74
michael@0 75 // Toggles whether Unreachable Code Elimination is performed.
michael@0 76 bool uce_;
michael@0 77
michael@0 78 // Toggles whether Range Analysis is used.
michael@0 79 bool rangeAnalysis_;
michael@0 80
michael@0 81 // Describes which register allocator to use.
michael@0 82 IonRegisterAllocator registerAllocator_;
michael@0 83
michael@0 84 // The maximum total bytecode size of an inline call site.
michael@0 85 uint32_t inlineMaxTotalBytecodeLength_;
michael@0 86
michael@0 87 // The maximum bytecode length the caller may have,
michael@0 88 // before we stop inlining large functions in that caller.
michael@0 89 uint32_t inliningMaxCallerBytecodeLength_;
michael@0 90
michael@0 91 // The maximum inlining depth.
michael@0 92 uint32_t maxInlineDepth_;
michael@0 93
michael@0 94 // The maximum inlining depth for functions.
michael@0 95 //
michael@0 96 // Inlining small functions has almost no compiling overhead
michael@0 97 // and removes the otherwise needed call overhead.
michael@0 98 // The value is currently very low.
michael@0 99 // Actually it is only needed to make sure we don't blow out the stack.
michael@0 100 uint32_t smallFunctionMaxInlineDepth_;
michael@0 101
michael@0 102 // How many invocations or loop iterations are needed before functions
michael@0 103 // are compiled.
michael@0 104 uint32_t usesBeforeCompile_;
michael@0 105
michael@0 106 // How many invocations or loop iterations are needed before calls
michael@0 107 // are inlined, as a fraction of usesBeforeCompile.
michael@0 108 double usesBeforeInliningFactor_;
michael@0 109
michael@0 110 OptimizationInfo()
michael@0 111 { }
michael@0 112
michael@0 113 void initNormalOptimizationInfo();
michael@0 114 void initAsmjsOptimizationInfo();
michael@0 115
michael@0 116 OptimizationLevel level() const {
michael@0 117 return level_;
michael@0 118 }
michael@0 119
michael@0 120 bool inlineInterpreted() const {
michael@0 121 return inlineInterpreted_ && !js_JitOptions.disableInlining;
michael@0 122 }
michael@0 123
michael@0 124 bool inlineNative() const {
michael@0 125 return inlineNative_ && !js_JitOptions.disableInlining;
michael@0 126 }
michael@0 127
michael@0 128 uint32_t usesBeforeCompile(JSScript *script, jsbytecode *pc = nullptr) const;
michael@0 129
michael@0 130 bool gvnEnabled() const {
michael@0 131 return gvn_ && !js_JitOptions.disableGvn;
michael@0 132 }
michael@0 133
michael@0 134 bool licmEnabled() const {
michael@0 135 return licm_ && !js_JitOptions.disableLicm;
michael@0 136 }
michael@0 137
michael@0 138 bool uceEnabled() const {
michael@0 139 return uce_ && !js_JitOptions.disableUce;
michael@0 140 }
michael@0 141
michael@0 142 bool rangeAnalysisEnabled() const {
michael@0 143 return rangeAnalysis_ && !js_JitOptions.disableRangeAnalysis;
michael@0 144 }
michael@0 145
michael@0 146 bool eaaEnabled() const {
michael@0 147 return eaa_ && !js_JitOptions.disableEaa;
michael@0 148 }
michael@0 149
michael@0 150 bool edgeCaseAnalysisEnabled() const {
michael@0 151 return edgeCaseAnalysis_ && !js_JitOptions.disableEdgeCaseAnalysis;
michael@0 152 }
michael@0 153
michael@0 154 bool eliminateRedundantChecksEnabled() const {
michael@0 155 return eliminateRedundantChecks_;
michael@0 156 }
michael@0 157
michael@0 158 IonGvnKind gvnKind() const {
michael@0 159 if (!js_JitOptions.forceGvnKind)
michael@0 160 return gvnKind_;
michael@0 161 return js_JitOptions.forcedGvnKind;
michael@0 162 }
michael@0 163
michael@0 164 IonRegisterAllocator registerAllocator() const {
michael@0 165 if (!js_JitOptions.forceRegisterAllocator)
michael@0 166 return registerAllocator_;
michael@0 167 return js_JitOptions.forcedRegisterAllocator;
michael@0 168 }
michael@0 169
michael@0 170 uint32_t smallFunctionMaxInlineDepth() const {
michael@0 171 return smallFunctionMaxInlineDepth_;
michael@0 172 }
michael@0 173
michael@0 174 bool isSmallFunction(JSScript *script) const;
michael@0 175
michael@0 176 uint32_t maxInlineDepth() const {
michael@0 177 return maxInlineDepth_;
michael@0 178 }
michael@0 179
michael@0 180 uint32_t inlineMaxTotalBytecodeLength() const {
michael@0 181 return inlineMaxTotalBytecodeLength_;
michael@0 182 }
michael@0 183
michael@0 184 uint32_t inliningMaxCallerBytecodeLength() const {
michael@0 185 return inlineMaxTotalBytecodeLength_;
michael@0 186 }
michael@0 187
michael@0 188 uint32_t usesBeforeInlining() const {
michael@0 189 uint32_t usesBeforeCompile = usesBeforeCompile_;
michael@0 190 if (js_JitOptions.forceDefaultIonUsesBeforeCompile)
michael@0 191 usesBeforeCompile = js_JitOptions.forcedDefaultIonUsesBeforeCompile;
michael@0 192 return usesBeforeCompile * usesBeforeInliningFactor_;
michael@0 193 }
michael@0 194 };
michael@0 195
michael@0 196 class OptimizationInfos
michael@0 197 {
michael@0 198 private:
michael@0 199 OptimizationInfo infos_[Optimization_Count - 1];
michael@0 200
michael@0 201 public:
michael@0 202 OptimizationInfos();
michael@0 203
michael@0 204 const OptimizationInfo *get(OptimizationLevel level) const {
michael@0 205 JS_ASSERT(level < Optimization_Count);
michael@0 206 JS_ASSERT(level != Optimization_DontCompile);
michael@0 207
michael@0 208 return &infos_[level - 1];
michael@0 209 }
michael@0 210
michael@0 211 OptimizationLevel nextLevel(OptimizationLevel level) const;
michael@0 212 OptimizationLevel firstLevel() const;
michael@0 213 bool isLastLevel(OptimizationLevel level) const;
michael@0 214 OptimizationLevel levelForScript(JSScript *script, jsbytecode *pc = nullptr) const;
michael@0 215 };
michael@0 216
michael@0 217 extern OptimizationInfos js_IonOptimizations;
michael@0 218
michael@0 219 #endif // JS_ION
michael@0 220
michael@0 221 } // namespace jit
michael@0 222 } // namespace js
michael@0 223
michael@0 224 #endif /* jit_IonOptimizationLevels_h */

mercurial