Bug 623105 - Back out 350fa5d366df on suspicion of breaking regress-290575.js on 64-bit, a=bustage
authorPhil Ringnalda <philringnalda@gmail.com>
Tue, 04 Jan 2011 21:00:17 -0800
changeset 60000 d2bd42931b03811b65dcd358d90245c43821accf
parent 59999 f539d05eec83bb29448238b4a25b63dd4fc0f4c9
child 60001 1ea92ceef5f04d505f8d01812e63c735a6c8d64b
push id17822
push userphilringnalda@gmail.com
push dateWed, 05 Jan 2011 05:18:20 +0000
treeherdermozilla-central@d2bd42931b03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs623105, 290575
milestone2.0b9pre
first release with
nightly linux32
d2bd42931b03 / 4.0b9pre / 20110105030550 / files
nightly linux64
d2bd42931b03 / 4.0b9pre / 20110105030550 / files
nightly mac
d2bd42931b03 / 4.0b9pre / 20110105030550 / files
nightly win32
d2bd42931b03 / 4.0b9pre / 20110105030550 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 623105 - Back out 350fa5d366df on suspicion of breaking regress-290575.js on 64-bit, a=bustage
dom/base/nsJSEnvironment.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -3999,29 +3999,36 @@ ReportAllJSExceptionsPrefChangedCallback
   PRBool reportAll = nsContentUtils::GetBoolPref(aPrefName, PR_FALSE);
   nsContentUtils::XPConnect()->SetReportAllJSExceptions(reportAll);
   return 0;
 }
 
 static int
 SetMemoryHighWaterMarkPrefChangedCallback(const char* aPrefName, void* aClosure)
 {
-  PRInt32 highwatermark = nsContentUtils::GetIntPref(aPrefName, 80);
-
-  JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_MALLOC_BYTES,
-                    highwatermark * 1024L * 1024L);
-  return 0;
-}
-
-static int
-SetMemoryMaxPrefChangedCallback(const char* aPrefName, void* aClosure)
-{
-  PRInt32 max = nsContentUtils::GetIntPref(aPrefName, -1);
-  JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_BYTES,
-                    max * 1024L * 1024L);
+  PRInt32 highwatermark = nsContentUtils::GetIntPref(aPrefName, 32);
+
+  if (highwatermark >= 32) {
+    /*
+     * There are two ways to allocate memory in SpiderMonkey. One is
+     * to use jsmalloc() and the other is to use GC-owned memory
+     * (e.g. js_NewGCThing()).
+     *
+     * In the browser, we don't cap the amount of GC-owned memory.
+     */
+    JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_MALLOC_BYTES,
+                      128L * 1024L * 1024L);
+    JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_BYTES,
+                      0xffffffff);
+  } else {
+    JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_MALLOC_BYTES,
+                      highwatermark * 1024L * 1024L);
+    JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_BYTES,
+                      highwatermark * 1024L * 1024L);
+  }
   return 0;
 }
 
 static int
 SetMemoryGCFrequencyPrefChangedCallback(const char* aPrefName, void* aClosure)
 {
   PRInt32 triggerFactor = nsContentUtils::GetIntPref(aPrefName, 300);
   JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_TRIGGER_FACTOR, triggerFactor);
@@ -4149,22 +4156,16 @@ nsJSRuntime::Init()
                                            nsnull);
 
   nsContentUtils::RegisterPrefCallback("javascript.options.mem.high_water_mark",
                                        SetMemoryHighWaterMarkPrefChangedCallback,
                                        nsnull);
   SetMemoryHighWaterMarkPrefChangedCallback("javascript.options.mem.high_water_mark",
                                             nsnull);
 
-  nsContentUtils::RegisterPrefCallback("javascript.options.mem.max",
-                                       SetMemoryMaxPrefChangedCallback,
-                                       nsnull);
-  SetMemoryMaxPrefChangedCallback("javascript.options.mem.max",
-                                  nsnull);
-
   nsContentUtils::RegisterPrefCallback("javascript.options.mem.gc_frequency",
                                        SetMemoryGCFrequencyPrefChangedCallback,
                                        nsnull);
   SetMemoryGCFrequencyPrefChangedCallback("javascript.options.mem.gc_frequency",
                                           nsnull);
 
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (!obs)