diff options
Diffstat (limited to 'src/components/script/script_task.rs')
-rw-r--r-- | src/components/script/script_task.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index f7873ca3c24..ce0d18b8c87 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -50,6 +50,7 @@ use servo_util::task::spawn_named_with_send_on_failure; use geom::point::Point2D; use js::jsapi::{JS_SetWrapObjectCallbacks, JS_SetGCZeal, JS_DEFAULT_ZEAL_FREQ, JS_GC}; use js::jsapi::{JSContext, JSRuntime}; +use js::jsapi::{JS_SetGCParameter, JSGC_MAX_BYTES}; use js::rust::{Cx, RtUtils}; use js::rust::with_compartment; use js; @@ -62,6 +63,7 @@ use std::cell::RefCell; use std::comm::{channel, Sender, Receiver, Select}; use std::mem::replace; use std::rc::Rc; +use std::u32; local_data_key!(pub StackRoots: *const RootCollection) @@ -324,6 +326,15 @@ impl ScriptTask { ptr.is_not_null() }); + // Unconstrain the runtime's threshold on nominal heap size, to avoid + // triggering GC too often if operating continuously near an arbitrary + // finite threshold. This leaves the maximum-JS_malloc-bytes threshold + // still in effect to cause periodical, and we hope hygienic, + // last-ditch GCs from within the GC's allocator. + unsafe { + JS_SetGCParameter(js_runtime.ptr, JSGC_MAX_BYTES, u32::MAX); + } + let js_context = js_runtime.cx(); assert!({ let ptr: *mut JSContext = (*js_context).ptr; |