Bug 463642 - Safe mode should disable JIT, r+sr=jst
authorBenjamin Smedberg <benjamin@smedbergs.us>
Mon, 12 Jan 2009 11:05:10 -0500
changeset 23546 3b9d2ef2e4a8b474c1998e917da206ff8bac829d
parent 23545 5e45ba40a88ae5d71a449db11fcafa994a523313
child 23547 0b56d4b6c7ea5886a3ef4139e762ca847180a81b
push id4594
push userbsmedberg@mozilla.com
push dateMon, 12 Jan 2009 16:07:43 +0000
treeherdermozilla-central@3b9d2ef2e4a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs463642
milestone1.9.2a1pre
Bug 463642 - Safe mode should disable JIT, r+sr=jst
chrome/src/nsChromeRegistry.cpp
dom/src/base/nsJSEnvironment.cpp
extensions/metrics/src/nsProfileCollector.cpp
toolkit/components/downloads/src/nsDownloadScanner.cpp
toolkit/xre/Makefile.in
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsIXULRuntime.idl
toolkit/xre/nsXULAppAPI.h
xpcom/build/nsXPCOMCIDInternal.h
xpcom/system/Makefile.in
xpcom/system/nsIXULRuntime.idl
--- a/chrome/src/nsChromeRegistry.cpp
+++ b/chrome/src/nsChromeRegistry.cpp
@@ -64,16 +64,17 @@
 #include "nsLayoutCID.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsReadableUtils.h"
 #include "nsStaticAtom.h"
 #include "nsString.h"
 #include "nsUnicharUtils.h"
 #include "nsWidgetsCID.h"
+#include "nsXPCOMCIDInternal.h"
 #include "nsXPIDLString.h"
 #include "nsXULAppAPI.h"
 #include "nsTextFormatter.h"
 
 #include "nsIAtom.h"
 #include "nsICommandLine.h"
 #include "nsICSSLoader.h"
 #include "nsICSSStyleSheet.h"
--- a/dom/src/base/nsJSEnvironment.cpp
+++ b/dom/src/base/nsJSEnvironment.cpp
@@ -76,16 +76,18 @@
 #include "nsITimer.h"
 #include "nsIAtom.h"
 #include "nsContentUtils.h"
 #include "jscntxt.h"
 #include "nsEventDispatcher.h"
 #include "nsIContent.h"
 #include "nsCycleCollector.h"
 #include "nsNetUtil.h"
+#include "nsXPCOMCIDInternal.h"
+#include "nsIXULRuntime.h"
 
 // For locale aware string methods
 #include "plstr.h"
 #include "nsIPlatformCharset.h"
 #include "nsICharsetConverterManager.h"
 #include "nsUnicharUtils.h"
 #include "nsILocaleService.h"
 #include "nsICollation.h"
@@ -1166,19 +1168,28 @@ nsJSContext::JSOptionChangedCallback(con
     newDefaultJSOptions |= JSOPTION_STRICT;
   else
     newDefaultJSOptions &= ~JSOPTION_STRICT;
 
   nsIScriptGlobalObject *global = context->GetGlobalObject();
   // XXX should we check for sysprin instead of a chrome window, to make
   // XXX components be covered by the chrome pref instead of the content one?
   nsCOMPtr<nsIDOMChromeWindow> chromeWindow(do_QueryInterface(global));
+
   PRBool useJIT = nsContentUtils::GetBoolPref(chromeWindow ?
                                               js_jit_chrome_str :
                                               js_jit_content_str);
+  nsCOMPtr<nsIXULRuntime> xr = do_GetService(XULRUNTIME_SERVICE_CONTRACTID);
+  if (xr) {
+    PRBool safeMode = PR_FALSE;
+    xr->GetInSafeMode(&safeMode);
+    if (safeMode)
+      useJIT = PR_FALSE;
+  }    
+
   if (useJIT)
     newDefaultJSOptions |= JSOPTION_JIT;
   else
     newDefaultJSOptions &= ~JSOPTION_JIT;
 
 #ifdef DEBUG
   // In debug builds, warnings are always enabled in chrome context
   // Note this callback is also called from context's InitClasses thus we don't
--- a/extensions/metrics/src/nsProfileCollector.cpp
+++ b/extensions/metrics/src/nsProfileCollector.cpp
@@ -54,16 +54,17 @@
 #include "nsDirectoryServiceUtils.h"
 #include "nsAutoPtr.h"
 #include "nsTArray.h"
 #include "nsINavBookmarksService.h"
 #include "nsINavHistoryService.h"
 #include "nsILivemarkService.h"
 #include "nsILocaleService.h"
 #include "nsToolkitCompsCID.h"
+#include "nsXPCOMCIDInternal.h"
 
 // We need to suppress inclusion of nsString.h
 #define nsString_h___
 #include "nsIPluginHost.h"
 #undef nsString_h___
 
 // Logs data on all installed plugins.
 class nsProfileCollector::PluginEnumerator
--- a/toolkit/components/downloads/src/nsDownloadScanner.cpp
+++ b/toolkit/components/downloads/src/nsDownloadScanner.cpp
@@ -43,16 +43,17 @@
 #include "nsDownloadManager.h"
 #include "nsIXULAppInfo.h"
 #include "nsXULAppAPI.h"
 #include "nsIPrefService.h"
 #include "nsNetUtil.h"
 #include "nsDeque.h"
 #include "nsIFileURL.h"
 #include "nsIPrefBranch2.h"
+#include "nsXPCOMCIDInternal.h"
 
 /**
  * Code overview
  *
  * Download scanner attempts to make use of one of two different virus
  * scanning interfaces available on Windows - IOfficeAntiVirus (Windows
  * 95/NT 4 and IE 5) and IAttachmentExecute (XPSP2 and up).  The latter
  * interface supports calling IOfficeAntiVirus internally, while also
--- a/toolkit/xre/Makefile.in
+++ b/toolkit/xre/Makefile.in
@@ -84,17 +84,16 @@ endif
 ifdef MOZ_CRASHREPORTER
 REQUIRES += crashreporter
 endif
 
 FORCE_STATIC_LIB = 1
 
 XPIDLSRCS = \
 	nsINativeAppSupport.idl \
-	nsIXULRuntime.idl \
 	$(NULL)
 
 ifneq (,$(filter WINCE WINNT,$(OS_ARCH)))
 XPIDLSRCS += nsIWinAppHelper.idl
 endif
 
 EXPORTS = \
 	xrecore.h \
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -118,16 +118,17 @@
 #include "nsCOMPtr.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsEmbedCID.h"
 #include "nsNetUtil.h"
 #include "nsReadableUtils.h"
 #include "nsStaticComponents.h"
 #include "nsXPCOM.h"
+#include "nsXPCOMCIDInternal.h"
 #include "nsXPIDLString.h"
 #include "nsXPFEComponentsCID.h"
 #include "nsVersionComparator.h"
 
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsXULAppAPI.h"
 #include "nsXREDirProvider.h"
 #include "nsToolkitCompsCID.h"
@@ -888,16 +889,22 @@ ScopedXPCOMStartup::~ScopedXPCOMStartup(
 
 static nsModuleComponentInfo kComponents[] =
 {
   {
     "nsXULAppInfo",
     APPINFO_CID,
     XULAPPINFO_SERVICE_CONTRACTID,
     AppInfoConstructor
+  },
+  {
+    "nsXULAppInfo",
+    APPINFO_CID,
+    XULRUNTIME_SERVICE_CONTRACTID,
+    AppInfoConstructor
   }
 #ifdef MOZ_CRASHREPORTER
 ,
   {
     "nsXULAppInfo",
     APPINFO_CID,
     NS_CRASHREPORTER_CONTRACTID,
     AppInfoConstructor
--- a/toolkit/xre/nsXULAppAPI.h
+++ b/toolkit/xre/nsXULAppAPI.h
@@ -170,22 +170,16 @@ struct nsXREAppData
 #define NS_XRE_ENABLE_EXTENSION_MANAGER (1 << 2)
 
 /**
  * Indicates whether or not to use Breakpad crash reporting.
  */
 #define NS_XRE_ENABLE_CRASH_REPORTER (1 << 3)
 
 /**
- * The contract id for the nsIXULAppInfo service.
- */
-#define XULAPPINFO_SERVICE_CONTRACTID \
-  "@mozilla.org/xre/app-info;1"
-
-/**
  * A directory service key which provides the platform-correct "application
  * data" directory as follows, where $name and $vendor are as defined above and
  * $vendor is optional:
  *
  * Windows:
  *   HOME = Documents and Settings\$USER\Application Data
  *   UAppData = $HOME[\$vendor]\$name
  *
--- a/xpcom/build/nsXPCOMCIDInternal.h
+++ b/xpcom/build/nsXPCOMCIDInternal.h
@@ -77,9 +77,21 @@
  */
 #define NS_XPCOMPROXY_CONTRACTID "@mozilla.org/xpcomproxy;1"
 
 /**
  * Memory reporter service CID
  */
 #define NS_MEMORY_REPORTER_MANAGER_CONTRACTID "@mozilla.org/memory-reporter-manager;1"
 
+/**
+ * The contract id for the nsIXULAppInfo service.
+ */
+#define XULAPPINFO_SERVICE_CONTRACTID \
+  "@mozilla.org/xre/app-info;1"
+
+/**
+ * The contract id for the nsIXULRuntime service.
+ */
+#define XULRUNTIME_SERVICE_CONTRACTID \
+  "@mozilla.org/xre/runtime;1"
+
 #endif  // nsXPCOMCIDInternal_h__
--- a/xpcom/system/Makefile.in
+++ b/xpcom/system/Makefile.in
@@ -42,16 +42,17 @@ VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE          = xpcom
 XPIDL_MODULE    = xpcom_system
 
 XPIDLSRCS = \
         nsIXULAppInfo.idl \
+        nsIXULRuntime.idl \
         nsIGConfService.idl \
         nsIGnomeVFSService.idl \
         nsIBlocklistService.idl \
         $(NULL)
 
 ifdef MOZ_CRASHREPORTER
 XPIDLSRCS += nsICrashReporter.idl
 endif
rename from toolkit/xre/nsIXULRuntime.idl
rename to xpcom/system/nsIXULRuntime.idl