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.
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 jsopcodeinlines_h |
michael@0 | 8 | #define jsopcodeinlines_h |
michael@0 | 9 | |
michael@0 | 10 | #include "jsopcode.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "jsscript.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace js { |
michael@0 | 15 | |
michael@0 | 16 | static inline unsigned |
michael@0 | 17 | GetDefCount(JSScript *script, unsigned offset) |
michael@0 | 18 | { |
michael@0 | 19 | jsbytecode *pc = script->offsetToPC(offset); |
michael@0 | 20 | |
michael@0 | 21 | /* |
michael@0 | 22 | * Add an extra pushed value for OR/AND opcodes, so that they are included |
michael@0 | 23 | * in the pushed array of stack values for type inference. |
michael@0 | 24 | */ |
michael@0 | 25 | switch (JSOp(*pc)) { |
michael@0 | 26 | case JSOP_OR: |
michael@0 | 27 | case JSOP_AND: |
michael@0 | 28 | return 1; |
michael@0 | 29 | case JSOP_PICK: |
michael@0 | 30 | /* |
michael@0 | 31 | * Pick pops and pushes how deep it looks in the stack + 1 |
michael@0 | 32 | * items. i.e. if the stack were |a b[2] c[1] d[0]|, pick 2 |
michael@0 | 33 | * would pop b, c, and d to rearrange the stack to |a c[0] |
michael@0 | 34 | * d[1] b[2]|. |
michael@0 | 35 | */ |
michael@0 | 36 | return pc[1] + 1; |
michael@0 | 37 | default: |
michael@0 | 38 | return StackDefs(script, pc); |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | static inline unsigned |
michael@0 | 43 | GetUseCount(JSScript *script, unsigned offset) |
michael@0 | 44 | { |
michael@0 | 45 | jsbytecode *pc = script->offsetToPC(offset); |
michael@0 | 46 | |
michael@0 | 47 | if (JSOp(*pc) == JSOP_PICK) |
michael@0 | 48 | return pc[1] + 1; |
michael@0 | 49 | if (js_CodeSpec[*pc].nuses == -1) |
michael@0 | 50 | return StackUses(script, pc); |
michael@0 | 51 | return js_CodeSpec[*pc].nuses; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | static inline JSOp |
michael@0 | 55 | ReverseCompareOp(JSOp op) |
michael@0 | 56 | { |
michael@0 | 57 | switch (op) { |
michael@0 | 58 | case JSOP_GT: |
michael@0 | 59 | return JSOP_LT; |
michael@0 | 60 | case JSOP_GE: |
michael@0 | 61 | return JSOP_LE; |
michael@0 | 62 | case JSOP_LT: |
michael@0 | 63 | return JSOP_GT; |
michael@0 | 64 | case JSOP_LE: |
michael@0 | 65 | return JSOP_GE; |
michael@0 | 66 | case JSOP_EQ: |
michael@0 | 67 | case JSOP_NE: |
michael@0 | 68 | case JSOP_STRICTEQ: |
michael@0 | 69 | case JSOP_STRICTNE: |
michael@0 | 70 | return op; |
michael@0 | 71 | default: |
michael@0 | 72 | MOZ_ASSUME_UNREACHABLE("unrecognized op"); |
michael@0 | 73 | } |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | static inline JSOp |
michael@0 | 77 | NegateCompareOp(JSOp op) |
michael@0 | 78 | { |
michael@0 | 79 | switch (op) { |
michael@0 | 80 | case JSOP_GT: |
michael@0 | 81 | return JSOP_LE; |
michael@0 | 82 | case JSOP_GE: |
michael@0 | 83 | return JSOP_LT; |
michael@0 | 84 | case JSOP_LT: |
michael@0 | 85 | return JSOP_GE; |
michael@0 | 86 | case JSOP_LE: |
michael@0 | 87 | return JSOP_GT; |
michael@0 | 88 | case JSOP_EQ: |
michael@0 | 89 | return JSOP_NE; |
michael@0 | 90 | case JSOP_NE: |
michael@0 | 91 | return JSOP_EQ; |
michael@0 | 92 | case JSOP_STRICTNE: |
michael@0 | 93 | return JSOP_STRICTEQ; |
michael@0 | 94 | case JSOP_STRICTEQ: |
michael@0 | 95 | return JSOP_STRICTNE; |
michael@0 | 96 | default: |
michael@0 | 97 | MOZ_ASSUME_UNREACHABLE("unrecognized op"); |
michael@0 | 98 | } |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | class BytecodeRange { |
michael@0 | 102 | public: |
michael@0 | 103 | BytecodeRange(JSContext *cx, JSScript *script) |
michael@0 | 104 | : script(cx, script), pc(script->code()), end(pc + script->length()) |
michael@0 | 105 | {} |
michael@0 | 106 | bool empty() const { return pc == end; } |
michael@0 | 107 | jsbytecode *frontPC() const { return pc; } |
michael@0 | 108 | JSOp frontOpcode() const { return JSOp(*pc); } |
michael@0 | 109 | size_t frontOffset() const { return script->pcToOffset(pc); } |
michael@0 | 110 | void popFront() { pc += GetBytecodeLength(pc); } |
michael@0 | 111 | |
michael@0 | 112 | private: |
michael@0 | 113 | RootedScript script; |
michael@0 | 114 | jsbytecode *pc, *end; |
michael@0 | 115 | }; |
michael@0 | 116 | |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | #endif /* jsopcodeinlines_h */ |