Turn on GC all the time. Fix rooting errors during parsing and storing timers. Fix borrow errors during tracing.

This commit is contained in:
Josh Matthews 2014-03-28 10:17:56 -04:00
parent 4051a8096d
commit ffdc3f5b32
109 changed files with 1567 additions and 996 deletions

View file

@ -6,6 +6,7 @@ use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable, Reflector};
use js::jsapi::{JSObject, JSTracer, JS_CallTracer, JSTRACE_OBJECT};
use js::jsval::JSVal;
use libc;
use std::cast;
@ -42,6 +43,22 @@ pub trait JSTraceable {
fn trace(&self, trc: *mut JSTracer);
}
pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: JSVal) {
if !val.is_gcthing() {
return;
}
unsafe {
description.to_c_str().with_ref(|name| {
(*tracer).debugPrinter = ptr::null();
(*tracer).debugPrintIndex = -1;
(*tracer).debugPrintArg = name as *libc::c_void;
debug!("tracing value {:s}", description);
JS_CallTracer(tracer as *JSTracer, val.to_gcthing(), val.trace_kind());
});
}
}
pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) {
trace_object(tracer, description, reflector.get_jsobject())
}
@ -132,3 +149,10 @@ impl<S: Encoder<E>, E> Encodable<S, E> for Traceable<*JSObject> {
Ok(())
}
}
impl<S: Encoder<E>, E> Encodable<S, E> for Traceable<JSVal> {
fn encode(&self, s: &mut S) -> Result<(), E> {
trace_jsval(get_jstracer(s), "val", **self);
Ok(())
}
}