Resume tracing our collections of roots.

The second JS_SetExtraGCRootsTracer call clobbered the first, so
trace_collections was no longer being called.
This commit is contained in:
Ms2ger 2015-04-10 12:56:46 +02:00
parent ec417a84b1
commit d46db6d7f1
2 changed files with 5 additions and 4 deletions

View file

@ -428,7 +428,7 @@ impl<T> DerefMut for RootedVec<T> {
/// SM Callback that traces the rooted collections /// SM Callback that traces the rooted collections
pub unsafe extern fn trace_collections(tracer: *mut JSTracer, _data: *mut libc::c_void) { pub unsafe fn trace_collections(tracer: *mut JSTracer) {
ROOTED_COLLECTIONS.with(|ref collections| { ROOTED_COLLECTIONS.with(|ref collections| {
let collections = collections.borrow(); let collections = collections.borrow();
collections.trace(tracer); collections.trace(tracer);

View file

@ -99,12 +99,14 @@ use time::Tm;
thread_local!(pub static STACK_ROOTS: Cell<Option<RootCollectionPtr>> = Cell::new(None)); thread_local!(pub static STACK_ROOTS: Cell<Option<RootCollectionPtr>> = Cell::new(None));
thread_local!(static SCRIPT_TASK_ROOT: RefCell<Option<*const ScriptTask>> = RefCell::new(None)); thread_local!(static SCRIPT_TASK_ROOT: RefCell<Option<*const ScriptTask>> = RefCell::new(None));
unsafe extern fn trace_script_tasks(tr: *mut JSTracer, _data: *mut libc::c_void) { unsafe extern fn trace_rust_roots(tr: *mut JSTracer, _data: *mut libc::c_void) {
SCRIPT_TASK_ROOT.with(|root| { SCRIPT_TASK_ROOT.with(|root| {
if let Some(script_task) = *root.borrow() { if let Some(script_task) = *root.borrow() {
(*script_task).trace(tr); (*script_task).trace(tr);
} }
}); });
trace_collections(tr);
} }
/// A document load that is in the process of fetching the requested resource. Contains /// A document load that is in the process of fetching the requested resource. Contains
@ -463,7 +465,7 @@ impl ScriptTask {
unsafe { unsafe {
JS_SetExtraGCRootsTracer((*js_runtime).ptr, Some(trace_collections), ptr::null_mut()); JS_SetExtraGCRootsTracer((*js_runtime).ptr, Some(trace_rust_roots), ptr::null_mut());
} }
// Unconstrain the runtime's threshold on nominal heap size, to avoid // Unconstrain the runtime's threshold on nominal heap size, to avoid
// triggering GC too often if operating continuously near an arbitrary // triggering GC too often if operating continuously near an arbitrary
@ -483,7 +485,6 @@ impl ScriptTask {
js_context.set_logging_error_reporter(); js_context.set_logging_error_reporter();
unsafe { unsafe {
JS_SetGCZeal((*js_context).ptr, 0, JS_DEFAULT_ZEAL_FREQ); JS_SetGCZeal((*js_context).ptr, 0, JS_DEFAULT_ZEAL_FREQ);
JS_SetExtraGCRootsTracer((*js_runtime).ptr, Some(trace_script_tasks), ptr::null_mut());
} }
// Needed for debug assertions about whether GC is running. // Needed for debug assertions about whether GC is running.