Reorganize the Darwin xptcall code so that it works correctly with prebinding:

- Move all functions into the text section.
 - Use m4 to generate the StubNNN() functions in the .s file, so that we don't have to use an indirect call to SharedStub (which would clobber r12, where we pass the method index).
 - Use indirect calls for calling invoke_count_words and invoke_copy_to_stack from inside XPTC_InvokeByIndex.

Bug 151978, r=pavlov, sr=beard.
This commit is contained in:
bryner%netscape.com 2002-06-22 00:09:55 +00:00
Родитель dcacf42e5a
Коммит 9c28b9bcd8
5 изменённых файлов: 162 добавлений и 27 удалений

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

@ -223,7 +223,7 @@ endif
ifeq ($(OS_ARCH),Darwin)
CPPSRCS := xptcinvoke_ppc_rhapsody.cpp xptcstubs_ppc_rhapsody.cpp
ASFILES := xptcinvoke_asm_ppc_rhapsody.s xptcstubs_asm_ppc_rhapsody.s
ASFILES := xptcinvoke_asm_ppc_rhapsody.s xptcstubs_asm_ppc_darwin.s
endif
######################################################################
@ -300,6 +300,13 @@ xptcstubs_asm_mips.o: xptcstubs_asm_mips.s.m4 $(PUBLIC)/xptcstubsdef.inc
endif
endif
ifeq ($(OS_ARCH),Darwin)
xptcstubs_asm_ppc_darwin.o: xptcstubs_asm_ppc_darwin.s.m4 $(PUBLIC)/xptcstubsdef.inc Makefile
gm4 $(INCLUDES) $< > ./xptcstubs_asm_ppc_darwin.s && \
$(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) ./xptcstubs_asm_ppc_darwin.s
$(RM) -f ./xptcstubs_asm_ppc_darwin.s
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.

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

@ -28,7 +28,7 @@
# ** from index to entry is (4 * index) + 8.
#
.data
.text
.align 2
#
# XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
@ -58,7 +58,7 @@ __XPTC_InvokeByIndex:
mr r4,r6
stwu r1,-24(r1)
bl _invoke_count_words
bl L_invoke_count_words$stub
lwz r1,0(r1)
# prepare args for 'invoke_copy_to_stack' call
@ -77,7 +77,7 @@ __XPTC_InvokeByIndex:
# create "temporary" stack frame for _invoke_copy_to_stack to operate in.
stwu r1,-40(r1)
bl _invoke_copy_to_stack
bl L_invoke_copy_to_stack$stub
# remove temporary stack frame.
lwz r1,0(r1)
@ -120,3 +120,41 @@ __XPTC_InvokeByIndex:
lwz r31,-4(r1)
blr
.picsymbol_stub
L_invoke_count_words$stub:
.indirect_symbol _invoke_count_words
mflr r0
bcl 20,31,L1$pb
L1$pb:
mflr r11
addis r11,r11,ha16(L1$lz-L1$pb)
mtlr r0
lwz r12,lo16(L1$lz-L1$pb)(r11)
mtctr r12
addi r11,r11,lo16(L1$lz-L1$pb)
bctr
.lazy_symbol_pointer
L1$lz:
.indirect_symbol _invoke_count_words
.long dyld_stub_binding_helper
.picsymbol_stub
L_invoke_copy_to_stack$stub:
.indirect_symbol _invoke_copy_to_stack
mflr r0
bcl 20,31,L2$pb
L2$pb:
mflr r11
addis r11,r11,ha16(L2$lz-L2$pb)
mtlr r0
lwz r12,lo16(L2$lz-L2$pb)(r11)
mtctr r12
addi r11,r11,lo16(L2$lz-L2$pb)
bctr
.lazy_symbol_pointer
L2$lz:
.indirect_symbol _invoke_copy_to_stack
.long dyld_stub_binding_helper

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

@ -0,0 +1,112 @@
/* -*- Mode: asm; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.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 Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999-2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
.text
.globl _SharedStub
define(STUB_NAME, `_Stub'$1`__14nsXPTCStubBase')
define(STUB_ENTRY,
` .globl 'STUB_NAME($1)`
.align 2
'STUB_NAME($1)`:
addi r12, 0, '$1`
b _SharedStub
')
define(SENTINEL_ENTRY, `')
include(xptcstubsdef.inc)
_SharedStub:
mflr r0
stw r0,8(r1)
stwu r1,-176(r1)
stw r4,44(r1)
stw r5,48(r1)
stw r6,52(r1)
stw r7,56(r1)
stw r8,60(r1)
stw r9,64(r1)
stw r10,68(r1)
stfd f1,72(r1)
stfd f2,80(r1)
stfd f3,88(r1)
stfd f4,96(r1)
stfd f5,104(r1)
stfd f6,112(r1)
stfd f7,120(r1)
stfd f8,128(r1)
stfd f9,136(r1)
stfd f10,144(r1)
stfd f11,152(r1)
stfd f12,156(r1)
stfd f13,164(r1)
addi r6,r1,44
addi r7,r1,72
mr r4,r12
addi r5,r1,232
bl L_PrepareAndDispatch$stub
nop
lwz r0,184(r1)
addi r1,r1,176
mtlr r0
blr
.picsymbol_stub
L_PrepareAndDispatch$stub:
.indirect_symbol _PrepareAndDispatch
mflr r0
bcl 20,31,L1$pb
L1$pb:
mflr r11
addis r11,r11,ha16(L1$lz-L1$pb)
mtlr r0
lwz r12,lo16(L1$lz-L1$pb)(r11)
mtctr r12
addi r11,r11,lo16(L1$lz-L1$pb)
bctr
.lazy_symbol_pointer
L1$lz:
.indirect_symbol _PrepareAndDispatch
.long dyld_stub_binding_helper

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

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

@ -242,27 +242,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, PRUint32 methodIndex, PRUint32* args, P
}
#if 1
//extern "C" void SharedStub();
#define STUB_ENTRY(n) \
__asm__ ( \
".data\n\t" \
".align 2\n\t" \
".globl _Stub"#n"__14nsXPTCStubBase\n" \
"_Stub"#n"__14nsXPTCStubBase:\n\t" \
"addi r12,0,"#n"\n\t" \
"b _SharedStub" \
);
#else
extern "C" nsresult SharedStub();
#define STUB_ENTRY(n) \
nsresult nsXPTCStubBase::Stub##n() \
{\
return SharedStub();\
}
#endif
#define STUB_ENTRY(n)
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \
{ \
@ -272,5 +252,3 @@ nsresult nsXPTCStubBase::Sentinel##n() \
#include "xptcstubsdef.inc"