Sat, 03 Jan 2015 20:18:00 +0100
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.
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 | #include "jit/IonOptimizationLevels.h" |
michael@0 | 8 | |
michael@0 | 9 | #include "jsanalyze.h" |
michael@0 | 10 | #include "jsscript.h" |
michael@0 | 11 | |
michael@0 | 12 | using namespace js; |
michael@0 | 13 | using namespace js::jit; |
michael@0 | 14 | |
michael@0 | 15 | namespace js { |
michael@0 | 16 | namespace jit { |
michael@0 | 17 | |
michael@0 | 18 | OptimizationInfos js_IonOptimizations; |
michael@0 | 19 | |
michael@0 | 20 | void |
michael@0 | 21 | OptimizationInfo::initNormalOptimizationInfo() |
michael@0 | 22 | { |
michael@0 | 23 | level_ = Optimization_Normal; |
michael@0 | 24 | |
michael@0 | 25 | eaa_ = true; |
michael@0 | 26 | edgeCaseAnalysis_ = true; |
michael@0 | 27 | eliminateRedundantChecks_ = true; |
michael@0 | 28 | inlineInterpreted_ = true; |
michael@0 | 29 | inlineNative_ = true; |
michael@0 | 30 | gvn_ = true; |
michael@0 | 31 | gvnKind_ = GVN_Optimistic; |
michael@0 | 32 | licm_ = true; |
michael@0 | 33 | uce_ = true; |
michael@0 | 34 | rangeAnalysis_ = true; |
michael@0 | 35 | registerAllocator_ = RegisterAllocator_LSRA; |
michael@0 | 36 | |
michael@0 | 37 | inlineMaxTotalBytecodeLength_ = 1000; |
michael@0 | 38 | inliningMaxCallerBytecodeLength_ = 10000; |
michael@0 | 39 | maxInlineDepth_ = 3; |
michael@0 | 40 | smallFunctionMaxInlineDepth_ = 10; |
michael@0 | 41 | usesBeforeCompile_ = 1000; |
michael@0 | 42 | usesBeforeInliningFactor_ = 0.125; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | void |
michael@0 | 46 | OptimizationInfo::initAsmjsOptimizationInfo() |
michael@0 | 47 | { |
michael@0 | 48 | // The AsmJS optimization level |
michael@0 | 49 | // Disables some passes that don't work well with asmjs. |
michael@0 | 50 | |
michael@0 | 51 | // Take normal option values for not specified values. |
michael@0 | 52 | initNormalOptimizationInfo(); |
michael@0 | 53 | |
michael@0 | 54 | level_ = Optimization_AsmJS; |
michael@0 | 55 | edgeCaseAnalysis_ = false; |
michael@0 | 56 | eliminateRedundantChecks_ = false; |
michael@0 | 57 | registerAllocator_ = RegisterAllocator_Backtracking; |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | uint32_t |
michael@0 | 61 | OptimizationInfo::usesBeforeCompile(JSScript *script, jsbytecode *pc) const |
michael@0 | 62 | { |
michael@0 | 63 | JS_ASSERT(pc == nullptr || pc == script->code() || JSOp(*pc) == JSOP_LOOPENTRY); |
michael@0 | 64 | |
michael@0 | 65 | if (pc == script->code()) |
michael@0 | 66 | pc = nullptr; |
michael@0 | 67 | |
michael@0 | 68 | uint32_t minUses = usesBeforeCompile_; |
michael@0 | 69 | if (js_JitOptions.forceDefaultIonUsesBeforeCompile) |
michael@0 | 70 | minUses = js_JitOptions.forcedDefaultIonUsesBeforeCompile; |
michael@0 | 71 | |
michael@0 | 72 | // If the script is too large to compile on the main thread, we can still |
michael@0 | 73 | // compile it off thread. In these cases, increase the use count threshold |
michael@0 | 74 | // to improve the compilation's type information and hopefully avoid later |
michael@0 | 75 | // recompilation. |
michael@0 | 76 | |
michael@0 | 77 | if (script->length() > MAX_MAIN_THREAD_SCRIPT_SIZE) |
michael@0 | 78 | minUses = minUses * (script->length() / (double) MAX_MAIN_THREAD_SCRIPT_SIZE); |
michael@0 | 79 | |
michael@0 | 80 | uint32_t numLocalsAndArgs = analyze::TotalSlots(script); |
michael@0 | 81 | if (numLocalsAndArgs > MAX_MAIN_THREAD_LOCALS_AND_ARGS) |
michael@0 | 82 | minUses = minUses * (numLocalsAndArgs / (double) MAX_MAIN_THREAD_LOCALS_AND_ARGS); |
michael@0 | 83 | |
michael@0 | 84 | if (!pc || js_JitOptions.eagerCompilation) |
michael@0 | 85 | return minUses; |
michael@0 | 86 | |
michael@0 | 87 | // It's more efficient to enter outer loops, rather than inner loops, via OSR. |
michael@0 | 88 | // To accomplish this, we use a slightly higher threshold for inner loops. |
michael@0 | 89 | // Note that the loop depth is always > 0 so we will prefer non-OSR over OSR. |
michael@0 | 90 | uint32_t loopDepth = LoopEntryDepthHint(pc); |
michael@0 | 91 | JS_ASSERT(loopDepth > 0); |
michael@0 | 92 | return minUses + loopDepth * 100; |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | OptimizationInfos::OptimizationInfos() |
michael@0 | 96 | { |
michael@0 | 97 | infos_[Optimization_Normal - 1].initNormalOptimizationInfo(); |
michael@0 | 98 | infos_[Optimization_AsmJS - 1].initAsmjsOptimizationInfo(); |
michael@0 | 99 | |
michael@0 | 100 | #ifdef DEBUG |
michael@0 | 101 | OptimizationLevel level = firstLevel(); |
michael@0 | 102 | while (!isLastLevel(level)) { |
michael@0 | 103 | OptimizationLevel next = nextLevel(level); |
michael@0 | 104 | JS_ASSERT(level < next); |
michael@0 | 105 | level = next; |
michael@0 | 106 | } |
michael@0 | 107 | #endif |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | OptimizationLevel |
michael@0 | 111 | OptimizationInfos::nextLevel(OptimizationLevel level) const |
michael@0 | 112 | { |
michael@0 | 113 | JS_ASSERT(!isLastLevel(level)); |
michael@0 | 114 | switch (level) { |
michael@0 | 115 | case Optimization_DontCompile: |
michael@0 | 116 | return Optimization_Normal; |
michael@0 | 117 | default: |
michael@0 | 118 | MOZ_ASSUME_UNREACHABLE("Unknown optimization level."); |
michael@0 | 119 | } |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | OptimizationLevel |
michael@0 | 123 | OptimizationInfos::firstLevel() const |
michael@0 | 124 | { |
michael@0 | 125 | return nextLevel(Optimization_DontCompile); |
michael@0 | 126 | } |
michael@0 | 127 | |
michael@0 | 128 | bool |
michael@0 | 129 | OptimizationInfos::isLastLevel(OptimizationLevel level) const |
michael@0 | 130 | { |
michael@0 | 131 | return level == Optimization_Normal; |
michael@0 | 132 | } |
michael@0 | 133 | |
michael@0 | 134 | OptimizationLevel |
michael@0 | 135 | OptimizationInfos::levelForScript(JSScript *script, jsbytecode *pc) const |
michael@0 | 136 | { |
michael@0 | 137 | OptimizationLevel prev = Optimization_DontCompile; |
michael@0 | 138 | |
michael@0 | 139 | while (!isLastLevel(prev)) { |
michael@0 | 140 | OptimizationLevel level = nextLevel(prev); |
michael@0 | 141 | const OptimizationInfo *info = get(level); |
michael@0 | 142 | if (script->getUseCount() < info->usesBeforeCompile(script, pc)) |
michael@0 | 143 | return prev; |
michael@0 | 144 | |
michael@0 | 145 | prev = level; |
michael@0 | 146 | } |
michael@0 | 147 | |
michael@0 | 148 | return prev; |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | } // namespace jit |
michael@0 | 152 | } // namespace js |