diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2016-05-10 01:24:40 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2016-05-12 16:44:40 +0200 |
commit | afd29b7c1ee941592a2b357f66c07bf570236e38 (patch) | |
tree | 9dbfef16488cdecd7db25fadcc36bc55a41317f7 /components/script/script_runtime.rs | |
parent | 9eb7162b8a24662e895a8b04275f0c46e1805f4b (diff) | |
download | servo-afd29b7c1ee941592a2b357f66c07bf570236e38.tar.gz servo-afd29b7c1ee941592a2b357f66c07bf570236e38.zip |
Support GC zeal
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) {} |