diff options
author | Keegan McAllister <kmcallister@mozilla.com> | 2014-10-23 18:10:00 -0700 |
---|---|---|
committer | Keegan McAllister <kmcallister@mozilla.com> | 2014-10-24 16:27:37 -0700 |
commit | 49234484d6539a4d8df8374a9548c2004b8e68b7 (patch) | |
tree | f08c75e46b6ccf17c93ad2142410b11b0ad35bb6 /components/script/script_task.rs | |
parent | 6ec0939a2248e0e092242076ed5b2cd2486c736c (diff) | |
download | servo-49234484d6539a4d8df8374a9548c2004b8e68b7.tar.gz servo-49234484d6539a4d8df8374a9548c2004b8e68b7.zip |
Ignore the HTML parser's borrow flag in GC tracing
Adds some other dynamic checks in debug builds.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r-- | components/script/script_task.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 398e9b8d4db..a5658ac6c5e 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -60,6 +60,7 @@ use geom::point::Point2D; use js::jsapi::{JS_SetWrapObjectCallbacks, JS_SetGCZeal, JS_DEFAULT_ZEAL_FREQ, JS_GC}; use js::jsapi::{JSContext, JSRuntime, JSTracer}; use js::jsapi::{JS_SetGCParameter, JSGC_MAX_BYTES}; +use js::jsapi::{JS_SetGCCallback, JSGCStatus, JSGC_BEGIN, JSGC_END}; use js::rust::{Cx, RtUtils}; use js::rust::with_compartment; use js; @@ -285,6 +286,16 @@ impl ScriptTaskFactory for ScriptTask { } } +unsafe extern "C" fn debug_gc_callback(rt: *mut JSRuntime, status: JSGCStatus) { + js::rust::gc_callback(rt, status); + + match status { + JSGC_BEGIN => task_state::enter(task_state::InGC), + JSGC_END => task_state::exit(task_state::InGC), + _ => (), + } +} + impl ScriptTask { /// Creates a new script task. pub fn new(id: PipelineId, @@ -376,6 +387,13 @@ impl ScriptTask { JS_SetGCZeal((*js_context).ptr, 0, JS_DEFAULT_ZEAL_FREQ); } + // Needed for debug assertions about whether GC is running. + if !cfg!(ndebug) { + unsafe { + JS_SetGCCallback(js_runtime.ptr, Some(debug_gc_callback)); + } + } + (js_runtime, js_context) } |