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