js/src/jit/BytecodeAnalysis.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.

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_BytecodeAnalysis_h
michael@0 8 #define jit_BytecodeAnalysis_h
michael@0 9
michael@0 10 #include "jsscript.h"
michael@0 11 #include "jit/IonAllocPolicy.h"
michael@0 12 #include "js/Vector.h"
michael@0 13
michael@0 14 namespace js {
michael@0 15 namespace jit {
michael@0 16
michael@0 17 // Basic information about bytecodes in the script. Used to help baseline compilation.
michael@0 18 struct BytecodeInfo
michael@0 19 {
michael@0 20 static const uint16_t MAX_STACK_DEPTH = 0xffffU;
michael@0 21 uint16_t stackDepth;
michael@0 22 bool initialized : 1;
michael@0 23 bool jumpTarget : 1;
michael@0 24 bool jumpFallthrough : 1;
michael@0 25 bool fallthrough : 1;
michael@0 26
michael@0 27 // If true, this is a JSOP_LOOPENTRY op inside a catch or finally block.
michael@0 28 bool loopEntryInCatchOrFinally : 1;
michael@0 29
michael@0 30 void init(unsigned depth) {
michael@0 31 JS_ASSERT(depth <= MAX_STACK_DEPTH);
michael@0 32 JS_ASSERT_IF(initialized, stackDepth == depth);
michael@0 33 initialized = true;
michael@0 34 stackDepth = depth;
michael@0 35 }
michael@0 36 };
michael@0 37
michael@0 38 class BytecodeAnalysis
michael@0 39 {
michael@0 40 JSScript *script_;
michael@0 41 Vector<BytecodeInfo, 0, IonAllocPolicy> infos_;
michael@0 42
michael@0 43 bool usesScopeChain_;
michael@0 44 bool hasTryFinally_;
michael@0 45 bool hasSetArg_;
michael@0 46
michael@0 47 public:
michael@0 48 explicit BytecodeAnalysis(TempAllocator &alloc, JSScript *script);
michael@0 49
michael@0 50 bool init(TempAllocator &alloc, GSNCache &gsn);
michael@0 51
michael@0 52 BytecodeInfo &info(jsbytecode *pc) {
michael@0 53 JS_ASSERT(infos_[script_->pcToOffset(pc)].initialized);
michael@0 54 return infos_[script_->pcToOffset(pc)];
michael@0 55 }
michael@0 56
michael@0 57 BytecodeInfo *maybeInfo(jsbytecode *pc) {
michael@0 58 if (infos_[script_->pcToOffset(pc)].initialized)
michael@0 59 return &infos_[script_->pcToOffset(pc)];
michael@0 60 return nullptr;
michael@0 61 }
michael@0 62
michael@0 63 bool usesScopeChain() const {
michael@0 64 return usesScopeChain_;
michael@0 65 }
michael@0 66
michael@0 67 bool hasTryFinally() const {
michael@0 68 return hasTryFinally_;
michael@0 69 }
michael@0 70
michael@0 71 bool hasSetArg() const {
michael@0 72 return hasSetArg_;
michael@0 73 }
michael@0 74 };
michael@0 75
michael@0 76
michael@0 77 } // namespace jit
michael@0 78 } // namespace js
michael@0 79
michael@0 80 #endif /* jit_BytecodeAnalysis_h */

mercurial