From 1235b76ff895623d1aab7356adfc03af7f1d5597 Mon Sep 17 00:00:00 2001 From: eeh Date: Sun, 11 Feb 2001 19:57:58 +0000 Subject: Add the necessary support files for sparc64. --- www/mozilla/files/xptcinvoke_asm_sparc64_netbsd.s | 98 ++++++++++++++++ www/mozilla/files/xptcinvoke_sparc64_netbsd.cpp | 129 ++++++++++++++++++++++ www/mozilla/files/xptcstubs_asm_sparc64_netbsd.s | 67 +++++++++++ www/mozilla/files/xptcstubs_sparc64_netbsd.cpp | 122 ++++++++++++++++++++ 4 files changed, 416 insertions(+) create mode 100644 www/mozilla/files/xptcinvoke_asm_sparc64_netbsd.s create mode 100644 www/mozilla/files/xptcinvoke_sparc64_netbsd.cpp create mode 100644 www/mozilla/files/xptcstubs_asm_sparc64_netbsd.s create mode 100644 www/mozilla/files/xptcstubs_sparc64_netbsd.cpp diff --git a/www/mozilla/files/xptcinvoke_asm_sparc64_netbsd.s b/www/mozilla/files/xptcinvoke_asm_sparc64_netbsd.s new file mode 100644 index 00000000000..4e9362822ac --- /dev/null +++ b/www/mozilla/files/xptcinvoke_asm_sparc64_netbsd.s @@ -0,0 +1,98 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* Platform specific code to invoke XPCOM methods on native objects */ + .global XPTC_InvokeByIndex +/* + XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex, + PRUint32 paramCount, nsXPTCVariant* params); + +*/ +/* + * Note: To simplify stack handling we allocate an extra stack + * frame here. In principle invoke_copy_to_stack() could + * save the parameters our caller's frame and we could + * reclaim the stackframe and do a tail call to the + * function. However, this gets complicated.... + * + * The vtable consist of be: + * + * struct { + * short __delta; + * short __index; + * union { + * P __pfn; + * short __delta2; + * } __pfn_or_delta2; + * }; + * + * See gcc/cp/cp-tree.h + */ + +XPTC_InvokeByIndex: + save %sp,-(128+8),%sp ! room for the register window and this + sllx %i2,3,%l0 ! required stack size in bytes + sub %sp,%l0,%sp ! create the additional stack space + + add %sp,0x7ff+128,%l2 ! pointer to parameter save area + add %l2,8,%o0 ! %o1's parameter save area + mov %i2,%o1 ! paramCount + call invoke_copy_to_stack + mov %i3,%o2 ! params +! +! calculate the target address from the vtable +! + inc %i1 ! vTable is zero-based, index is 1 based (?) + ldx [%i0],%l1 ! *that --> vTable + sllx %i1,4,%i1 ! Each vtable entry is 16-bytes long + add %i1,%l1,%l1 + ldsh [%l1],%l0 ! this adjustor + add %l0,%i0,%i0 ! adjust this + ldx [%l1 + 8],%l0 ! target address + +.L15: ldd [%sp + 0x7ff + 128 + 120],%f30 +.L14: ldd [%sp + 0x7ff + 128 + 112],%f28 +.L13: ldd [%sp + 0x7ff + 128 + 104],%f26 +.L12: ldd [%sp + 0x7ff + 128 + 96],%f24 +.L11: ldd [%sp + 0x7ff + 128 + 88],%f22 +.L10: ldd [%sp + 0x7ff + 128 + 80],%f20 +.L9: ldd [%sp + 0x7ff + 128 + 72],%f18 +.L8: ldd [%sp + 0x7ff + 128 + 64],%f16 +.L7: ldd [%sp + 0x7ff + 128 + 56],%f14 +.L6: ldd [%sp + 0x7ff + 128 + 48],%f12 +.L5: ldx [%sp + 0x7ff + 128 + 40],%o5 + ldd [%sp + 0x7ff + 128 + 40],%f10 +.L4: ldx [%sp + 0x7ff + 128 + 32],%o4 + ldd [%sp + 0x7ff + 128 + 32],%f8 +.L3: ldx [%sp + 0x7ff + 128 + 24],%o3 + ldd [%sp + 0x7ff + 128 + 24],%f6 +.L2: ldx [%sp + 0x7ff + 128 + 16],%o2 + ldd [%sp + 0x7ff + 128 + 16],%f4 +.L1: ldx [%sp + 0x7ff + 128 + 8],%o1 + ldd [%sp + 0x7ff + 128 + 8],%f2 +.L0: + jmpl %l0,%o7 ! call the routine +! always have a 'this', from the incoming 'that' + mov %i0,%o0 + + ret + restore %o0,0,%o0 ! propogate return value diff --git a/www/mozilla/files/xptcinvoke_sparc64_netbsd.cpp b/www/mozilla/files/xptcinvoke_sparc64_netbsd.cpp new file mode 100644 index 00000000000..f719be15937 --- /dev/null +++ b/www/mozilla/files/xptcinvoke_sparc64_netbsd.cpp @@ -0,0 +1,129 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* Platform specific code to invoke XPCOM methods on native objects */ + +#include "xptcprivate.h" + +/* solaris defines __sparc for workshop compilers and + linux defines __sparc__ */ + +#if !defined(__sparc64__) && !defined(__sparc_v9__) +#error "This code is for Sparc64 only" +#endif + +typedef unsigned nsXPCVariant; + +extern "C" PRUint32 +invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s) +{ + PRUint32 result = 0; + for(PRUint32 i = 0; i < paramCount; i++, s++) + { + if(s->IsPtrData()) + { + result++; + continue; + } + switch(s->type) + { + case nsXPTType::T_I8 : + case nsXPTType::T_I16 : + case nsXPTType::T_I32 : + case nsXPTType::T_I64 : + result++; + break; + case nsXPTType::T_U8 : + case nsXPTType::T_U16 : + case nsXPTType::T_U32 : + case nsXPTType::T_U64 : + result++; + break; + case nsXPTType::T_FLOAT : + case nsXPTType::T_DOUBLE : + result++; + break; + case nsXPTType::T_BOOL : + case nsXPTType::T_CHAR : + case nsXPTType::T_WCHAR : + result++; + break; + default: + // all the others are plain pointer types + result++; + break; + } + } + // nuts, I know there's a cooler way of doing this, but it's late + // now and it'll probably come to me in the morning. + if (result & 0x7) result += 8 - (result & 0x7); // ensure 16-byte alignment + return result; +} + +extern "C" PRUint32 +invoke_copy_to_stack(PRUint64* d, PRUint32 paramCount, nsXPTCVariant* s) +{ +/* + We need to copy the parameters for this function to locals and use them + from there since the parameters occupy the same stack space as the stack + we're trying to populate. +*/ + uint64 *l_d = d; + nsXPTCVariant *l_s = s; + uint32 l_paramCount = paramCount; + uint32 regCount = 0; // return the number of registers to load from the stack + + for(uint32 i = 0; i < l_paramCount; i++, l_d++, l_s++) + { + if (regCount < 5) regCount++; + if(l_s->IsPtrData()) + { + *((void**)l_d) = l_s->ptr; + continue; + } + switch(l_s->type) + { + case nsXPTType::T_I8 : *((int64*) l_d) = l_s->val.i8; break; + case nsXPTType::T_I16 : *((int64*) l_d) = l_s->val.i16; break; + case nsXPTType::T_I32 : *((int64*) l_d) = l_s->val.i32; break; + case nsXPTType::T_I64 : *((int64*) l_d) = l_s->val.i64; break; + case nsXPTType::T_U64 : *((uint64*) l_d) = l_s->val.u64; break; + case nsXPTType::T_U8 : *((uint64*) l_d) = l_s->val.u8; break; + case nsXPTType::T_U16 : *((uint64*) l_d) = l_s->val.u16; break; + case nsXPTType::T_U32 : *((uint64*) l_d) = l_s->val.u32; break; + case nsXPTType::T_FLOAT : + struct floats { float pad; float data; }; + ((floats*) l_d)->pad = 0; + ((floats*) l_d)->data = l_s->val.f; break; + case nsXPTType::T_DOUBLE : *((uint64*) l_d) = l_s->val.u64; break; + case nsXPTType::T_BOOL : *((uint64*) l_d) = l_s->val.b; break; + case nsXPTType::T_CHAR : *((uint64*) l_d) = l_s->val.c; break; + case nsXPTType::T_WCHAR : *((uint64*) l_d) = l_s->val.wc; break; + default: + // all the others are plain pointer types + *((void**)l_d) = l_s->val.p; + break; + } + } + return regCount; +} + diff --git a/www/mozilla/files/xptcstubs_asm_sparc64_netbsd.s b/www/mozilla/files/xptcstubs_asm_sparc64_netbsd.s new file mode 100644 index 00000000000..d493a5cd21e --- /dev/null +++ b/www/mozilla/files/xptcstubs_asm_sparc64_netbsd.s @@ -0,0 +1,67 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + + .global SharedStub + +/* + in the frame for the function that called SharedStub are the + rest of the parameters we need + +*/ + +SharedStub: +! we don't create a new frame yet, but work within the frame of the calling +! function to give ourselves the other parameters we want + + mov %o0, %o1 ! shuffle the index up to 2nd place + mov %i0, %o0 ! the original 'this' + add %fp, 0x7ff+128+(2*8), %o2 ! previous stack top adjusted to the first argument slot (beyond 'this') +! save off the original incoming parameters that arrived in +! registers, the ABI guarantees the space for us to do this + st %i1, [%o2 + 0] + st %i2, [%o2 + 8] + st %i3, [%o2 + 16] + st %i4, [%o2 + 24] + st %i5, [%o2 + 32] +! now we can build our own stack frame + save %sp,-(176),%sp ! room for the register window +! our function now appears to have been called +! as SharedStub(nsISupports* that, PRUint32 index, PRUint32* args) +! so we can just copy these through + + mov %i0, %o0 + mov %i1, %o1 + mov %i2, %o2 + call PrepareAndDispatch + nop + ret + restore %o0,0,%o0 +! XXXX what's all the rest of this for? + mov %o0,%i0 ! propogate return value + b .LL1 + nop +.LL1: + ret + restore + + .size SharedStub, .-SharedStub + .type SharedStub, #function diff --git a/www/mozilla/files/xptcstubs_sparc64_netbsd.cpp b/www/mozilla/files/xptcstubs_sparc64_netbsd.cpp new file mode 100644 index 00000000000..1d5a5b30c6c --- /dev/null +++ b/www/mozilla/files/xptcstubs_sparc64_netbsd.cpp @@ -0,0 +1,122 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* Implement shared vtbl methods. */ + +#include "xptcprivate.h" + +#if defined(__sparc64__) || defined(__sparc_v9__) + +extern "C" nsresult +PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, uint64* args) +{ + +#define PARAM_BUFFER_COUNT 16 + + nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; + nsXPTCMiniVariant* dispatchParams = NULL; + nsIInterfaceInfo* iface_info = NULL; + const nsXPTMethodInfo* info; + PRUint8 paramCount; + PRUint8 i; + nsresult result = NS_ERROR_FAILURE; + + NS_ASSERTION(self,"no self"); + + self->GetInterfaceInfo(&iface_info); + NS_ASSERTION(iface_info,"no interface info"); + + iface_info->GetMethodInfo(PRUint16(methodIndex), &info); + NS_ASSERTION(info,"no interface info"); + + paramCount = info->GetParamCount(); + + // setup variant array pointer + if(paramCount > PARAM_BUFFER_COUNT) + dispatchParams = new nsXPTCMiniVariant[paramCount]; + else + dispatchParams = paramBuffer; + NS_ASSERTION(dispatchParams,"no place for params"); + + PRUint64* ap = args; + for(i = 0; i < paramCount; i++, ap++) + { + const nsXPTParamInfo& param = info->GetParam(i); + const nsXPTType& type = param.GetType(); + nsXPTCMiniVariant* dp = &dispatchParams[i]; + + if(param.IsOut() || !type.IsArithmetic()) + { + dp->val.p = (void*) *ap; + continue; + } + // else + switch(type) + { + case nsXPTType::T_I8 : dp->val.i8 = *((PRInt64*) ap); break; + case nsXPTType::T_I16 : dp->val.i16 = *((PRInt64*) ap); break; + case nsXPTType::T_I32 : dp->val.i32 = *((PRInt64*) ap); break; + case nsXPTType::T_I64 : dp->val.i64 = *((PRInt64*) ap); break; + case nsXPTType::T_U8 : dp->val.u8 = *((PRUint64*)ap); break; + case nsXPTType::T_U16 : dp->val.u16 = *((PRUint64*)ap); break; + case nsXPTType::T_U32 : dp->val.u32 = *((PRUint64*)ap); break; + case nsXPTType::T_U64 : dp->val.u64 = *((PRUint64*)ap); break; + case nsXPTType::T_DOUBLE : dp->val.u64 = *((PRUint64*)ap); break; + case nsXPTType::T_FLOAT : dp->val.f = *((double*) ap); break; + case nsXPTType::T_BOOL : dp->val.b = *((PRUint64*)ap); break; + case nsXPTType::T_CHAR : dp->val.c = *((PRUint64*)ap); break; + case nsXPTType::T_WCHAR : dp->val.wc = *((PRInt64*) ap); break; + default: + NS_ASSERTION(0, "bad type"); + break; + } + } + + result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams); + + NS_RELEASE(iface_info); + + if(dispatchParams != paramBuffer) + delete [] dispatchParams; + + return result; +} + +extern "C" int SharedStub(int, int*); + +#define STUB_ENTRY(n) \ +nsresult nsXPTCStubBase::Stub##n() \ +{ \ + int dummy; /* defeat tail-call optimization */ \ + return SharedStub(n, &dummy); \ +} + +#define SENTINEL_ENTRY(n) \ +nsresult nsXPTCStubBase::Sentinel##n() \ +{ \ + NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \ + return NS_ERROR_NOT_IMPLEMENTED; \ +} + +#include "xptcstubsdef.inc" + +#endif /* sparc || __sparc__ */ -- cgit v1.2.3