diff options
author | mycroft <mycroft> | 2000-10-26 07:49:59 +0000 |
---|---|---|
committer | mycroft <mycroft> | 2000-10-26 07:49:59 +0000 |
commit | 8381734e17e8fab39784e852af0946f04de599cc (patch) | |
tree | ccb47f1ff5643c0d9e4db23e14f70ea42763b729 /www/mozilla/files | |
parent | a40fd9fab7fc1b2f93e2e6320dc41e05302ed871 (diff) | |
download | pkgsrc-8381734e17e8fab39784e852af0946f04de599cc.tar.gz |
Rework machdep NSPR code to not rely on the compiler playing nice after a
setjmp() call when we frob the stack pointer. Instead, poke the return PC
in the saved context.
Add support for SPARC.
Diffstat (limited to 'www/mozilla/files')
-rw-r--r-- | www/mozilla/files/md5 | 2 | ||||
-rw-r--r-- | www/mozilla/files/patch-sum | 6 | ||||
-rw-r--r-- | www/mozilla/files/xptcinvoke_asm_sparc_netbsd.s | 71 | ||||
-rw-r--r-- | www/mozilla/files/xptcinvoke_sparc_netbsd.cpp | 141 | ||||
-rw-r--r-- | www/mozilla/files/xptcstubs_asm_sparc_netbsd.s | 65 | ||||
-rw-r--r-- | www/mozilla/files/xptcstubs_sparc_netbsd.cpp | 131 |
6 files changed, 412 insertions, 4 deletions
diff --git a/www/mozilla/files/md5 b/www/mozilla/files/md5 index a787cf310e3..068e7835838 100644 --- a/www/mozilla/files/md5 +++ b/www/mozilla/files/md5 @@ -1,3 +1,3 @@ -$NetBSD: md5,v 1.16 2000/10/25 22:02:35 mycroft Exp $ +$NetBSD: md5,v 1.17 2000/10/26 07:49:59 mycroft Exp $ MD5 (mozilla-source-M18.tar.bz2) = c92aadfd0a15ca7f48fafc2bbf321e0d diff --git a/www/mozilla/files/patch-sum b/www/mozilla/files/patch-sum index 7c7cba5bd40..3e248437907 100644 --- a/www/mozilla/files/patch-sum +++ b/www/mozilla/files/patch-sum @@ -1,8 +1,8 @@ -$NetBSD: patch-sum,v 1.16 2000/10/25 22:02:36 mycroft Exp $ +$NetBSD: patch-sum,v 1.17 2000/10/26 07:49:59 mycroft Exp $ MD5 (patch-aa) = a07a4956a8c6a91fce0ef653b59c902f MD5 (patch-ab) = dfa8ac0ffaac96293904adb6372c5b8d MD5 (patch-ac) = e06e6cb1261f97e6fec8b04cdf4cb0a1 -MD5 (patch-ad) = 459e7b70961122090c2e6228a46ffcb6 +MD5 (patch-ad) = 44e9a9ababd47fdb7fbdfb447575cbad MD5 (patch-ae) = 925a6dc3b7354f0c82a7e2411463617e -MD5 (patch-af) = b12d2dcedf9e0acf1e458615eb86848a +MD5 (patch-af) = 919c4da464918e676c90349ca9bb3b1d diff --git a/www/mozilla/files/xptcinvoke_asm_sparc_netbsd.s b/www/mozilla/files/xptcinvoke_asm_sparc_netbsd.s new file mode 100644 index 00000000000..dfe6fde9963 --- /dev/null +++ b/www/mozilla/files/xptcinvoke_asm_sparc_netbsd.s @@ -0,0 +1,71 @@ +/* -*- 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); + +*/ +XPTC_InvokeByIndex: + save %sp,-(64 + 16),%sp ! room for the register window and + ! struct pointer, rounded up to 0 % 16 + mov %i2,%o0 ! paramCount + call invoke_count_words ! returns the required stack size in %o0 + mov %i3,%o1 ! params + + sll %o0,2,%l0 ! number of bytes + sub %sp,%l0,%sp ! create the additional stack space + + mov %sp,%o0 ! pointer for copied args + add %o0,72,%o0 ! step past the register window, the + ! struct result pointer and the 'this' slot + mov %i2,%o1 ! paramCount + call invoke_copy_to_stack + mov %i3,%o2 ! params +! +! calculate the target address from the vtable +! + add %i1,1,%i1 ! vTable is zero-based, index is 1 based (?) + ld [%i0],%l1 ! *that --> vTable + sll %i1,3,%i1 + add %i1,%l1,%l1 ! vTable[index * 8], l1 now points to vTable entry + lduh [%l1],%l0 ! this adjustor + sll %l0,16,%l0 ! sign extend to 32 bits + sra %l0,16,%l0 + add %l0,%i0,%i0 ! adjust this + ld [%l1 + 4],%l0 ! target address + +.L5: ld [%sp + 88],%o5 +.L4: ld [%sp + 84],%o4 +.L3: ld [%sp + 80],%o3 +.L2: ld [%sp + 76],%o2 +.L1: ld [%sp + 72],%o1 +.L0: + jmpl %l0,%o7 ! call the routine +! always have a 'this', from the incoming 'that' + mov %i0,%o0 + + mov %o0,%i0 ! propogate return value + ret + restore diff --git a/www/mozilla/files/xptcinvoke_sparc_netbsd.cpp b/www/mozilla/files/xptcinvoke_sparc_netbsd.cpp new file mode 100644 index 00000000000..ba1f1a0298d --- /dev/null +++ b/www/mozilla/files/xptcinvoke_sparc_netbsd.cpp @@ -0,0 +1,141 @@ +/* -*- 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(__sparc) && !defined(__sparc__) +#error "This code is for Sparc 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 : + result++; + break; + case nsXPTType::T_I64 : + result+=2; + break; + case nsXPTType::T_U8 : + case nsXPTType::T_U16 : + case nsXPTType::T_U32 : + result++; + break; + case nsXPTType::T_U64 : + result+=2; + break; + case nsXPTType::T_FLOAT : + result++; + break; + case nsXPTType::T_DOUBLE : + result+=2; + 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 & 0x3) result += 4 - (result & 0x3); // ensure q-word alignment + return result; +} + +extern "C" PRUint32 +invoke_copy_to_stack(PRUint32* 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. +*/ + uint32 *l_d = d; + nsXPTCVariant *l_s = s; + uint32 l_paramCount = paramCount; + uint32 regCount = 0; // return the number of registers to load from the stack + + typedef struct { + uint32 hi; + uint32 lo; + } DU; // have to move 64 bit entities as 32 bit halves since + // stack slots are not guaranteed 16 byte aligned + + 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 : *((int32*) l_d) = l_s->val.i8; break; + case nsXPTType::T_I16 : *((int32*) l_d) = l_s->val.i16; break; + case nsXPTType::T_I32 : *((int32*) l_d) = l_s->val.i32; break; + case nsXPTType::T_I64 : + case nsXPTType::T_U64 : + case nsXPTType::T_DOUBLE : *((uint32*) l_d++) = ((DU *)l_s)->hi; + if (regCount < 5) regCount++; + *((uint32*) l_d) = ((DU *)l_s)->lo; + break; + case nsXPTType::T_U8 : *((uint32*) l_d) = l_s->val.u8; break; + case nsXPTType::T_U16 : *((uint32*) l_d) = l_s->val.u16; break; + case nsXPTType::T_U32 : *((uint32*) l_d) = l_s->val.u32; break; + case nsXPTType::T_FLOAT : *((float*) l_d) = l_s->val.f; break; + case nsXPTType::T_BOOL : *((PRBool*) l_d) = l_s->val.b; break; + case nsXPTType::T_CHAR : *((uint32*) l_d) = l_s->val.c; break; + case nsXPTType::T_WCHAR : *((int32*)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_sparc_netbsd.s b/www/mozilla/files/xptcstubs_asm_sparc_netbsd.s new file mode 100644 index 00000000000..a208d31c220 --- /dev/null +++ b/www/mozilla/files/xptcstubs_asm_sparc_netbsd.s @@ -0,0 +1,65 @@ +/* -*- 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, 72, %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, [%fp + 72] + st %i2, [%fp + 76] + st %i3, [%fp + 80] + st %i4, [%fp + 84] + st %i5, [%fp + 88] +! now we can build our own stack frame + save %sp,-(64 + 32),%sp ! room for the register window and + ! struct pointer, rounded up to 0 % 32 +! 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 + 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_sparc_netbsd.cpp b/www/mozilla/files/xptcstubs_sparc_netbsd.cpp new file mode 100644 index 00000000000..787b2775ed8 --- /dev/null +++ b/www/mozilla/files/xptcstubs_sparc_netbsd.cpp @@ -0,0 +1,131 @@ +/* -*- 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(sparc) || defined(__sparc__) + +extern "C" nsresult +PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, uint32* args) +{ + + typedef struct { + uint32 hi; + uint32 lo; + } DU; // have to move 64 bit entities as 32 bit halves since + // stack slots are not guaranteed 16 byte aligned + +#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"); + + PRUint32* 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 = *((PRInt32*) ap); break; + case nsXPTType::T_I16 : dp->val.i16 = *((PRInt32*) ap); break; + case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break; + case nsXPTType::T_DOUBLE : + case nsXPTType::T_U64 : + case nsXPTType::T_I64 : ((DU *)dp)->hi = ((DU *)ap)->hi; + ((DU *)dp)->lo = ((DU *)ap)->lo; + ap++; + break; + case nsXPTType::T_U8 : dp->val.u8 = *((PRUint32*) ap); break; + case nsXPTType::T_U16 : dp->val.u16 = *((PRUint32*)ap); break; + case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break; + case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break; + case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break; + case nsXPTType::T_CHAR : dp->val.c = *((PRUint32*) ap); break; + case nsXPTType::T_WCHAR : dp->val.wc = *((PRInt32*) 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__ */ |