aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/js.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2015-07-31 12:46:36 -0400
committerJosh Matthews <josh@joshmatthews.net>2015-08-03 23:05:00 -0400
commit8620fe599538effe755029e895fca6b9ca3b0f47 (patch)
treeb7e1661271c4e358a7d003cf0b4837196ad198d0 /components/script/dom/bindings/js.rs
parentc2497fcd49933f3782d529b891f4c8bb5de198c4 (diff)
downloadservo-8620fe599538effe755029e895fca6b9ca3b0f47.tar.gz
servo-8620fe599538effe755029e895fca6b9ca3b0f47.zip
Start reporting memory usage for Window and all nodes in all DOM trees for frame treese in script tasks.
Diffstat (limited to 'components/script/dom/bindings/js.rs')
-rw-r--r--components/script/dom/bindings/js.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs
index fc929db1cac..0fde5678ab2 100644
--- a/components/script/dom/bindings/js.rs
+++ b/components/script/dom/bindings/js.rs
@@ -31,6 +31,7 @@ use js::jsapi::{JSObject, Heap, JSTracer};
use js::jsval::JSVal;
use layout_interface::TrustedNodeAddress;
use script_task::STACK_ROOTS;
+use util::mem::HeapSizeOf;
use core::nonzero::NonZero;
use std::cell::{Cell, UnsafeCell};
@@ -44,6 +45,14 @@ pub struct JS<T> {
ptr: NonZero<*const T>
}
+// JS<T> is similar to Rc<T>, in that it's not always clear how to avoid double-counting.
+// For now, we choose not to follow any such pointers.
+impl<T> HeapSizeOf for JS<T> {
+ fn heap_size_of_children(&self) -> usize {
+ 0
+ }
+}
+
impl<T> JS<T> {
/// Returns `LayoutJS<T>` containing the same pointer.
pub unsafe fn to_layout(self) -> LayoutJS<T> {
@@ -226,7 +235,7 @@ impl<T: HeapGCValue+Copy> MutHeap<T> {
/// place of traditional internal mutability to ensure that the proper GC
/// barriers are enforced.
#[must_root]
-#[derive(JSTraceable)]
+#[derive(JSTraceable, HeapSizeOf)]
pub struct MutNullableHeap<T: HeapGCValue+Copy> {
ptr: Cell<Option<T>>
}