Added
Link Here
|
1 |
--- xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_freebsd.s.orig 2009-09-26 22:23:56.000000000 +0200 |
2 |
+++ xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_freebsd.s 2009-09-27 10:01:48.000000000 +0200 |
3 |
@@ -0,0 +1,110 @@ |
4 |
+# -*- Mode: Asm -*- |
5 |
+# |
6 |
+# The contents of this file are subject to the Netscape Public |
7 |
+# License Version 1.1 (the "License"); you may not use this file |
8 |
+# except in compliance with the License. You may obtain a copy of |
9 |
+# the License at http://www.mozilla.org/NPL/ |
10 |
+# |
11 |
+# Software distributed under the License is distributed on an "AS |
12 |
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
13 |
+# implied. See the License for the specific language governing |
14 |
+# rights and limitations under the License. |
15 |
+# |
16 |
+# The Original Code is mozilla.org code. |
17 |
+# |
18 |
+# The Initial Developer of the Original Code is Netscape |
19 |
+# Communications Corporation. Portions created by Netscape are |
20 |
+# Copyright (C) 1999 Netscape Communications Corporation. All |
21 |
+# Rights Reserved. |
22 |
+# |
23 |
+# Contributor(s): |
24 |
+# Franz.Sirl-kernel@lauterbach.com (Franz Sirl) |
25 |
+# beard@netscape.com (Patrick Beard) |
26 |
+# waterson@netscape.com (Chris Waterson) |
27 |
+# |
28 |
+.set r0,0; .set sp,1; .set RTOC,2; .set r3,3; .set r4,4 |
29 |
+.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 |
30 |
+.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 |
31 |
+.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 |
32 |
+.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 |
33 |
+.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 |
34 |
+.set r30,30; .set r31,31 |
35 |
+.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4 |
36 |
+.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9 |
37 |
+.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14 |
38 |
+.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19 |
39 |
+.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24 |
40 |
+.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29 |
41 |
+.set f30,30; .set f31,31 |
42 |
+ |
43 |
+ .section ".text" |
44 |
+ .align 2 |
45 |
+ .globl NS_InvokeByIndex_P |
46 |
+ .type NS_InvokeByIndex_P,@function |
47 |
+ |
48 |
+# |
49 |
+# NS_InvokeByIndex_P(nsISupports* that, PRUint32 methodIndex, |
50 |
+# PRUint32 paramCount, nsXPTCVariant* params) |
51 |
+# |
52 |
+ |
53 |
+NS_InvokeByIndex_P: |
54 |
+ stwu sp,-32(sp) # setup standard stack frame |
55 |
+ mflr r0 # save LR |
56 |
+ stw r3,8(sp) # r3 <= that |
57 |
+ stw r4,12(sp) # r4 <= methodIndex |
58 |
+ stw r30,16(sp) |
59 |
+ stw r31,20(sp) |
60 |
+ |
61 |
+ stw r0,36(sp) # store LR backchain |
62 |
+ mr r31,sp |
63 |
+ |
64 |
+ rlwinm r10,r5,3,0,27 # r10 = (ParamCount * 2 * 4) & ~0x0f |
65 |
+ addi r0,r10,96 # reserve stack for GPR and FPR register save area r0 = r10 + 96 |
66 |
+ lwz r9,0(sp) # r9 = backchain |
67 |
+ neg r0,r0 |
68 |
+ stwux r9,sp,r0 # reserve stack sapce and save SP backchain |
69 |
+ |
70 |
+ addi r3,sp,8 # r3 <= args |
71 |
+ mr r4,r5 # r4 <= paramCount |
72 |
+ mr r5,r6 # r5 <= params |
73 |
+ add r6,r3,r10 # r6 <= gpregs ( == args + r10 ) |
74 |
+ mr r30,r6 # store in r30 for use later... |
75 |
+ addi r7,r6,32 # r7 <= fpregs ( == gpregs + 32 ) |
76 |
+ |
77 |
+ bl invoke_copy_to_stack@local # (args, paramCount, params, gpregs, fpregs) |
78 |
+ |
79 |
+ lfd f1,32(r30) # load FP registers with method parameters |
80 |
+ lfd f2,40(r30) |
81 |
+ lfd f3,48(r30) |
82 |
+ lfd f4,56(r30) |
83 |
+ lfd f5,64(r30) |
84 |
+ lfd f6,72(r30) |
85 |
+ lfd f7,80(r30) |
86 |
+ lfd f8,88(r30) |
87 |
+ |
88 |
+ lwz r3,8(r31) # r3 <= that |
89 |
+ lwz r4,12(r31) # r4 <= methodIndex |
90 |
+ lwz r5,0(r3) # r5 <= vtable ( == *that ) |
91 |
+ |
92 |
+ slwi r4,r4,2 # convert to offset ( *= 4 ) |
93 |
+ lwzx r0,r5,r4 # r0 <= methodpointer ( == vtable + offset ) |
94 |
+ |
95 |
+ lwz r4,4(r30) # load GP regs with method parameters |
96 |
+ lwz r5,8(r30) |
97 |
+ lwz r6,12(r30) |
98 |
+ lwz r7,16(r30) |
99 |
+ lwz r8,20(r30) |
100 |
+ lwz r9,24(r30) |
101 |
+ lwz r10,28(r30) |
102 |
+ |
103 |
+ mtlr r0 # copy methodpointer to LR |
104 |
+ blrl # call method |
105 |
+ |
106 |
+ lwz r30,16(r31) # restore r30 & r31 |
107 |
+ lwz r31,20(r31) |
108 |
+ |
109 |
+ lwz r11,0(sp) # clean up the stack |
110 |
+ lwz r0,4(r11) |
111 |
+ mtlr r0 |
112 |
+ mr sp,r11 |
113 |
+ blr |
114 |
--- xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_freebsd.cpp.orig 2009-09-26 22:23:56.000000000 +0200 |
115 |
+++ xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_freebsd.cpp 2009-09-27 09:58:59.000000000 +0200 |
116 |
@@ -0,0 +1,141 @@ |
117 |
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
118 |
+/* ***** BEGIN LICENSE BLOCK ***** |
119 |
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
120 |
+ * |
121 |
+ * The contents of this file are subject to the Mozilla Public License Version |
122 |
+ * 1.1 (the "License"); you may not use this file except in compliance with |
123 |
+ * the License. You may obtain a copy of the License at |
124 |
+ * http://www.mozilla.org/MPL/ |
125 |
+ * |
126 |
+ * Software distributed under the License is distributed on an "AS IS" basis, |
127 |
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
128 |
+ * for the specific language governing rights and limitations under the |
129 |
+ * License. |
130 |
+ * |
131 |
+ * The Original Code is mozilla.org code. |
132 |
+ * |
133 |
+ * The Initial Developer of the Original Code is |
134 |
+ * Netscape Communications Corporation. |
135 |
+ * Portions created by the Initial Developer are Copyright (C) 1998 |
136 |
+ * the Initial Developer. All Rights Reserved. |
137 |
+ * |
138 |
+ * Contributor(s): |
139 |
+ * Franz.Sirl-kernel@lauterbach.com (Franz Sirl) |
140 |
+ * beard@netscape.com (Patrick Beard) |
141 |
+ * waterson@netscape.com (Chris Waterson) |
142 |
+ * |
143 |
+ * Alternatively, the contents of this file may be used under the terms of |
144 |
+ * either of the GNU General Public License Version 2 or later (the "GPL"), |
145 |
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
146 |
+ * in which case the provisions of the GPL or the LGPL are applicable instead |
147 |
+ * of those above. If you wish to allow use of your version of this file only |
148 |
+ * under the terms of either the GPL or the LGPL, and not to allow others to |
149 |
+ * use your version of this file under the terms of the MPL, indicate your |
150 |
+ * decision by deleting the provisions above and replace them with the notice |
151 |
+ * and other provisions required by the GPL or the LGPL. If you do not delete |
152 |
+ * the provisions above, a recipient may use your version of this file under |
153 |
+ * the terms of any one of the MPL, the GPL or the LGPL. |
154 |
+ * |
155 |
+ * ***** END LICENSE BLOCK ***** */ |
156 |
+ |
157 |
+// Platform specific code to invoke XPCOM methods on native objects |
158 |
+ |
159 |
+// The purpose of NS_InvokeByIndex_P() is to map a platform |
160 |
+// indepenpent call to the platform ABI. To do that, |
161 |
+// NS_InvokeByIndex_P() has to determine the method to call via vtable |
162 |
+// access. The parameters for the method are read from the |
163 |
+// nsXPTCVariant* and prepared for th native ABI. For the Linux/PPC |
164 |
+// ABI this means that the first 8 integral and floating point |
165 |
+// parameters are passed in registers. |
166 |
+ |
167 |
+#include "xptcprivate.h" |
168 |
+ |
169 |
+// 8 integral parameters are passed in registers |
170 |
+#define GPR_COUNT 8 |
171 |
+ |
172 |
+// 8 floating point parameters are passed in registers, floats are |
173 |
+// promoted to doubles when passed in registers |
174 |
+#define FPR_COUNT 8 |
175 |
+ |
176 |
+extern "C" PRUint32 |
177 |
+invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s) |
178 |
+{ |
179 |
+ return PRUint32(((paramCount * 2) + 3) & ~3); |
180 |
+} |
181 |
+ |
182 |
+extern "C" void |
183 |
+invoke_copy_to_stack(PRUint32* d, |
184 |
+ PRUint32 paramCount, |
185 |
+ nsXPTCVariant* s, |
186 |
+ PRUint32* gpregs, |
187 |
+ double* fpregs) |
188 |
+{ |
189 |
+ PRUint32 gpr = 1; // skip one GP reg for 'that' |
190 |
+ PRUint32 fpr = 0; |
191 |
+ PRUint32 tempu32; |
192 |
+ PRUint64 tempu64; |
193 |
+ |
194 |
+ for(uint32 i = 0; i < paramCount; i++, s++) { |
195 |
+ if(s->IsPtrData()) |
196 |
+ tempu32 = (PRUint32) s->ptr; |
197 |
+ else { |
198 |
+ switch(s->type) { |
199 |
+ case nsXPTType::T_FLOAT: break; |
200 |
+ case nsXPTType::T_DOUBLE: break; |
201 |
+ case nsXPTType::T_I8: tempu32 = s->val.i8; break; |
202 |
+ case nsXPTType::T_I16: tempu32 = s->val.i16; break; |
203 |
+ case nsXPTType::T_I32: tempu32 = s->val.i32; break; |
204 |
+ case nsXPTType::T_I64: tempu64 = s->val.i64; break; |
205 |
+ case nsXPTType::T_U8: tempu32 = s->val.u8; break; |
206 |
+ case nsXPTType::T_U16: tempu32 = s->val.u16; break; |
207 |
+ case nsXPTType::T_U32: tempu32 = s->val.u32; break; |
208 |
+ case nsXPTType::T_U64: tempu64 = s->val.u64; break; |
209 |
+ case nsXPTType::T_BOOL: tempu32 = s->val.b; break; |
210 |
+ case nsXPTType::T_CHAR: tempu32 = s->val.c; break; |
211 |
+ case nsXPTType::T_WCHAR: tempu32 = s->val.wc; break; |
212 |
+ default: tempu32 = (PRUint32) s->val.p; break; |
213 |
+ } |
214 |
+ } |
215 |
+ |
216 |
+ if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) { |
217 |
+ if (fpr < FPR_COUNT) |
218 |
+ fpregs[fpr++] = s->val.d; |
219 |
+ else { |
220 |
+ if ((PRUint32) d & 4) d++; // doubles are 8-byte aligned on stack |
221 |
+ *((double*) d) = s->val.d; |
222 |
+ d += 2; |
223 |
+ } |
224 |
+ } |
225 |
+ else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) { |
226 |
+ if (fpr < FPR_COUNT) |
227 |
+ fpregs[fpr++] = s->val.f; // if passed in registers, floats are promoted to doubles |
228 |
+ else |
229 |
+ *((float*) d++) = s->val.f; |
230 |
+ } |
231 |
+ else if (!s->IsPtrData() && (s->type == nsXPTType::T_I64 |
232 |
+ || s->type == nsXPTType::T_U64)) { |
233 |
+ if ((gpr + 1) < GPR_COUNT) { |
234 |
+ if (gpr & 1) gpr++; // longlongs are aligned in odd/even register pairs, eg. r5/r6 |
235 |
+ *((PRUint64*) &gpregs[gpr]) = tempu64; |
236 |
+ gpr += 2; |
237 |
+ } |
238 |
+ else { |
239 |
+ if ((PRUint32) d & 4) d++; // longlongs are 8-byte aligned on stack |
240 |
+ *((PRUint64*) d) = tempu64; |
241 |
+ d += 2; |
242 |
+ } |
243 |
+ } |
244 |
+ else { |
245 |
+ if (gpr < GPR_COUNT) |
246 |
+ gpregs[gpr++] = tempu32; |
247 |
+ else |
248 |
+ *d++ = tempu32; |
249 |
+ } |
250 |
+ |
251 |
+ } |
252 |
+} |
253 |
+ |
254 |
+extern "C" |
255 |
+EXPORT_XPCOM_API(nsresult) |
256 |
+NS_InvokeByIndex_P(nsISupports* that, PRUint32 methodIndex, |
257 |
+ PRUint32 paramCount, nsXPTCVariant* params); |
258 |
--- xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc_freebsd.s.orig 2009-09-26 22:23:56.000000000 +0200 |
259 |
+++ xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc_freebsd.s 2009-09-26 22:23:56.000000000 +0200 |
260 |
@@ -0,0 +1,89 @@ |
261 |
+# -*- Mode: Asm -*- |
262 |
+# |
263 |
+# The contents of this file are subject to the Netscape Public |
264 |
+# License Version 1.1 (the "License"); you may not use this file |
265 |
+# except in compliance with the License. You may obtain a copy of |
266 |
+# the License at http://www.mozilla.org/NPL/ |
267 |
+# |
268 |
+# Software distributed under the License is distributed on an "AS |
269 |
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
270 |
+# implied. See the License for the specific language governing |
271 |
+# rights and limitations under the License. |
272 |
+# |
273 |
+# The Original Code is mozilla.org code. |
274 |
+# |
275 |
+# The Initial Developer of the Original Code is Netscape |
276 |
+# Communications Corporation. Portions created by Netscape are |
277 |
+# Copyright (C) 1999 Netscape Communications Corporation. All |
278 |
+# Rights Reserved. |
279 |
+# |
280 |
+# Contributor(s): |
281 |
+# Franz.Sirl-kernel@lauterbach.com (Franz Sirl) |
282 |
+# beard@netscape.com (Patrick Beard) |
283 |
+# waterson@netscape.com (Chris Waterson) |
284 |
+# |
285 |
+ |
286 |
+.set r0,0; .set sp,1; .set RTOC,2; .set r3,3; .set r4,4 |
287 |
+.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 |
288 |
+.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 |
289 |
+.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 |
290 |
+.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 |
291 |
+.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 |
292 |
+.set r30,30; .set r31,31 |
293 |
+.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4 |
294 |
+.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9 |
295 |
+.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14 |
296 |
+.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19 |
297 |
+.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24 |
298 |
+.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29 |
299 |
+.set f30,30; .set f31,31 |
300 |
+ |
301 |
+ .section ".text" |
302 |
+ .align 2 |
303 |
+ .globl SharedStub |
304 |
+ .type SharedStub,@function |
305 |
+ |
306 |
+SharedStub: |
307 |
+ stwu sp,-112(sp) # room for |
308 |
+ # linkage (8), |
309 |
+ # gprData (32), |
310 |
+ # fprData (64), |
311 |
+ # stack alignment(8) |
312 |
+ mflr r0 |
313 |
+ stw r0,116(sp) # save LR backchain |
314 |
+ |
315 |
+ stw r4,12(sp) # save GP registers |
316 |
+ stw r5,16(sp) # (n.b. that we don't save r3 |
317 |
+ stw r6,20(sp) # because PrepareAndDispatch() is savvy) |
318 |
+ stw r7,24(sp) |
319 |
+ stw r8,28(sp) |
320 |
+ stw r9,32(sp) |
321 |
+ stw r10,36(sp) |
322 |
+ |
323 |
+ stfd f1,40(sp) # save FP registers |
324 |
+ stfd f2,48(sp) |
325 |
+ stfd f3,56(sp) |
326 |
+ stfd f4,64(sp) |
327 |
+ stfd f5,72(sp) |
328 |
+ stfd f6,80(sp) |
329 |
+ stfd f7,88(sp) |
330 |
+ stfd f8,96(sp) |
331 |
+ |
332 |
+ # r3 has the 'self' pointer already |
333 |
+ |
334 |
+ mr r4,r11 # r4 <= methodIndex selector, passed |
335 |
+ # via r11 in the nsXPTCStubBase::StubXX() call |
336 |
+ |
337 |
+ addi r5,sp,120 # r5 <= pointer to callers args area, |
338 |
+ # beyond r3-r10/f1-f8 mapped range |
339 |
+ |
340 |
+ addi r6,sp,8 # r6 <= gprData |
341 |
+ addi r7,sp,40 # r7 <= fprData |
342 |
+ |
343 |
+ bl PrepareAndDispatch@local # Go! |
344 |
+ |
345 |
+ lwz r0,116(sp) # restore LR |
346 |
+ mtlr r0 |
347 |
+ la sp,112(sp) # clean up the stack |
348 |
+ blr |
349 |
+ |
350 |
--- xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_freebsd.cpp.orig 2009-09-26 22:23:56.000000000 +0200 |
351 |
+++ xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_freebsd.cpp 2009-09-26 22:43:57.000000000 +0200 |
352 |
@@ -0,0 +1,228 @@ |
353 |
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
354 |
+/* ***** BEGIN LICENSE BLOCK ***** |
355 |
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
356 |
+ * |
357 |
+ * The contents of this file are subject to the Mozilla Public License Version |
358 |
+ * 1.1 (the "License"); you may not use this file except in compliance with |
359 |
+ * the License. You may obtain a copy of the License at |
360 |
+ * http://www.mozilla.org/MPL/ |
361 |
+ * |
362 |
+ * Software distributed under the License is distributed on an "AS IS" basis, |
363 |
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
364 |
+ * for the specific language governing rights and limitations under the |
365 |
+ * License. |
366 |
+ * |
367 |
+ * The Original Code is mozilla.org code. |
368 |
+ * |
369 |
+ * The Initial Developer of the Original Code is |
370 |
+ * Netscape Communications Corporation. |
371 |
+ * Portions created by the Initial Developer are Copyright (C) 1999 |
372 |
+ * the Initial Developer. All Rights Reserved. |
373 |
+ * |
374 |
+ * Contributor(s): |
375 |
+ * Franz.Sirl-kernel@lauterbach.com (Franz Sirl) |
376 |
+ * beard@netscape.com (Patrick Beard) |
377 |
+ * waterson@netscape.com (Chris Waterson) |
378 |
+ * |
379 |
+ * Alternatively, the contents of this file may be used under the terms of |
380 |
+ * either of the GNU General Public License Version 2 or later (the "GPL"), |
381 |
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
382 |
+ * in which case the provisions of the GPL or the LGPL are applicable instead |
383 |
+ * of those above. If you wish to allow use of your version of this file only |
384 |
+ * under the terms of either the GPL or the LGPL, and not to allow others to |
385 |
+ * use your version of this file under the terms of the MPL, indicate your |
386 |
+ * decision by deleting the provisions above and replace them with the notice |
387 |
+ * and other provisions required by the GPL or the LGPL. If you do not delete |
388 |
+ * the provisions above, a recipient may use your version of this file under |
389 |
+ * the terms of any one of the MPL, the GPL or the LGPL. |
390 |
+ * |
391 |
+ * ***** END LICENSE BLOCK ***** */ |
392 |
+ |
393 |
+// Implement shared vtbl methods. |
394 |
+ |
395 |
+#include "xptcprivate.h" |
396 |
+#include "xptiprivate.h" |
397 |
+ |
398 |
+// The PPC/SYSV ABI passes the first 8 integral |
399 |
+// parameters and the first 8 floating point parameters in registers |
400 |
+// (r3-r10 and f1-f8), no stack space is allocated for these by the |
401 |
+// caller. The rest of the parameters are passed in the callers stack |
402 |
+// area. The stack pointer has to retain 16-byte alignment, longlongs |
403 |
+// and doubles are aligned on 8-byte boundaries. |
404 |
+ |
405 |
+#define PARAM_BUFFER_COUNT 16 |
406 |
+#define GPR_COUNT 8 |
407 |
+#define FPR_COUNT 8 |
408 |
+ |
409 |
+// PrepareAndDispatch() is called by SharedStub() and calls the actual method. |
410 |
+// |
411 |
+// - 'args[]' contains the arguments passed on stack |
412 |
+// - 'gprData[]' contains the arguments passed in integer registers |
413 |
+// - 'fprData[]' contains the arguments passed in floating point registers |
414 |
+// |
415 |
+// The parameters are mapped into an array of type 'nsXPTCMiniVariant' |
416 |
+// and then the method gets called. |
417 |
+ |
418 |
+extern "C" nsresult |
419 |
+PrepareAndDispatch(nsXPTCStubBase* self, |
420 |
+ PRUint32 methodIndex, |
421 |
+ PRUint32* args, |
422 |
+ PRUint32 *gprData, |
423 |
+ double *fprData) |
424 |
+{ |
425 |
+ nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; |
426 |
+ nsXPTCMiniVariant* dispatchParams = NULL; |
427 |
+ const nsXPTMethodInfo* info = NULL; |
428 |
+ PRUint32 paramCount; |
429 |
+ PRUint32 i; |
430 |
+ nsresult result = NS_ERROR_FAILURE; |
431 |
+ |
432 |
+ NS_ASSERTION(self,"no self"); |
433 |
+ |
434 |
+ self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info); |
435 |
+ NS_ASSERTION(info,"no method info"); |
436 |
+ if (! info) |
437 |
+ return NS_ERROR_UNEXPECTED; |
438 |
+ |
439 |
+ paramCount = info->GetParamCount(); |
440 |
+ |
441 |
+ // setup variant array pointer |
442 |
+ if(paramCount > PARAM_BUFFER_COUNT) |
443 |
+ dispatchParams = new nsXPTCMiniVariant[paramCount]; |
444 |
+ else |
445 |
+ dispatchParams = paramBuffer; |
446 |
+ |
447 |
+ NS_ASSERTION(dispatchParams,"no place for params"); |
448 |
+ if (! dispatchParams) |
449 |
+ return NS_ERROR_OUT_OF_MEMORY; |
450 |
+ |
451 |
+ PRUint32* ap = args; |
452 |
+ PRUint32 gpr = 1; // skip one GPR register |
453 |
+ PRUint32 fpr = 0; |
454 |
+ PRUint32 tempu32; |
455 |
+ PRUint64 tempu64; |
456 |
+ |
457 |
+ for(i = 0; i < paramCount; i++) { |
458 |
+ const nsXPTParamInfo& param = info->GetParam(i); |
459 |
+ const nsXPTType& type = param.GetType(); |
460 |
+ nsXPTCMiniVariant* dp = &dispatchParams[i]; |
461 |
+ |
462 |
+ if (!param.IsOut() && type == nsXPTType::T_DOUBLE) { |
463 |
+ if (fpr < FPR_COUNT) |
464 |
+ dp->val.d = fprData[fpr++]; |
465 |
+ else { |
466 |
+ if ((PRUint32) ap & 4) ap++; // doubles are 8-byte aligned on stack |
467 |
+ dp->val.d = *(double*) ap; |
468 |
+ ap += 2; |
469 |
+ } |
470 |
+ continue; |
471 |
+ } |
472 |
+ else if (!param.IsOut() && type == nsXPTType::T_FLOAT) { |
473 |
+ if (fpr < FPR_COUNT) |
474 |
+ dp->val.f = (float) fprData[fpr++]; // in registers floats are passed as doubles |
475 |
+ else |
476 |
+ dp->val.f = *(float*) ap++; |
477 |
+ continue; |
478 |
+ } |
479 |
+ else if (!param.IsOut() && (type == nsXPTType::T_I64 |
480 |
+ || type == nsXPTType::T_U64)) { |
481 |
+ if (gpr & 1) gpr++; // longlongs are aligned in odd/even register pairs, eg. r5/r6 |
482 |
+ if ((gpr + 1) < GPR_COUNT) { |
483 |
+ tempu64 = *(PRUint64*) &gprData[gpr]; |
484 |
+ gpr += 2; |
485 |
+ } |
486 |
+ else { |
487 |
+ if ((PRUint32) ap & 4) ap++; // longlongs are 8-byte aligned on stack |
488 |
+ tempu64 = *(PRUint64*) ap; |
489 |
+ ap += 2; |
490 |
+ } |
491 |
+ } |
492 |
+ else { |
493 |
+ if (gpr < GPR_COUNT) |
494 |
+ tempu32 = gprData[gpr++]; |
495 |
+ else |
496 |
+ tempu32 = *ap++; |
497 |
+ } |
498 |
+ |
499 |
+ if(param.IsOut() || !type.IsArithmetic()) { |
500 |
+ dp->val.p = (void*) tempu32; |
501 |
+ continue; |
502 |
+ } |
503 |
+ |
504 |
+ switch(type) { |
505 |
+ case nsXPTType::T_I8: dp->val.i8 = (PRInt8) tempu32; break; |
506 |
+ case nsXPTType::T_I16: dp->val.i16 = (PRInt16) tempu32; break; |
507 |
+ case nsXPTType::T_I32: dp->val.i32 = (PRInt32) tempu32; break; |
508 |
+ case nsXPTType::T_I64: dp->val.i64 = (PRInt64) tempu64; break; |
509 |
+ case nsXPTType::T_U8: dp->val.u8 = (PRUint8) tempu32; break; |
510 |
+ case nsXPTType::T_U16: dp->val.u16 = (PRUint16) tempu32; break; |
511 |
+ case nsXPTType::T_U32: dp->val.u32 = (PRUint32) tempu32; break; |
512 |
+ case nsXPTType::T_U64: dp->val.u64 = (PRUint64) tempu64; break; |
513 |
+ case nsXPTType::T_BOOL: dp->val.b = (PRBool) tempu32; break; |
514 |
+ case nsXPTType::T_CHAR: dp->val.c = (char) tempu32; break; |
515 |
+ case nsXPTType::T_WCHAR: dp->val.wc = (wchar_t) tempu32; break; |
516 |
+ |
517 |
+ default: |
518 |
+ NS_ASSERTION(0, "bad type"); |
519 |
+ break; |
520 |
+ } |
521 |
+ } |
522 |
+ |
523 |
+ result = self->mOuter->CallMethod((PRUint16)methodIndex, |
524 |
+ info, |
525 |
+ dispatchParams); |
526 |
+ |
527 |
+ if (dispatchParams != paramBuffer) |
528 |
+ delete [] dispatchParams; |
529 |
+ |
530 |
+ return result; |
531 |
+ |
532 |
+} |
533 |
+ |
534 |
+// Load r11 with the constant 'n' and branch to SharedStub(). |
535 |
+ |
536 |
+// As G++3 ABI contains the length of the functionname in the mangled |
537 |
+// name, it is difficult to get a generic assembler mechanism like |
538 |
+// in the G++ 2.95 case. |
539 |
+// Create names would be like: |
540 |
+// _ZN14nsXPTCStubBase5Stub1Ev |
541 |
+// _ZN14nsXPTCStubBase6Stub12Ev |
542 |
+// _ZN14nsXPTCStubBase7Stub123Ev |
543 |
+// _ZN14nsXPTCStubBase8Stub1234Ev |
544 |
+// etc. |
545 |
+// Use assembler directives to get the names right... |
546 |
+ |
547 |
+# define STUB_ENTRY(n) \ |
548 |
+__asm__ ( \ |
549 |
+ ".align 2 \n\t" \ |
550 |
+ ".if "#n" < 10 \n\t" \ |
551 |
+ ".globl _ZN14nsXPTCStubBase5Stub"#n"Ev \n\t" \ |
552 |
+ ".type _ZN14nsXPTCStubBase5Stub"#n"Ev,@function \n\n" \ |
553 |
+"_ZN14nsXPTCStubBase5Stub"#n"Ev: \n\t" \ |
554 |
+ \ |
555 |
+ ".elseif "#n" < 100 \n\t" \ |
556 |
+ ".globl _ZN14nsXPTCStubBase6Stub"#n"Ev \n\t" \ |
557 |
+ ".type _ZN14nsXPTCStubBase6Stub"#n"Ev,@function \n\n" \ |
558 |
+"_ZN14nsXPTCStubBase6Stub"#n"Ev: \n\t" \ |
559 |
+ \ |
560 |
+ ".elseif "#n" < 1000 \n\t" \ |
561 |
+ ".globl _ZN14nsXPTCStubBase7Stub"#n"Ev \n\t" \ |
562 |
+ ".type _ZN14nsXPTCStubBase7Stub"#n"Ev,@function \n\n" \ |
563 |
+"_ZN14nsXPTCStubBase7Stub"#n"Ev: \n\t" \ |
564 |
+ \ |
565 |
+ ".else \n\t" \ |
566 |
+ ".err \"stub number "#n" >= 1000 not yet supported\"\n" \ |
567 |
+ ".endif \n\t" \ |
568 |
+ \ |
569 |
+ "li 11,"#n" \n\t" \ |
570 |
+ "b SharedStub@local \n" \ |
571 |
+); |
572 |
+ |
573 |
+#define SENTINEL_ENTRY(n) \ |
574 |
+nsresult nsXPTCStubBase::Sentinel##n() \ |
575 |
+{ \ |
576 |
+ NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \ |
577 |
+ return NS_ERROR_NOT_IMPLEMENTED; \ |
578 |
+} |
579 |
+ |
580 |
+#include "xptcstubsdef.inc" |