Bug 776079 - Many -Wsometimes-uninitialized warnings in xptcinvoke_x86_64_unix.cpp. r=timeless.
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Thu, 26 Jul 2012 16:09:11 -0400
changeset 100646 727721e5d8ac0c9e32e9ef7433abc39ebf01cd64
parent 100645 1eaa10b26d24dabca67825f65ff3caa91ba9e962
child 100647 9dec76dd3b3cf5e66b38f663ed3894bd6a318cae
push id23188
push useremorley@mozilla.com
push dateFri, 27 Jul 2012 08:54:50 +0000
treeherdermozilla-central@399aff2fb74f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstimeless
bugs776079
milestone17.0a1
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 776079 - Many -Wsometimes-uninitialized warnings in xptcinvoke_x86_64_unix.cpp. r=timeless.
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
@@ -12,18 +12,20 @@
 const PRUint32 GPR_COUNT = 6;
 
 // 8 floating point parameters are passed in SSE registers
 const PRUint32 FPR_COUNT = 8;
 
 // Remember that these 'words' are 64-bit long
 static inline void
 invoke_count_words(PRUint32 paramCount, nsXPTCVariant * s,
-                   PRUint32 & nr_gpr, PRUint32 & nr_fpr, PRUint32 & nr_stack)
+                   PRUint32 & nr_stack)
 {
+    PRUint32 nr_gpr;
+    PRUint32 nr_fpr;
     nr_gpr = 1; // skip one GP register for 'that'
     nr_fpr = 0;
     nr_stack = 0;
 
     /* Compute number of eightbytes of class MEMORY.  */
     for (uint32 i = 0; i < paramCount; i++, s++) {
         if (!s->IsPtrData()
             && (s->type == nsXPTType::T_FLOAT || s->type == nsXPTType::T_DOUBLE)) {
@@ -98,63 +100,62 @@ invoke_copy_to_stack(PRUint64 * d, PRUin
         }
     }
 }
 
 EXPORT_XPCOM_API(nsresult)
 NS_InvokeByIndex_P(nsISupports * that, PRUint32 methodIndex,
                  PRUint32 paramCount, nsXPTCVariant * params)
 {
-    PRUint32 nr_gpr, nr_fpr, nr_stack;
-    invoke_count_words(paramCount, params, nr_gpr, nr_fpr, nr_stack);
+    PRUint32 nr_stack;
+    invoke_count_words(paramCount, params, nr_stack);
     
     // Stack, if used, must be 16-bytes aligned
     if (nr_stack)
         nr_stack = (nr_stack + 1) & ~1;
 
     // 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);
 
+    // We used to have switches to make sure we would only load the registers
+    // that are needed for this call. That produced larger code that was
+    // not faster in practice. It also caused compiler warnings about the
+    // variables being used uninitialized.
+    // We now just load every every register. There could still be a warning
+    // from a memory analysis tools that we are loading uninitialized stack
+    // positions.
+
+    // FIXME: this function depends on the above __builtin_alloca placing
+    // the array in the correct spot for the ABI.
+
     // Load FPR registers from fpregs[]
     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);
-        ARG_FPR(3);
-        ARG_FPR(2);
-        ARG_FPR(1);
-        ARG_FPR(0);
-    case 0:;
-#undef ARG_FPR
-    }
-    
+    d7 = fpregs[7];
+    d6 = fpregs[6];
+    d5 = fpregs[5];
+    d4 = fpregs[4];
+    d3 = fpregs[3];
+    d2 = fpregs[2];
+    d1 = fpregs[1];
+    d0 = fpregs[0];
+
     // Load GPR registers from gpregs[]
     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
-    }
-    
+
+    a5 = gpregs[5];
+    a4 = gpregs[4];
+    a3 = gpregs[3];
+    a2 = gpregs[2];
+    a1 = gpregs[1];
+    a0 = (PRUint64) that;
+
     // Get pointer to method
     PRUint64 methodAddress = *((PRUint64 *)that);
     methodAddress += 8 * methodIndex;
     methodAddress = *((PRUint64 *)methodAddress);
     
     typedef PRUint32 (*Method)(PRUint64, PRUint64, PRUint64, PRUint64,
                                PRUint64, PRUint64, double, double, double,
                                double, double, double, double, double);