js/src/jit/MIRGenerator.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_MIRGenerator_h
michael@0 8 #define jit_MIRGenerator_h
michael@0 9
michael@0 10 // This file declares the data structures used to build a control-flow graph
michael@0 11 // containing MIR.
michael@0 12
michael@0 13 #include "mozilla/Atomics.h"
michael@0 14
michael@0 15 #include <stdarg.h>
michael@0 16
michael@0 17 #include "jscntxt.h"
michael@0 18 #include "jscompartment.h"
michael@0 19
michael@0 20 #include "jit/CompileInfo.h"
michael@0 21 #include "jit/IonAllocPolicy.h"
michael@0 22 #include "jit/JitCompartment.h"
michael@0 23 #ifdef JS_ION_PERF
michael@0 24 # include "jit/PerfSpewer.h"
michael@0 25 #endif
michael@0 26 #include "jit/RegisterSets.h"
michael@0 27
michael@0 28 namespace js {
michael@0 29 namespace jit {
michael@0 30
michael@0 31 class MBasicBlock;
michael@0 32 class MIRGraph;
michael@0 33 class MStart;
michael@0 34 class OptimizationInfo;
michael@0 35
michael@0 36 class MIRGenerator
michael@0 37 {
michael@0 38 public:
michael@0 39 MIRGenerator(CompileCompartment *compartment, const JitCompileOptions &options,
michael@0 40 TempAllocator *alloc, MIRGraph *graph,
michael@0 41 CompileInfo *info, const OptimizationInfo *optimizationInfo);
michael@0 42
michael@0 43 TempAllocator &alloc() {
michael@0 44 return *alloc_;
michael@0 45 }
michael@0 46 MIRGraph &graph() {
michael@0 47 return *graph_;
michael@0 48 }
michael@0 49 bool ensureBallast() {
michael@0 50 return alloc().ensureBallast();
michael@0 51 }
michael@0 52 const JitRuntime *jitRuntime() const {
michael@0 53 return GetIonContext()->runtime->jitRuntime();
michael@0 54 }
michael@0 55 CompileInfo &info() {
michael@0 56 return *info_;
michael@0 57 }
michael@0 58 const OptimizationInfo &optimizationInfo() const {
michael@0 59 return *optimizationInfo_;
michael@0 60 }
michael@0 61
michael@0 62 template <typename T>
michael@0 63 T * allocate(size_t count = 1) {
michael@0 64 if (count & mozilla::tl::MulOverflowMask<sizeof(T)>::value)
michael@0 65 return nullptr;
michael@0 66 return reinterpret_cast<T *>(alloc().allocate(sizeof(T) * count));
michael@0 67 }
michael@0 68
michael@0 69 // Set an error state and prints a message. Returns false so errors can be
michael@0 70 // propagated up.
michael@0 71 bool abort(const char *message, ...);
michael@0 72 bool abortFmt(const char *message, va_list ap);
michael@0 73
michael@0 74 bool errored() const {
michael@0 75 return error_;
michael@0 76 }
michael@0 77
michael@0 78 bool instrumentedProfiling() {
michael@0 79 return GetIonContext()->runtime->spsProfiler().enabled();
michael@0 80 }
michael@0 81
michael@0 82 // Whether the main thread is trying to cancel this build.
michael@0 83 bool shouldCancel(const char *why) {
michael@0 84 return cancelBuild_;
michael@0 85 }
michael@0 86 void cancel() {
michael@0 87 cancelBuild_ = true;
michael@0 88 }
michael@0 89
michael@0 90 bool compilingAsmJS() const {
michael@0 91 return info_->script() == nullptr;
michael@0 92 }
michael@0 93
michael@0 94 uint32_t maxAsmJSStackArgBytes() const {
michael@0 95 JS_ASSERT(compilingAsmJS());
michael@0 96 return maxAsmJSStackArgBytes_;
michael@0 97 }
michael@0 98 uint32_t resetAsmJSMaxStackArgBytes() {
michael@0 99 JS_ASSERT(compilingAsmJS());
michael@0 100 uint32_t old = maxAsmJSStackArgBytes_;
michael@0 101 maxAsmJSStackArgBytes_ = 0;
michael@0 102 return old;
michael@0 103 }
michael@0 104 void setAsmJSMaxStackArgBytes(uint32_t n) {
michael@0 105 JS_ASSERT(compilingAsmJS());
michael@0 106 maxAsmJSStackArgBytes_ = n;
michael@0 107 }
michael@0 108 void setPerformsCall() {
michael@0 109 performsCall_ = true;
michael@0 110 }
michael@0 111 bool performsCall() const {
michael@0 112 return performsCall_;
michael@0 113 }
michael@0 114 void setPerformsAsmJSCall() {
michael@0 115 JS_ASSERT(compilingAsmJS());
michael@0 116 setPerformsCall();
michael@0 117 performsAsmJSCall_ = true;
michael@0 118 }
michael@0 119 bool performsAsmJSCall() const {
michael@0 120 JS_ASSERT(compilingAsmJS());
michael@0 121 return performsAsmJSCall_;
michael@0 122 }
michael@0 123 void noteMinAsmJSHeapLength(uint32_t len) {
michael@0 124 minAsmJSHeapLength_ = len;
michael@0 125 }
michael@0 126 uint32_t minAsmJSHeapLength() const {
michael@0 127 return minAsmJSHeapLength_;
michael@0 128 }
michael@0 129
michael@0 130 bool modifiesFrameArguments() const {
michael@0 131 return modifiesFrameArguments_;
michael@0 132 }
michael@0 133
michael@0 134 public:
michael@0 135 CompileCompartment *compartment;
michael@0 136
michael@0 137 protected:
michael@0 138 CompileInfo *info_;
michael@0 139 const OptimizationInfo *optimizationInfo_;
michael@0 140 TempAllocator *alloc_;
michael@0 141 JSFunction *fun_;
michael@0 142 uint32_t nslots_;
michael@0 143 MIRGraph *graph_;
michael@0 144 bool error_;
michael@0 145 mozilla::Atomic<bool, mozilla::Relaxed> cancelBuild_;
michael@0 146
michael@0 147 uint32_t maxAsmJSStackArgBytes_;
michael@0 148 bool performsCall_;
michael@0 149 bool performsAsmJSCall_;
michael@0 150 uint32_t minAsmJSHeapLength_;
michael@0 151
michael@0 152 // Keep track of whether frame arguments are modified during execution.
michael@0 153 // RegAlloc needs to know this as spilling values back to their register
michael@0 154 // slots is not compatible with that.
michael@0 155 bool modifiesFrameArguments_;
michael@0 156
michael@0 157 #if defined(JS_ION_PERF)
michael@0 158 AsmJSPerfSpewer asmJSPerfSpewer_;
michael@0 159
michael@0 160 public:
michael@0 161 AsmJSPerfSpewer &perfSpewer() { return asmJSPerfSpewer_; }
michael@0 162 #endif
michael@0 163
michael@0 164 public:
michael@0 165 const JitCompileOptions options;
michael@0 166 };
michael@0 167
michael@0 168 } // namespace jit
michael@0 169 } // namespace js
michael@0 170
michael@0 171 #endif /* jit_MIRGenerator_h */

mercurial