xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips64.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_mips64.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,185 @@
     1.4 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     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 +#include "xptcprivate.h"
    1.10 +#include "xptiprivate.h"
    1.11 +
    1.12 +#if (_MIPS_SIM != _ABIN32)
    1.13 +#error "This code is for MIPS N32 only"
    1.14 +#endif
    1.15 +
    1.16 +/*
    1.17 + * This is for MIPS N32 ABI
    1.18 + *
    1.19 + * When we're called, the "gp" registers are stored in gprData and
    1.20 + * the "fp" registers are stored in fprData.  There are 8 regs
    1.21 + * available which correspond to the first 7 parameters of the
    1.22 + * function and the "this" pointer.  If there are additional parms,
    1.23 + * they are stored on the stack at address "args".
    1.24 + *
    1.25 + */
    1.26 +extern "C" nsresult ATTRIBUTE_USED
    1.27 +PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args,
    1.28 +                   uint64_t *gprData, double *fprData)
    1.29 +{
    1.30 +#define PARAM_BUFFER_COUNT        16
    1.31 +#define PARAM_GPR_COUNT            7
    1.32 +#define PARAM_FPR_COUNT            7
    1.33 +
    1.34 +    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    1.35 +    nsXPTCMiniVariant* dispatchParams = nullptr;
    1.36 +    const nsXPTMethodInfo* info;
    1.37 +    uint8_t paramCount;
    1.38 +    uint8_t i;
    1.39 +    nsresult result = NS_ERROR_FAILURE;
    1.40 +
    1.41 +    NS_ASSERTION(self,"no self");
    1.42 +
    1.43 +    self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
    1.44 +    NS_ASSERTION(info,"no method info");
    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 +
    1.55 +    uint64_t* ap = args;
    1.56 +    uint32_t iCount = 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:
    1.75 +            if (iCount < PARAM_GPR_COUNT)
    1.76 +                dp->val.i8  = (int8_t)gprData[iCount++];
    1.77 +            else
    1.78 +                dp->val.i8  = (int8_t)*ap++;
    1.79 +            break;
    1.80 +
    1.81 +        case nsXPTType::T_I16:
    1.82 +             if (iCount < PARAM_GPR_COUNT)
    1.83 +                 dp->val.i16  = (int16_t)gprData[iCount++];
    1.84 +             else
    1.85 +                 dp->val.i16  = (int16_t)*ap++;
    1.86 +             break;
    1.87 +
    1.88 +        case nsXPTType::T_I32:
    1.89 +             if (iCount < PARAM_GPR_COUNT)
    1.90 +                 dp->val.i32  = (int32_t)gprData[iCount++];
    1.91 +             else
    1.92 +                 dp->val.i32  = (int32_t)*ap++;
    1.93 +             break;
    1.94 +
    1.95 +        case nsXPTType::T_I64:
    1.96 +             if (iCount < PARAM_GPR_COUNT)
    1.97 +                 dp->val.i64  = (int64_t)gprData[iCount++];
    1.98 +             else
    1.99 +                 dp->val.i64  = (int64_t)*ap++;
   1.100 +             break;
   1.101 +
   1.102 +        case nsXPTType::T_U8:
   1.103 +             if (iCount < PARAM_GPR_COUNT)
   1.104 +                 dp->val.u8  = (uint8_t)gprData[iCount++];
   1.105 +             else
   1.106 +                 dp->val.u8  = (uint8_t)*ap++;
   1.107 +             break;
   1.108 +
   1.109 +        case nsXPTType::T_U16:
   1.110 +             if (iCount < PARAM_GPR_COUNT)
   1.111 +                 dp->val.u16  = (uint16_t)gprData[iCount++];
   1.112 +             else
   1.113 +                  dp->val.u16  = (uint16_t)*ap++;
   1.114 +             break;
   1.115 +
   1.116 +        case nsXPTType::T_U32:
   1.117 +             if (iCount < PARAM_GPR_COUNT)
   1.118 +                 dp->val.u32  = (uint32_t)gprData[iCount++];
   1.119 +             else
   1.120 +                 dp->val.u32  = (uint32_t)*ap++;
   1.121 +             break;
   1.122 +
   1.123 +        case nsXPTType::T_U64:
   1.124 +             if (iCount < PARAM_GPR_COUNT)
   1.125 +                 dp->val.u64  = (uint64_t)gprData[iCount++];
   1.126 +             else
   1.127 +                 dp->val.u64  = (uint64_t)*ap++;
   1.128 +             break;
   1.129 +
   1.130 +        case nsXPTType::T_FLOAT:
   1.131 +              if (iCount < PARAM_FPR_COUNT)
   1.132 +                  dp->val.f  = (double)fprData[iCount++];
   1.133 +              else
   1.134 +                  dp->val.f  = *((double*)ap++);
   1.135 +              break;
   1.136 +
   1.137 +        case nsXPTType::T_DOUBLE:
   1.138 +               if (iCount < PARAM_FPR_COUNT)
   1.139 +                   dp->val.d  = (double)fprData[iCount++];
   1.140 +               else
   1.141 +                   dp->val.d  = *((double*)ap++);
   1.142 +               break;
   1.143 +
   1.144 +        case nsXPTType::T_BOOL:
   1.145 +            if (iCount < PARAM_GPR_COUNT)
   1.146 +                dp->val.b  = (bool)gprData[iCount++];
   1.147 +            else
   1.148 +                dp->val.b  = (bool)*ap++;
   1.149 +            break;
   1.150 +
   1.151 +        case nsXPTType::T_CHAR:
   1.152 +            if (iCount < PARAM_GPR_COUNT)
   1.153 +                dp->val.c  = (char)gprData[iCount++];
   1.154 +            else
   1.155 +                dp->val.c  = (char)*ap++;
   1.156 +            break;
   1.157 +
   1.158 +        case nsXPTType::T_WCHAR:
   1.159 +            if (iCount < PARAM_GPR_COUNT)
   1.160 +                dp->val.wc  = (wchar_t)gprData[iCount++];
   1.161 +            else
   1.162 +                dp->val.wc  = (wchar_t)*ap++;
   1.163 +            break;
   1.164 +
   1.165 +        default:
   1.166 +            NS_ASSERTION(0, "bad type");
   1.167 +            break;
   1.168 +        }
   1.169 +    }
   1.170 +
   1.171 +    result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams);
   1.172 +
   1.173 +    if(dispatchParams != paramBuffer)
   1.174 +        delete [] dispatchParams;
   1.175 +
   1.176 +    return result;
   1.177 +}
   1.178 +
   1.179 +#define STUB_ENTRY(n)        /* defined in the assembly file */
   1.180 +
   1.181 +#define SENTINEL_ENTRY(n)                              \
   1.182 +nsresult nsXPTCStubBase::Sentinel##n()                 \
   1.183 +{                                                      \
   1.184 +    NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
   1.185 +    return NS_ERROR_NOT_IMPLEMENTED;                   \
   1.186 +}
   1.187 +
   1.188 +#include "xptcstubsdef.inc"

mercurial