[RFC] Firefox/PPC64 support

David Woodhouse dwmw2 at infradead.org
Wed Nov 22 22:03:18 EST 2006


On Wed, 2006-11-22 at 08:00 +0000, David Woodhouse wrote:
> My understanding of the PPC64 C++ ABI is largely empirical. Could
> someone else glance over the attached patch which adds ppc64 support to
> firefox?

Bug #1: I wasn't ensuring that the stack pointer remained aligned to 16
bytes in XPTC_InvokeByIndex(). Fixed (and use of r28 eliminated since I
didn't use it in the end as I intended to) thus:

(full updated patch at http://david.woodhou.se/firefox-1.5-ppc64.patch)

--- mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s~	2006-11-21 18:11:30.000000000 +0000
+++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s	2006-11-22 10:43:26.000000000 +0000
@@ -18,6 +18,7 @@
 // Rights Reserved.
 //
 // Contributor(s):
+//   dwmw2 at infradead.org (David Woodhouse)
 //   Franz.Sirl-kernel at lauterbach.com (Franz Sirl)
 //   beard at netscape.com (Patrick Beard)
 //   waterson at netscape.com (Chris Waterson)
@@ -58,7 +59,6 @@ XPTC_InvokeByIndex:
         mflr	0
 	std	0,16(r1)
 	
-        std	r28,-32(r1)
         std	r29,-24(r1)
 	std	r30,-16(r1)
         std	r31,-8(r1)
@@ -67,17 +67,19 @@ XPTC_InvokeByIndex:
 	mr	r30,r4			// Save 'methodIndex' in r30
 	mr	r31,r1			// Save old frame
 
-	// Allocate stack frame with space for params
-	
-	sldi	r28,r5,3		// Max. 8 bytes per parameter
-	addi	r28,r28,128+(24*8)	// Standard frame, 15 dwords for GP/FP, 4 for r28-r31
-	neg	r28,r28
-	stdux	r1,r1,r28
+	// Allocate stack frame with space for params. Since at least the
+	// first 7 parameters (not including 'that') will be in registers,
+	// we don't actually need stack space for those. Start by rounding
+	// down to make sure the stack remains 16-byte aligned.
+
+	rldicr	r7,r5,r5,59		// r7 = (r3 << 3) & ~15
+	addi	r7,r7,128+(18*8)	// Standard frame, 7 dwords for GPR,
+					// 13 dwords for FPR, 3 for r29-r31,
+					// less 5 of the extra unused params
+	neg	r7,r7
+	stdux	r1,r1,r7
 
 	
-	addi	r28,r1,112		// Stack parameter area.
-
-
 	// Call invoke_copy_to_stack(PRUint64* gpregs, double* fpregs,
         //			     PRUint32 paramCount, nsXPTCVariant* s, 
         //			     PRUint64* d))
@@ -135,8 +137,7 @@ XPTC_InvokeByIndex:
         ld	r2,40(r1)	// Load our own TOC pointer
         ld	r1,0(r1)	// Revert stack frame
         ld	0,16(r1)	// Reload lr
-        ld	28,-32(r1)	// Restore NVGPRS
-        ld	29,-24(r1)
+        ld	29,-24(r1)	// Restore NVGPRS
         ld	30,-16(r1)
         ld	31,-8(r1)
         mtlr	0


-- 
dwmw2




More information about the Linuxppc-dev mailing list