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

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:987bc27c96f9
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/. */
6
7
8 /* Platform specific code to invoke XPCOM methods on native objects */
9
10 #include "xptcprivate.h"
11
12 #if !defined(__sparc) && !defined(__sparc__)
13 #error "This code is for Sparc only"
14 #endif
15
16 /* Prototype specifies unmangled function name */
17 extern "C" uint64_t
18 invoke_copy_to_stack(uint64_t* d, uint32_t paramCount, nsXPTCVariant* s);
19
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
32
33 for(uint64_t i = 0; i < l_paramCount; i++, l_d++, l_s++)
34 {
35 if (regCount < 5) regCount++;
36
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;
48
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;
53
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;
64
65 default:
66 // all the others are plain pointer types
67 *((void**)l_d) = l_s->val.p;
68 break;
69 }
70 }
71
72 return regCount;
73 }

mercurial