Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 101821 | Differences between
and this patch

Collapse All | Expand All

(-)xpcom/reflect/xptcall/src/md/unix/Makefile.in (+5 lines)
Lines 273-278 CPPSRCS := xptcinvoke_ppc_linux.cpp xpt Link Here
273
ASFILES		:= xptcinvoke_asm_ppc_linux.s xptcstubs_asm_ppc_linux.s
273
ASFILES		:= xptcinvoke_asm_ppc_linux.s xptcstubs_asm_ppc_linux.s
274
AS		:= $(CC) -c -x assembler-with-cpp
274
AS		:= $(CC) -c -x assembler-with-cpp
275
endif
275
endif
276
ifeq ($(OS_ARCH)$(OS_TEST),Linuxppc64)
277
CPPSRCS		:= xptcinvoke_ppc64_linux.cpp xptcstubs_ppc64_linux.cpp
278
ASFILES		:= xptcinvoke_asm_ppc64_linux.s xptcstubs_asm_ppc64_linux.s
279
AS		:= $(CC) -c -x assembler-with-cpp
280
endif
276
281
277
#
282
#
278
# NetBSD/PPC
283
# NetBSD/PPC
(-)xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_linux.s (-5 / +5 lines)
Lines 40-54 Link Here
40
		      
40
		      
41
        .section ".text"
41
        .section ".text"
42
	.align 2
42
	.align 2
43
	.globl XPTC_InvokeByIndex
43
	.globl NS_InvokeByIndex
44
	.type  XPTC_InvokeByIndex,@function
44
	.type  NS_InvokeByIndex,@function
45
45
46
//
46
//
47
// XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
47
// NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
48
//                    PRUint32 paramCount, nsXPTCVariant* params)
48
//                  PRUint32 paramCount, nsXPTCVariant* params)
49
//
49
//
50
50
51
XPTC_InvokeByIndex:
51
NS_InvokeByIndex:
52
	stwu    sp,-32(sp)			// setup standard stack frame
52
	stwu    sp,-32(sp)			// setup standard stack frame
53
	mflr    r0				// save LR
53
	mflr    r0				// save LR
54
	stw     r3,8(sp)			// r3 <= that
54
	stw     r3,8(sp)			// r3 <= that
(-)xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_linux.cpp (-10 / +4 lines)
Lines 41-46 Link Here
41
// Implement shared vtbl methods.
41
// Implement shared vtbl methods.
42
42
43
#include "xptcprivate.h"
43
#include "xptcprivate.h"
44
#include "xptiprivate.h"
44
45
45
// The Linux/PPC ABI (aka PPC/SYSV ABI) passes the first 8 integral
46
// The Linux/PPC ABI (aka PPC/SYSV ABI) passes the first 8 integral
46
// parameters and the first 8 floating point parameters in registers
47
// parameters and the first 8 floating point parameters in registers
Lines 71-77 PrepareAndDispatch(nsXPTCStubBase* self, Link Here
71
{
72
{
72
    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
73
    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
73
    nsXPTCMiniVariant* dispatchParams = NULL;
74
    nsXPTCMiniVariant* dispatchParams = NULL;
74
    nsIInterfaceInfo* iface_info = NULL;
75
    const nsXPTMethodInfo* info;
75
    const nsXPTMethodInfo* info;
76
    PRUint32 paramCount;
76
    PRUint32 paramCount;
77
    PRUint32 i;
77
    PRUint32 i;
Lines 79-90 PrepareAndDispatch(nsXPTCStubBase* self, Link Here
79
79
80
    NS_ASSERTION(self,"no self");
80
    NS_ASSERTION(self,"no self");
81
81
82
    self->GetInterfaceInfo(&iface_info);
82
    self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
83
    NS_ASSERTION(iface_info,"no interface info");
84
    if (! iface_info)
85
        return NS_ERROR_UNEXPECTED;
86
87
    iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
88
    NS_ASSERTION(info,"no method info");
83
    NS_ASSERTION(info,"no method info");
89
    if (! info)
84
    if (! info)
90
        return NS_ERROR_UNEXPECTED;
85
        return NS_ERROR_UNEXPECTED;
Lines 173-181 PrepareAndDispatch(nsXPTCStubBase* self, Link Here
173
        }
168
        }
174
    }
169
    }
175
170
176
    result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
171
    result = self->mOuter->CallMethod((PRUint16) methodIndex, info,
177
172
                                      dispatchParams);
178
    NS_RELEASE(iface_info);
179
173
180
    if (dispatchParams != paramBuffer)
174
    if (dispatchParams != paramBuffer)
181
        delete [] dispatchParams;
175
        delete [] dispatchParams;
(-) (+153 lines)
Added Link Here
1
// -*- Mode: Asm -*-
2
//
3
// The contents of this file are subject to the Netscape Public
4
// License Version 1.1 (the "License"); you may not use this file
5
// except in compliance with the License. You may obtain a copy of
6
// the License at http://www.mozilla.org/NPL/
7
//
8
// Software distributed under the License is distributed on an "AS
9
// IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
// implied. See the License for the specific language governing
11
// rights and limitations under the License.
12
//
13
// The Original Code is mozilla.org code.
14
//
15
// The Initial Developer of the Original Code is Netscape
16
// Communications Corporation.  Portions created by Netscape are
17
// Copyright (C) 1999 Netscape Communications Corporation. All
18
// Rights Reserved.
19
//
20
// Contributor(s):
21
//   dwmw2@infradead.org (David Woodhouse)
22
//   Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
23
//   beard@netscape.com (Patrick Beard)
24
//   waterson@netscape.com (Chris Waterson)
25
//
26
27
.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
28
.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
29
.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
30
.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
31
.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
32
.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
33
.set r30,30; .set r31,31
34
.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4
35
.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9
36
.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14
37
.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19
38
.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24
39
.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
40
.set f30,30; .set f31,31
41
42
43
//
44
// NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
45
//                  PRUint32 paramCount, nsXPTCVariant* params)
46
//
47
48
	.section ".toc","aw"
49
	.section ".text"
50
	.align 2
51
	.globl NS_InvokeByIndex
52
	.section ".opd","aw"
53
	.align 3
54
NS_InvokeByIndex:
55
	.quad   .NS_InvokeByIndex,.TOC.@tocbase
56
	.previous
57
	.type  NS_InvokeByIndex,@function
58
.NS_InvokeByIndex:
59
	mflr	0
60
	std	0,16(r1)
61
	
62
	std	r29,-24(r1)
63
	std	r30,-16(r1)
64
	std	r31,-8(r1)
65
66
	mr	r29,r3			// Save 'that' in r29
67
	mr	r30,r4			// Save 'methodIndex' in r30
68
	mr	r31,r1			// Save old frame
69
70
	// Allocate stack frame with space for params. Since at least the
71
	// first 7 parameters (not including 'that') will be in registers,
72
	// we don't actually need stack space for those. We must ensure
73
	// that the stack remains 16-byte aligned.
74
	//
75
	//  | ..128-byte stack frame.. |     | 7 GP | 13 FP | 3 NV |
76
	//  |               |(params)........| regs | regs  | regs |
77
	// (r1)...........(+112)....(+128)
78
	//                               (-23*8).(-16*8).(-3*8)..(r31)
79
80
	// +stack frame, -unused stack params, +regs storage, +1 for alignment
81
	addi	r7,r5,((112/8)-7+7+13+3+1)
82
	rldicr	r7,r7,3,59		// multiply by 8 and mask with ~15
83
	neg	r7,r7
84
	stdux	r1,r1,r7
85
86
	
87
	// Call invoke_copy_to_stack(PRUint64* gpregs, double* fpregs,
88
	//			     PRUint32 paramCount, nsXPTCVariant* s, 
89
	//			     PRUint64* d))
90
	
91
	// r5, r6 are passed through intact (paramCount, params)
92
	// r7 (d) has to be r1+112 -- where parameters are passed on the stack.
93
	// r3, r4 are above that, easier to address from r31 than from r1
94
95
	subi	r3,r31,(23*8)		// r3 --> GPRS
96
	subi	r4,r31,(16*8)		// r4 --> FPRS
97
	addi	r7,r1,112		// r7 --> params
98
	bl	invoke_copy_to_stack
99
100
	// Set up to invoke function
101
	
102
	ld	r9,0(r29)		// vtable (r29 is 'that')
103
	mr	r3,r29		// self is first arg, obviously
104
105
	sldi	r30,r30,3	// Find function descriptor 
106
	add	r9,r9,r30
107
	ld	r9,0(r9)
108
	
109
	ld	r0,0(r9)	// Actual address from fd.
110
	std	r2,40(r1)	// Save r2 (TOC pointer)
111
112
	mtctr	0
113
	ld	r11,16(r9)	// Environment pointer from fd.
114
	ld	r2,8(r9)	// TOC pointer from fd.
115
116
	// Load FP and GP registers as required
117
	ld	r4, -(23*8)(r31) 
118
	ld	r5, -(22*8)(r31) 
119
	ld	r6, -(21*8)(r31) 
120
	ld	r7, -(20*8)(r31) 
121
	ld	r8, -(19*8)(r31) 
122
	ld	r9, -(18*8)(r31) 
123
	ld	r10, -(17*8)(r31) 
124
125
	lfd	f1, -(16*8)(r31)
126
	lfd	f2, -(15*8)(r31)
127
	lfd	f3, -(14*8)(r31)
128
	lfd	f4, -(13*8)(r31)
129
	lfd	f5, -(12*8)(r31)
130
	lfd	f6, -(11*8)(r31)
131
	lfd	f7, -(10*8)(r31)
132
	lfd	f8, -(9*8)(r31)
133
	lfd	f9, -(8*8)(r31)
134
	lfd	f10, -(7*8)(r31)
135
	lfd	f11, -(6*8)(r31)
136
	lfd	f12, -(5*8)(r31)
137
	lfd	f13, -(4*8)(r31)
138
139
	bctrl			// Do it
140
141
	ld	r2,40(r1)	// Load our own TOC pointer
142
	ld	r1,0(r1)	// Revert stack frame
143
	ld	0,16(r1)	// Reload lr
144
	ld	29,-24(r1)	// Restore NVGPRS
145
	ld	30,-16(r1)
146
	ld	31,-8(r1)
147
	mtlr	0
148
	blr
149
150
	.size   NS_InvokeByIndex,.-.NS_InvokeByIndex
151
152
	/* Magic indicating no need for an executable stack */
153
	.section .note.GNU-stack, "", @progbits ; .previous
(-) (+126 lines)
Added Link Here
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version
6
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 * the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/MPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is mozilla.org code.
16
 *
17
 * The Initial Developer of the Original Code is
18
 * Netscape Communications Corporation.
19
 * Portions created by the Initial Developer are Copyright (C) 1998
20
 * the Initial Developer. All Rights Reserved.
21
 *
22
 * Contributor(s):
23
 *   dwmw2@infradead.org (David Woodhouse)
24
 *   Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
25
 *   beard@netscape.com (Patrick Beard)
26
 *   waterson@netscape.com (Chris Waterson)
27
 *
28
 * Alternatively, the contents of this file may be used under the terms of
29
 * either of the GNU General Public License Version 2 or later (the "GPL"),
30
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31
 * in which case the provisions of the GPL or the LGPL are applicable instead
32
 * of those above. If you wish to allow use of your version of this file only
33
 * under the terms of either the GPL or the LGPL, and not to allow others to
34
 * use your version of this file under the terms of the MPL, indicate your
35
 * decision by deleting the provisions above and replace them with the notice
36
 * and other provisions required by the GPL or the LGPL. If you do not delete
37
 * the provisions above, a recipient may use your version of this file under
38
 * the terms of any one of the MPL, the GPL or the LGPL.
39
 *
40
 * ***** END LICENSE BLOCK ***** */
41
42
// Platform specific code to invoke XPCOM methods on native objects
43
44
// The purpose of XPTC_InvokeByIndex() is to map a platform
45
// independent call to the platform ABI. To do that,
46
// XPTC_InvokeByIndex() has to determine the method to call via vtable
47
// access. The parameters for the method are read from the
48
// nsXPTCVariant* and prepared for the native ABI.
49
50
#include <stdio.h>
51
#include "xptcprivate.h"
52
53
// 8 integral parameters are passed in registers, not including 'that'
54
#define GPR_COUNT     7
55
56
// 8 floating point parameters are passed in registers, floats are
57
// promoted to doubles when passed in registers
58
#define FPR_COUNT     13
59
60
extern "C" PRUint32
61
invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
62
{
63
  return PRUint32(((paramCount * 2) + 3) & ~3);
64
}
65
66
extern "C" void
67
invoke_copy_to_stack(PRUint64* gpregs,
68
                     double* fpregs,
69
                     PRUint32 paramCount,
70
                     nsXPTCVariant* s, 
71
                     PRUint64* d)
72
{
73
    PRUint64 tempu64;
74
75
    for(uint32 i = 0; i < paramCount; i++, s++) {
76
        if(s->IsPtrData())
77
            tempu64 = (PRUint64) s->ptr;
78
        else {
79
            switch(s->type) {
80
            case nsXPTType::T_FLOAT:                                  break;
81
            case nsXPTType::T_DOUBLE:                                 break;
82
            case nsXPTType::T_I8:     tempu64 = s->val.i8;            break;
83
            case nsXPTType::T_I16:    tempu64 = s->val.i16;           break;
84
            case nsXPTType::T_I32:    tempu64 = s->val.i32;           break;
85
            case nsXPTType::T_I64:    tempu64 = s->val.i64;           break;
86
            case nsXPTType::T_U8:     tempu64 = s->val.u8;            break;
87
            case nsXPTType::T_U16:    tempu64 = s->val.u16;           break;
88
            case nsXPTType::T_U32:    tempu64 = s->val.u32;           break;
89
            case nsXPTType::T_U64:    tempu64 = s->val.u64;           break;
90
            case nsXPTType::T_BOOL:   tempu64 = s->val.b;             break;
91
            case nsXPTType::T_CHAR:   tempu64 = s->val.c;             break;
92
            case nsXPTType::T_WCHAR:  tempu64 = s->val.wc;            break;
93
            default:                  tempu64 = (PRUint64) s->val.p;  break;
94
            }
95
        }
96
97
        if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
98
            if (i < FPR_COUNT)
99
                fpregs[i]    = s->val.d;
100
            else
101
                *(double *)d = s->val.d;
102
        }
103
        else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
104
            if (i < FPR_COUNT) {
105
                fpregs[i]   = s->val.f; // if passed in registers, floats are promoted to doubles
106
            } else {
107
                float *p = (float *)d;
108
                p++;
109
                *p = s->val.f;
110
            }
111
        }
112
        else {
113
            if (i < GPR_COUNT)
114
                gpregs[i] = tempu64;
115
            else
116
                *d          = tempu64;
117
        }
118
        if (i >= 7)
119
            d++;
120
    }
121
}
122
123
EXPORT_XPCOM_API(nsresult)
124
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
125
                 PRUint32 paramCount, nsXPTCVariant* params);
126
(-) (+101 lines)
Added Link Here
1
// -*- Mode: Asm -*-
2
//
3
// The contents of this file are subject to the Netscape Public
4
// License Version 1.1 (the "License"); you may not use this file
5
// except in compliance with the License. You may obtain a copy of
6
// the License at http://www.mozilla.org/NPL/
7
//
8
// Software distributed under the License is distributed on an "AS
9
// IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
// implied. See the License for the specific language governing
11
// rights and limitations under the License.
12
//
13
// The Original Code is mozilla.org code.
14
//
15
// The Initial Developer of the Original Code is Netscape
16
// Communications Corporation.  Portions created by Netscape are
17
// Copyright (C) 1999 Netscape Communications Corporation. All
18
// Rights Reserved.
19
//
20
// Contributor(s):
21
//   dwmw2@infradead.org (David Woodhouse)
22
//   Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
23
//   beard@netscape.com (Patrick Beard)
24
//   waterson@netscape.com (Chris Waterson)
25
//
26
27
.set r0,0; .set r1,1; .set RTOC,2; .set r3,3; .set r4,4
28
.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
29
.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
30
.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
31
.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
32
.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
33
.set r30,30; .set r31,31
34
.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4
35
.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9
36
.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14
37
.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19
38
.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24
39
.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
40
.set f30,30; .set f31,31
41
42
	.section ".text"
43
	.align 2
44
	.globl SharedStub
45
	.section	".opd","aw"
46
	.align 3
47
48
SharedStub:
49
	.quad   .SharedStub,.TOC.@tocbase
50
	.previous
51
      	.type  SharedStub,@function
52
53
.SharedStub:
54
	mflr	r0
55
56
	std	r4, -56(r1)			// Save all GPRS
57
	std	r5, -48(r1)
58
	std	r6, -40(r1)
59
	std	r7, -32(r1)
60
	std	r8, -24(r1)
61
	std	r9, -16(r1)
62
	std	r10, -8(r1)
63
64
	stfd	f13, -64(r1)			// ... and FPRS
65
	stfd	f12, -72(r1)
66
	stfd	f11, -80(r1)
67
	stfd	f10, -88(r1)
68
	stfd	f9, -96(r1)
69
	stfd	f8, -104(r1)
70
	stfd	f7, -112(r1)
71
	stfd	f6, -120(r1)
72
	stfd	f5, -128(r1)
73
	stfd	f4, -136(r1)
74
	stfd	f3, -144(r1)
75
	stfd	f2, -152(r1)
76
	stfd	f1, -160(r1)
77
78
	subi	r6,r1,56			// r6 --> gprData
79
	subi	r7,r1,160			// r7 --> fprData
80
	addi	r5,r1,112			// r5 --> extra stack args
81
82
	std	r0, 16(r1)
83
	
84
	stdu	r1,-288(r1)
85
					// r3 has the 'self' pointer already
86
	
87
	mr      r4,r11		// r4 is methodIndex selector, passed
88
				// via r11 in the nsXPTCStubBase::StubXX() call
89
	
90
	bl	PrepareAndDispatch
91
92
	ld	1,0(r1)				// restore stack
93
	ld	r0,16(r1)			// restore LR
94
	mtlr	r0
95
	blr
96
97
	.size   SharedStub,.-.SharedStub
98
99
100
/* Magic indicating no need for an executable stack */
101
.section .note.GNU-stack, "", @progbits ; .previous
(-) (+240 lines)
Added Link Here
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version
6
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 * the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/MPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is mozilla.org code.
16
 *
17
 * The Initial Developer of the Original Code is
18
 * Netscape Communications Corporation.
19
 * Portions created by the Initial Developer are Copyright (C) 1999
20
 * the Initial Developer. All Rights Reserved.
21
 *
22
 * Contributor(s):
23
 *   dwmw2@infradead.org (David Woodhouse)
24
 *   Franz.Sirl-kernel@lauterbach.com (Franz Sirl)
25
 *   beard@netscape.com (Patrick Beard)
26
 *   waterson@netscape.com (Chris Waterson)
27
 *
28
 * Alternatively, the contents of this file may be used under the terms of
29
 * either of the GNU General Public License Version 2 or later (the "GPL"),
30
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31
 * in which case the provisions of the GPL or the LGPL are applicable instead
32
 * of those above. If you wish to allow use of your version of this file only
33
 * under the terms of either the GPL or the LGPL, and not to allow others to
34
 * use your version of this file under the terms of the MPL, indicate your
35
 * decision by deleting the provisions above and replace them with the notice
36
 * and other provisions required by the GPL or the LGPL. If you do not delete
37
 * the provisions above, a recipient may use your version of this file under
38
 * the terms of any one of the MPL, the GPL or the LGPL.
39
 *
40
 * ***** END LICENSE BLOCK ***** */
41
42
// Implement shared vtbl methods.
43
44
#include "xptcprivate.h"
45
#include "xptiprivate.h"
46
47
// The Linux/PPC64 ABI passes the first 8 integral
48
// parameters and the first 13 floating point parameters in registers
49
// (r3-r10 and f1-f13), no stack space is allocated for these by the
50
// caller.  The rest of the parameters are passed in the callers stack
51
// area. The stack pointer has to retain 16-byte alignment.
52
53
#define PARAM_BUFFER_COUNT     16
54
#define GPR_COUNT               7
55
#define FPR_COUNT               13
56
57
// PrepareAndDispatch() is called by SharedStub() and calls the actual method.
58
//
59
// - 'args[]' contains the arguments passed on stack
60
// - 'gprData[]' contains the arguments passed in integer registers
61
// - 'fprData[]' contains the arguments passed in floating point registers
62
// 
63
// The parameters are mapped into an array of type 'nsXPTCMiniVariant'
64
// and then the method gets called.
65
#include <stdio.h>
66
extern "C" nsresult
67
PrepareAndDispatch(nsXPTCStubBase* self,
68
                   PRUint64 methodIndex,
69
                   PRUint64* args,
70
                   PRUint64 *gprData,
71
                   double *fprData)
72
{
73
    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
74
    nsXPTCMiniVariant* dispatchParams = NULL;
75
    const nsXPTMethodInfo* info;
76
    PRUint32 paramCount;
77
    PRUint32 i;
78
    nsresult result = NS_ERROR_FAILURE;
79
80
    NS_ASSERTION(self,"no self");
81
82
    self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
83
    NS_ASSERTION(info,"no method info");
84
    if (! info)
85
        return NS_ERROR_UNEXPECTED;
86
87
    paramCount = info->GetParamCount();
88
89
    // setup variant array pointer
90
    if(paramCount > PARAM_BUFFER_COUNT)
91
        dispatchParams = new nsXPTCMiniVariant[paramCount];
92
    else
93
        dispatchParams = paramBuffer;
94
95
    NS_ASSERTION(dispatchParams,"no place for params");
96
    if (! dispatchParams)
97
        return NS_ERROR_OUT_OF_MEMORY;
98
99
    PRUint64* ap = args;
100
    PRUint64 tempu64;
101
102
    for(i = 0; i < paramCount; i++) {
103
        const nsXPTParamInfo& param = info->GetParam(i);
104
        const nsXPTType& type = param.GetType();
105
        nsXPTCMiniVariant* dp = &dispatchParams[i];
106
	
107
        if (!param.IsOut() && type == nsXPTType::T_DOUBLE) {
108
            if (i < FPR_COUNT)
109
                dp->val.d = fprData[i];
110
            else
111
                dp->val.d = *(double*) ap;
112
        } else if (!param.IsOut() && type == nsXPTType::T_FLOAT) {
113
            if (i < FPR_COUNT)
114
                dp->val.f = (float) fprData[i]; // in registers floats are passed as doubles
115
            else {
116
                float *p = (float *)ap;
117
                p++;
118
                dp->val.f = *p;
119
            }
120
        } else { /* integer type or pointer */
121
            if (i < GPR_COUNT)
122
                tempu64 = gprData[i];
123
            else
124
                tempu64 = *ap;
125
126
            if (param.IsOut() || !type.IsArithmetic())
127
                dp->val.p = (void*) tempu64;
128
            else if (type ==nsXPTType::T_I8)
129
                dp->val.i8  = (PRInt8)   tempu64;
130
            else if (type ==nsXPTType::T_I16)
131
                dp->val.i16 = (PRInt16)  tempu64;
132
            else if (type ==nsXPTType::T_I32)
133
                dp->val.i32 = (PRInt32)  tempu64;
134
            else if (type ==nsXPTType::T_I64)
135
                dp->val.i64 = (PRInt64)  tempu64;
136
            else if (type ==nsXPTType::T_U8)
137
                dp->val.u8  = (PRUint8)  tempu64;
138
            else if (type ==nsXPTType::T_U16)
139
                dp->val.u16 = (PRUint16) tempu64;
140
            else if (type ==nsXPTType::T_U32)
141
                dp->val.u32 = (PRUint32) tempu64;
142
            else if (type ==nsXPTType::T_U64)
143
                dp->val.u64 = (PRUint64) tempu64;
144
            else if (type ==nsXPTType::T_BOOL)
145
                dp->val.b   = (PRBool)   tempu64;
146
            else if (type ==nsXPTType::T_CHAR)
147
                dp->val.c   = (char)     tempu64;
148
            else if (type ==nsXPTType::T_WCHAR)
149
                dp->val.wc  = (wchar_t)  tempu64;
150
            else
151
                NS_ASSERTION(0, "bad type");
152
        }
153
154
        if (i >= 7)
155
            ap++;
156
    }
157
158
    result = self->mOuter->CallMethod((PRUint16) methodIndex, info,
159
                                      dispatchParams);
160
161
    if (dispatchParams != paramBuffer)
162
        delete [] dispatchParams;
163
164
    return result;
165
}
166
167
// Load r11 with the constant 'n' and branch to SharedStub().
168
//
169
// XXX Yes, it's ugly that we're relying on gcc's name-mangling here;
170
// however, it's quick, dirty, and'll break when the ABI changes on
171
// us, which is what we want ;-).
172
173
#if __GXX_ABI_VERSION < 100
174
#error Prehistoric GCC not supported here
175
#else
176
// gcc-3 version
177
//
178
// As G++3 ABI contains the length of the functionname in the mangled
179
// name, it is difficult to get a generic assembler mechanism like
180
// in the G++ 2.95 case.
181
// Create names would be like:
182
// _ZN14nsXPTCStubBase5Stub1Ev
183
// _ZN14nsXPTCStubBase6Stub12Ev
184
// _ZN14nsXPTCStubBase7Stub123Ev
185
// _ZN14nsXPTCStubBase8Stub1234Ev
186
// etc.
187
// Use assembler directives to get the names right...
188
189
# define STUB_ENTRY(n)							\
190
__asm__ (								\
191
        ".section \".toc\",\"aw\" \n\t"                                 \
192
        ".section \".text\" \n\t"                                       \
193
	".align	2 \n\t"							\
194
	".if	"#n" < 10 \n\t"						\
195
	".globl	_ZN14nsXPTCStubBase5Stub"#n"Ev \n\t"			\
196
        ".section \".opd\",\"aw\" \n\t"                                 \
197
	".align	3 \n\t"							\
198
"_ZN14nsXPTCStubBase5Stub"#n"Ev: \n\t"					\
199
        ".quad  ._ZN14nsXPTCStubBase5Stub"#n"Ev,.TOC.@tocbase \n\t"     \
200
	".previous \n\t"						\
201
	".type	_ZN14nsXPTCStubBase5Stub"#n"Ev,@function \n\n"		\
202
"._ZN14nsXPTCStubBase5Stub"#n"Ev: \n\t"					\
203
									\
204
	".elseif "#n" < 100 \n\t"					\
205
	".globl	_ZN14nsXPTCStubBase6Stub"#n"Ev \n\t"			\
206
        ".section \".opd\",\"aw\" \n\t"                                 \
207
	".align	3 \n\t"							\
208
"_ZN14nsXPTCStubBase6Stub"#n"Ev: \n\t"					\
209
        ".quad  ._ZN14nsXPTCStubBase6Stub"#n"Ev,.TOC.@tocbase \n\t"     \
210
	".previous \n\t"						\
211
	".type	_ZN14nsXPTCStubBase6Stub"#n"Ev,@function \n\n"		\
212
"._ZN14nsXPTCStubBase6Stub"#n"Ev: \n\t"					\
213
									\
214
	".elseif "#n" < 1000 \n\t"					\
215
	".globl	_ZN14nsXPTCStubBase7Stub"#n"Ev \n\t"			\
216
        ".section \".opd\",\"aw\" \n\t"                                 \
217
	".align	3 \n\t"							\
218
"_ZN14nsXPTCStubBase7Stub"#n"Ev: \n\t"					\
219
        ".quad  ._ZN14nsXPTCStubBase7Stub"#n"Ev,.TOC.@tocbase \n\t"     \
220
	".previous \n\t"						\
221
	".type	_ZN14nsXPTCStubBase7Stub"#n"Ev,@function \n\n"		\
222
"._ZN14nsXPTCStubBase7Stub"#n"Ev: \n\t"					\
223
									\
224
	".else \n\t"							\
225
	".err	\"stub number "#n" >= 1000 not yet supported\"\n"	\
226
	".endif \n\t"							\
227
									\
228
	"li	11,"#n" \n\t"						\
229
	"b	SharedStub \n"					\
230
);
231
#endif
232
233
#define SENTINEL_ENTRY(n)                            \
234
nsresult nsXPTCStubBase::Sentinel##n()               \
235
{                                                    \
236
  NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
237
  return NS_ERROR_NOT_IMPLEMENTED;                   \
238
}
239
240
#include "xptcstubsdef.inc"
(-)xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_linux.cpp (-6 / +5 lines)
Lines 40-48 Link Here
40
40
41
// Platform specific code to invoke XPCOM methods on native objects
41
// Platform specific code to invoke XPCOM methods on native objects
42
42
43
// The purpose of XPTC_InvokeByIndex() is to map a platform
43
// The purpose of NS_InvokeByIndex() is to map a platform
44
// indepenpent call to the platform ABI. To do that,
44
// indepenpent call to the platform ABI. To do that,
45
// XPTC_InvokeByIndex() has to determine the method to call via vtable
45
// NS_InvokeByIndex() has to determine the method to call via vtable
46
// access. The parameters for the method are read from the
46
// access. The parameters for the method are read from the
47
// nsXPTCVariant* and prepared for th native ABI.  For the Linux/PPC
47
// nsXPTCVariant* and prepared for th native ABI.  For the Linux/PPC
48
// ABI this means that the first 8 integral and floating point
48
// ABI this means that the first 8 integral and floating point
Lines 135-141 invoke_copy_to_stack(PRUint32* d, Link Here
135
    }
135
    }
136
}
136
}
137
137
138
extern "C"
138
EXPORT_XPCOM_API(nsresult)
139
XPTC_PUBLIC_API(nsresult)
139
NS_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
140
XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex,
140
                 PRUint32 paramCount, nsXPTCVariant* params);
141
                   PRUint32 paramCount, nsXPTCVariant* params);

Return to bug 101821