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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  *
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 /* Platform specific code to invoke XPCOM methods on native objects */
    10 #include "xptcprivate.h"
    12 #if !defined(__sparc) && !defined(__sparc__)
    13 #error "This code is for Sparc only"
    14 #endif
    16 /* Prototype specifies unmangled function name */
    17 extern "C" uint64_t
    18 invoke_copy_to_stack(uint64_t* d, uint32_t paramCount, nsXPTCVariant* s);
    20 extern "C" uint64_t
    21 invoke_copy_to_stack(uint64_t* d, uint32_t paramCount, nsXPTCVariant* s)
    22 {
    23   /*
    24     We need to copy the parameters for this function to locals and use them
    25     from there since the parameters occupy the same stack space as the stack
    26     we're trying to populate.
    27   */
    28   uint64_t *l_d = d;
    29   nsXPTCVariant *l_s = s;
    30   uint64_t l_paramCount = paramCount;
    31   uint64_t regCount = 0;  // return the number of registers to load from the stack
    33   for(uint64_t i = 0; i < l_paramCount; i++, l_d++, l_s++)
    34   {
    35     if (regCount < 5) regCount++;
    37     if (l_s->IsPtrData())
    38     {
    39       *l_d = (uint64_t)l_s->ptr;
    40       continue;
    41     }
    42     switch (l_s->type)
    43     {
    44       case nsXPTType::T_I8    : *((int64_t*)l_d)     = l_s->val.i8;    break;
    45       case nsXPTType::T_I16   : *((int64_t*)l_d)     = l_s->val.i16;   break;
    46       case nsXPTType::T_I32   : *((int64_t*)l_d)     = l_s->val.i32;   break;
    47       case nsXPTType::T_I64   : *((int64_t*)l_d)     = l_s->val.i64;   break;
    49       case nsXPTType::T_U8    : *((uint64_t*)l_d)    = l_s->val.u8;    break;
    50       case nsXPTType::T_U16   : *((uint64_t*)l_d)    = l_s->val.u16;   break;
    51       case nsXPTType::T_U32   : *((uint64_t*)l_d)    = l_s->val.u32;   break;
    52       case nsXPTType::T_U64   : *((uint64_t*)l_d)    = l_s->val.u64;   break;
    54       /* in the case of floats, we want to put the bits in to the
    55          64bit space right justified... floats in the parameter array on
    56          sparcv9 use odd numbered registers.. %f1, %f3, so we have to skip
    57          the space that would be occupied by %f0, %f2, etc.
    58       */
    59       case nsXPTType::T_FLOAT : *(((float*)l_d) + 1) = l_s->val.f;     break;
    60       case nsXPTType::T_DOUBLE: *((double*)l_d)      = l_s->val.d;     break;
    61       case nsXPTType::T_BOOL  : *((uint64_t*)l_d)    = l_s->val.b;     break;
    62       case nsXPTType::T_CHAR  : *((uint64_t*)l_d)    = l_s->val.c;     break;
    63       case nsXPTType::T_WCHAR : *((int64_t*)l_d)     = l_s->val.wc;    break;
    65       default:
    66         // all the others are plain pointer types
    67         *((void**)l_d) = l_s->val.p;
    68         break;
    69     }
    70   }
    72   return regCount;
    73 }

mercurial