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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_aix.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,185 @@
     1.4 +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/* Implement shared vtbl methods. */
    1.10 +
    1.11 +#include "xptcprivate.h"
    1.12 +#include "xptiprivate.h"
    1.13 +
    1.14 +#if defined(AIX)
    1.15 +
    1.16 +/*
    1.17 +        For PPC (AIX & MAC), the first 8 integral and the first 13 f.p. parameters 
    1.18 +        arrive in a separate chunk of data that has been loaded from the registers. 
    1.19 +        The args pointer has been set to the start of the parameters BEYOND the ones
    1.20 +        arriving in registers
    1.21 +*/
    1.22 +extern "C" nsresult ATTRIBUTE_USED
    1.23 +PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args, uint32_t *gprData, double *fprData)
    1.24 +{
    1.25 +    typedef struct {
    1.26 +        uint32_t hi;
    1.27 +        uint32_t lo;      // have to move 64 bit entities as 32 bit halves since
    1.28 +    } DU;               // stack slots are not guaranteed 16 byte aligned
    1.29 +
    1.30 +#define PARAM_BUFFER_COUNT     16
    1.31 +#define PARAM_GPR_COUNT         7  
    1.32 +
    1.33 +    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    1.34 +    nsXPTCMiniVariant* dispatchParams = nullptr;
    1.35 +    const nsXPTMethodInfo* info = nullptr;
    1.36 +    uint8_t paramCount;
    1.37 +    uint8_t i;
    1.38 +    nsresult result = NS_ERROR_FAILURE;
    1.39 +
    1.40 +    NS_ASSERTION(self,"no self");
    1.41 +
    1.42 +    self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
    1.43 +    NS_ASSERTION(info,"no method info");
    1.44 +
    1.45 +    paramCount = info->GetParamCount();
    1.46 +
    1.47 +    // setup variant array pointer
    1.48 +    if(paramCount > PARAM_BUFFER_COUNT)
    1.49 +        dispatchParams = new nsXPTCMiniVariant[paramCount];
    1.50 +    else
    1.51 +        dispatchParams = paramBuffer;
    1.52 +    NS_ASSERTION(dispatchParams,"no place for params");
    1.53 +
    1.54 +    uint32_t* ap = args;
    1.55 +    uint32_t iCount = 0;
    1.56 +    uint32_t fpCount = 0;
    1.57 +    for(i = 0; i < paramCount; i++)
    1.58 +    {
    1.59 +        const nsXPTParamInfo& param = info->GetParam(i);
    1.60 +        const nsXPTType& type = param.GetType();
    1.61 +        nsXPTCMiniVariant* dp = &dispatchParams[i];
    1.62 +
    1.63 +        if(param.IsOut() || !type.IsArithmetic())
    1.64 +        {
    1.65 +            if (iCount < PARAM_GPR_COUNT)
    1.66 +                dp->val.p = (void*) gprData[iCount++];
    1.67 +            else
    1.68 +                dp->val.p = (void*) *ap++;
    1.69 +            continue;
    1.70 +        }
    1.71 +        // else
    1.72 +        switch(type)
    1.73 +        {
    1.74 +        case nsXPTType::T_I8      :  if (iCount < PARAM_GPR_COUNT)
    1.75 +                                         dp->val.i8  = (int8_t) gprData[iCount++];
    1.76 +                                     else
    1.77 +                                         dp->val.i8  = (int8_t)  *ap++;
    1.78 +                                     break;
    1.79 +        case nsXPTType::T_I16     :  if (iCount < PARAM_GPR_COUNT)
    1.80 +                                         dp->val.i16  = (int16_t) gprData[iCount++];
    1.81 +                                     else
    1.82 +                                         dp->val.i16  = (int16_t)  *ap++;
    1.83 +                                     break;
    1.84 +        case nsXPTType::T_I32     :  if (iCount < PARAM_GPR_COUNT)
    1.85 +                                         dp->val.i32  = (int32_t) gprData[iCount++];
    1.86 +                                     else
    1.87 +                                         dp->val.i32  = (int32_t)  *ap++;
    1.88 +                                     break;
    1.89 +        case nsXPTType::T_I64     :  if (iCount < PARAM_GPR_COUNT)
    1.90 +                                         ((DU *)dp)->hi  = (int32_t) gprData[iCount++];
    1.91 +                                     else
    1.92 +                                         ((DU *)dp)->hi  = (int32_t)  *ap++;
    1.93 +                                     if (iCount < PARAM_GPR_COUNT)
    1.94 +                                         ((DU *)dp)->lo  = (uint32_t) gprData[iCount++];
    1.95 +                                     else
    1.96 +                                         ((DU *)dp)->lo  = (uint32_t)  *ap++;
    1.97 +                                     break;
    1.98 +        case nsXPTType::T_U8      :  if (iCount < PARAM_GPR_COUNT)
    1.99 +                                         dp->val.u8  = (uint8_t) gprData[iCount++];
   1.100 +                                     else
   1.101 +                                         dp->val.u8  = (uint8_t)  *ap++;
   1.102 +                                     break;
   1.103 +        case nsXPTType::T_U16     :  if (iCount < PARAM_GPR_COUNT)
   1.104 +                                         dp->val.u16  = (uint16_t) gprData[iCount++];
   1.105 +                                     else
   1.106 +                                         dp->val.u16  = (uint16_t)  *ap++;
   1.107 +                                     break;
   1.108 +        case nsXPTType::T_U32     :  if (iCount < PARAM_GPR_COUNT)
   1.109 +                                         dp->val.u32  = (uint32_t) gprData[iCount++];
   1.110 +                                     else
   1.111 +                                         dp->val.u32  = (uint32_t)  *ap++;
   1.112 +                                     break;
   1.113 +        case nsXPTType::T_U64     :  if (iCount < PARAM_GPR_COUNT)
   1.114 +                                         ((DU *)dp)->hi  = (uint32_t) gprData[iCount++];
   1.115 +                                     else
   1.116 +                                         ((DU *)dp)->hi  = (uint32_t)  *ap++;
   1.117 +                                     if (iCount < PARAM_GPR_COUNT)
   1.118 +                                         ((DU *)dp)->lo  = (uint32_t) gprData[iCount++];
   1.119 +                                     else
   1.120 +                                         ((DU *)dp)->lo  = (uint32_t)  *ap++;
   1.121 +                                     break;
   1.122 +        case nsXPTType::T_FLOAT   :  if (fpCount < 13) {
   1.123 +                                         dp->val.f  = (float) fprData[fpCount++];
   1.124 +                                         if (iCount < PARAM_GPR_COUNT)
   1.125 +                                             ++iCount;
   1.126 +                                         else
   1.127 +                                             ++ap;
   1.128 +                                     }
   1.129 +                                     else
   1.130 +                                         dp->val.f   = *((float*)   ap++);
   1.131 +                                     break;
   1.132 +        case nsXPTType::T_DOUBLE  :  if (fpCount < 13) {
   1.133 +                                         dp->val.d  = (double) fprData[fpCount++];
   1.134 +                                         if (iCount < PARAM_GPR_COUNT)
   1.135 +                                             ++iCount;
   1.136 +                                         else
   1.137 +                                             ++ap;
   1.138 +                                         if (iCount < PARAM_GPR_COUNT)
   1.139 +                                             ++iCount;
   1.140 +                                         else
   1.141 +                                             ++ap;
   1.142 +                                     }
   1.143 +                                     else {
   1.144 +                                         dp->val.f   = *((double*)   ap);
   1.145 +                                         ap += 2;
   1.146 +                                     }
   1.147 +                                     break;
   1.148 +        case nsXPTType::T_BOOL    :  if (iCount < PARAM_GPR_COUNT)
   1.149 +                                         dp->val.b  = (bool) gprData[iCount++];
   1.150 +                                     else
   1.151 +                                         dp->val.b  = (bool)  *ap++;
   1.152 +                                     break;
   1.153 +        case nsXPTType::T_CHAR    :  if (iCount < PARAM_GPR_COUNT)
   1.154 +                                         dp->val.c  = (char) gprData[iCount++];
   1.155 +                                     else
   1.156 +                                         dp->val.c  = (char)  *ap++;
   1.157 +                                     break;
   1.158 +        case nsXPTType::T_WCHAR   :  if (iCount < PARAM_GPR_COUNT)
   1.159 +                                         dp->val.wc  = (wchar_t) gprData[iCount++];
   1.160 +                                     else
   1.161 +                                         dp->val.wc  = (wchar_t)  *ap++;
   1.162 +                                     break;
   1.163 +        default:
   1.164 +            NS_ERROR("bad type");
   1.165 +            break;
   1.166 +        }
   1.167 +    }
   1.168 +
   1.169 +    result = self->mOuter->CallMethod((uint16_t)methodIndex,info,dispatchParams);
   1.170 +
   1.171 +    if(dispatchParams != paramBuffer)
   1.172 +        delete [] dispatchParams;
   1.173 +
   1.174 +    return result;
   1.175 +}
   1.176 +
   1.177 +#define STUB_ENTRY(n)
   1.178 +
   1.179 +#define SENTINEL_ENTRY(n) \
   1.180 +nsresult nsXPTCStubBase::Sentinel##n() \
   1.181 +{ \
   1.182 +    NS_ERROR("nsXPTCStubBase::Sentinel called"); \
   1.183 +    return NS_ERROR_NOT_IMPLEMENTED; \
   1.184 +}
   1.185 +
   1.186 +#include "xptcstubsdef.inc"
   1.187 +
   1.188 +#endif /* AIX */

mercurial