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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* Implement shared vtbl methods. */ |
michael@0 | 7 | |
michael@0 | 8 | #include "xptcprivate.h" |
michael@0 | 9 | #include "xptiprivate.h" |
michael@0 | 10 | |
michael@0 | 11 | /* Prototype specifies unmangled function name and disables unused warning */ |
michael@0 | 12 | static nsresult |
michael@0 | 13 | PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args) |
michael@0 | 14 | __asm__("PrepareAndDispatch") ATTRIBUTE_USED; |
michael@0 | 15 | |
michael@0 | 16 | static nsresult |
michael@0 | 17 | PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args) |
michael@0 | 18 | { |
michael@0 | 19 | const uint8_t PARAM_BUFFER_COUNT = 16; |
michael@0 | 20 | const uint8_t NUM_ARG_REGS = 6-1; // -1 for "this" pointer |
michael@0 | 21 | |
michael@0 | 22 | nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; |
michael@0 | 23 | nsXPTCMiniVariant* dispatchParams = nullptr; |
michael@0 | 24 | const nsXPTMethodInfo* info; |
michael@0 | 25 | uint8_t paramCount; |
michael@0 | 26 | uint8_t i; |
michael@0 | 27 | nsresult result = NS_ERROR_FAILURE; |
michael@0 | 28 | |
michael@0 | 29 | NS_ASSERTION(self,"no self"); |
michael@0 | 30 | |
michael@0 | 31 | self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info); |
michael@0 | 32 | |
michael@0 | 33 | paramCount = info->GetParamCount(); |
michael@0 | 34 | |
michael@0 | 35 | // setup variant array pointer |
michael@0 | 36 | if(paramCount > PARAM_BUFFER_COUNT) |
michael@0 | 37 | dispatchParams = new nsXPTCMiniVariant[paramCount]; |
michael@0 | 38 | else |
michael@0 | 39 | dispatchParams = paramBuffer; |
michael@0 | 40 | |
michael@0 | 41 | NS_ASSERTION(dispatchParams,"no place for params"); |
michael@0 | 42 | if (!dispatchParams) |
michael@0 | 43 | return NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 44 | |
michael@0 | 45 | // args[0] to args[NUM_ARG_REGS] hold floating point register values |
michael@0 | 46 | uint64_t* ap = args + NUM_ARG_REGS; |
michael@0 | 47 | for(i = 0; i < paramCount; i++, ap++) |
michael@0 | 48 | { |
michael@0 | 49 | const nsXPTParamInfo& param = info->GetParam(i); |
michael@0 | 50 | const nsXPTType& type = param.GetType(); |
michael@0 | 51 | nsXPTCMiniVariant* dp = &dispatchParams[i]; |
michael@0 | 52 | |
michael@0 | 53 | if(param.IsOut() || !type.IsArithmetic()) |
michael@0 | 54 | { |
michael@0 | 55 | dp->val.p = (void*) *ap; |
michael@0 | 56 | continue; |
michael@0 | 57 | } |
michael@0 | 58 | // else |
michael@0 | 59 | switch(type) |
michael@0 | 60 | { |
michael@0 | 61 | case nsXPTType::T_I8 : dp->val.i8 = (int8_t) *ap; break; |
michael@0 | 62 | case nsXPTType::T_I16 : dp->val.i16 = (int16_t) *ap; break; |
michael@0 | 63 | case nsXPTType::T_I32 : dp->val.i32 = (int32_t) *ap; break; |
michael@0 | 64 | case nsXPTType::T_I64 : dp->val.i64 = (int64_t) *ap; break; |
michael@0 | 65 | case nsXPTType::T_U8 : dp->val.u8 = (uint8_t) *ap; break; |
michael@0 | 66 | case nsXPTType::T_U16 : dp->val.u16 = (uint16_t) *ap; break; |
michael@0 | 67 | case nsXPTType::T_U32 : dp->val.u32 = (uint32_t) *ap; break; |
michael@0 | 68 | case nsXPTType::T_U64 : dp->val.u64 = (uint64_t) *ap; break; |
michael@0 | 69 | case nsXPTType::T_FLOAT : |
michael@0 | 70 | if(i < NUM_ARG_REGS) |
michael@0 | 71 | { |
michael@0 | 72 | // floats passed via registers are stored as doubles |
michael@0 | 73 | // in the first NUM_ARG_REGS entries in args |
michael@0 | 74 | dp->val.u64 = (uint64_t) args[i]; |
michael@0 | 75 | dp->val.f = (float) dp->val.d; // convert double to float |
michael@0 | 76 | } |
michael@0 | 77 | else |
michael@0 | 78 | dp->val.u32 = (uint32_t) *ap; |
michael@0 | 79 | break; |
michael@0 | 80 | case nsXPTType::T_DOUBLE : |
michael@0 | 81 | // doubles passed via registers are also stored |
michael@0 | 82 | // in the first NUM_ARG_REGS entries in args |
michael@0 | 83 | dp->val.u64 = (i < NUM_ARG_REGS) ? args[i] : *ap; |
michael@0 | 84 | break; |
michael@0 | 85 | case nsXPTType::T_BOOL : dp->val.b = (bool) *ap; break; |
michael@0 | 86 | case nsXPTType::T_CHAR : dp->val.c = (char) *ap; break; |
michael@0 | 87 | case nsXPTType::T_WCHAR : dp->val.wc = (char16_t) *ap; break; |
michael@0 | 88 | default: |
michael@0 | 89 | NS_ERROR("bad type"); |
michael@0 | 90 | break; |
michael@0 | 91 | } |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams); |
michael@0 | 95 | |
michael@0 | 96 | if(dispatchParams != paramBuffer) |
michael@0 | 97 | delete [] dispatchParams; |
michael@0 | 98 | |
michael@0 | 99 | return result; |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | /* |
michael@0 | 103 | * SharedStub() |
michael@0 | 104 | * Collects arguments and calls PrepareAndDispatch. The "methodIndex" is |
michael@0 | 105 | * passed to this function via $1 to preserve the argument registers. |
michael@0 | 106 | */ |
michael@0 | 107 | __asm__( |
michael@0 | 108 | "#### SharedStub ####\n" |
michael@0 | 109 | ".text\n\t" |
michael@0 | 110 | ".align 5\n\t" |
michael@0 | 111 | ".ent SharedStub\n" |
michael@0 | 112 | "SharedStub:\n\t" |
michael@0 | 113 | ".frame $30,96,$26,0\n\t" |
michael@0 | 114 | ".mask 0x4000000,-96\n\t" |
michael@0 | 115 | "ldgp $29,0($27)\n" |
michael@0 | 116 | "$SharedStub..ng:\n\t" |
michael@0 | 117 | "subq $30,96,$30\n\t" |
michael@0 | 118 | "stq $26,0($30)\n\t" |
michael@0 | 119 | ".prologue 1\n\t" |
michael@0 | 120 | |
michael@0 | 121 | /* |
michael@0 | 122 | * Store arguments passed via registers to the stack. |
michael@0 | 123 | * Floating point registers are stored as doubles and converted |
michael@0 | 124 | * to floats in PrepareAndDispatch if necessary. |
michael@0 | 125 | */ |
michael@0 | 126 | "stt $f17,16($30)\n\t" /* floating point registers */ |
michael@0 | 127 | "stt $f18,24($30)\n\t" |
michael@0 | 128 | "stt $f19,32($30)\n\t" |
michael@0 | 129 | "stt $f20,40($30)\n\t" |
michael@0 | 130 | "stt $f21,48($30)\n\t" |
michael@0 | 131 | "stq $17,56($30)\n\t" /* integer registers */ |
michael@0 | 132 | "stq $18,64($30)\n\t" |
michael@0 | 133 | "stq $19,72($30)\n\t" |
michael@0 | 134 | "stq $20,80($30)\n\t" |
michael@0 | 135 | "stq $21,88($30)\n\t" |
michael@0 | 136 | |
michael@0 | 137 | /* |
michael@0 | 138 | * Call PrepareAndDispatch function. |
michael@0 | 139 | */ |
michael@0 | 140 | "bis $1,$1,$17\n\t" /* pass "methodIndex" */ |
michael@0 | 141 | "addq $30,16,$18\n\t" /* pass "args" */ |
michael@0 | 142 | "bsr $26,$PrepareAndDispatch..ng\n\t" |
michael@0 | 143 | |
michael@0 | 144 | "ldq $26,0($30)\n\t" |
michael@0 | 145 | "addq $30,96,$30\n\t" |
michael@0 | 146 | "ret $31,($26),1\n\t" |
michael@0 | 147 | ".end SharedStub" |
michael@0 | 148 | ); |
michael@0 | 149 | |
michael@0 | 150 | /* |
michael@0 | 151 | * nsresult nsXPTCStubBase::Stub##n() |
michael@0 | 152 | * Sets register $1 to "methodIndex" and jumps to SharedStub. |
michael@0 | 153 | */ |
michael@0 | 154 | #define STUB_MANGLED_ENTRY(n, symbol) \ |
michael@0 | 155 | "#### Stub"#n" ####" "\n\t" \ |
michael@0 | 156 | ".text" "\n\t" \ |
michael@0 | 157 | ".align 5" "\n\t" \ |
michael@0 | 158 | ".globl " symbol "\n\t" \ |
michael@0 | 159 | ".ent " symbol "\n" \ |
michael@0 | 160 | symbol ":" "\n\t" \ |
michael@0 | 161 | ".frame $30,0,$26,0" "\n\t" \ |
michael@0 | 162 | "ldgp $29,0($27)" "\n" \ |
michael@0 | 163 | "$" symbol "..ng:" "\n\t" \ |
michael@0 | 164 | ".prologue 1" "\n\t" \ |
michael@0 | 165 | "lda $1,"#n "\n\t" \ |
michael@0 | 166 | "br $31,$SharedStub..ng" "\n\t" \ |
michael@0 | 167 | ".end " symbol |
michael@0 | 168 | |
michael@0 | 169 | #define STUB_ENTRY(n) \ |
michael@0 | 170 | __asm__( \ |
michael@0 | 171 | ".if "#n" < 10" "\n\t" \ |
michael@0 | 172 | STUB_MANGLED_ENTRY(n, "_ZN14nsXPTCStubBase5Stub"#n"Ev") "\n\t" \ |
michael@0 | 173 | ".elseif "#n" < 100" "\n\t" \ |
michael@0 | 174 | STUB_MANGLED_ENTRY(n, "_ZN14nsXPTCStubBase6Stub"#n"Ev") "\n\t" \ |
michael@0 | 175 | ".elseif "#n" < 1000" "\n\t" \ |
michael@0 | 176 | STUB_MANGLED_ENTRY(n, "_ZN14nsXPTCStubBase7Stub"#n"Ev") "\n\t" \ |
michael@0 | 177 | ".else" "\n\t" \ |
michael@0 | 178 | ".err \"Stub"#n" >= 1000 not yet supported.\"" "\n\t" \ |
michael@0 | 179 | ".endif" \ |
michael@0 | 180 | ); |
michael@0 | 181 | |
michael@0 | 182 | #define SENTINEL_ENTRY(n) \ |
michael@0 | 183 | nsresult nsXPTCStubBase::Sentinel##n() \ |
michael@0 | 184 | { \ |
michael@0 | 185 | NS_ERROR("nsXPTCStubBase::Sentinel called"); \ |
michael@0 | 186 | return NS_ERROR_NOT_IMPLEMENTED; \ |
michael@0 | 187 | } |
michael@0 | 188 | |
michael@0 | 189 | #include "xptcstubsdef.inc" |