Bug 519376 - NJ merge: move __SUNPRO _CC gunk. r=dvander.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 30 Sep 2009 11:25:39 +1000
changeset 33558 600318dd0ac5913fb940fff41b1d35e88febf1ac
parent 33557 e3cbe5691b7230b46e00dc5c716214941943fbdc
child 33559 67417b2e65f74e38b1337ccea8c5e956a8218844
push idunknown
push userunknown
push dateunknown
reviewersdvander
bugs519376
milestone1.9.3a1pre
Bug 519376 - NJ merge: move __SUNPRO _CC gunk. r=dvander.
js/src/nanojit/Nativei386.cpp
--- a/js/src/nanojit/Nativei386.cpp
+++ b/js/src/nanojit/Nativei386.cpp
@@ -1220,16 +1220,34 @@ namespace nanojit
             } else {
                 freeRsrcOf(ins, false);
                 Register qr = findRegFor(q, XmmRegs);
                 SSE_MOVD(rr,qr);
             }
         }
     }
 
+	// negateMask is used by asm_fneg.
+#if defined __SUNPRO_CC
+    // From Sun Studio C++ Readme: #pragma align inside namespace requires mangled names.
+    // Initialize here to avoid multithreading contention issues during initialization.
+    static uint32_t negateMask_temp[] = {0, 0, 0, 0, 0, 0, 0};
+
+    static uint32_t* negateMaskInit()
+    {
+        uint32_t* negateMask = (uint32_t*)alignUp(negateMask_temp, 16);
+        negateMask[1] = 0x80000000;
+        return negateMask;
+    }
+
+    static uint32_t *negateMask = negateMaskInit();
+#else
+    static const AVMPLUS_ALIGN16(uint32_t) negateMask[] = {0,0x80000000,0,0};
+#endif
+
     void Assembler::asm_fneg(LInsp ins)
     {
         if (config.sse2)
         {
             LIns *lhs = ins->oprnd1();
 
             Register rr = prepResultReg(ins, XmmRegs);
             Register ra;
@@ -1244,24 +1262,16 @@ namespace nanojit
                     /* We need this case on AMD64, because it's possible that
                      * an earlier instruction has done a quadword load and reserved a
                      * GPR.  If so, ask for a new register.
                      */
                     ra = findRegFor(lhs, XmmRegs);
                 }
             }
 
-#if defined __SUNPRO_CC
-            // from Sun Studio C++ Readme: #pragma align inside namespace requires mangled names
-            static uint32_t temp[] = {0, 0, 0, 0, 0, 0, 0};
-            static uint32_t *negateMask = (uint32_t *)alignUp(temp, 16);
-            negateMask[1] = 0x80000000;
-#else
-            static const AVMPLUS_ALIGN16(uint32_t) negateMask[] = {0,0x80000000,0,0};
-#endif
             SSE_XORPD(rr, negateMask);
 
             if (rr != ra)
                 SSE_MOVSD(rr, ra);
         }
         else
         {
             Register rr = prepResultReg(ins, FpRegs);