summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dom/base/nsJSEnvironment.cpp5
-rw-r--r--js/src/jsapi.cpp11
-rw-r--r--js/src/jsapi.h3
-rw-r--r--modules/libpref/init/all.js1
4 files changed, 20 insertions, 0 deletions
diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp
index b273d00c9..576f3052a 100644
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -2282,6 +2282,7 @@ SetMemoryGCModePrefChangedCallback(const char* aPrefName, void* aClosure)
{
bool enableZoneGC = Preferences::GetBool("javascript.options.mem.gc_per_zone");
bool enableIncrementalGC = Preferences::GetBool("javascript.options.mem.gc_incremental");
+ bool enableGenerationalGC = Preferences::GetBool("javascript.options.mem.gc_generational");
JSGCMode mode;
if (enableIncrementalGC) {
mode = JSGC_MODE_INCREMENTAL;
@@ -2291,6 +2292,7 @@ SetMemoryGCModePrefChangedCallback(const char* aPrefName, void* aClosure)
mode = JSGC_MODE_GLOBAL;
}
JS_SetGCParameter(sContext, JSGC_MODE, mode);
+ JS_SetGGCMode(sContext, enableGenerationalGC);
}
static void
@@ -2485,6 +2487,9 @@ nsJSContext::EnsureStatics()
Preferences::RegisterCallbackAndCall(SetMemoryGCSliceTimePrefChangedCallback,
"javascript.options.mem.gc_incremental_slice_ms");
+ Preferences::RegisterCallbackAndCall(SetMemoryGCModePrefChangedCallback,
+ "javascript.options.mem.gc_generational");
+
Preferences::RegisterCallbackAndCall(SetMemoryGCCompactingPrefChangedCallback,
"javascript.options.mem.gc_compacting");
diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
index a99d08951..e4e86effa 100644
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1410,6 +1410,17 @@ JS_SetGCParameter(JSContext* cx, JSGCParamKey key, uint32_t value)
MOZ_ALWAYS_TRUE(cx->gc.setParameter(key, value, lock));
}
+JS_PUBLIC_API(void)
+JS_SetGGCMode(JSContext* cx, bool enabled)
+{
+ // Control GGC
+ if (enabled && !cx->gc.isGenerationalGCEnabled()) {
+ cx->gc.enableGenerationalGC();
+ } else if (!enabled && cx->gc.isGenerationalGCEnabled()) {
+ cx->gc.disableGenerationalGC();
+ }
+}
+
JS_PUBLIC_API(uint32_t)
JS_GetGCParameter(JSContext* cx, JSGCParamKey key)
{
diff --git a/js/src/jsapi.h b/js/src/jsapi.h
index 46aa15947..6700a6c51 100644
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1768,6 +1768,9 @@ typedef enum JSGCParamKey {
extern JS_PUBLIC_API(void)
JS_SetGCParameter(JSContext* cx, JSGCParamKey key, uint32_t value);
+extern JS_PUBLIC_API(void)
+JS_SetGGCMode(JSContext* cx, bool enabled);
+
extern JS_PUBLIC_API(uint32_t)
JS_GetGCParameter(JSContext* cx, JSGCParamKey key);
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index 72eb8524e..67c632e71 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1258,6 +1258,7 @@ pref("javascript.options.mem.max", -1);
pref("javascript.options.mem.gc_per_zone", true);
pref("javascript.options.mem.gc_incremental", true);
pref("javascript.options.mem.gc_incremental_slice_ms", 10);
+pref("javascript.options.mem.gc_generational", true);
pref("javascript.options.mem.gc_compacting", true);
pref("javascript.options.mem.log", false);
pref("javascript.options.mem.notify", false);