From 4b282d13ac39d8ce92e2fd37eee0b220b2ec001a Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Mon, 12 Jan 2009 11:05:10 -0500 Subject: [PATCH] Bug 463642 - Safe mode should disable JIT, r+sr=jst --HG-- rename : toolkit/xre/nsIXULRuntime.idl => xpcom/system/nsIXULRuntime.idl --- chrome/src/nsChromeRegistry.cpp | 1 + dom/src/base/nsJSEnvironment.cpp | 11 +++++++++++ extensions/metrics/src/nsProfileCollector.cpp | 1 + .../components/downloads/src/nsDownloadScanner.cpp | 1 + toolkit/xre/Makefile.in | 1 - toolkit/xre/nsAppRunner.cpp | 7 +++++++ toolkit/xre/nsXULAppAPI.h | 6 ------ xpcom/build/nsXPCOMCIDInternal.h | 12 ++++++++++++ xpcom/system/Makefile.in | 1 + {toolkit/xre => xpcom/system}/nsIXULRuntime.idl | 0 10 files changed, 34 insertions(+), 7 deletions(-) rename {toolkit/xre => xpcom/system}/nsIXULRuntime.idl (100%) diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp index c5950a0265fc..5cb184d83133 100644 --- a/chrome/src/nsChromeRegistry.cpp +++ b/chrome/src/nsChromeRegistry.cpp @@ -69,6 +69,7 @@ #include "nsString.h" #include "nsUnicharUtils.h" #include "nsWidgetsCID.h" +#include "nsXPCOMCIDInternal.h" #include "nsXPIDLString.h" #include "nsXULAppAPI.h" #include "nsTextFormatter.h" diff --git a/dom/src/base/nsJSEnvironment.cpp b/dom/src/base/nsJSEnvironment.cpp index fe6dbc9705b9..a990e10042e9 100644 --- a/dom/src/base/nsJSEnvironment.cpp +++ b/dom/src/base/nsJSEnvironment.cpp @@ -81,6 +81,8 @@ #include "nsIContent.h" #include "nsCycleCollector.h" #include "nsNetUtil.h" +#include "nsXPCOMCIDInternal.h" +#include "nsIXULRuntime.h" // For locale aware string methods #include "plstr.h" @@ -1171,9 +1173,18 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) // 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 chromeWindow(do_QueryInterface(global)); + PRBool useJIT = nsContentUtils::GetBoolPref(chromeWindow ? js_jit_chrome_str : js_jit_content_str); + nsCOMPtr 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 diff --git a/extensions/metrics/src/nsProfileCollector.cpp b/extensions/metrics/src/nsProfileCollector.cpp index 244f1c325777..40a417ada8f6 100644 --- a/extensions/metrics/src/nsProfileCollector.cpp +++ b/extensions/metrics/src/nsProfileCollector.cpp @@ -59,6 +59,7 @@ #include "nsILivemarkService.h" #include "nsILocaleService.h" #include "nsToolkitCompsCID.h" +#include "nsXPCOMCIDInternal.h" // We need to suppress inclusion of nsString.h #define nsString_h___ diff --git a/toolkit/components/downloads/src/nsDownloadScanner.cpp b/toolkit/components/downloads/src/nsDownloadScanner.cpp index ea0bef4ed03e..cf7cbcaf99c7 100644 --- a/toolkit/components/downloads/src/nsDownloadScanner.cpp +++ b/toolkit/components/downloads/src/nsDownloadScanner.cpp @@ -48,6 +48,7 @@ #include "nsDeque.h" #include "nsIFileURL.h" #include "nsIPrefBranch2.h" +#include "nsXPCOMCIDInternal.h" /** * Code overview diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in index 161672be0a9f..6e3a388ae244 100644 --- a/toolkit/xre/Makefile.in +++ b/toolkit/xre/Makefile.in @@ -89,7 +89,6 @@ FORCE_STATIC_LIB = 1 XPIDLSRCS = \ nsINativeAppSupport.idl \ - nsIXULRuntime.idl \ $(NULL) ifneq (,$(filter WINCE WINNT,$(OS_ARCH))) diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 46830c65a5e4..2b1f6de785b2 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -123,6 +123,7 @@ #include "nsReadableUtils.h" #include "nsStaticComponents.h" #include "nsXPCOM.h" +#include "nsXPCOMCIDInternal.h" #include "nsXPIDLString.h" #include "nsXPFEComponentsCID.h" #include "nsVersionComparator.h" @@ -893,6 +894,12 @@ static nsModuleComponentInfo kComponents[] = APPINFO_CID, XULAPPINFO_SERVICE_CONTRACTID, AppInfoConstructor + }, + { + "nsXULAppInfo", + APPINFO_CID, + XULRUNTIME_SERVICE_CONTRACTID, + AppInfoConstructor } #ifdef MOZ_CRASHREPORTER , diff --git a/toolkit/xre/nsXULAppAPI.h b/toolkit/xre/nsXULAppAPI.h index f15eb36deb84..0db215bf9342 100644 --- a/toolkit/xre/nsXULAppAPI.h +++ b/toolkit/xre/nsXULAppAPI.h @@ -174,12 +174,6 @@ struct nsXREAppData */ #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 diff --git a/xpcom/build/nsXPCOMCIDInternal.h b/xpcom/build/nsXPCOMCIDInternal.h index 464443014c19..4e84040dc5af 100644 --- a/xpcom/build/nsXPCOMCIDInternal.h +++ b/xpcom/build/nsXPCOMCIDInternal.h @@ -82,4 +82,16 @@ */ #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__ diff --git a/xpcom/system/Makefile.in b/xpcom/system/Makefile.in index afda34d5d812..017524141bc6 100644 --- a/xpcom/system/Makefile.in +++ b/xpcom/system/Makefile.in @@ -47,6 +47,7 @@ XPIDL_MODULE = xpcom_system XPIDLSRCS = \ nsIXULAppInfo.idl \ + nsIXULRuntime.idl \ nsIGConfService.idl \ nsIGnomeVFSService.idl \ nsIBlocklistService.idl \ diff --git a/toolkit/xre/nsIXULRuntime.idl b/xpcom/system/nsIXULRuntime.idl similarity index 100% rename from toolkit/xre/nsIXULRuntime.idl rename to xpcom/system/nsIXULRuntime.idl