xpcom/reflect/xptcall/src/md/unix/xptcstubs_ipf64.cpp

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
michael@0 2 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 3 *
michael@0 4 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 7
michael@0 8
michael@0 9 #include "xptcprivate.h"
michael@0 10 #include "xptiprivate.h"
michael@0 11
michael@0 12 #include <stddef.h>
michael@0 13 #include <stdlib.h>
michael@0 14 #include <stdint.h>
michael@0 15
michael@0 16 // "This code is for IA64 only"
michael@0 17
michael@0 18 /* Implement shared vtbl methods. */
michael@0 19
michael@0 20 extern "C" nsresult ATTRIBUTE_USED
michael@0 21 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
michael@0 22 uint64_t* intargs, uint64_t* floatargs, uint64_t* restargs)
michael@0 23 {
michael@0 24
michael@0 25 #define PARAM_BUFFER_COUNT 16
michael@0 26
michael@0 27 nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
michael@0 28 nsXPTCMiniVariant* dispatchParams = nullptr;
michael@0 29 const nsXPTMethodInfo* info;
michael@0 30 nsresult result = NS_ERROR_FAILURE;
michael@0 31 uint64_t* iargs = intargs;
michael@0 32 uint64_t* fargs = floatargs;
michael@0 33 uint8_t paramCount;
michael@0 34 uint8_t i;
michael@0 35
michael@0 36 NS_ASSERTION(self,"no self");
michael@0 37
michael@0 38 self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
michael@0 39 NS_ASSERTION(info,"no method info");
michael@0 40 if (! info)
michael@0 41 return NS_ERROR_UNEXPECTED;
michael@0 42
michael@0 43 paramCount = info->GetParamCount();
michael@0 44
michael@0 45 // setup variant array pointer
michael@0 46 if(paramCount > PARAM_BUFFER_COUNT)
michael@0 47 dispatchParams = new nsXPTCMiniVariant[paramCount];
michael@0 48 else
michael@0 49 dispatchParams = paramBuffer;
michael@0 50 NS_ASSERTION(dispatchParams,"no place for params");
michael@0 51 if (! dispatchParams)
michael@0 52 return NS_ERROR_OUT_OF_MEMORY;
michael@0 53
michael@0 54 for(i = 0; i < paramCount; ++i)
michael@0 55 {
michael@0 56 int isfloat = 0;
michael@0 57 const nsXPTParamInfo& param = info->GetParam(i);
michael@0 58 const nsXPTType& type = param.GetType();
michael@0 59 nsXPTCMiniVariant* dp = &dispatchParams[i];
michael@0 60
michael@0 61 if(param.IsOut() || !type.IsArithmetic())
michael@0 62 {
michael@0 63 #ifdef __LP64__
michael@0 64 /* 64 bit pointer mode */
michael@0 65 dp->val.p = (void*) *iargs;
michael@0 66 #else
michael@0 67 /* 32 bit pointer mode */
michael@0 68 uint32_t* adr = (uint32_t*) iargs;
michael@0 69 dp->val.p = (void*) (*(adr+1));
michael@0 70 #endif
michael@0 71 }
michael@0 72 else
michael@0 73 switch(type)
michael@0 74 {
michael@0 75 case nsXPTType::T_I8 : dp->val.i8 = *(iargs); break;
michael@0 76 case nsXPTType::T_I16 : dp->val.i16 = *(iargs); break;
michael@0 77 case nsXPTType::T_I32 : dp->val.i32 = *(iargs); break;
michael@0 78 case nsXPTType::T_I64 : dp->val.i64 = *(iargs); break;
michael@0 79 case nsXPTType::T_U8 : dp->val.u8 = *(iargs); break;
michael@0 80 case nsXPTType::T_U16 : dp->val.u16 = *(iargs); break;
michael@0 81 case nsXPTType::T_U32 : dp->val.u32 = *(iargs); break;
michael@0 82 case nsXPTType::T_U64 : dp->val.u64 = *(iargs); break;
michael@0 83 case nsXPTType::T_FLOAT :
michael@0 84 isfloat = 1;
michael@0 85 if (i < 7)
michael@0 86 dp->val.f = (float) *((double*) fargs); /* register */
michael@0 87 else
michael@0 88 dp->val.u32 = *(fargs); /* memory */
michael@0 89 break;
michael@0 90 case nsXPTType::T_DOUBLE :
michael@0 91 isfloat = 1;
michael@0 92 dp->val.u64 = *(fargs);
michael@0 93 break;
michael@0 94 case nsXPTType::T_BOOL : dp->val.b = *(iargs); break;
michael@0 95 case nsXPTType::T_CHAR : dp->val.c = *(iargs); break;
michael@0 96 case nsXPTType::T_WCHAR : dp->val.wc = *(iargs); break;
michael@0 97 default:
michael@0 98 NS_ERROR("bad type");
michael@0 99 break;
michael@0 100 }
michael@0 101 if (i < 7)
michael@0 102 {
michael@0 103 /* we are parsing register arguments */
michael@0 104 if (i == 6)
michael@0 105 {
michael@0 106 // run out of register arguments, move on to memory arguments
michael@0 107 iargs = restargs;
michael@0 108 fargs = restargs;
michael@0 109 }
michael@0 110 else
michael@0 111 {
michael@0 112 ++iargs; // advance one integer register slot
michael@0 113 if (isfloat) ++fargs; // advance float register slot if isfloat
michael@0 114 }
michael@0 115 }
michael@0 116 else
michael@0 117 {
michael@0 118 /* we are parsing memory arguments */
michael@0 119 ++iargs;
michael@0 120 ++fargs;
michael@0 121 }
michael@0 122 }
michael@0 123
michael@0 124 result = self->mOuter->CallMethod((uint16_t) methodIndex, info, dispatchParams);
michael@0 125
michael@0 126 if(dispatchParams != paramBuffer)
michael@0 127 delete [] dispatchParams;
michael@0 128
michael@0 129 return result;
michael@0 130 }
michael@0 131
michael@0 132 extern "C" nsresult SharedStub(uint64_t,uint64_t,uint64_t,uint64_t,
michael@0 133 uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t *);
michael@0 134
michael@0 135 /* Variable a0-a7 were put there so we can have access to the 8 input
michael@0 136 registers on Stubxyz entry */
michael@0 137
michael@0 138 #define STUB_ENTRY(n) \
michael@0 139 nsresult nsXPTCStubBase::Stub##n(uint64_t a1, \
michael@0 140 uint64_t a2,uint64_t a3,uint64_t a4,uint64_t a5,uint64_t a6,uint64_t a7, \
michael@0 141 uint64_t a8) \
michael@0 142 { uint64_t a0 = (uint64_t) this; \
michael@0 143 return SharedStub(a0,a1,a2,a3,a4,a5,a6,a7,(uint64_t) n, &a8); \
michael@0 144 }
michael@0 145
michael@0 146 #define SENTINEL_ENTRY(n) \
michael@0 147 nsresult nsXPTCStubBase::Sentinel##n() \
michael@0 148 { \
michael@0 149 NS_ERROR("nsXPTCStubBase::Sentinel called"); \
michael@0 150 return NS_ERROR_NOT_IMPLEMENTED; \
michael@0 151 }
michael@0 152
michael@0 153 #include "xptcstubsdef.inc"
michael@0 154

mercurial