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

mercurial