1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_linux_s390x.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,187 @@ 1.4 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +/* Implement shared vtbl methods. */ 1.11 + 1.12 +#include "xptcprivate.h" 1.13 +#include "xptiprivate.h" 1.14 + 1.15 +static nsresult ATTRIBUTE_USED 1.16 +PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, 1.17 + uint64_t* a_gpr, uint64_t *a_fpr, uint64_t *a_ov) 1.18 +{ 1.19 +#define PARAM_BUFFER_COUNT 16 1.20 + 1.21 + nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; 1.22 + nsXPTCMiniVariant* dispatchParams = nullptr; 1.23 + const nsXPTMethodInfo* info; 1.24 + uint8_t paramCount; 1.25 + uint8_t i; 1.26 + nsresult result = NS_ERROR_FAILURE; 1.27 + 1.28 + NS_ASSERTION(self,"no self"); 1.29 + 1.30 + self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info); 1.31 + NS_ASSERTION(info,"no info"); 1.32 + 1.33 + paramCount = info->GetParamCount(); 1.34 + 1.35 + // setup variant array pointer 1.36 + if(paramCount > PARAM_BUFFER_COUNT) 1.37 + dispatchParams = new nsXPTCMiniVariant[paramCount]; 1.38 + else 1.39 + dispatchParams = paramBuffer; 1.40 + NS_ASSERTION(dispatchParams,"no place for params"); 1.41 + 1.42 + uint32_t gpr = 1, fpr = 0; 1.43 + 1.44 + for(i = 0; i < paramCount; i++) 1.45 + { 1.46 + const nsXPTParamInfo& param = info->GetParam(i); 1.47 + const nsXPTType& type = param.GetType(); 1.48 + nsXPTCMiniVariant* dp = &dispatchParams[i]; 1.49 + 1.50 + if(param.IsOut() || !type.IsArithmetic()) 1.51 + { 1.52 + if (gpr < 5) 1.53 + dp->val.p = (void*) *a_gpr++, gpr++; 1.54 + else 1.55 + dp->val.p = (void*) *a_ov++; 1.56 + continue; 1.57 + } 1.58 + // else 1.59 + switch(type) 1.60 + { 1.61 + case nsXPTType::T_I8 : 1.62 + if (gpr < 5) 1.63 + dp->val.i8 = *((int64_t*) a_gpr), a_gpr++, gpr++; 1.64 + else 1.65 + dp->val.i8 = *((int64_t*) a_ov ), a_ov++; 1.66 + break; 1.67 + case nsXPTType::T_I16 : 1.68 + if (gpr < 5) 1.69 + dp->val.i16 = *((int64_t*) a_gpr), a_gpr++, gpr++; 1.70 + else 1.71 + dp->val.i16 = *((int64_t*) a_ov ), a_ov++; 1.72 + break; 1.73 + case nsXPTType::T_I32 : 1.74 + if (gpr < 5) 1.75 + dp->val.i32 = *((int64_t*) a_gpr), a_gpr++, gpr++; 1.76 + else 1.77 + dp->val.i32 = *((int64_t*) a_ov ), a_ov++; 1.78 + break; 1.79 + case nsXPTType::T_I64 : 1.80 + if (gpr < 5) 1.81 + dp->val.i64 = *((int64_t*) a_gpr), a_gpr++, gpr++; 1.82 + else 1.83 + dp->val.i64 = *((int64_t*) a_ov ), a_ov++; 1.84 + break; 1.85 + case nsXPTType::T_U8 : 1.86 + if (gpr < 5) 1.87 + dp->val.u8 = *((uint64_t*)a_gpr), a_gpr++, gpr++; 1.88 + else 1.89 + dp->val.u8 = *((uint64_t*)a_ov ), a_ov++; 1.90 + break; 1.91 + case nsXPTType::T_U16 : 1.92 + if (gpr < 5) 1.93 + dp->val.u16 = *((uint64_t*)a_gpr), a_gpr++, gpr++; 1.94 + else 1.95 + dp->val.u16 = *((uint64_t*)a_ov ), a_ov++; 1.96 + break; 1.97 + case nsXPTType::T_U32 : 1.98 + if (gpr < 5) 1.99 + dp->val.u32 = *((uint64_t*)a_gpr), a_gpr++, gpr++; 1.100 + else 1.101 + dp->val.u32 = *((uint64_t*)a_ov ), a_ov++; 1.102 + break; 1.103 + case nsXPTType::T_U64 : 1.104 + if (gpr < 5) 1.105 + dp->val.u64 = *((uint64_t*)a_gpr), a_gpr++, gpr++; 1.106 + else 1.107 + dp->val.u64 = *((uint64_t*)a_ov ), a_ov++; 1.108 + break; 1.109 + case nsXPTType::T_FLOAT : 1.110 + if (fpr < 4) 1.111 + dp->val.f = *((float*) a_fpr), a_fpr++, fpr++; 1.112 + else 1.113 + dp->val.f = *(((float*) a_ov )+1), a_ov++; 1.114 + break; 1.115 + case nsXPTType::T_DOUBLE : 1.116 + if (fpr < 4) 1.117 + dp->val.d = *((double*) a_fpr), a_fpr++, fpr++; 1.118 + else 1.119 + dp->val.d = *((double*) a_ov ), a_ov++; 1.120 + break; 1.121 + case nsXPTType::T_BOOL : 1.122 + if (gpr < 5) 1.123 + dp->val.b = *((uint64_t*)a_gpr), a_gpr++, gpr++; 1.124 + else 1.125 + dp->val.b = *((uint64_t*)a_ov ), a_ov++; 1.126 + break; 1.127 + case nsXPTType::T_CHAR : 1.128 + if (gpr < 5) 1.129 + dp->val.c = *((uint64_t*)a_gpr), a_gpr++, gpr++; 1.130 + else 1.131 + dp->val.c = *((uint64_t*)a_ov ), a_ov++; 1.132 + break; 1.133 + case nsXPTType::T_WCHAR : 1.134 + if (gpr < 5) 1.135 + dp->val.wc = *((uint64_t*)a_gpr), a_gpr++, gpr++; 1.136 + else 1.137 + dp->val.wc = *((uint64_t*)a_ov ), a_ov++; 1.138 + break; 1.139 + default: 1.140 + NS_ERROR("bad type"); 1.141 + break; 1.142 + } 1.143 + } 1.144 + 1.145 + result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams); 1.146 + 1.147 + if(dispatchParams != paramBuffer) 1.148 + delete [] dispatchParams; 1.149 + 1.150 + return result; 1.151 +} 1.152 + 1.153 +#define STUB_ENTRY(n) \ 1.154 +nsresult nsXPTCStubBase::Stub##n() \ 1.155 +{ \ 1.156 + uint64_t a_gpr[4]; \ 1.157 + uint64_t a_fpr[4]; \ 1.158 + uint64_t *a_ov; \ 1.159 + \ 1.160 + __asm__ __volatile__ \ 1.161 + ( \ 1.162 + "lg %0,0(15)\n\t" \ 1.163 + "aghi %0,160\n\t" \ 1.164 + "stmg 3,6,0(%5)\n\t"\ 1.165 + "std 0,%1\n\t" \ 1.166 + "std 2,%2\n\t" \ 1.167 + "std 4,%3\n\t" \ 1.168 + "std 6,%4\n\t" \ 1.169 + : "=&a" (a_ov), \ 1.170 + "=m" (a_fpr[0]), \ 1.171 + "=m" (a_fpr[1]), \ 1.172 + "=m" (a_fpr[2]), \ 1.173 + "=m" (a_fpr[3]) \ 1.174 + : "a" (a_gpr) \ 1.175 + : "memory", "cc", \ 1.176 + "3", "4", "5", "6" \ 1.177 + ); \ 1.178 + \ 1.179 + return PrepareAndDispatch(this, n, a_gpr, a_fpr, a_ov); \ 1.180 +} 1.181 + 1.182 +#define SENTINEL_ENTRY(n) \ 1.183 +nsresult nsXPTCStubBase::Sentinel##n() \ 1.184 +{ \ 1.185 + NS_ERROR("nsXPTCStubBase::Sentinel called"); \ 1.186 + return NS_ERROR_NOT_IMPLEMENTED; \ 1.187 +} 1.188 + 1.189 +#include "xptcstubsdef.inc" 1.190 +