js/src/jit/IonSpewer.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_IonSpewer_h
michael@0 8 #define jit_IonSpewer_h
michael@0 9
michael@0 10 #include "mozilla/DebugOnly.h"
michael@0 11
michael@0 12 #include <stdarg.h>
michael@0 13
michael@0 14 #include "jit/C1Spewer.h"
michael@0 15 #include "jit/JSONSpewer.h"
michael@0 16 #include "js/RootingAPI.h"
michael@0 17
michael@0 18 namespace js {
michael@0 19 namespace jit {
michael@0 20
michael@0 21 // New channels may be added below.
michael@0 22 #define IONSPEW_CHANNEL_LIST(_) \
michael@0 23 /* Used to abort SSA construction */ \
michael@0 24 _(Abort) \
michael@0 25 /* Information about compiled scripts */\
michael@0 26 _(Scripts) \
michael@0 27 /* Information during MIR building */ \
michael@0 28 _(Logs) \
michael@0 29 /* Info about failing to log script */ \
michael@0 30 _(MIR) \
michael@0 31 /* Information during alias analysis */ \
michael@0 32 _(Alias) \
michael@0 33 /* Information during GVN */ \
michael@0 34 _(GVN) \
michael@0 35 /* Information during Range analysis */ \
michael@0 36 _(Range) \
michael@0 37 /* Information during LICM */ \
michael@0 38 _(LICM) \
michael@0 39 /* Information during regalloc */ \
michael@0 40 _(RegAlloc) \
michael@0 41 /* Information during inlining */ \
michael@0 42 _(Inlining) \
michael@0 43 /* Information during codegen */ \
michael@0 44 _(Codegen) \
michael@0 45 /* Information during bailouts */ \
michael@0 46 _(Bailouts) \
michael@0 47 /* Information during OSI */ \
michael@0 48 _(Invalidate) \
michael@0 49 /* Debug info about snapshots */ \
michael@0 50 _(Snapshots) \
michael@0 51 /* Generated inline cache stubs */ \
michael@0 52 _(InlineCaches) \
michael@0 53 /* Debug info about safepoints */ \
michael@0 54 _(Safepoints) \
michael@0 55 /* Debug info about Pools*/ \
michael@0 56 _(Pools) \
michael@0 57 /* Calls to js::jit::Trace() */ \
michael@0 58 _(Trace) \
michael@0 59 /* Debug info about the I$ */ \
michael@0 60 _(CacheFlush) \
michael@0 61 \
michael@0 62 /* BASELINE COMPILER SPEW */ \
michael@0 63 \
michael@0 64 /* Aborting Script Compilation. */ \
michael@0 65 _(BaselineAbort) \
michael@0 66 /* Script Compilation. */ \
michael@0 67 _(BaselineScripts) \
michael@0 68 /* Detailed op-specific spew. */ \
michael@0 69 _(BaselineOp) \
michael@0 70 /* Inline caches. */ \
michael@0 71 _(BaselineIC) \
michael@0 72 /* Inline cache fallbacks. */ \
michael@0 73 _(BaselineICFallback) \
michael@0 74 /* OSR from Baseline => Ion. */ \
michael@0 75 _(BaselineOSR) \
michael@0 76 /* Bailouts. */ \
michael@0 77 _(BaselineBailouts) \
michael@0 78 /* Debug Mode On Stack Recompile . */ \
michael@0 79 _(BaselineDebugModeOSR)
michael@0 80
michael@0 81
michael@0 82 enum IonSpewChannel {
michael@0 83 #define IONSPEW_CHANNEL(name) IonSpew_##name,
michael@0 84 IONSPEW_CHANNEL_LIST(IONSPEW_CHANNEL)
michael@0 85 #undef IONSPEW_CHANNEL
michael@0 86 IonSpew_Terminator
michael@0 87 };
michael@0 88
michael@0 89
michael@0 90 // The IonSpewer is only available on debug builds.
michael@0 91 // None of the global functions have effect on non-debug builds.
michael@0 92 static const int NULL_ID = -1;
michael@0 93
michael@0 94 #ifdef DEBUG
michael@0 95
michael@0 96 class IonSpewer
michael@0 97 {
michael@0 98 private:
michael@0 99 MIRGraph *graph;
michael@0 100 JS::HandleScript function;
michael@0 101 C1Spewer c1Spewer;
michael@0 102 JSONSpewer jsonSpewer;
michael@0 103 bool inited_;
michael@0 104
michael@0 105 public:
michael@0 106 IonSpewer()
michael@0 107 : graph(nullptr), function(NullPtr()), inited_(false)
michael@0 108 { }
michael@0 109
michael@0 110 // File output is terminated safely upon destruction.
michael@0 111 ~IonSpewer();
michael@0 112
michael@0 113 bool init();
michael@0 114 void beginFunction(MIRGraph *graph, JS::HandleScript);
michael@0 115 bool isSpewingFunction() const;
michael@0 116 void spewPass(const char *pass);
michael@0 117 void spewPass(const char *pass, LinearScanAllocator *ra);
michael@0 118 void endFunction();
michael@0 119 };
michael@0 120
michael@0 121 void IonSpewNewFunction(MIRGraph *graph, JS::HandleScript function);
michael@0 122 void IonSpewPass(const char *pass);
michael@0 123 void IonSpewPass(const char *pass, LinearScanAllocator *ra);
michael@0 124 void IonSpewEndFunction();
michael@0 125
michael@0 126 void CheckLogging();
michael@0 127 extern FILE *IonSpewFile;
michael@0 128 void IonSpew(IonSpewChannel channel, const char *fmt, ...);
michael@0 129 void IonSpewStart(IonSpewChannel channel, const char *fmt, ...);
michael@0 130 void IonSpewCont(IonSpewChannel channel, const char *fmt, ...);
michael@0 131 void IonSpewFin(IonSpewChannel channel);
michael@0 132 void IonSpewHeader(IonSpewChannel channel);
michael@0 133 bool IonSpewEnabled(IonSpewChannel channel);
michael@0 134 void IonSpewVA(IonSpewChannel channel, const char *fmt, va_list ap);
michael@0 135 void IonSpewStartVA(IonSpewChannel channel, const char *fmt, va_list ap);
michael@0 136 void IonSpewContVA(IonSpewChannel channel, const char *fmt, va_list ap);
michael@0 137
michael@0 138 void EnableChannel(IonSpewChannel channel);
michael@0 139 void DisableChannel(IonSpewChannel channel);
michael@0 140 void EnableIonDebugLogging();
michael@0 141
michael@0 142 #else
michael@0 143
michael@0 144 static inline void IonSpewNewFunction(MIRGraph *graph, JS::HandleScript function)
michael@0 145 { }
michael@0 146 static inline void IonSpewPass(const char *pass)
michael@0 147 { }
michael@0 148 static inline void IonSpewPass(const char *pass, LinearScanAllocator *ra)
michael@0 149 { }
michael@0 150 static inline void IonSpewEndFunction()
michael@0 151 { }
michael@0 152
michael@0 153 static inline void CheckLogging()
michael@0 154 { }
michael@0 155 static FILE *const IonSpewFile = nullptr;
michael@0 156 static inline void IonSpew(IonSpewChannel, const char *fmt, ...)
michael@0 157 { }
michael@0 158 static inline void IonSpewStart(IonSpewChannel channel, const char *fmt, ...)
michael@0 159 { }
michael@0 160 static inline void IonSpewCont(IonSpewChannel channel, const char *fmt, ...)
michael@0 161 { }
michael@0 162 static inline void IonSpewFin(IonSpewChannel channel)
michael@0 163 { }
michael@0 164
michael@0 165 static inline void IonSpewHeader(IonSpewChannel channel)
michael@0 166 { }
michael@0 167 static inline bool IonSpewEnabled(IonSpewChannel channel)
michael@0 168 { return false; }
michael@0 169 static inline void IonSpewVA(IonSpewChannel channel, const char *fmt, va_list ap)
michael@0 170 { }
michael@0 171
michael@0 172 static inline void EnableChannel(IonSpewChannel)
michael@0 173 { }
michael@0 174 static inline void DisableChannel(IonSpewChannel)
michael@0 175 { }
michael@0 176 static inline void EnableIonDebugLogging()
michael@0 177 { }
michael@0 178
michael@0 179 #endif /* DEBUG */
michael@0 180
michael@0 181 template <IonSpewChannel Channel>
michael@0 182 class AutoDisableSpew
michael@0 183 {
michael@0 184 mozilla::DebugOnly<bool> enabled_;
michael@0 185
michael@0 186 public:
michael@0 187 AutoDisableSpew()
michael@0 188 : enabled_(IonSpewEnabled(Channel))
michael@0 189 {
michael@0 190 DisableChannel(Channel);
michael@0 191 }
michael@0 192
michael@0 193 ~AutoDisableSpew()
michael@0 194 {
michael@0 195 #ifdef DEBUG
michael@0 196 if (enabled_)
michael@0 197 EnableChannel(Channel);
michael@0 198 #endif
michael@0 199 }
michael@0 200 };
michael@0 201
michael@0 202 } /* ion */
michael@0 203 } /* js */
michael@0 204
michael@0 205 #endif /* jit_IonSpewer_h */

mercurial