Bug 1277359 - Report SSE2 instruction support on linux update pings. r=rstrong,smaug a=gchang
authorRalph Giles <giles@mozilla.com>
Tue, 01 Nov 2016 10:18:31 -0700
changeset 340857 46f75e5764770c6b6f24881aea714b2613fb509b
parent 340856 b3ed92294f434e05ea178c6ae3fb3e71d8da10ec
child 340858 27607838026a6e1a3185c1e18b5cdaa7405da592
push id10235
push userkwierso@gmail.com
push dateTue, 01 Nov 2016 17:29:49 +0000
treeherdermozilla-aurora@3c4ab75a8bcb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong, smaug, gchang
bugs1277359
milestone51.0a2
Bug 1277359 - Report SSE2 instruction support on linux update pings. r=rstrong,smaug a=gchang This is a roll-up of several patches implementing this feature from Firefox 52. It includes fixup patches by gps and Jan Beich. We need to advertise this to the update server to avoid downloading updates which won't run because of unsupported cpu features on the recipient's hardware. Add chrome-only navigator.cpuHasSSE2 api. Make the host's support for SSE2 instructions available to javascript so we can report that status in update pings.
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/webidl/Navigator.webidl
toolkit/modules/UpdateUtils.jsm
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -52,16 +52,17 @@
 #include "mozilla/dom/Telephony.h"
 #include "mozilla/dom/Voicemail.h"
 #include "mozilla/dom/TVManager.h"
 #include "mozilla/dom/VRDisplay.h"
 #include "mozilla/dom/workers/RuntimeService.h"
 #include "mozilla/Hal.h"
 #include "nsISiteSpecificUserAgent.h"
 #include "mozilla/ClearOnShutdown.h"
+#include "mozilla/SSE.h"
 #include "mozilla/StaticPtr.h"
 #include "Connection.h"
 #include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
 #include "nsGlobalWindow.h"
 #ifdef MOZ_B2G_RIL
 #include "mozilla/dom/MobileConnectionArray.h"
 #endif
 #include "nsIIdleObserver.h"
@@ -808,16 +809,22 @@ Navigator::HardwareConcurrency()
   workers::RuntimeService* rts = workers::RuntimeService::GetOrCreateService();
   if (!rts) {
     return 1;
   }
 
   return rts->ClampedHardwareConcurrency();
 }
 
+bool
+Navigator::CpuHasSSE2()
+{
+  return mozilla::supports_sse2();
+}
+
 void
 Navigator::RefreshMIMEArray()
 {
   if (mMimeTypes) {
     mMimeTypes->Refresh();
   }
 }
 
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -202,16 +202,17 @@ public:
   bool CookieEnabled();
   void GetBuildID(nsString& aBuildID, ErrorResult& aRv)
   {
     aRv = GetBuildID(aBuildID);
   }
   PowerManager* GetMozPower(ErrorResult& aRv);
   bool JavaEnabled(ErrorResult& aRv);
   uint64_t HardwareConcurrency();
+  bool CpuHasSSE2();
   bool TaintEnabled()
   {
     return false;
   }
   void AddIdleObserver(MozIdleObserver& aObserver, ErrorResult& aRv);
   void RemoveIdleObserver(MozIdleObserver& aObserver, ErrorResult& aRv);
   already_AddRefed<WakeLock> RequestWakeLock(const nsAString &aTopic,
                                              ErrorResult& aRv);
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -230,16 +230,22 @@ partial interface Navigator {
    * The returned MozWakeLock object is a token of the lock.  You can
    * unlock the lock via the object's |unlock| method.  The lock is released
    * automatically when its associated window is unloaded.
    *
    * @param aTopic resource name
    */
   [Throws, Pref="dom.wakelock.enabled", Func="Navigator::HasWakeLockSupport", UnsafeInPrerendering]
   MozWakeLock requestWakeLock(DOMString aTopic);
+
+  /**
+   * Make CPU instruction subset information available for UpdateUtils.
+   */
+  [ChromeOnly]
+  readonly attribute boolean cpuHasSSE2;
 };
 
 partial interface Navigator {
   [Throws, Pref="device.storage.enabled"]
   readonly attribute DeviceStorageAreaListener deviceStorageAreaListener;
 };
 
 // nsIDOMNavigatorDeviceStorage
--- a/toolkit/modules/UpdateUtils.jsm
+++ b/toolkit/modules/UpdateUtils.jsm
@@ -182,16 +182,24 @@ XPCOMUtils.defineLazyGetter(this, "gSyst
       Cu.reportError("Error getting processor instruction set. " +
                      "Exception: " + e);
     }
 
     lib.close();
     return instructionSet;
   }
 
+  if (AppConstants == "linux") {
+    let instructionSet = "unknown";
+    if (navigator.cpuHasSSE2) {
+      instructionSet = "SSE2";
+    }
+    return instructionSet;
+  }
+
   return "NA"
 });
 
 /* Windows only getter that returns the processor architecture. */
 XPCOMUtils.defineLazyGetter(this, "gWinCPUArch", function aus_gWinCPUArch() {
   // Get processor architecture
   let arch = "unknown";