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 Deref for JS { impl JSTraceable for JS { 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::() }); + #[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); } }); } diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index 057c67c0ef4..25239a3dc3b 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -201,13 +201,14 @@ impl LiveDOMReferences { /// A JSTraceDataOp for tracing reflectors held in LIVE_REFERENCES pub unsafe extern "C" fn trace_refcounted_objects(tracer: *mut JSTracer, _data: *mut os::raw::c_void) { + debug!("tracing live refcounted references"); LIVE_REFERENCES.with(|ref r| { let r = r.borrow(); let live_references = r.as_ref().unwrap(); let table = live_references.table.borrow(); for obj in table.keys() { let reflectable = &*(*obj as *const Reflector); - trace_reflector(tracer, "LIVE_REFERENCES", reflectable); + trace_reflector(tracer, "refcounted", reflectable); } }); } diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 1ec19ac15bc..e7377c82e69 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -171,14 +171,14 @@ impl JSTraceable for Heap<*mut JSObject> { if self.get().is_null() { return; } - trace_object(trc, "object", self); + trace_object(trc, "heap object", self); } } impl JSTraceable for Heap { fn trace(&self, trc: *mut JSTracer) { - trace_jsval(trc, "val", self); + trace_jsval(trc, "heap value", self); } } @@ -552,6 +552,7 @@ impl FromIterator> for RootedVec> { /// SM Callback that traces the rooted traceables pub unsafe fn trace_traceables(tracer: *mut JSTracer) { + debug!("tracing stack-rooted traceables"); ROOTED_TRACEABLES.with(|ref traceables| { let traceables = traceables.borrow(); traceables.trace(tracer); diff --git a/components/script/lib.rs b/components/script/lib.rs index 4feaae05845..e8b22c353a0 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -17,6 +17,7 @@ #![feature(peekable_is_empty)] #![feature(plugin)] #![feature(slice_patterns)] +#![feature(stmt_expr_attributes)] #![deny(unsafe_code)] #![allow(non_snake_case)] diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 783433b9a21..4a6d73949a9 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -371,7 +371,9 @@ unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus, #[allow(unsafe_code)] unsafe extern fn trace_rust_roots(tr: *mut JSTracer, _data: *mut os::raw::c_void) { + debug!("starting custom root handler"); trace_thread(tr); trace_traceables(tr); trace_roots(tr); + debug!("done custom root handler"); } diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index a46c1a28b18..a3b374ac161 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -115,6 +115,7 @@ thread_local!(static SCRIPT_THREAD_ROOT: RefCell> = pub unsafe fn trace_thread(tr: *mut JSTracer) { SCRIPT_THREAD_ROOT.with(|root| { if let Some(script_thread) = *root.borrow() { + debug!("tracing fields of ScriptThread"); (*script_thread).trace(tr); } });