From 54646c2f7495af7142e97743ca3e4b17f17b2599 Mon Sep 17 00:00:00 2001 From: "joshmoz%gmail.com" Date: Tue, 26 Jul 2005 00:59:40 +0000 Subject: [PATCH] xptcall stack alignment fix for x86 Mac OS X. Symptom is usually a crash due to an invalid (truncated SSE3) instruction on the stack with xptcall stuff earlier on. Patch by dbaron, built on a patch by Apple Computer, Inc.. Thanks dbaron! Only affects x86 Mac OS X. b=297326 r=josh sr=dbaron a=asa --- .../src/md/unix/xptcinvoke_unixish_x86.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp index 83a4629ba716..29d0d7f49ab6 100644 --- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp +++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_x86.cpp @@ -85,8 +85,22 @@ XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex, void (*fn_copy) (unsigned int, nsXPTCVariant *, PRUint32 *) = invoke_copy_to_stack; int temp1, temp2, temp3; +#ifdef XP_MACOSX + unsigned int saved_esp; + __asm__ __volatile__( + "movl %%esp, %0\n\t" + : "=r"(saved_esp)); +#endif + __asm__ __volatile__( "subl %8, %%esp\n\t" /* make room for params */ +#ifdef XP_MACOSX + /* the subl and the addl around the andl compensate for the push + of the this parameter below */ + "subl $0x4, %%esp\n\t" + "andl $0xfffffff0, %%esp\n\t" /* make sure stack is 16-byte aligned */ + "addl $0x4, %%esp\n\t" +#endif "pushl %%esp\n\t" "pushl %7\n\t" "pushl %6\n\t" @@ -127,8 +141,18 @@ XPTC_InvokeByIndex(nsISupports* that, PRUint32 methodIndex, "g" (n), /* %8 */ "0" (fn_copy) /* %3 */ : "memory" +#ifdef XP_MACOSX + , "%esp" +#endif ); +#ifdef XP_MACOSX + __asm__ __volatile__( + "movl %0, %%esp\n\t" + : + : "r"(saved_esp)); +#endif + return result; #else