Bug 686571 - Add options javascript.options.pccounts.content and javascript.options.pccounts.chrome for controlling JSOPTION_PCCOUNTS (r=dmandelin)
authorSteve Fink <sfink@mozilla.com>
Wed, 07 Sep 2011 16:58:28 -0700
changeset 76930 8ad3742f0f8350b417eb297ba936b2d9c36bbf1f
parent 76929 4236dfa034487958aaa5b0ebc0513a80e73ee8b0
child 76931 c13a8d2c0cbb0dee08addaa2bd3628553ab9bffe
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersdmandelin
bugs686571
milestone9.0a1
Bug 686571 - Add options javascript.options.pccounts.content and javascript.options.pccounts.chrome for controlling JSOPTION_PCCOUNTS (r=dmandelin)
dom/base/nsJSEnvironment.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -911,16 +911,18 @@ static const char js_zeal_compartment_st
 static const char js_tracejit_content_str[]   = JS_OPTIONS_DOT_STR "tracejit.content";
 static const char js_tracejit_chrome_str[]    = JS_OPTIONS_DOT_STR "tracejit.chrome";
 static const char js_methodjit_content_str[]  = JS_OPTIONS_DOT_STR "methodjit.content";
 static const char js_methodjit_chrome_str[]   = JS_OPTIONS_DOT_STR "methodjit.chrome";
 static const char js_profiling_content_str[]  = JS_OPTIONS_DOT_STR "jitprofiling.content";
 static const char js_profiling_chrome_str[]   = JS_OPTIONS_DOT_STR "jitprofiling.chrome";
 static const char js_methodjit_always_str[]   = JS_OPTIONS_DOT_STR "methodjit_always";
 static const char js_typeinfer_str[]          = JS_OPTIONS_DOT_STR "typeinference";
+static const char js_pccounts_content_str[]   = JS_OPTIONS_DOT_STR "pccounts.content";
+static const char js_pccounts_chrome_str[]    = JS_OPTIONS_DOT_STR "pccounts.chrome";
 static const char js_memlog_option_str[] = JS_OPTIONS_DOT_STR "mem.log";
 
 int
 nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
 {
   nsJSContext *context = reinterpret_cast<nsJSContext *>(data);
   PRUint32 oldDefaultJSOptions = context->mDefaultJSOptions;
   PRUint32 newDefaultJSOptions = oldDefaultJSOptions;
@@ -942,26 +944,30 @@ nsJSContext::JSOptionChangedCallback(con
                                               js_tracejit_chrome_str :
                                               js_tracejit_content_str);
   PRBool useMethodJIT = Preferences::GetBool(chromeWindow ?
                                                js_methodjit_chrome_str :
                                                js_methodjit_content_str);
   PRBool useProfiling = Preferences::GetBool(chromeWindow ?
                                                js_profiling_chrome_str :
                                                js_profiling_content_str);
+  PRBool usePCCounts = Preferences::GetBool(chromeWindow ?
+                                            js_pccounts_chrome_str :
+                                            js_pccounts_content_str);
   PRBool useMethodJITAlways = Preferences::GetBool(js_methodjit_always_str);
   PRBool useTypeInference = !chromeWindow && Preferences::GetBool(js_typeinfer_str);
   nsCOMPtr<nsIXULRuntime> xr = do_GetService(XULRUNTIME_SERVICE_CONTRACTID);
   if (xr) {
     PRBool safeMode = PR_FALSE;
     xr->GetInSafeMode(&safeMode);
     if (safeMode) {
       useTraceJIT = PR_FALSE;
       useMethodJIT = PR_FALSE;
       useProfiling = PR_FALSE;
+      usePCCounts = PR_FALSE;
       useTypeInference = PR_FALSE;
       useMethodJITAlways = PR_TRUE;
     }
   }    
 
   if (useTraceJIT)
     newDefaultJSOptions |= JSOPTION_JIT;
   else
@@ -972,16 +978,21 @@ nsJSContext::JSOptionChangedCallback(con
   else
     newDefaultJSOptions &= ~JSOPTION_METHODJIT;
 
   if (useProfiling)
     newDefaultJSOptions |= JSOPTION_PROFILING;
   else
     newDefaultJSOptions &= ~JSOPTION_PROFILING;
 
+  if (usePCCounts)
+    newDefaultJSOptions |= JSOPTION_PCCOUNT;
+  else
+    newDefaultJSOptions &= ~JSOPTION_PCCOUNT;
+
   if (useMethodJITAlways)
     newDefaultJSOptions |= JSOPTION_METHODJIT_ALWAYS;
   else
     newDefaultJSOptions &= ~JSOPTION_METHODJIT_ALWAYS;
 
   if (useTypeInference)
     newDefaultJSOptions |= JSOPTION_TYPE_INFERENCE;
   else