Adding Irix implementation from Jason Heirtzler <jasonh@cthulhu.engr.sgi.com>

This commit is contained in:
jband%netscape.com 1999-06-08 21:49:30 +00:00
parent 30cc0a5962
commit 322f8084b6
8 changed files with 618 additions and 8 deletions

View File

@ -109,6 +109,12 @@ struct nsXPTCVariant : public nsXPTCMiniVariant
class nsXPTCStubBase : public nsISupports
{
public:
// We are going to implement this to force the compiler to generate a
// vtbl for this class. Since this is overridden in the inheriting class
// we expect it to never be called.
// *This is needed by the Irix implementation.*
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
// Include generated vtbl stub declarations.
// These are virtual and *also* implemented by this class..
#include "xptcstubsdecl.inc"

View File

@ -79,6 +79,19 @@ CPPSRCS = \
endif
endif
# IRIX
ifeq ($(OS_ARCH), IRIX)
CPPSRCS = \
xptcinvoke_irix.cpp \
xptcstubs_irix.cpp \
$(NULL)
ASFILES = \
xptcinvoke_asm_irix.s \
xptcstubs_asm_irix.s \
$(NULL)
endif
# we don't want the shared lib, but we want to force the creation of a static lib.
override NO_SHARED_LIB=1
override NO_STATIC_LIB=

View File

@ -0,0 +1,134 @@
#include <sys/regdef.h>
#include <sys/asm.h>
.text
.globl invoke_count_words
.globl invoke_copy_to_stack
LOCALSZ=7 # a0, a1, a2, a3, s0, ra, gp
FRAMESZ=(((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
RAOFF=FRAMESZ-(1*SZREG)
A0OFF=FRAMESZ-(2*SZREG)
A1OFF=FRAMESZ-(3*SZREG)
A2OFF=FRAMESZ-(4*SZREG)
A3OFF=FRAMESZ-(5*SZREG)
S0OFF=FRAMESZ-(6*SZREG)
GPOFF=FRAMESZ-(7*SZREG)
#
# _XPTC_InvokeByIndex(that, methodIndex, paramCount, params)
# a0 a1 a2 a3
NESTED(_XPTC_InvokeByIndex, FRAMESZ, ra)
SETUP_GP
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, _XPTC_InvokeByIndex)
SAVE_GP(GPOFF)
REG_S ra, RAOFF(sp)
REG_S a0, A0OFF(sp)
REG_S a1, A1OFF(sp)
REG_S a2, A2OFF(sp)
REG_S a3, A3OFF(sp)
REG_S s0, S0OFF(sp)
REG_S gp, GPOFF(sp)
# invoke_count_words(paramCount, params)
move a0, a2
move a1, a3
jal invoke_count_words
# invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount,
# nsXPTCVariant* s, PRUint32 *reg)
REG_L a1, A2OFF(sp) # a1 - paramCount
REG_L a2, A3OFF(sp) # a2 - params
# save sp before we copy the params to the stack
move t0, sp
# assume full size of 8 bytes per param to be safe
sll v0, 4 # 8 bytes * num params
subu sp, sp, v0 # make room
move a0, sp # a0 - param stack address
# create temporary stack space to write int and fp regs
subu sp, 64 # 64 = 8 regs of 8 bytes
move a3, sp
# save the old sp and save the arg stack
subu sp, sp, 16
REG_S t0, 0(sp)
REG_S a0, 8(sp)
# copy the param into the stack areas
jal invoke_copy_to_stack
REG_L t3, 8(sp) # get previous a0
REG_L sp, 0(sp) # get orig sp back
REG_L a0, A0OFF(sp) # a0 - that
REG_L a1, A1OFF(sp) # a1 - methodIndex
# t1 = methodIndex * 12
# (use shift and subtract trick instead of mult)
sll t1, a1, 2
subu t1, t1, a1
sll t1, t1, 2
# calculate the function we need to jump to,
# which must then be saved in t9
lw t9, 0(a0)
addu t9, t9, t1
li t2, 20
addu t9, t9, t2
lw t9, 0(t9) # t9 = *(that+t1+20)
# calculate the proper "this" pointer for the
# function that they asked for
lw t0, 0(a0)
addu t0, t1
lw t0, 12(t0)
addu a0, a0, t0
# get register save area from invoke_copy_to_stack
subu t1, t3, 64
# a1..a7 and f13..f19 should now be set to what
# invoke_copy_to_stack told us. skip a0 and f12
# because that's the "this" pointer
REG_L a1, 0(t1)
REG_L a2, 8(t1)
REG_L a3, 16(t1)
REG_L a4, 24(t1)
REG_L a5, 32(t1)
REG_L a6, 40(t1)
REG_L a7, 48(t1)
l.d $f13, 0(t1)
l.d $f14, 8(t1)
l.d $f15, 16(t1)
l.d $f16, 24(t1)
l.d $f17, 32(t1)
l.d $f18, 40(t1)
l.d $f19, 48(t1)
# save away our stack pointer and create
# the stack pointer for the function
move s0, sp
move sp, t3
jalr ra, t9
move sp, s0
RESTORE_GP64
REG_L ra, RAOFF(sp)
REG_L s0, S0OFF(sp)
PTR_ADDU sp, FRAMESZ
j ra
.end _XPTC_InvokeByIndex

View File

@ -0,0 +1,153 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* Platform specific code to invoke XPCOM methods on native objects */
#include "xptcprivate.h"
#if (_MIPS_SIM != _ABIN32)
#error "This code is for IRIX N32 only"
#endif
extern "C" uint32
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
{
return(paramCount*2);
}
extern "C" void
invoke_copy_to_stack(PRUint64* d, PRUint32 paramCount,
nsXPTCVariant* s, PRUint64 *regs)
{
#define N_ARG_REGS 7 /* 8 regs minus 1 for "this" ptr */
for (PRUint32 i = 0; i < paramCount; i++, s++)
{
if (s->IsPtrData()) {
if (i < N_ARG_REGS)
regs[i] = (PRUint64)s->ptr;
else
*d++ = (PRUint64)s->ptr;
continue;
}
switch (s->type) {
//
// signed types first
//
case nsXPTType::T_I8:
if (i < N_ARG_REGS)
((PRInt64*)regs)[i] = s->val.i8;
else
*d++ = s->val.i8;
break;
case nsXPTType::T_I16:
if (i < N_ARG_REGS)
((PRInt64*)regs)[i] = s->val.i16;
else
*d++ = s->val.i16;
break;
case nsXPTType::T_I32:
if (i < N_ARG_REGS)
((PRInt64*)regs)[i] = s->val.i32;
else
*d++ = s->val.i64;
break;
case nsXPTType::T_I64:
if (i < N_ARG_REGS)
((PRInt64*)regs)[i] = s->val.i64;
else
*d++ = s->val.i64;
break;
//
// unsigned types next
//
case nsXPTType::T_U8:
if (i < N_ARG_REGS)
regs[i] = s->val.u8;
else
*d++ = s->val.u8;
break;
case nsXPTType::T_U16:
if (i < N_ARG_REGS)
regs[i] = s->val.u16;
else
*d++ = s->val.u16;
break;
case nsXPTType::T_U32:
if (i < N_ARG_REGS)
regs[i] = s->val.u32;
else
*d++ = s->val.u32;
break;
case nsXPTType::T_U64:
if (i < N_ARG_REGS)
regs[i] = s->val.u64;
else
*d++ = s->val.u64;
break;
case nsXPTType::T_FLOAT:
if (i < N_ARG_REGS)
((double*)regs)[i] = s->val.f;
else
*((double*)d++) = s->val.f;
break;
case nsXPTType::T_DOUBLE:
if (i < N_ARG_REGS)
((double*)regs)[i] = s->val.d;
else
*((double*)d++) = s->val.d;
break;
case nsXPTType::T_BOOL:
if (i < N_ARG_REGS)
regs[i] = s->val.b;
else
*d++ = s->val.b;
break;
case nsXPTType::T_CHAR:
if (i < N_ARG_REGS)
regs[i] = s->val.c;
else
*d++ = s->val.c;
break;
case nsXPTType::T_WCHAR:
if (i < N_ARG_REGS)
regs[i] = s->val.wc;
else
*d++ = s->val.wc;
break;
default:
// all the others are plain pointer types
if (i < N_ARG_REGS)
regs[i] = (PRUint64)s->val.p;
else
*d++ = (PRUint64)s->val.p;
break;
}
}
}
extern "C" nsresult _XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params);
extern "C"
XPTC_PUBLIC_API(nsresult)
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
PRUint32 paramCount, nsXPTCVariant* params)
{
return _XPTC_InvokeByIndex(that, methodIndex, paramCount, params);
}

View File

@ -0,0 +1,93 @@
#include <sys/regdef.h>
#include <sys/asm.h>
.text
.globl PrepareAndDispatch
LOCALSZ=16
FRAMESZ=(((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
A1OFF=FRAMESZ-(9*SZREG)
A2OFF=FRAMESZ-(8*SZREG)
A3OFF=FRAMESZ-(7*SZREG)
A4OFF=FRAMESZ-(6*SZREG)
A5OFF=FRAMESZ-(5*SZREG)
A6OFF=FRAMESZ-(4*SZREG)
A7OFF=FRAMESZ-(3*SZREG)
GPOFF=FRAMESZ-(2*SZREG)
RAOFF=FRAMESZ-(1*SZREG)
F13OFF=FRAMESZ-(16*SZREG)
F14OFF=FRAMESZ-(15*SZREG)
F15OFF=FRAMESZ-(14*SZREG)
F16OFF=FRAMESZ-(13*SZREG)
F17OFF=FRAMESZ-(12*SZREG)
F18OFF=FRAMESZ-(11*SZREG)
F19OFF=FRAMESZ-(10*SZREG)
#define SENTINEL_ENTRY(nn) /* defined in cpp file, not here */
#define STUB_ENTRY(nn) MAKE_STUB(nn, Stub/**/nn/**/__14nsXPTCStubBaseGv)
#define MAKE_STUB(nn, name) \
NESTED(name, FRAMESZ, ra); \
SETUP_GP; \
PTR_SUBU sp, FRAMESZ; \
SETUP_GP64(GPOFF, name); \
SAVE_GP(GPOFF); \
li t0, nn; \
b sharedstub; \
.end name; \
#include "xptcstubsdef.inc"
.globl sharedstub
.ent sharedstub
sharedstub:
REG_S a1, A1OFF(sp)
REG_S a2, A2OFF(sp)
REG_S a3, A3OFF(sp)
REG_S a4, A4OFF(sp)
REG_S a5, A5OFF(sp)
REG_S a6, A6OFF(sp)
REG_S a7, A7OFF(sp)
REG_S ra, RAOFF(sp)
s.d $f13, F13OFF(sp)
s.d $f14, F14OFF(sp)
s.d $f15, F15OFF(sp)
s.d $f16, F16OFF(sp)
s.d $f17, F17OFF(sp)
s.d $f18, F18OFF(sp)
s.d $f19, F19OFF(sp)
# t0 is methodIndex
move a1, t0
# a2 is stack address where extra function params
# are stored that do not fit in registers
move a2, sp
addi a2, FRAMESZ
# a3 is stack address of a1..a7
move a3, sp
addi a3, A1OFF
# a4 is stack address of f13..f19
move a4, sp
addi a4, F13OFF
# PrepareAndDispatch(that, methodIndex, args, gprArgs, fpArgs)
# a0 a1 a2 a3 a4
#
jal PrepareAndDispatch
REG_L ra, RAOFF(sp)
REG_L gp, GPOFF(sp)
PTR_ADDU sp, FRAMESZ
j ra
.end sharedstub

View File

@ -0,0 +1,207 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "xptcprivate.h"
#if defined(IRIX)
#if (_MIPS_SIM != _ABIN32)
#error "This code is for IRIX N32 only"
#endif
/*
* This is for IRIX N32 ABI
*
* When we're called, the "gp" registers are stored in gprData and
* the "fp" registers are stored in fprData. There are 8 regs
* available which coorespond to the first 7 parameters of the
* function and the "this" pointer. If there are additional parms,
* they are stored on the stack at address "args".
*
*/
extern "C" nsresult
PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex, PRUint64* args,
PRUint64 *gprData, double *fprData)
{
#define PARAM_BUFFER_COUNT 16
#define PARAM_GPR_COUNT 7
#define PARAM_FPR_COUNT 7
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;
PRUint32 iCount = 0;
for(i = 0; i < paramCount; i++)
{
const nsXPTParamInfo& param = info->GetParam(i);
const nsXPTType& type = param.GetType();
nsXPTCMiniVariant* dp = &dispatchParams[i];
if(param.IsOut() || !type.IsArithmetic())
{
if (iCount < PARAM_GPR_COUNT)
dp->val.p = (void*)gprData[iCount++];
else
dp->val.p = (void*)*ap++;
continue;
}
// else
switch(type)
{
case nsXPTType::T_I8:
if (iCount < PARAM_GPR_COUNT)
dp->val.i8 = (PRInt8)gprData[iCount++];
else
dp->val.i8 = (PRInt8)*ap++;
break;
case nsXPTType::T_I16:
if (iCount < PARAM_GPR_COUNT)
dp->val.i16 = (PRInt16)gprData[iCount++];
else
dp->val.i16 = (PRInt16)*ap++;
break;
case nsXPTType::T_I32:
if (iCount < PARAM_GPR_COUNT)
dp->val.i32 = (PRInt32)gprData[iCount++];
else
dp->val.i32 = (PRInt32)*ap++;
break;
case nsXPTType::T_I64:
if (iCount < PARAM_GPR_COUNT)
dp->val.i64 = (PRInt64)gprData[iCount++];
else
dp->val.i64 = (PRInt64)*ap++;
break;
case nsXPTType::T_U8:
if (iCount < PARAM_GPR_COUNT)
dp->val.u8 = (PRUint8)gprData[iCount++];
else
dp->val.u8 = (PRUint8)*ap++;
break;
case nsXPTType::T_U16:
if (iCount < PARAM_GPR_COUNT)
dp->val.u16 = (PRUint16)gprData[iCount++];
else
dp->val.u16 = (PRUint16)*ap++;
break;
case nsXPTType::T_U32:
if (iCount < PARAM_GPR_COUNT)
dp->val.u32 = (PRUint32)gprData[iCount++];
else
dp->val.u32 = (PRUint32)*ap++;
break;
case nsXPTType::T_U64:
if (iCount < PARAM_GPR_COUNT)
dp->val.u64 = (PRUint64)gprData[iCount++];
else
dp->val.u64 = (PRUint64)*ap++;
break;
case nsXPTType::T_FLOAT:
if (iCount < PARAM_FPR_COUNT)
dp->val.f = (double)fprData[iCount++];
else
dp->val.f = *((double*)ap++);
break;
case nsXPTType::T_DOUBLE:
if (iCount < PARAM_FPR_COUNT)
dp->val.d = (double)fprData[iCount++];
else
dp->val.d = *((double*)ap++);
break;
case nsXPTType::T_BOOL:
if (iCount < PARAM_GPR_COUNT)
dp->val.b = (PRBool)gprData[iCount++];
else
dp->val.b = (PRBool)*ap++;
break;
case nsXPTType::T_CHAR:
if (iCount < PARAM_GPR_COUNT)
dp->val.c = (char)gprData[iCount++];
else
dp->val.c = (char)*ap++;
break;
case nsXPTType::T_WCHAR:
if (iCount < PARAM_GPR_COUNT)
dp->val.wc = (wchar_t)gprData[iCount++];
else
dp->val.wc = (wchar_t)*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;
}
#define STUB_ENTRY(n) /* defined in the assembly file */
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xptcstubsdef.inc"
#endif

View File

@ -19,3 +19,14 @@
/* entry point wrappers. */
#include "xptcprivate.h"
// This method is never called and is only here so the compiler
// will generate a vtbl for this class.
// *Needed by the Irix implementation.*
NS_IMETHODIMP nsXPTCStubBase::QueryInterface(REFNSIID aIID,
void** aInstancePtr)
{
NS_ASSERTION(0,"wowa! nsXPTCStubBase::QueryInterface called");
return NS_ERROR_FAILURE;
}

View File

@ -198,16 +198,9 @@ but eventually I will verify.
</TD>
</TR>
<TR>
<TD bgcolor="red"><font color="white"><b>HELP!</b></font></TD>
<TD>Irix</TD>
<TD align="center">-</TD>
<TD align="center">-</TD>
</TR>
<TR>
<TD bgcolor="khaki"><font color="black"><b>Coded</b></font></TD>
<TD>Irix/MIPS</TD>
<TD>Irix</TD>
<TD><img alt="Coded" src="http://cvs-mirror.mozilla.org/webtools/tinderbox/star.gif">
<a href="mailto:jasonh@m7.engr.sgi.com">Jason Heirtzler &lt;jasonh@m7.engr.sgi.com&gt;</a><BR>
</TD>