js/src/jit/BaselineCompiler.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_BaselineCompiler_h
michael@0 8 #define jit_BaselineCompiler_h
michael@0 9
michael@0 10 #ifdef JS_ION
michael@0 11
michael@0 12 #include "jit/FixedList.h"
michael@0 13 #if defined(JS_CODEGEN_X86)
michael@0 14 # include "jit/x86/BaselineCompiler-x86.h"
michael@0 15 #elif defined(JS_CODEGEN_X64)
michael@0 16 # include "jit/x64/BaselineCompiler-x64.h"
michael@0 17 #elif defined(JS_CODEGEN_ARM)
michael@0 18 # include "jit/arm/BaselineCompiler-arm.h"
michael@0 19 #elif defined(JS_CODEGEN_MIPS)
michael@0 20 # include "jit/mips/BaselineCompiler-mips.h"
michael@0 21 #else
michael@0 22 # error "Unknown architecture!"
michael@0 23 #endif
michael@0 24
michael@0 25 namespace js {
michael@0 26 namespace jit {
michael@0 27
michael@0 28 #define OPCODE_LIST(_) \
michael@0 29 _(JSOP_NOP) \
michael@0 30 _(JSOP_LABEL) \
michael@0 31 _(JSOP_POP) \
michael@0 32 _(JSOP_POPN) \
michael@0 33 _(JSOP_DUPAT) \
michael@0 34 _(JSOP_ENTERWITH) \
michael@0 35 _(JSOP_LEAVEWITH) \
michael@0 36 _(JSOP_DUP) \
michael@0 37 _(JSOP_DUP2) \
michael@0 38 _(JSOP_SWAP) \
michael@0 39 _(JSOP_PICK) \
michael@0 40 _(JSOP_GOTO) \
michael@0 41 _(JSOP_IFEQ) \
michael@0 42 _(JSOP_IFNE) \
michael@0 43 _(JSOP_AND) \
michael@0 44 _(JSOP_OR) \
michael@0 45 _(JSOP_NOT) \
michael@0 46 _(JSOP_POS) \
michael@0 47 _(JSOP_LOOPHEAD) \
michael@0 48 _(JSOP_LOOPENTRY) \
michael@0 49 _(JSOP_VOID) \
michael@0 50 _(JSOP_UNDEFINED) \
michael@0 51 _(JSOP_HOLE) \
michael@0 52 _(JSOP_NULL) \
michael@0 53 _(JSOP_THIS) \
michael@0 54 _(JSOP_TRUE) \
michael@0 55 _(JSOP_FALSE) \
michael@0 56 _(JSOP_ZERO) \
michael@0 57 _(JSOP_ONE) \
michael@0 58 _(JSOP_INT8) \
michael@0 59 _(JSOP_INT32) \
michael@0 60 _(JSOP_UINT16) \
michael@0 61 _(JSOP_UINT24) \
michael@0 62 _(JSOP_DOUBLE) \
michael@0 63 _(JSOP_STRING) \
michael@0 64 _(JSOP_OBJECT) \
michael@0 65 _(JSOP_REGEXP) \
michael@0 66 _(JSOP_LAMBDA) \
michael@0 67 _(JSOP_LAMBDA_ARROW) \
michael@0 68 _(JSOP_BITOR) \
michael@0 69 _(JSOP_BITXOR) \
michael@0 70 _(JSOP_BITAND) \
michael@0 71 _(JSOP_LSH) \
michael@0 72 _(JSOP_RSH) \
michael@0 73 _(JSOP_URSH) \
michael@0 74 _(JSOP_ADD) \
michael@0 75 _(JSOP_SUB) \
michael@0 76 _(JSOP_MUL) \
michael@0 77 _(JSOP_DIV) \
michael@0 78 _(JSOP_MOD) \
michael@0 79 _(JSOP_LT) \
michael@0 80 _(JSOP_LE) \
michael@0 81 _(JSOP_GT) \
michael@0 82 _(JSOP_GE) \
michael@0 83 _(JSOP_EQ) \
michael@0 84 _(JSOP_NE) \
michael@0 85 _(JSOP_STRICTEQ) \
michael@0 86 _(JSOP_STRICTNE) \
michael@0 87 _(JSOP_CONDSWITCH) \
michael@0 88 _(JSOP_CASE) \
michael@0 89 _(JSOP_DEFAULT) \
michael@0 90 _(JSOP_LINENO) \
michael@0 91 _(JSOP_BITNOT) \
michael@0 92 _(JSOP_NEG) \
michael@0 93 _(JSOP_NEWARRAY) \
michael@0 94 _(JSOP_INITELEM_ARRAY) \
michael@0 95 _(JSOP_NEWOBJECT) \
michael@0 96 _(JSOP_NEWINIT) \
michael@0 97 _(JSOP_INITELEM) \
michael@0 98 _(JSOP_INITELEM_GETTER) \
michael@0 99 _(JSOP_INITELEM_SETTER) \
michael@0 100 _(JSOP_MUTATEPROTO) \
michael@0 101 _(JSOP_INITPROP) \
michael@0 102 _(JSOP_INITPROP_GETTER) \
michael@0 103 _(JSOP_INITPROP_SETTER) \
michael@0 104 _(JSOP_ENDINIT) \
michael@0 105 _(JSOP_ARRAYPUSH) \
michael@0 106 _(JSOP_GETELEM) \
michael@0 107 _(JSOP_SETELEM) \
michael@0 108 _(JSOP_CALLELEM) \
michael@0 109 _(JSOP_DELELEM) \
michael@0 110 _(JSOP_IN) \
michael@0 111 _(JSOP_GETGNAME) \
michael@0 112 _(JSOP_BINDGNAME) \
michael@0 113 _(JSOP_SETGNAME) \
michael@0 114 _(JSOP_SETNAME) \
michael@0 115 _(JSOP_GETPROP) \
michael@0 116 _(JSOP_SETPROP) \
michael@0 117 _(JSOP_CALLPROP) \
michael@0 118 _(JSOP_DELPROP) \
michael@0 119 _(JSOP_LENGTH) \
michael@0 120 _(JSOP_GETXPROP) \
michael@0 121 _(JSOP_GETALIASEDVAR) \
michael@0 122 _(JSOP_SETALIASEDVAR) \
michael@0 123 _(JSOP_NAME) \
michael@0 124 _(JSOP_BINDNAME) \
michael@0 125 _(JSOP_DELNAME) \
michael@0 126 _(JSOP_GETINTRINSIC) \
michael@0 127 _(JSOP_DEFVAR) \
michael@0 128 _(JSOP_DEFCONST) \
michael@0 129 _(JSOP_SETCONST) \
michael@0 130 _(JSOP_DEFFUN) \
michael@0 131 _(JSOP_GETLOCAL) \
michael@0 132 _(JSOP_SETLOCAL) \
michael@0 133 _(JSOP_GETARG) \
michael@0 134 _(JSOP_SETARG) \
michael@0 135 _(JSOP_CALL) \
michael@0 136 _(JSOP_FUNCALL) \
michael@0 137 _(JSOP_FUNAPPLY) \
michael@0 138 _(JSOP_NEW) \
michael@0 139 _(JSOP_EVAL) \
michael@0 140 _(JSOP_IMPLICITTHIS) \
michael@0 141 _(JSOP_INSTANCEOF) \
michael@0 142 _(JSOP_TYPEOF) \
michael@0 143 _(JSOP_TYPEOFEXPR) \
michael@0 144 _(JSOP_SETCALL) \
michael@0 145 _(JSOP_THROW) \
michael@0 146 _(JSOP_TRY) \
michael@0 147 _(JSOP_FINALLY) \
michael@0 148 _(JSOP_GOSUB) \
michael@0 149 _(JSOP_RETSUB) \
michael@0 150 _(JSOP_PUSHBLOCKSCOPE) \
michael@0 151 _(JSOP_POPBLOCKSCOPE) \
michael@0 152 _(JSOP_DEBUGLEAVEBLOCK) \
michael@0 153 _(JSOP_EXCEPTION) \
michael@0 154 _(JSOP_DEBUGGER) \
michael@0 155 _(JSOP_ARGUMENTS) \
michael@0 156 _(JSOP_RUNONCE) \
michael@0 157 _(JSOP_REST) \
michael@0 158 _(JSOP_TOID) \
michael@0 159 _(JSOP_TABLESWITCH) \
michael@0 160 _(JSOP_ITER) \
michael@0 161 _(JSOP_MOREITER) \
michael@0 162 _(JSOP_ITERNEXT) \
michael@0 163 _(JSOP_ENDITER) \
michael@0 164 _(JSOP_CALLEE) \
michael@0 165 _(JSOP_SETRVAL) \
michael@0 166 _(JSOP_RETRVAL) \
michael@0 167 _(JSOP_RETURN)
michael@0 168
michael@0 169 class BaselineCompiler : public BaselineCompilerSpecific
michael@0 170 {
michael@0 171 FixedList<Label> labels_;
michael@0 172 NonAssertingLabel return_;
michael@0 173 #ifdef JSGC_GENERATIONAL
michael@0 174 NonAssertingLabel postBarrierSlot_;
michael@0 175 #endif
michael@0 176
michael@0 177 // Native code offset right before the scope chain is initialized.
michael@0 178 CodeOffsetLabel prologueOffset_;
michael@0 179
michael@0 180 // Native code offset right before the frame is popped and the method
michael@0 181 // returned from.
michael@0 182 CodeOffsetLabel epilogueOffset_;
michael@0 183
michael@0 184 // Native code offset right after debug prologue and epilogue, or
michael@0 185 // equivalent positions when debug mode is off.
michael@0 186 CodeOffsetLabel postDebugPrologueOffset_;
michael@0 187
michael@0 188 // Whether any on stack arguments are modified.
michael@0 189 bool modifiesArguments_;
michael@0 190
michael@0 191 Label *labelOf(jsbytecode *pc) {
michael@0 192 return &labels_[script->pcToOffset(pc)];
michael@0 193 }
michael@0 194
michael@0 195 // If a script has more |nslots| than this, then emit code to do an
michael@0 196 // early stack check.
michael@0 197 static const unsigned EARLY_STACK_CHECK_SLOT_COUNT = 128;
michael@0 198 bool needsEarlyStackCheck() const {
michael@0 199 return script->nslots() > EARLY_STACK_CHECK_SLOT_COUNT;
michael@0 200 }
michael@0 201
michael@0 202 public:
michael@0 203 BaselineCompiler(JSContext *cx, TempAllocator &alloc, JSScript *script);
michael@0 204 bool init();
michael@0 205
michael@0 206 MethodStatus compile();
michael@0 207
michael@0 208 private:
michael@0 209 MethodStatus emitBody();
michael@0 210
michael@0 211 bool emitPrologue();
michael@0 212 bool emitEpilogue();
michael@0 213 #ifdef JSGC_GENERATIONAL
michael@0 214 bool emitOutOfLinePostBarrierSlot();
michael@0 215 #endif
michael@0 216 bool emitIC(ICStub *stub, ICEntry::Kind kind);
michael@0 217 bool emitOpIC(ICStub *stub) {
michael@0 218 return emitIC(stub, ICEntry::Kind_Op);
michael@0 219 }
michael@0 220 bool emitNonOpIC(ICStub *stub) {
michael@0 221 return emitIC(stub, ICEntry::Kind_NonOp);
michael@0 222 }
michael@0 223
michael@0 224 bool emitStackCheck(bool earlyCheck=false);
michael@0 225 bool emitInterruptCheck();
michael@0 226 bool emitUseCountIncrement(bool allowOsr=true);
michael@0 227 bool emitArgumentTypeChecks();
michael@0 228 bool emitDebugPrologue();
michael@0 229 bool emitDebugTrap();
michael@0 230 bool emitSPSPush();
michael@0 231 void emitSPSPop();
michael@0 232
michael@0 233 bool initScopeChain();
michael@0 234
michael@0 235 void storeValue(const StackValue *source, const Address &dest,
michael@0 236 const ValueOperand &scratch);
michael@0 237
michael@0 238 #define EMIT_OP(op) bool emit_##op();
michael@0 239 OPCODE_LIST(EMIT_OP)
michael@0 240 #undef EMIT_OP
michael@0 241
michael@0 242 // JSOP_NEG, JSOP_BITNOT
michael@0 243 bool emitUnaryArith();
michael@0 244
michael@0 245 // JSOP_BITXOR, JSOP_LSH, JSOP_ADD etc.
michael@0 246 bool emitBinaryArith();
michael@0 247
michael@0 248 // Handles JSOP_LT, JSOP_GT, and friends
michael@0 249 bool emitCompare();
michael@0 250
michael@0 251 bool emitReturn();
michael@0 252
michael@0 253 bool emitToBoolean();
michael@0 254 bool emitTest(bool branchIfTrue);
michael@0 255 bool emitAndOr(bool branchIfTrue);
michael@0 256 bool emitCall();
michael@0 257
michael@0 258 bool emitInitPropGetterSetter();
michael@0 259 bool emitInitElemGetterSetter();
michael@0 260
michael@0 261 bool emitFormalArgAccess(uint32_t arg, bool get);
michael@0 262
michael@0 263 bool addPCMappingEntry(bool addIndexEntry);
michael@0 264
michael@0 265 void getScopeCoordinateObject(Register reg);
michael@0 266 Address getScopeCoordinateAddressFromObject(Register objReg, Register reg);
michael@0 267 Address getScopeCoordinateAddress(Register reg);
michael@0 268 };
michael@0 269
michael@0 270 } // namespace jit
michael@0 271 } // namespace js
michael@0 272
michael@0 273 #endif // JS_ION
michael@0 274
michael@0 275 #endif /* jit_BaselineCompiler_h */

mercurial