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 | * |
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 | /* Implement shared vtbl methods. */ |
michael@0 | 8 | |
michael@0 | 9 | #include "xptcprivate.h" |
michael@0 | 10 | #include "xptiprivate.h" |
michael@0 | 11 | |
michael@0 | 12 | static nsresult ATTRIBUTE_USED |
michael@0 | 13 | PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, |
michael@0 | 14 | uint32_t* a_gpr, uint64_t *a_fpr, uint32_t *a_ov) |
michael@0 | 15 | { |
michael@0 | 16 | #define PARAM_BUFFER_COUNT 16 |
michael@0 | 17 | |
michael@0 | 18 | nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; |
michael@0 | 19 | nsXPTCMiniVariant* dispatchParams = nullptr; |
michael@0 | 20 | const nsXPTMethodInfo* info; |
michael@0 | 21 | uint8_t paramCount; |
michael@0 | 22 | uint8_t i; |
michael@0 | 23 | nsresult result = NS_ERROR_FAILURE; |
michael@0 | 24 | |
michael@0 | 25 | NS_ASSERTION(self,"no self"); |
michael@0 | 26 | |
michael@0 | 27 | self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info); |
michael@0 | 28 | NS_ASSERTION(info,"no info"); |
michael@0 | 29 | |
michael@0 | 30 | paramCount = info->GetParamCount(); |
michael@0 | 31 | |
michael@0 | 32 | // setup variant array pointer |
michael@0 | 33 | if(paramCount > PARAM_BUFFER_COUNT) |
michael@0 | 34 | dispatchParams = new nsXPTCMiniVariant[paramCount]; |
michael@0 | 35 | else |
michael@0 | 36 | dispatchParams = paramBuffer; |
michael@0 | 37 | NS_ASSERTION(dispatchParams,"no place for params"); |
michael@0 | 38 | |
michael@0 | 39 | uint32_t gpr = 1, fpr = 0; |
michael@0 | 40 | |
michael@0 | 41 | for(i = 0; i < paramCount; i++) |
michael@0 | 42 | { |
michael@0 | 43 | const nsXPTParamInfo& param = info->GetParam(i); |
michael@0 | 44 | const nsXPTType& type = param.GetType(); |
michael@0 | 45 | nsXPTCMiniVariant* dp = &dispatchParams[i]; |
michael@0 | 46 | |
michael@0 | 47 | if(param.IsOut() || !type.IsArithmetic()) |
michael@0 | 48 | { |
michael@0 | 49 | if (gpr < 5) |
michael@0 | 50 | dp->val.p = (void*) *a_gpr++, gpr++; |
michael@0 | 51 | else |
michael@0 | 52 | dp->val.p = (void*) *a_ov++; |
michael@0 | 53 | continue; |
michael@0 | 54 | } |
michael@0 | 55 | // else |
michael@0 | 56 | switch(type) |
michael@0 | 57 | { |
michael@0 | 58 | case nsXPTType::T_I8 : |
michael@0 | 59 | if (gpr < 5) |
michael@0 | 60 | dp->val.i8 = *((int32_t*) a_gpr), a_gpr++, gpr++; |
michael@0 | 61 | else |
michael@0 | 62 | dp->val.i8 = *((int32_t*) a_ov ), a_ov++; |
michael@0 | 63 | break; |
michael@0 | 64 | case nsXPTType::T_I16 : |
michael@0 | 65 | if (gpr < 5) |
michael@0 | 66 | dp->val.i16 = *((int32_t*) a_gpr), a_gpr++, gpr++; |
michael@0 | 67 | else |
michael@0 | 68 | dp->val.i16 = *((int32_t*) a_ov ), a_ov++; |
michael@0 | 69 | break; |
michael@0 | 70 | case nsXPTType::T_I32 : |
michael@0 | 71 | if (gpr < 5) |
michael@0 | 72 | dp->val.i32 = *((int32_t*) a_gpr), a_gpr++, gpr++; |
michael@0 | 73 | else |
michael@0 | 74 | dp->val.i32 = *((int32_t*) a_ov ), a_ov++; |
michael@0 | 75 | break; |
michael@0 | 76 | case nsXPTType::T_I64 : |
michael@0 | 77 | if (gpr < 4) |
michael@0 | 78 | dp->val.i64 = *((int64_t*) a_gpr), a_gpr+=2, gpr+=2; |
michael@0 | 79 | else |
michael@0 | 80 | dp->val.i64 = *((int64_t*) a_ov ), a_ov+=2, gpr=5; |
michael@0 | 81 | break; |
michael@0 | 82 | case nsXPTType::T_U8 : |
michael@0 | 83 | if (gpr < 5) |
michael@0 | 84 | dp->val.u8 = *((uint32_t*)a_gpr), a_gpr++, gpr++; |
michael@0 | 85 | else |
michael@0 | 86 | dp->val.u8 = *((uint32_t*)a_ov ), a_ov++; |
michael@0 | 87 | break; |
michael@0 | 88 | case nsXPTType::T_U16 : |
michael@0 | 89 | if (gpr < 5) |
michael@0 | 90 | dp->val.u16 = *((uint32_t*)a_gpr), a_gpr++, gpr++; |
michael@0 | 91 | else |
michael@0 | 92 | dp->val.u16 = *((uint32_t*)a_ov ), a_ov++; |
michael@0 | 93 | break; |
michael@0 | 94 | case nsXPTType::T_U32 : |
michael@0 | 95 | if (gpr < 5) |
michael@0 | 96 | dp->val.u32 = *((uint32_t*)a_gpr), a_gpr++, gpr++; |
michael@0 | 97 | else |
michael@0 | 98 | dp->val.u32 = *((uint32_t*)a_ov ), a_ov++; |
michael@0 | 99 | break; |
michael@0 | 100 | case nsXPTType::T_U64 : |
michael@0 | 101 | if (gpr < 4) |
michael@0 | 102 | dp->val.u64 = *((uint64_t*)a_gpr), a_gpr+=2, gpr+=2; |
michael@0 | 103 | else |
michael@0 | 104 | dp->val.u64 = *((uint64_t*)a_ov ), a_ov+=2, gpr=5; |
michael@0 | 105 | break; |
michael@0 | 106 | case nsXPTType::T_FLOAT : |
michael@0 | 107 | if (fpr < 2) |
michael@0 | 108 | dp->val.f = *((float*) a_fpr), a_fpr++, fpr++; |
michael@0 | 109 | else |
michael@0 | 110 | dp->val.f = *((float*) a_ov ), a_ov++; |
michael@0 | 111 | break; |
michael@0 | 112 | case nsXPTType::T_DOUBLE : |
michael@0 | 113 | if (fpr < 2) |
michael@0 | 114 | dp->val.d = *((double*) a_fpr), a_fpr++, fpr++; |
michael@0 | 115 | else |
michael@0 | 116 | dp->val.d = *((double*) a_ov ), a_ov+=2; |
michael@0 | 117 | break; |
michael@0 | 118 | case nsXPTType::T_BOOL : |
michael@0 | 119 | if (gpr < 5) |
michael@0 | 120 | dp->val.b = *((uint32_t*)a_gpr), a_gpr++, gpr++; |
michael@0 | 121 | else |
michael@0 | 122 | dp->val.b = *((uint32_t*)a_ov ), a_ov++; |
michael@0 | 123 | break; |
michael@0 | 124 | case nsXPTType::T_CHAR : |
michael@0 | 125 | if (gpr < 5) |
michael@0 | 126 | dp->val.c = *((uint32_t*)a_gpr), a_gpr++, gpr++; |
michael@0 | 127 | else |
michael@0 | 128 | dp->val.c = *((uint32_t*)a_ov ), a_ov++; |
michael@0 | 129 | break; |
michael@0 | 130 | case nsXPTType::T_WCHAR : |
michael@0 | 131 | if (gpr < 5) |
michael@0 | 132 | dp->val.wc = *((uint32_t*)a_gpr), a_gpr++, gpr++; |
michael@0 | 133 | else |
michael@0 | 134 | dp->val.wc = *((uint32_t*)a_ov ), a_ov++; |
michael@0 | 135 | break; |
michael@0 | 136 | default: |
michael@0 | 137 | NS_ERROR("bad type"); |
michael@0 | 138 | break; |
michael@0 | 139 | } |
michael@0 | 140 | } |
michael@0 | 141 | |
michael@0 | 142 | result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams); |
michael@0 | 143 | |
michael@0 | 144 | if(dispatchParams != paramBuffer) |
michael@0 | 145 | delete [] dispatchParams; |
michael@0 | 146 | |
michael@0 | 147 | return result; |
michael@0 | 148 | } |
michael@0 | 149 | |
michael@0 | 150 | #define STUB_ENTRY(n) \ |
michael@0 | 151 | nsresult nsXPTCStubBase::Stub##n() \ |
michael@0 | 152 | { \ |
michael@0 | 153 | uint32_t a_gpr[4]; \ |
michael@0 | 154 | uint64_t a_fpr[2]; \ |
michael@0 | 155 | uint32_t *a_ov; \ |
michael@0 | 156 | \ |
michael@0 | 157 | __asm__ __volatile__ \ |
michael@0 | 158 | ( \ |
michael@0 | 159 | "l %0,0(15)\n\t" \ |
michael@0 | 160 | "ahi %0,96\n\t" \ |
michael@0 | 161 | "stm 3,6,0(%3)\n\t" \ |
michael@0 | 162 | "std 0,%1\n\t" \ |
michael@0 | 163 | "std 2,%2\n\t" \ |
michael@0 | 164 | : "=&a" (a_ov), \ |
michael@0 | 165 | "=m" (a_fpr[0]), \ |
michael@0 | 166 | "=m" (a_fpr[1]) \ |
michael@0 | 167 | : "a" (a_gpr) \ |
michael@0 | 168 | : "memory", "cc", \ |
michael@0 | 169 | "3", "4", "5", "6" \ |
michael@0 | 170 | ); \ |
michael@0 | 171 | \ |
michael@0 | 172 | return PrepareAndDispatch(this, n, a_gpr, a_fpr, a_ov); \ |
michael@0 | 173 | } |
michael@0 | 174 | |
michael@0 | 175 | #define SENTINEL_ENTRY(n) \ |
michael@0 | 176 | nsresult nsXPTCStubBase::Sentinel##n() \ |
michael@0 | 177 | { \ |
michael@0 | 178 | NS_ERROR("nsXPTCStubBase::Sentinel called"); \ |
michael@0 | 179 | return NS_ERROR_NOT_IMPLEMENTED; \ |
michael@0 | 180 | } |
michael@0 | 181 | |
michael@0 | 182 | #include "xptcstubsdef.inc" |
michael@0 | 183 |