mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Turn on GC all the time. Fix rooting errors during parsing and storing timers. Fix borrow errors during tracing.
This commit is contained in:
parent
4051a8096d
commit
ffdc3f5b32
109 changed files with 1567 additions and 996 deletions
|
@ -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(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue