diff options
Diffstat (limited to 'components/script/script_runtime.rs')
-rw-r--r-- | components/script/script_runtime.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 4a6d73949a9..543574ccc62 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -117,6 +117,8 @@ pub unsafe fn new_rt_and_cx() -> Runtime { // Pre barriers aren't working correctly at the moment DisableIncrementalGC(runtime.rt()); + set_gc_zeal_options(runtime.cx()); + // Enable or disable the JITs. let rt_opts = &mut *RuntimeOptionsRef(runtime.rt()); if let Some(val) = get_pref("js.baseline.enabled").as_boolean() { @@ -377,3 +379,23 @@ unsafe extern fn trace_rust_roots(tr: *mut JSTracer, _data: *mut os::raw::c_void trace_roots(tr); debug!("done custom root handler"); } + +#[allow(unsafe_code)] +#[cfg(feature = "debugmozjs")] +unsafe fn set_gc_zeal_options(cx: *mut JSContext) { + use js::jsapi::{JS_DEFAULT_ZEAL_FREQ, JS_SetGCZeal}; + + let level = match get_pref("js.mem.gc.zeal.level").as_i64() { + Some(level @ 0...14) => level as u8, + _ => return, + }; + let frequency = match get_pref("js.mem.gc.zeal.frequency").as_i64() { + Some(frequency) if frequency >= 0 => frequency as u32, + _ => JS_DEFAULT_ZEAL_FREQ, + }; + JS_SetGCZeal(cx, level, frequency); +} + +#[allow(unsafe_code)] +#[cfg(not(feature = "debugmozjs"))] +unsafe fn set_gc_zeal_options(_: *mut JSContext) {} |