Bug 410509 - Set 128-bit alignment for stack in x86, r=bsmedberg
authorSteve Snyder <swsnyder@snydernet.net>
Thu, 30 Oct 2008 10:08:42 -0700
changeset 21103 c4c01d41e11a5ffb8ea260cdf3490b30589c0073
parent 21102 80406c10f79550033c169b537db21669d3aef401
child 21104 9a5f7f7d0141bbb004d74caae959b1c49d4bbd86
push id3315
push userbsmedberg@mozilla.com
push dateThu, 30 Oct 2008 17:08:58 +0000
treeherdermozilla-central@c4c01d41e11a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs410509
milestone1.9.1b2pre
Bug 410509 - Set 128-bit alignment for stack in x86, r=bsmedberg
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_gcc_x86_unix.cpp
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_gcc_x86_unix.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_gcc_x86_unix.cpp
@@ -151,21 +151,23 @@ extern "C" {
 	"ret\n\t"
 	".previous\n\t"
 	"addl  $_GLOBAL_OFFSET_TABLE_, %ebx\n\t"
 #endif
 	"movl  0x10(%ebp), %eax\n\t"
 	"leal  0(,%eax,8),%edx\n\t"
 	"movl  %esp, %ecx\n\t"
 	"subl  %edx, %ecx\n\t"
-/* Since there may be 64-bit data, it occurs to me that aligning this
-   space might be a performance gain. However, I don't think the rest
-   of mozilla worries about such things. In any event, do it here.
-	"andl  $0xfffffff8, %ecx\n\t"
+/* Align to maximum x86 data size: 128 bits == 16 bytes == XMM register size.
+ * This is to avoid protection faults where SSE+ alignment of stack pointer
+ * is assumed and required, e.g. by GCC4's -ftree-vectorize option.
  */
+	"andl  $0xfffffff0, %ecx\n\t"   /* drop(?) stack ptr to 128-bit align */
+	"subl  $8, %ecx\n\t"	        /* lower again; push/call below will re-align */
+	
 	"movl  %ecx, %esp\n\t"          /* make stack space */
 	"movl  0x14(%ebp), %edx\n\t"
 	"call  " SYMBOL_UNDERSCORE "invoke_copy_to_stack\n\t"
 	"movl  0x08(%ebp), %ecx\n\t"	/* 'that' */
 #ifdef CFRONT_STYLE_THIS_ADJUST
 	"movl  (%ecx), %edx\n\t"
 	"movl  0x0c(%ebp), %eax\n\t"    /* function index */
 	"shll  $3, %eax\n\t"	        /* *= 8 */