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