Bug 1160148 followup - need the fix in libxul too
authorDavid Major <dmajor@mozilla.com>
Fri, 08 May 2015 23:04:49 -0400
changeset 243078 f7a79386ab63a58fc4791a526cd238bcefee2f15
parent 243077 a9a4f21d0daf6fb2f956cdc9caf0f8382b696d7b
child 243079 60e13432ce2e86ac301b65098f734a79f75ce0fa
push id59590
push userdmajor@mozilla.com
push dateSat, 09 May 2015 03:06:31 +0000
treeherdermozilla-inbound@f7a79386ab63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1160148
milestone40.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 1160148 followup - need the fix in libxul too
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -90,16 +90,18 @@
 
 #include "base/histogram.h"
 
 #include "mozilla/unused.h"
 
 #ifdef XP_WIN
 #include "nsIWinAppHelper.h"
 #include <windows.h>
+#include <intrin.h>
+#include <math.h>
 #include "cairo/cairo-features.h"
 #include "mozilla/WindowsVersion.h"
 
 #ifndef PROCESS_DEP_ENABLE
 #define PROCESS_DEP_ENABLE 0x1
 #endif
 #endif
 
@@ -4100,16 +4102,27 @@ XREMain::XRE_main(int argc, char* argv[]
 
   nsresult rv = NS_OK;
 
   gArgc = argc;
   gArgv = argv;
 
   NS_ENSURE_TRUE(aAppData, 2);
 
+#if defined(_MSC_VER) && _MSC_VER < 1900 && defined(_M_X64)
+  // Disable CRT use of FMA3 on non-AVX2 processors because of bug 1160148
+  int cpuid0[4] = {0};
+  int cpuid7[4] = {0};
+  __cpuid(cpuid0, 0); // Get the maximum supported CPUID function
+  __cpuid(cpuid7, 7); // AVX2 is function 7, subfunction 0, EBX, bit 5
+  if (cpuid0[0] < 7 || !(cpuid7[1] & 0x20)) {
+    _set_FMA3_enable(0);
+  }
+#endif
+
   // A initializer to initialize histogram collection, a chromium
   // thing used by Telemetry.
   mStatisticsRecorder = MakeUnique<base::StatisticsRecorder>();
 
   mAppData = new ScopedAppData(aAppData);
   if (!mAppData)
     return 1;
   if (!mAppData->remotingName) {