Bug 623129 - x86_64 NS_InvokeByIndex_P asm decl to reserve registers is not guaranteed to work as advertised; r=glandium a=shaver
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Wed, 26 Jan 2011 15:27:34 -0500
changeset 62017 236989b3a807fafa2e1057f879da2fb89dcfa023
parent 62016 025a5df6580136dc94067bb05177c4d5545582e1
child 62018 2ce5e1843ce88e2b3d8e542c3789041195a85411
push id18579
push usereakhgari@mozilla.com
push dateSun, 06 Feb 2011 19:52:20 +0000
treeherdermozilla-central@236989b3a807 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium, shaver
bugs623129
milestone2.0b12pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 623129 - x86_64 NS_InvokeByIndex_P asm decl to reserve registers is not guaranteed to work as advertised; r=glandium a=shaver
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp
@@ -144,24 +144,17 @@ NS_InvokeByIndex_P(nsISupports * that, P
 
     // Load parameters to stack, if necessary
     PRUint64 *stack = (PRUint64 *) __builtin_alloca(nr_stack * 8);
     PRUint64 gpregs[GPR_COUNT];
     double fpregs[FPR_COUNT];
     invoke_copy_to_stack(stack, paramCount, params, gpregs, fpregs);
 
     // Load FPR registers from fpregs[]
-    register double d0 asm("xmm0");
-    register double d1 asm("xmm1");
-    register double d2 asm("xmm2");
-    register double d3 asm("xmm3");
-    register double d4 asm("xmm4");
-    register double d5 asm("xmm5");
-    register double d6 asm("xmm6");
-    register double d7 asm("xmm7");
+    double d0, d1, d2, d3, d4, d5, d6, d7;
 
     switch (nr_fpr) {
 #define ARG_FPR(N) \
     case N+1: d##N = fpregs[N];
         ARG_FPR(7);
         ARG_FPR(6);
         ARG_FPR(5);
         ARG_FPR(4);
@@ -169,42 +162,36 @@ NS_InvokeByIndex_P(nsISupports * that, P
         ARG_FPR(2);
         ARG_FPR(1);
         ARG_FPR(0);
     case 0:;
 #undef ARG_FPR
     }
     
     // Load GPR registers from gpregs[]
-    register PRUint64 a0 asm("rdi");
-    register PRUint64 a1 asm("rsi");
-    register PRUint64 a2 asm("rdx");
-    register PRUint64 a3 asm("rcx");
-    register PRUint64 a4 asm("r8");
-    register PRUint64 a5 asm("r9");
+    PRUint64 a0, a1, a2, a3, a4, a5;
     
     switch (nr_gpr) {
 #define ARG_GPR(N) \
     case N+1: a##N = gpregs[N];
         ARG_GPR(5);
         ARG_GPR(4);
         ARG_GPR(3);
         ARG_GPR(2);
         ARG_GPR(1);
     case 1: a0 = (PRUint64) that;
     case 0:;
 #undef ARG_GPR
     }
-
-    // Ensure that assignments to SSE registers won't be optimized away
-    asm("" ::
-        "x" (d0), "x" (d1), "x" (d2), "x" (d3),
-        "x" (d4), "x" (d5), "x" (d6), "x" (d7));
     
     // Get pointer to method
     PRUint64 methodAddress = *((PRUint64 *)that);
     methodAddress += 8 * methodIndex;
     methodAddress = *((PRUint64 *)methodAddress);
     
-    typedef PRUint32 (*Method)(PRUint64, PRUint64, PRUint64, PRUint64, PRUint64, PRUint64);
-    PRUint32 result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5);
+    typedef PRUint32 (*Method)(PRUint64, PRUint64, PRUint64, PRUint64,
+                               PRUint64, PRUint64, double, double, double,
+                               double, double, double, double, double);
+    PRUint32 result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5,
+                                              d0, d1, d2, d3, d4, d5,
+                                              d6, d7);
     return result;
 }