1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ipf64.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,154 @@ 1.4 + 1.5 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.6 + * 1.7 + * This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 + 1.12 +#include "xptcprivate.h" 1.13 +#include "xptiprivate.h" 1.14 + 1.15 +#include <stddef.h> 1.16 +#include <stdlib.h> 1.17 +#include <stdint.h> 1.18 + 1.19 +// "This code is for IA64 only" 1.20 + 1.21 +/* Implement shared vtbl methods. */ 1.22 + 1.23 +extern "C" nsresult ATTRIBUTE_USED 1.24 +PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, 1.25 + uint64_t* intargs, uint64_t* floatargs, uint64_t* restargs) 1.26 +{ 1.27 + 1.28 +#define PARAM_BUFFER_COUNT 16 1.29 + 1.30 + nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; 1.31 + nsXPTCMiniVariant* dispatchParams = nullptr; 1.32 + const nsXPTMethodInfo* info; 1.33 + nsresult result = NS_ERROR_FAILURE; 1.34 + uint64_t* iargs = intargs; 1.35 + uint64_t* fargs = floatargs; 1.36 + uint8_t paramCount; 1.37 + uint8_t i; 1.38 + 1.39 + NS_ASSERTION(self,"no self"); 1.40 + 1.41 + self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info); 1.42 + NS_ASSERTION(info,"no method info"); 1.43 + if (! info) 1.44 + return NS_ERROR_UNEXPECTED; 1.45 + 1.46 + paramCount = info->GetParamCount(); 1.47 + 1.48 + // setup variant array pointer 1.49 + if(paramCount > PARAM_BUFFER_COUNT) 1.50 + dispatchParams = new nsXPTCMiniVariant[paramCount]; 1.51 + else 1.52 + dispatchParams = paramBuffer; 1.53 + NS_ASSERTION(dispatchParams,"no place for params"); 1.54 + if (! dispatchParams) 1.55 + return NS_ERROR_OUT_OF_MEMORY; 1.56 + 1.57 + for(i = 0; i < paramCount; ++i) 1.58 + { 1.59 + int isfloat = 0; 1.60 + const nsXPTParamInfo& param = info->GetParam(i); 1.61 + const nsXPTType& type = param.GetType(); 1.62 + nsXPTCMiniVariant* dp = &dispatchParams[i]; 1.63 + 1.64 + if(param.IsOut() || !type.IsArithmetic()) 1.65 + { 1.66 +#ifdef __LP64__ 1.67 + /* 64 bit pointer mode */ 1.68 + dp->val.p = (void*) *iargs; 1.69 +#else 1.70 + /* 32 bit pointer mode */ 1.71 + uint32_t* adr = (uint32_t*) iargs; 1.72 + dp->val.p = (void*) (*(adr+1)); 1.73 +#endif 1.74 + } 1.75 + else 1.76 + switch(type) 1.77 + { 1.78 + case nsXPTType::T_I8 : dp->val.i8 = *(iargs); break; 1.79 + case nsXPTType::T_I16 : dp->val.i16 = *(iargs); break; 1.80 + case nsXPTType::T_I32 : dp->val.i32 = *(iargs); break; 1.81 + case nsXPTType::T_I64 : dp->val.i64 = *(iargs); break; 1.82 + case nsXPTType::T_U8 : dp->val.u8 = *(iargs); break; 1.83 + case nsXPTType::T_U16 : dp->val.u16 = *(iargs); break; 1.84 + case nsXPTType::T_U32 : dp->val.u32 = *(iargs); break; 1.85 + case nsXPTType::T_U64 : dp->val.u64 = *(iargs); break; 1.86 + case nsXPTType::T_FLOAT : 1.87 + isfloat = 1; 1.88 + if (i < 7) 1.89 + dp->val.f = (float) *((double*) fargs); /* register */ 1.90 + else 1.91 + dp->val.u32 = *(fargs); /* memory */ 1.92 + break; 1.93 + case nsXPTType::T_DOUBLE : 1.94 + isfloat = 1; 1.95 + dp->val.u64 = *(fargs); 1.96 + break; 1.97 + case nsXPTType::T_BOOL : dp->val.b = *(iargs); break; 1.98 + case nsXPTType::T_CHAR : dp->val.c = *(iargs); break; 1.99 + case nsXPTType::T_WCHAR : dp->val.wc = *(iargs); break; 1.100 + default: 1.101 + NS_ERROR("bad type"); 1.102 + break; 1.103 + } 1.104 + if (i < 7) 1.105 + { 1.106 + /* we are parsing register arguments */ 1.107 + if (i == 6) 1.108 + { 1.109 + // run out of register arguments, move on to memory arguments 1.110 + iargs = restargs; 1.111 + fargs = restargs; 1.112 + } 1.113 + else 1.114 + { 1.115 + ++iargs; // advance one integer register slot 1.116 + if (isfloat) ++fargs; // advance float register slot if isfloat 1.117 + } 1.118 + } 1.119 + else 1.120 + { 1.121 + /* we are parsing memory arguments */ 1.122 + ++iargs; 1.123 + ++fargs; 1.124 + } 1.125 + } 1.126 + 1.127 + result = self->mOuter->CallMethod((uint16_t) methodIndex, info, dispatchParams); 1.128 + 1.129 + if(dispatchParams != paramBuffer) 1.130 + delete [] dispatchParams; 1.131 + 1.132 + return result; 1.133 +} 1.134 + 1.135 +extern "C" nsresult SharedStub(uint64_t,uint64_t,uint64_t,uint64_t, 1.136 + uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t *); 1.137 + 1.138 +/* Variable a0-a7 were put there so we can have access to the 8 input 1.139 + registers on Stubxyz entry */ 1.140 + 1.141 +#define STUB_ENTRY(n) \ 1.142 +nsresult nsXPTCStubBase::Stub##n(uint64_t a1, \ 1.143 +uint64_t a2,uint64_t a3,uint64_t a4,uint64_t a5,uint64_t a6,uint64_t a7, \ 1.144 +uint64_t a8) \ 1.145 +{ uint64_t a0 = (uint64_t) this; \ 1.146 + return SharedStub(a0,a1,a2,a3,a4,a5,a6,a7,(uint64_t) n, &a8); \ 1.147 +} 1.148 + 1.149 +#define SENTINEL_ENTRY(n) \ 1.150 +nsresult nsXPTCStubBase::Sentinel##n() \ 1.151 +{ \ 1.152 + NS_ERROR("nsXPTCStubBase::Sentinel called"); \ 1.153 + return NS_ERROR_NOT_IMPLEMENTED; \ 1.154 +} 1.155 + 1.156 +#include "xptcstubsdef.inc" 1.157 +