xpcom/reflect/xptcall/src/md/unix/xptcinvoke_sparcv9_solaris.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/xptcinvoke_sparcv9_solaris.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     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 +
    1.11 +/* Platform specific code to invoke XPCOM methods on native objects */
    1.12 +
    1.13 +#include "xptcprivate.h"
    1.14 +
    1.15 +#if !defined(__sparc) && !defined(__sparc__)
    1.16 +#error "This code is for Sparc only"
    1.17 +#endif
    1.18 +
    1.19 +/* Prototype specifies unmangled function name */
    1.20 +extern "C" uint64_t
    1.21 +invoke_copy_to_stack(uint64_t* d, uint32_t paramCount, nsXPTCVariant* s);
    1.22 +
    1.23 +extern "C" uint64_t
    1.24 +invoke_copy_to_stack(uint64_t* d, uint32_t paramCount, nsXPTCVariant* s)
    1.25 +{
    1.26 +  /*
    1.27 +    We need to copy the parameters for this function to locals and use them
    1.28 +    from there since the parameters occupy the same stack space as the stack
    1.29 +    we're trying to populate.
    1.30 +  */
    1.31 +  uint64_t *l_d = d;
    1.32 +  nsXPTCVariant *l_s = s;
    1.33 +  uint64_t l_paramCount = paramCount;
    1.34 +  uint64_t regCount = 0;  // return the number of registers to load from the stack
    1.35 +
    1.36 +  for(uint64_t i = 0; i < l_paramCount; i++, l_d++, l_s++)
    1.37 +  {
    1.38 +    if (regCount < 5) regCount++;
    1.39 +
    1.40 +    if (l_s->IsPtrData())
    1.41 +    {
    1.42 +      *l_d = (uint64_t)l_s->ptr;
    1.43 +      continue;
    1.44 +    }
    1.45 +    switch (l_s->type)
    1.46 +    {
    1.47 +      case nsXPTType::T_I8    : *((int64_t*)l_d)     = l_s->val.i8;    break;
    1.48 +      case nsXPTType::T_I16   : *((int64_t*)l_d)     = l_s->val.i16;   break;
    1.49 +      case nsXPTType::T_I32   : *((int64_t*)l_d)     = l_s->val.i32;   break;
    1.50 +      case nsXPTType::T_I64   : *((int64_t*)l_d)     = l_s->val.i64;   break;
    1.51 +      
    1.52 +      case nsXPTType::T_U8    : *((uint64_t*)l_d)    = l_s->val.u8;    break;
    1.53 +      case nsXPTType::T_U16   : *((uint64_t*)l_d)    = l_s->val.u16;   break;
    1.54 +      case nsXPTType::T_U32   : *((uint64_t*)l_d)    = l_s->val.u32;   break;
    1.55 +      case nsXPTType::T_U64   : *((uint64_t*)l_d)    = l_s->val.u64;   break;
    1.56 +
    1.57 +      /* in the case of floats, we want to put the bits in to the
    1.58 +         64bit space right justified... floats in the parameter array on
    1.59 +         sparcv9 use odd numbered registers.. %f1, %f3, so we have to skip
    1.60 +         the space that would be occupied by %f0, %f2, etc.
    1.61 +      */
    1.62 +      case nsXPTType::T_FLOAT : *(((float*)l_d) + 1) = l_s->val.f;     break;
    1.63 +      case nsXPTType::T_DOUBLE: *((double*)l_d)      = l_s->val.d;     break;
    1.64 +      case nsXPTType::T_BOOL  : *((uint64_t*)l_d)    = l_s->val.b;     break;
    1.65 +      case nsXPTType::T_CHAR  : *((uint64_t*)l_d)    = l_s->val.c;     break;
    1.66 +      case nsXPTType::T_WCHAR : *((int64_t*)l_d)     = l_s->val.wc;    break;
    1.67 +
    1.68 +      default:
    1.69 +        // all the others are plain pointer types
    1.70 +        *((void**)l_d) = l_s->val.p;
    1.71 +        break;
    1.72 +    }
    1.73 +  }
    1.74 +  
    1.75 +  return regCount;
    1.76 +}

mercurial