xptcstubs code for o32 mips/linux r=pavlov sr=waterson

This commit is contained in:
pavlov%netscape.com 2001-10-11 00:33:36 +00:00
Родитель ed6052662d
Коммит cfbfa26c40
4 изменённых файлов: 221 добавлений и 2 удалений

Просмотреть файл

@ -1 +1,2 @@
Makefile
xptcstubs_asm_mips.s

Просмотреть файл

@ -180,8 +180,8 @@ endif
ifeq ($(OS_ARCH),Linux)
ifeq ($(OS_TEST),mips)
CPPSRCS := xptcinvoke_mips.cpp xptcstubs_unsupported.cpp
ASFILES := xptcinvoke_asm_mips.s
CPPSRCS := xptcinvoke_mips.cpp xptcstubs_mips.cpp
ASFILES := xptcinvoke_asm_mips.s xptcstubs_asm_mips.s
#xptcstubs_mips.cpp
# xptcstubs_asm_mips.s
ifdef GNU_CC
@ -280,6 +280,14 @@ DEFINES += -DEXPORT_XPTC_API
INCLUDES += -I$(srcdir)/../..
ifeq ($(OS_ARCH),Linux)
ifeq ($(OS_TEST),mips)
xptcstubs_asm_mips.o: $(PUBLIC)/xptcstubsdef.inc $(srcdir)/xptcstubs_asm_mips.s.m4
m4 $(INCLUDES) $(srcdir)/xptcstubs_asm_mips.s.m4 > ./xptcstubs_asm_mips.s
$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) $(srcdir)/xptcstubs_asm_mips.s
endif
endif
ifeq ($(OS_ARCH),IRIX)
# The assembler on IRIX (6.3 only?) seems to have trouble with the default command,
# but works fine if we first copy the header and source file into the current dir.

Просмотреть файл

@ -0,0 +1,94 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Corp, Inc.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Chris Waterson <waterson@netscape.com>
*
*/
/* This code is for MIPS using the O32 ABI. */
#include <sys/regdef.h>
#include <sys/asm.h>
.text
.globl PrepareAndDispatch
NARGSAVE=4 # extra space for the callee to use. gccism
# we can put our a0-a3 in our callers space.
LOCALSZ=2 # gp, ra
FRAMESZ=(((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
define(STUB_NAME, `Stub'$1`__14nsXPTCStubBase')
define(STUB_ENTRY,
` .globl 'STUB_NAME($1)`
.align 2
.type 'STUB_NAME($1)`,@function
.ent 'STUB_NAME($1)`, 0
'STUB_NAME($1)`:
.frame sp, FRAMESZ, ra
.set noreorder
.cpload t9
.set reorder
subu sp, FRAMESZ
.cprestore 16
li t0, '$1`
b sharedstub
.end 'STUB_NAME($1)`
')
define(SENTINEL_ENTRY, `')
include(xptcstubsdef.inc)
.globl sharedstub
.ent sharedstub
sharedstub:
REG_S ra, 20(sp)
REG_S a0, 24(sp)
REG_S a1, 28(sp)
REG_S a2, 32(sp)
REG_S a3, 36(sp)
# t0 is methodIndex
move a1, t0
# put the start of a1, a2, a3, and stack
move a2, sp
addi a2, 24 # have a2 point to sp + 24 (where a0 is)
# PrepareAndDispatch(that, methodIndex, args)
# a0 a1 a2
#
jal PrepareAndDispatch
REG_L ra, 20(sp)
REG_L a1, 28(sp)
REG_L a2, 32(sp)
addu sp, FRAMESZ
j ra
.end sharedstub

Просмотреть файл

@ -0,0 +1,116 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Corp, Inc.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*
*/
#include "xptcprivate.h"
/*
* This is for MIPS O32 ABI
* Args contains a0-3 and then the stack.
* Because a0 is 'this', we want to skip it
*/
extern "C" nsresult
PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex, PRUint32* args)
{
args++; // always skip over a0
#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;
}
dp->val.p = (void*) *ap;
switch(type)
{
case nsXPTType::T_I64 :
if ((PRWord)ap & 4) ap++;
dp->val.i64 = *((PRInt64*) ap); ap++;
break;
case nsXPTType::T_U64 :
if ((PRWord)ap & 4) ap++;
dp->val.u64 = *((PRInt64*) ap); ap++;
break;
case nsXPTType::T_DOUBLE:
if ((PRWord)ap & 4) ap++;
dp->val.d = *((double*) ap); ap++;
break;
}
}
result = self->CallMethod((PRUint16)methodIndex, info, dispatchParams);
NS_RELEASE(iface_info);
if(dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
#define STUB_ENTRY(n) // done in the .s file
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#include "xptcstubsdef.inc"