js/src/jit/Ion.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_Ion_h
michael@0 8 #define jit_Ion_h
michael@0 9
michael@0 10 #ifdef JS_ION
michael@0 11
michael@0 12 #include "mozilla/MemoryReporting.h"
michael@0 13
michael@0 14 #include "jscntxt.h"
michael@0 15 #include "jscompartment.h"
michael@0 16
michael@0 17 #include "jit/CompileInfo.h"
michael@0 18 #include "jit/CompileWrappers.h"
michael@0 19 #include "jit/JitOptions.h"
michael@0 20
michael@0 21 namespace js {
michael@0 22 namespace jit {
michael@0 23
michael@0 24 class TempAllocator;
michael@0 25
michael@0 26 enum MethodStatus
michael@0 27 {
michael@0 28 Method_Error,
michael@0 29 Method_CantCompile,
michael@0 30 Method_Skipped,
michael@0 31 Method_Compiled
michael@0 32 };
michael@0 33
michael@0 34 enum AbortReason {
michael@0 35 AbortReason_Alloc,
michael@0 36 AbortReason_Inlining,
michael@0 37 AbortReason_Disable,
michael@0 38 AbortReason_Error,
michael@0 39 AbortReason_NoAbort
michael@0 40 };
michael@0 41
michael@0 42 // An Ion context is needed to enter into either an Ion method or an instance
michael@0 43 // of the Ion compiler. It points to a temporary allocator and the active
michael@0 44 // JSContext, either of which may be nullptr, and the active compartment, which
michael@0 45 // will not be nullptr.
michael@0 46
michael@0 47 class IonContext
michael@0 48 {
michael@0 49 public:
michael@0 50 IonContext(JSContext *cx, TempAllocator *temp);
michael@0 51 IonContext(ExclusiveContext *cx, TempAllocator *temp);
michael@0 52 IonContext(CompileRuntime *rt, CompileCompartment *comp, TempAllocator *temp);
michael@0 53 IonContext(CompileRuntime *rt);
michael@0 54 ~IonContext();
michael@0 55
michael@0 56 // Running context when executing on the main thread. Not available during
michael@0 57 // compilation.
michael@0 58 JSContext *cx;
michael@0 59
michael@0 60 // Allocator for temporary memory during compilation.
michael@0 61 TempAllocator *temp;
michael@0 62
michael@0 63 // Wrappers with information about the current runtime/compartment for use
michael@0 64 // during compilation.
michael@0 65 CompileRuntime *runtime;
michael@0 66 CompileCompartment *compartment;
michael@0 67
michael@0 68 int getNextAssemblerId() {
michael@0 69 return assemblerCount_++;
michael@0 70 }
michael@0 71 private:
michael@0 72 IonContext *prev_;
michael@0 73 int assemblerCount_;
michael@0 74 };
michael@0 75
michael@0 76 // Initialize Ion statically for all JSRuntimes.
michael@0 77 bool InitializeIon();
michael@0 78
michael@0 79 // Get and set the current Ion context.
michael@0 80 IonContext *GetIonContext();
michael@0 81 IonContext *MaybeGetIonContext();
michael@0 82
michael@0 83 void SetIonContext(IonContext *ctx);
michael@0 84
michael@0 85 bool CanIonCompileScript(JSContext *cx, JSScript *script, bool osr);
michael@0 86
michael@0 87 MethodStatus CanEnterAtBranch(JSContext *cx, JSScript *script,
michael@0 88 BaselineFrame *frame, jsbytecode *pc, bool isConstructing);
michael@0 89 MethodStatus CanEnter(JSContext *cx, RunState &state);
michael@0 90 MethodStatus CompileFunctionForBaseline(JSContext *cx, HandleScript script, BaselineFrame *frame,
michael@0 91 bool isConstructing);
michael@0 92 MethodStatus CanEnterUsingFastInvoke(JSContext *cx, HandleScript script, uint32_t numActualArgs);
michael@0 93
michael@0 94 MethodStatus CanEnterInParallel(JSContext *cx, HandleScript script);
michael@0 95
michael@0 96 MethodStatus
michael@0 97 Recompile(JSContext *cx, HandleScript script, BaselineFrame *osrFrame, jsbytecode *osrPc,
michael@0 98 bool constructing);
michael@0 99
michael@0 100 enum IonExecStatus
michael@0 101 {
michael@0 102 // The method call had to be aborted due to a stack limit check. This
michael@0 103 // error indicates that Ion never attempted to clean up frames.
michael@0 104 IonExec_Aborted,
michael@0 105
michael@0 106 // The method call resulted in an error, and IonMonkey has cleaned up
michael@0 107 // frames.
michael@0 108 IonExec_Error,
michael@0 109
michael@0 110 // The method call succeeed and returned a value.
michael@0 111 IonExec_Ok
michael@0 112 };
michael@0 113
michael@0 114 static inline bool
michael@0 115 IsErrorStatus(IonExecStatus status)
michael@0 116 {
michael@0 117 return status == IonExec_Error || status == IonExec_Aborted;
michael@0 118 }
michael@0 119
michael@0 120 struct EnterJitData;
michael@0 121
michael@0 122 bool SetEnterJitData(JSContext *cx, EnterJitData &data, RunState &state, AutoValueVector &vals);
michael@0 123
michael@0 124 IonExecStatus IonCannon(JSContext *cx, RunState &state);
michael@0 125
michael@0 126 // Used to enter Ion from C++ natives like Array.map. Called from FastInvokeGuard.
michael@0 127 IonExecStatus FastInvoke(JSContext *cx, HandleFunction fun, CallArgs &args);
michael@0 128
michael@0 129 // Walk the stack and invalidate active Ion frames for the invalid scripts.
michael@0 130 void Invalidate(types::TypeZone &types, FreeOp *fop,
michael@0 131 const Vector<types::RecompileInfo> &invalid, bool resetUses = true,
michael@0 132 bool cancelOffThread = true);
michael@0 133 void Invalidate(JSContext *cx, const Vector<types::RecompileInfo> &invalid, bool resetUses = true,
michael@0 134 bool cancelOffThread = true);
michael@0 135 bool Invalidate(JSContext *cx, JSScript *script, ExecutionMode mode, bool resetUses = true,
michael@0 136 bool cancelOffThread = true);
michael@0 137 bool Invalidate(JSContext *cx, JSScript *script, bool resetUses = true,
michael@0 138 bool cancelOffThread = true);
michael@0 139
michael@0 140 void MarkValueFromIon(JSRuntime *rt, Value *vp);
michael@0 141 void MarkShapeFromIon(JSRuntime *rt, Shape **shapep);
michael@0 142
michael@0 143 void ToggleBarriers(JS::Zone *zone, bool needs);
michael@0 144
michael@0 145 class IonBuilder;
michael@0 146 class MIRGenerator;
michael@0 147 class LIRGraph;
michael@0 148 class CodeGenerator;
michael@0 149
michael@0 150 bool OptimizeMIR(MIRGenerator *mir);
michael@0 151 LIRGraph *GenerateLIR(MIRGenerator *mir);
michael@0 152 CodeGenerator *GenerateCode(MIRGenerator *mir, LIRGraph *lir);
michael@0 153 CodeGenerator *CompileBackEnd(MIRGenerator *mir);
michael@0 154
michael@0 155 void AttachFinishedCompilations(JSContext *cx);
michael@0 156 void FinishOffThreadBuilder(IonBuilder *builder);
michael@0 157 void StopAllOffThreadCompilations(JSCompartment *comp);
michael@0 158
michael@0 159 static inline bool
michael@0 160 IsIonEnabled(JSContext *cx)
michael@0 161 {
michael@0 162 return cx->runtime()->options().ion() &&
michael@0 163 cx->runtime()->options().baseline() &&
michael@0 164 cx->runtime()->jitSupportsFloatingPoint;
michael@0 165 }
michael@0 166
michael@0 167 inline bool
michael@0 168 IsIonInlinablePC(jsbytecode *pc) {
michael@0 169 // CALL, FUNCALL, FUNAPPLY, EVAL, NEW (Normal Callsites)
michael@0 170 // GETPROP, CALLPROP, and LENGTH. (Inlined Getters)
michael@0 171 // SETPROP, SETNAME, SETGNAME (Inlined Setters)
michael@0 172 return IsCallPC(pc) || IsGetPropPC(pc) || IsSetPropPC(pc);
michael@0 173 }
michael@0 174
michael@0 175 inline bool
michael@0 176 TooManyArguments(unsigned nargs)
michael@0 177 {
michael@0 178 return nargs >= SNAPSHOT_MAX_NARGS || nargs > js_JitOptions.maxStackArgs;
michael@0 179 }
michael@0 180
michael@0 181 void ForbidCompilation(JSContext *cx, JSScript *script);
michael@0 182 void ForbidCompilation(JSContext *cx, JSScript *script, ExecutionMode mode);
michael@0 183
michael@0 184 void PurgeCaches(JSScript *script);
michael@0 185 size_t SizeOfIonData(JSScript *script, mozilla::MallocSizeOf mallocSizeOf);
michael@0 186 void DestroyIonScripts(FreeOp *fop, JSScript *script);
michael@0 187 void TraceIonScripts(JSTracer* trc, JSScript *script);
michael@0 188
michael@0 189 void RequestInterruptForIonCode(JSRuntime *rt, JSRuntime::InterruptMode mode);
michael@0 190
michael@0 191 bool RematerializeAllFrames(JSContext *cx, JSCompartment *comp);
michael@0 192 bool UpdateForDebugMode(JSContext *maybecx, JSCompartment *comp,
michael@0 193 AutoDebugModeInvalidation &invalidate);
michael@0 194
michael@0 195 } // namespace jit
michael@0 196 } // namespace js
michael@0 197
michael@0 198 #endif // JS_ION
michael@0 199
michael@0 200 #endif /* jit_Ion_h */

mercurial