aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/js.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2016-05-10 12:12:10 -0400
committerJosh Matthews <josh@joshmatthews.net>2016-05-11 08:34:48 -0400
commit293d465c59bda315ea1a7e789c6fa9ab4d48f5e2 (patch)
tree4827f5a0f7e8aa54fac97c5c168be4f3f3f9b27d /components/script/dom/bindings/js.rs
parent835f443865fbaa8784722ad6f950a2c8879fab31 (diff)
downloadservo-293d465c59bda315ea1a7e789c6fa9ab4d48f5e2.tar.gz
servo-293d465c59bda315ea1a7e789c6fa9ab4d48f5e2.zip
Make debug logging for tracing JS objects more informative.
Diffstat (limited to 'components/script/dom/bindings/js.rs')
-rw-r--r--components/script/dom/bindings/js.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs
index 10b9a481382..56193b543ad 100644
--- a/components/script/dom/bindings/js.rs
+++ b/components/script/dom/bindings/js.rs
@@ -38,6 +38,7 @@ use script_thread::STACK_ROOTS;
use std::cell::UnsafeCell;
use std::default::Default;
use std::hash::{Hash, Hasher};
+use std::intrinsics::type_name;
use std::mem;
use std::ops::Deref;
use std::ptr;
@@ -106,7 +107,16 @@ impl<T: Reflectable> Deref for JS<T> {
impl<T: Reflectable> JSTraceable for JS<T> {
fn trace(&self, trc: *mut JSTracer) {
- trace_reflector(trc, "", unsafe { (**self.ptr).reflector() });
+ #[cfg(debug_assertions)]
+ let trace_str = format!("for {} on heap", unsafe { type_name::<T>() });
+ #[cfg(debug_assertions)]
+ let trace_info = &trace_str[..];
+ #[cfg(not(debug_assertions))]
+ let trace_info = "for DOM object on heap";
+
+ trace_reflector(trc,
+ trace_info,
+ unsafe { (**self.ptr).reflector() });
}
}
@@ -520,11 +530,12 @@ impl RootCollection {
/// SM Callback that traces the rooted reflectors
pub unsafe fn trace_roots(tracer: *mut JSTracer) {
+ debug!("tracing stack roots");
STACK_ROOTS.with(|ref collection| {
let RootCollectionPtr(collection) = collection.get().unwrap();
let collection = &*(*collection).roots.get();
for root in collection {
- trace_reflector(tracer, "reflector", &**root);
+ trace_reflector(tracer, "on stack", &**root);
}
});
}