diff options
author | martin <martin> | 2003-11-26 21:22:12 +0000 |
---|---|---|
committer | martin <martin> | 2003-11-26 21:22:12 +0000 |
commit | 00a8207bfc3efeaf5800b21a5d81c2aeec25f004 (patch) | |
tree | 363c3e2c063d74e8390936f62b9af3427ac24594 | |
parent | 4bb409f8b0a37e58f25c8037a9b7bdc96c46afb4 (diff) | |
download | pkgsrc-00a8207bfc3efeaf5800b21a5d81c2aeec25f004.tar.gz |
Now that the toolchain is able to build this beast at all, replace the
untested MD xpcom routines with working ones for sparc64 - mostly copied
from the solaris sparc v9 versions.
-rw-r--r-- | www/mozilla/files/xptcinvoke_asm_sparc64_netbsd.s | 94 | ||||
-rw-r--r-- | www/mozilla/files/xptcinvoke_sparc64_netbsd.cpp | 135 | ||||
-rw-r--r-- | www/mozilla/files/xptcstubs_asm_sparc64_netbsd.s | 49 | ||||
-rw-r--r-- | www/mozilla/files/xptcstubs_sparc64_netbsd.cpp | 28 |
4 files changed, 137 insertions, 169 deletions
diff --git a/www/mozilla/files/xptcinvoke_asm_sparc64_netbsd.s b/www/mozilla/files/xptcinvoke_asm_sparc64_netbsd.s index 4e9362822ac..a35f0b18d73 100644 --- a/www/mozilla/files/xptcinvoke_asm_sparc64_netbsd.s +++ b/www/mozilla/files/xptcinvoke_asm_sparc64_netbsd.s @@ -22,6 +22,7 @@ /* Platform specific code to invoke XPCOM methods on native objects */ .global XPTC_InvokeByIndex + .type XPTC_InvokeByIndex, #function /* XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex, PRUint32 paramCount, nsXPTCVariant* params); @@ -49,50 +50,63 @@ */ XPTC_InvokeByIndex: - save %sp,-(128+8),%sp ! room for the register window and this - sllx %i2,3,%l0 ! required stack size in bytes + save %sp,-(128 + 64),%sp ! room for the register window and + ! struct pointer, rounded up to 0 % 64 + sll %i2,4,%l0 ! assume the worst case + ! paramCount * 2 * 8 bytes + cmp %l0, 0 ! are there any args? If not, + be .invoke ! no need to copy args to stack + nop + 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 + add %sp,0x7ff+136,%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 + mov %i3,%o2 ! params + +! +! load arguments from stack into the outgoing registers +! BIAS is 0x7ff (2047) +! + +! load the %o1..5 64bit (extended word) output registers registers + ldx [%sp + 0x7ff + 136],%o1 ! %i1 + ldx [%sp + 0x7ff + 144],%o2 ! %i2 + ldx [%sp + 0x7ff + 152],%o3 ! %i3 + ldx [%sp + 0x7ff + 160],%o4 ! %i4 + ldx [%sp + 0x7ff + 168],%o5 ! %i5 + +! load the even number double registers starting with %f2 + ldd [%sp + 0x7ff + 136],%f2 + ldd [%sp + 0x7ff + 144],%f4 + ldd [%sp + 0x7ff + 152],%f6 + ldd [%sp + 0x7ff + 160],%f8 + ldd [%sp + 0x7ff + 168],%f10 + ldd [%sp + 0x7ff + 176],%f12 + ldd [%sp + 0x7ff + 184],%f14 + ldd [%sp + 0x7ff + 192],%f16 + ldd [%sp + 0x7ff + 200],%f18 + ldd [%sp + 0x7ff + 208],%f20 + ldd [%sp + 0x7ff + 216],%f22 + ldd [%sp + 0x7ff + 224],%f24 + ldd [%sp + 0x7ff + 232],%f26 + ldd [%sp + 0x7ff + 240],%f28 + ldd [%sp + 0x7ff + 248],%f30 + ! ! 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 +.invoke: + sll %i1,3,%l0 ! index *= 8 + ldx [%i0],%l1 ! *this --> address of vtable + ldx [%l0 + %l1],%l0 ! this->vtable[index] --> 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 - + jmpl %l0,%o7 ! call the routine + mov %i0,%o0 ! move 'this' pointer to out register + + mov %o0,%i0 ! propagate return value ret - restore %o0,0,%o0 ! propogate return value + restore + + .size XPTC_InvokeByIndex, .-XPTC_InvokeByIndex diff --git a/www/mozilla/files/xptcinvoke_sparc64_netbsd.cpp b/www/mozilla/files/xptcinvoke_sparc64_netbsd.cpp index f719be15937..936ec1135ec 100644 --- a/www/mozilla/files/xptcinvoke_sparc64_netbsd.cpp +++ b/www/mozilla/files/xptcinvoke_sparc64_netbsd.cpp @@ -24,106 +24,61 @@ #include "xptcprivate.h" -/* solaris defines __sparc for workshop compilers and - linux defines __sparc__ */ - -#if !defined(__sparc64__) && !defined(__sparc_v9__) +#if !defined(__sparc64__) && !defined(_LP64) #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 + */ + PRUint64 *l_d = d; + nsXPTCVariant *l_s = s; + PRUint64 l_paramCount = paramCount; + PRUint64 regCount = 0; // return the number of registers to load from the stack + + for(PRUint64 i = 0; i < l_paramCount; i++, l_d++, l_s++) + { + if (regCount < 5) regCount++; - for(uint32 i = 0; i < l_paramCount; i++, l_d++, l_s++) + if (l_s->IsPtrData()) { - 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; - } + *l_d = (PRUint64)l_s->ptr; + continue; } - return regCount; -} + switch (l_s->type) + { + case nsXPTType::T_I8 : *((PRInt64*)l_d) = l_s->val.i8; break; + case nsXPTType::T_I16 : *((PRInt64*)l_d) = l_s->val.i16; break; + case nsXPTType::T_I32 : *((PRInt64*)l_d) = l_s->val.i32; break; + case nsXPTType::T_I64 : *((PRInt64*)l_d) = l_s->val.i64; break; + + case nsXPTType::T_U8 : *((PRUint64*)l_d) = l_s->val.u8; break; + case nsXPTType::T_U16 : *((PRUint64*)l_d) = l_s->val.u16; break; + case nsXPTType::T_U32 : *((PRUint64*)l_d) = l_s->val.u32; break; + case nsXPTType::T_U64 : *((PRUint64*)l_d) = l_s->val.u64; break; + /* in the case of floats, we want to put the bits in to the + 64bit space right justified... floats in the paramter array on + sparcv9 use odd numbered registers.. %f1, %f3, so we have to skip + the space that would be occupied by %f0, %f2, etc. + */ + case nsXPTType::T_FLOAT : *(((float*)l_d) + 1) = l_s->val.f; break; + case nsXPTType::T_DOUBLE: *((double*)l_d) = l_s->val.d; break; + case nsXPTType::T_BOOL : *((PRBool*)l_d) = l_s->val.b; break; + case nsXPTType::T_CHAR : *((PRUint64*)l_d) = l_s->val.c; break; + case nsXPTType::T_WCHAR : *((PRInt64*)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 index d493a5cd21e..6557db78b18 100644 --- a/www/mozilla/files/xptcstubs_asm_sparc64_netbsd.s +++ b/www/mozilla/files/xptcstubs_asm_sparc64_netbsd.s @@ -32,36 +32,35 @@ 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') + mov %o0, %o1 ! shuffle the index up to 2nd place + mov %i0, %o0 ! the original 'this' + add %fp, 0x7ff + 136, %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] + stx %i1, [%fp + 0x7ff + 136] + stx %i2, [%fp + 0x7ff + 144] + stx %i3, [%fp + 0x7ff + 152] + stx %i4, [%fp + 0x7ff + 160] + stx %i5, [%fp + 0x7ff + 168] ! now we can build our own stack frame - save %sp,-(176),%sp ! room for the register window + save %sp,-(128 + 64),%sp ! room for the register window and + ! struct pointer, rounded up to 0 % 64 ! 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 + + mov %i0, %o0 + mov %i1, %o1 + mov %i2, %o2 + call PrepareAndDispatch + nop + mov %o0,%i0 ! propagate return value + b .LL1 + nop .LL1: - ret - restore + ret + restore - .size SharedStub, .-SharedStub - .type SharedStub, #function + .size SharedStub, .-SharedStub + .type SharedStub, #function diff --git a/www/mozilla/files/xptcstubs_sparc64_netbsd.cpp b/www/mozilla/files/xptcstubs_sparc64_netbsd.cpp index 1d5a5b30c6c..c6fd89e6892 100644 --- a/www/mozilla/files/xptcstubs_sparc64_netbsd.cpp +++ b/www/mozilla/files/xptcstubs_sparc64_netbsd.cpp @@ -24,10 +24,10 @@ #include "xptcprivate.h" -#if defined(__sparc64__) || defined(__sparc_v9__) +#if defined(sparc) || defined(__sparc__) extern "C" nsresult -PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, uint64* args) +PrepareAndDispatch(nsXPTCStubBase* self, PRUint64 methodIndex, PRUint64* args) { #define PARAM_BUFFER_COUNT 16 @@ -72,19 +72,19 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, uint64* args) // 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_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 : dp->val.d = *((double*) ap); break; + case nsXPTType::T_U64 : dp->val.u64 = *((PRUint64*) 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; + 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; |