717 lines
22 KiB
Diff
717 lines
22 KiB
Diff
diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs
|
|
index 778082b5f0..7f527c930e 100644
|
|
--- a/components/malloc_size_of/lib.rs
|
|
+++ b/components/malloc_size_of/lib.rs
|
|
@@ -43,55 +43,39 @@
|
|
//! measured as well as the thing it points to. E.g.
|
|
//! `<Box<_> as MallocSizeOf>::size_of(field, ops)`.
|
|
|
|
-extern crate app_units;
|
|
-#[cfg(feature = "servo")]
|
|
-extern crate crossbeam_channel;
|
|
-extern crate cssparser;
|
|
-extern crate euclid;
|
|
-extern crate hashglobe;
|
|
-#[cfg(feature = "servo")]
|
|
-extern crate hyper;
|
|
-#[cfg(feature = "servo")]
|
|
-extern crate hyper_serde;
|
|
-#[cfg(feature = "servo")]
|
|
-extern crate keyboard_types;
|
|
-#[cfg(feature = "servo")]
|
|
-extern crate mozjs as js;
|
|
-extern crate selectors;
|
|
-#[cfg(feature = "servo")]
|
|
-extern crate serde;
|
|
-#[cfg(feature = "servo")]
|
|
-extern crate serde_bytes;
|
|
-extern crate servo_arc;
|
|
-extern crate smallbitvec;
|
|
-extern crate smallvec;
|
|
-#[cfg(feature = "servo")]
|
|
-extern crate string_cache;
|
|
-extern crate thin_slice;
|
|
-#[cfg(feature = "servo")]
|
|
-extern crate time;
|
|
-#[cfg(feature = "url")]
|
|
-extern crate url;
|
|
-extern crate void;
|
|
-#[cfg(feature = "webrender_api")]
|
|
-extern crate webrender_api;
|
|
-#[cfg(feature = "servo")]
|
|
-extern crate xml5ever;
|
|
-
|
|
-#[cfg(feature = "servo")]
|
|
-use serde_bytes::ByteBuf;
|
|
+
|
|
+// This file is patched at commit 5bdea7dc1c80790a852a3fb03edfb2b8fbd403dc DO NOT EDIT.
|
|
+
|
|
+
|
|
+#[cfg(not(feature = "std"))]
|
|
+use alloc::vec::Vec;
|
|
+#[cfg(not(feature = "std"))]
|
|
+use alloc::string::String;
|
|
+#[cfg(not(feature = "std"))]
|
|
+mod std {
|
|
+ pub use core::*;
|
|
+ pub use alloc::collections;
|
|
+}
|
|
+
|
|
+#[cfg(feature = "std")]
|
|
+use std::sync::Arc;
|
|
+
|
|
use std::hash::{BuildHasher, Hash};
|
|
use std::mem::size_of;
|
|
use std::ops::Range;
|
|
use std::ops::{Deref, DerefMut};
|
|
+#[cfg(feature = "std")]
|
|
use std::os::raw::c_void;
|
|
-use void::Void;
|
|
+#[cfg(not(feature = "std"))]
|
|
+use core::ffi::c_void;
|
|
+#[cfg(not(feature = "std"))]
|
|
+pub use alloc::boxed::Box;
|
|
|
|
/// A C function that takes a pointer to a heap allocation and returns its size.
|
|
-type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize;
|
|
+pub type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize;
|
|
|
|
/// A closure implementing a stateful predicate on pointers.
|
|
-type VoidPtrToBoolFnMut = FnMut(*const c_void) -> bool;
|
|
+pub type VoidPtrToBoolFnMut = FnMut(*const c_void) -> bool;
|
|
|
|
/// Operations used when measuring heap usage of data structures.
|
|
pub struct MallocSizeOfOps {
|
|
@@ -216,6 +200,7 @@ pub trait MallocConditionalShallowSizeOf {
|
|
fn conditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize;
|
|
}
|
|
|
|
+#[cfg(not(feature = "estimate-heapsize"))]
|
|
impl MallocSizeOf for String {
|
|
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
unsafe { ops.malloc_size_of(self.as_ptr()) }
|
|
@@ -229,6 +214,7 @@ impl<'a, T: ?Sized> MallocSizeOf for &'a T {
|
|
}
|
|
}
|
|
|
|
+#[cfg(not(feature = "estimate-heapsize"))]
|
|
impl<T: ?Sized> MallocShallowSizeOf for Box<T> {
|
|
fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
unsafe { ops.malloc_size_of(&**self) }
|
|
@@ -241,24 +227,6 @@ impl<T: MallocSizeOf + ?Sized> MallocSizeOf for Box<T> {
|
|
}
|
|
}
|
|
|
|
-impl<T> MallocShallowSizeOf for thin_slice::ThinBoxedSlice<T> {
|
|
- fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- let mut n = 0;
|
|
- unsafe {
|
|
- n += thin_slice::ThinBoxedSlice::spilled_storage(self)
|
|
- .map_or(0, |ptr| ops.malloc_size_of(ptr));
|
|
- n += ops.malloc_size_of(&**self);
|
|
- }
|
|
- n
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T: MallocSizeOf> MallocSizeOf for thin_slice::ThinBoxedSlice<T> {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.shallow_size_of(ops) + (**self).size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
impl MallocSizeOf for () {
|
|
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
|
0
|
|
@@ -329,6 +297,7 @@ impl<T: MallocSizeOf> MallocSizeOf for std::cell::RefCell<T> {
|
|
}
|
|
}
|
|
|
|
+#[cfg(feature = "std")]
|
|
impl<'a, B: ?Sized + ToOwned> MallocSizeOf for std::borrow::Cow<'a, B>
|
|
where
|
|
B::Owned: MallocSizeOf,
|
|
@@ -351,24 +320,7 @@ impl<T: MallocSizeOf> MallocSizeOf for [T] {
|
|
}
|
|
}
|
|
|
|
-#[cfg(feature = "servo")]
|
|
-impl MallocShallowSizeOf for ByteBuf {
|
|
- fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- unsafe { ops.malloc_size_of(self.as_ptr()) }
|
|
- }
|
|
-}
|
|
-
|
|
-#[cfg(feature = "servo")]
|
|
-impl MallocSizeOf for ByteBuf {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- let mut n = self.shallow_size_of(ops);
|
|
- for elem in self.iter() {
|
|
- n += elem.size_of(ops);
|
|
- }
|
|
- n
|
|
- }
|
|
-}
|
|
-
|
|
+#[cfg(not(feature = "estimate-heapsize"))]
|
|
impl<T> MallocShallowSizeOf for Vec<T> {
|
|
fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
unsafe { ops.malloc_size_of(self.as_ptr()) }
|
|
@@ -412,30 +364,7 @@ impl<T: MallocSizeOf> MallocSizeOf for std::collections::VecDeque<T> {
|
|
}
|
|
}
|
|
|
|
-impl<A: smallvec::Array> MallocShallowSizeOf for smallvec::SmallVec<A> {
|
|
- fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- if self.spilled() {
|
|
- unsafe { ops.malloc_size_of(self.as_ptr()) }
|
|
- } else {
|
|
- 0
|
|
- }
|
|
- }
|
|
-}
|
|
-
|
|
-impl<A> MallocSizeOf for smallvec::SmallVec<A>
|
|
-where
|
|
- A: smallvec::Array,
|
|
- A::Item: MallocSizeOf,
|
|
-{
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- let mut n = self.shallow_size_of(ops);
|
|
- for elem in self.iter() {
|
|
- n += elem.size_of(ops);
|
|
- }
|
|
- n
|
|
- }
|
|
-}
|
|
-
|
|
+#[cfg(feature = "std")]
|
|
impl<T, S> MallocShallowSizeOf for std::collections::HashSet<T, S>
|
|
where
|
|
T: Eq + Hash,
|
|
@@ -457,6 +386,7 @@ where
|
|
}
|
|
}
|
|
|
|
+#[cfg(feature = "std")]
|
|
impl<T, S> MallocSizeOf for std::collections::HashSet<T, S>
|
|
where
|
|
T: Eq + Hash + MallocSizeOf,
|
|
@@ -471,59 +401,7 @@ where
|
|
}
|
|
}
|
|
|
|
-impl<T, S> MallocShallowSizeOf for hashglobe::hash_set::HashSet<T, S>
|
|
-where
|
|
- T: Eq + Hash,
|
|
- S: BuildHasher,
|
|
-{
|
|
- fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- // See the implementation for std::collections::HashSet for details.
|
|
- if ops.has_malloc_enclosing_size_of() {
|
|
- self.iter()
|
|
- .next()
|
|
- .map_or(0, |t| unsafe { ops.malloc_enclosing_size_of(t) })
|
|
- } else {
|
|
- self.capacity() * (size_of::<T>() + size_of::<usize>())
|
|
- }
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T, S> MallocSizeOf for hashglobe::hash_set::HashSet<T, S>
|
|
-where
|
|
- T: Eq + Hash + MallocSizeOf,
|
|
- S: BuildHasher,
|
|
-{
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- let mut n = self.shallow_size_of(ops);
|
|
- for t in self.iter() {
|
|
- n += t.size_of(ops);
|
|
- }
|
|
- n
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T, S> MallocShallowSizeOf for hashglobe::fake::HashSet<T, S>
|
|
-where
|
|
- T: Eq + Hash,
|
|
- S: BuildHasher,
|
|
-{
|
|
- fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- use std::ops::Deref;
|
|
- self.deref().shallow_size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T, S> MallocSizeOf for hashglobe::fake::HashSet<T, S>
|
|
-where
|
|
- T: Eq + Hash + MallocSizeOf,
|
|
- S: BuildHasher,
|
|
-{
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- use std::ops::Deref;
|
|
- self.deref().size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
+#[cfg(feature = "std")]
|
|
impl<K, V, S> MallocShallowSizeOf for std::collections::HashMap<K, V, S>
|
|
where
|
|
K: Eq + Hash,
|
|
@@ -541,6 +419,7 @@ where
|
|
}
|
|
}
|
|
|
|
+#[cfg(feature = "std")]
|
|
impl<K, V, S> MallocSizeOf for std::collections::HashMap<K, V, S>
|
|
where
|
|
K: Eq + Hash + MallocSizeOf,
|
|
@@ -587,62 +466,6 @@ where
|
|
}
|
|
}
|
|
|
|
-impl<K, V, S> MallocShallowSizeOf for hashglobe::hash_map::HashMap<K, V, S>
|
|
-where
|
|
- K: Eq + Hash,
|
|
- S: BuildHasher,
|
|
-{
|
|
- fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- // See the implementation for std::collections::HashSet for details.
|
|
- if ops.has_malloc_enclosing_size_of() {
|
|
- self.values()
|
|
- .next()
|
|
- .map_or(0, |v| unsafe { ops.malloc_enclosing_size_of(v) })
|
|
- } else {
|
|
- self.capacity() * (size_of::<V>() + size_of::<K>() + size_of::<usize>())
|
|
- }
|
|
- }
|
|
-}
|
|
-
|
|
-impl<K, V, S> MallocSizeOf for hashglobe::hash_map::HashMap<K, V, S>
|
|
-where
|
|
- K: Eq + Hash + MallocSizeOf,
|
|
- V: MallocSizeOf,
|
|
- S: BuildHasher,
|
|
-{
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- let mut n = self.shallow_size_of(ops);
|
|
- for (k, v) in self.iter() {
|
|
- n += k.size_of(ops);
|
|
- n += v.size_of(ops);
|
|
- }
|
|
- n
|
|
- }
|
|
-}
|
|
-
|
|
-impl<K, V, S> MallocShallowSizeOf for hashglobe::fake::HashMap<K, V, S>
|
|
-where
|
|
- K: Eq + Hash,
|
|
- S: BuildHasher,
|
|
-{
|
|
- fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- use std::ops::Deref;
|
|
- self.deref().shallow_size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<K, V, S> MallocSizeOf for hashglobe::fake::HashMap<K, V, S>
|
|
-where
|
|
- K: Eq + Hash + MallocSizeOf,
|
|
- V: MallocSizeOf,
|
|
- S: BuildHasher,
|
|
-{
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- use std::ops::Deref;
|
|
- self.deref().size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
// PhantomData is always 0.
|
|
impl<T> MallocSizeOf for std::marker::PhantomData<T> {
|
|
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
|
@@ -657,21 +480,43 @@ impl<T> MallocSizeOf for std::marker::PhantomData<T> {
|
|
//impl<T> !MallocSizeOf for Arc<T> { }
|
|
//impl<T> !MallocShallowSizeOf for Arc<T> { }
|
|
|
|
-impl<T> MallocUnconditionalShallowSizeOf for servo_arc::Arc<T> {
|
|
+#[cfg(feature = "std")]
|
|
+fn arc_ptr<T>(s: &Arc<T>) -> * const T {
|
|
+ &(**s) as *const T
|
|
+}
|
|
+
|
|
+
|
|
+// currently this seems only fine with jemalloc
|
|
+#[cfg(feature = "std")]
|
|
+#[cfg(not(feature = "estimate-heapsize"))]
|
|
+#[cfg(any(prefixed_jemalloc, target_os = "macos", target_os = "ios", target_os = "android", feature = "jemalloc-global"))]
|
|
+impl<T> MallocUnconditionalShallowSizeOf for Arc<T> {
|
|
fn unconditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- unsafe { ops.malloc_size_of(self.heap_ptr()) }
|
|
+ unsafe { ops.malloc_size_of(arc_ptr(self)) }
|
|
}
|
|
}
|
|
|
|
-impl<T: MallocSizeOf> MallocUnconditionalSizeOf for servo_arc::Arc<T> {
|
|
+#[cfg(feature = "std")]
|
|
+#[cfg(not(feature = "estimate-heapsize"))]
|
|
+#[cfg(not(any(prefixed_jemalloc, target_os = "macos", target_os = "ios", target_os = "android", feature = "jemalloc-global")))]
|
|
+impl<T> MallocUnconditionalShallowSizeOf for Arc<T> {
|
|
+ fn unconditional_shallow_size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
|
+ size_of::<T>()
|
|
+ }
|
|
+}
|
|
+
|
|
+
|
|
+#[cfg(feature = "std")]
|
|
+impl<T: MallocSizeOf> MallocUnconditionalSizeOf for Arc<T> {
|
|
fn unconditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
self.unconditional_shallow_size_of(ops) + (**self).size_of(ops)
|
|
}
|
|
}
|
|
|
|
-impl<T> MallocConditionalShallowSizeOf for servo_arc::Arc<T> {
|
|
+#[cfg(feature = "std")]
|
|
+impl<T> MallocConditionalShallowSizeOf for Arc<T> {
|
|
fn conditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- if ops.have_seen_ptr(self.heap_ptr()) {
|
|
+ if ops.have_seen_ptr(arc_ptr(self)) {
|
|
0
|
|
} else {
|
|
self.unconditional_shallow_size_of(ops)
|
|
@@ -679,9 +524,10 @@ impl<T> MallocConditionalShallowSizeOf for servo_arc::Arc<T> {
|
|
}
|
|
}
|
|
|
|
-impl<T: MallocSizeOf> MallocConditionalSizeOf for servo_arc::Arc<T> {
|
|
+#[cfg(feature = "std")]
|
|
+impl<T: MallocSizeOf> MallocConditionalSizeOf for Arc<T> {
|
|
fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- if ops.have_seen_ptr(self.heap_ptr()) {
|
|
+ if ops.have_seen_ptr(arc_ptr(self)) {
|
|
0
|
|
} else {
|
|
self.unconditional_size_of(ops)
|
|
@@ -695,203 +541,13 @@ impl<T: MallocSizeOf> MallocConditionalSizeOf for servo_arc::Arc<T> {
|
|
/// If a mutex is stored inside of an Arc value as a member of a data type that is being measured,
|
|
/// the Arc will not be automatically measured so there is no risk of overcounting the mutex's
|
|
/// contents.
|
|
+#[cfg(feature = "std")]
|
|
impl<T: MallocSizeOf> MallocSizeOf for std::sync::Mutex<T> {
|
|
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
(*self.lock().unwrap()).size_of(ops)
|
|
}
|
|
}
|
|
|
|
-impl MallocSizeOf for smallbitvec::SmallBitVec {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- if let Some(ptr) = self.heap_ptr() {
|
|
- unsafe { ops.malloc_size_of(ptr) }
|
|
- } else {
|
|
- 0
|
|
- }
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T: MallocSizeOf, Unit> MallocSizeOf for euclid::Length<T, Unit> {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.0.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::TypedScale<T, Src, Dst> {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.0.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedPoint2D<T, U> {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.x.size_of(ops) + self.y.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedRect<T, U> {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.origin.size_of(ops) + self.size.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedSideOffsets2D<T, U> {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.top.size_of(ops) +
|
|
- self.right.size_of(ops) +
|
|
- self.bottom.size_of(ops) +
|
|
- self.left.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedSize2D<T, U> {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.width.size_of(ops) + self.height.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::TypedTransform2D<T, Src, Dst> {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.m11.size_of(ops) +
|
|
- self.m12.size_of(ops) +
|
|
- self.m21.size_of(ops) +
|
|
- self.m22.size_of(ops) +
|
|
- self.m31.size_of(ops) +
|
|
- self.m32.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::TypedTransform3D<T, Src, Dst> {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.m11.size_of(ops) +
|
|
- self.m12.size_of(ops) +
|
|
- self.m13.size_of(ops) +
|
|
- self.m14.size_of(ops) +
|
|
- self.m21.size_of(ops) +
|
|
- self.m22.size_of(ops) +
|
|
- self.m23.size_of(ops) +
|
|
- self.m24.size_of(ops) +
|
|
- self.m31.size_of(ops) +
|
|
- self.m32.size_of(ops) +
|
|
- self.m33.size_of(ops) +
|
|
- self.m34.size_of(ops) +
|
|
- self.m41.size_of(ops) +
|
|
- self.m42.size_of(ops) +
|
|
- self.m43.size_of(ops) +
|
|
- self.m44.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedVector2D<T, U> {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.x.size_of(ops) + self.y.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl MallocSizeOf for selectors::parser::AncestorHashes {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- let selectors::parser::AncestorHashes { ref packed_hashes } = *self;
|
|
- packed_hashes.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-impl<Impl: selectors::parser::SelectorImpl> MallocSizeOf for selectors::parser::Selector<Impl>
|
|
-where
|
|
- Impl::NonTSPseudoClass: MallocSizeOf,
|
|
- Impl::PseudoElement: MallocSizeOf,
|
|
-{
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- let mut n = 0;
|
|
-
|
|
- // It's OK to measure this ThinArc directly because it's the
|
|
- // "primary" reference. (The secondary references are on the
|
|
- // Stylist.)
|
|
- n += unsafe { ops.malloc_size_of(self.thin_arc_heap_ptr()) };
|
|
- for component in self.iter_raw_match_order() {
|
|
- n += component.size_of(ops);
|
|
- }
|
|
-
|
|
- n
|
|
- }
|
|
-}
|
|
-
|
|
-impl<Impl: selectors::parser::SelectorImpl> MallocSizeOf for selectors::parser::Component<Impl>
|
|
-where
|
|
- Impl::NonTSPseudoClass: MallocSizeOf,
|
|
- Impl::PseudoElement: MallocSizeOf,
|
|
-{
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- use selectors::parser::Component;
|
|
-
|
|
- match self {
|
|
- Component::AttributeOther(ref attr_selector) => attr_selector.size_of(ops),
|
|
- Component::Negation(ref components) => components.size_of(ops),
|
|
- Component::NonTSPseudoClass(ref pseudo) => (*pseudo).size_of(ops),
|
|
- Component::Slotted(ref selector) | Component::Host(Some(ref selector)) => {
|
|
- selector.size_of(ops)
|
|
- },
|
|
- Component::PseudoElement(ref pseudo) => (*pseudo).size_of(ops),
|
|
- Component::Combinator(..) |
|
|
- Component::ExplicitAnyNamespace |
|
|
- Component::ExplicitNoNamespace |
|
|
- Component::DefaultNamespace(..) |
|
|
- Component::Namespace(..) |
|
|
- Component::ExplicitUniversalType |
|
|
- Component::LocalName(..) |
|
|
- Component::ID(..) |
|
|
- Component::Class(..) |
|
|
- Component::AttributeInNoNamespaceExists { .. } |
|
|
- Component::AttributeInNoNamespace { .. } |
|
|
- Component::FirstChild |
|
|
- Component::LastChild |
|
|
- Component::OnlyChild |
|
|
- Component::Root |
|
|
- Component::Empty |
|
|
- Component::Scope |
|
|
- Component::NthChild(..) |
|
|
- Component::NthLastChild(..) |
|
|
- Component::NthOfType(..) |
|
|
- Component::NthLastOfType(..) |
|
|
- Component::FirstOfType |
|
|
- Component::LastOfType |
|
|
- Component::OnlyOfType |
|
|
- Component::Host(None) => 0,
|
|
- }
|
|
- }
|
|
-}
|
|
-
|
|
-impl<Impl: selectors::parser::SelectorImpl> MallocSizeOf
|
|
- for selectors::attr::AttrSelectorWithOptionalNamespace<Impl>
|
|
-{
|
|
- fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
|
- 0
|
|
- }
|
|
-}
|
|
-
|
|
-impl MallocSizeOf for Void {
|
|
- #[inline]
|
|
- fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
|
- void::unreachable(*self)
|
|
- }
|
|
-}
|
|
-
|
|
-#[cfg(feature = "servo")]
|
|
-impl<Static: string_cache::StaticAtomSet> MallocSizeOf for string_cache::Atom<Static> {
|
|
- fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
|
- 0
|
|
- }
|
|
-}
|
|
-
|
|
-// This is measured properly by the heap measurement implemented in
|
|
-// SpiderMonkey.
|
|
-#[cfg(feature = "servo")]
|
|
-impl<T: Copy + js::rust::GCMethods> MallocSizeOf for js::jsapi::Heap<T> {
|
|
- fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
|
- 0
|
|
- }
|
|
-}
|
|
-
|
|
-/// For use on types where size_of() returns 0.
|
|
#[macro_export]
|
|
macro_rules! malloc_size_of_is_0(
|
|
($($ty:ty),+) => (
|
|
@@ -929,117 +585,6 @@ malloc_size_of_is_0!(Range<u8>, Range<u16>, Range<u32>, Range<u64>, Range<usize>
|
|
malloc_size_of_is_0!(Range<i8>, Range<i16>, Range<i32>, Range<i64>, Range<isize>);
|
|
malloc_size_of_is_0!(Range<f32>, Range<f64>);
|
|
|
|
-malloc_size_of_is_0!(app_units::Au);
|
|
-
|
|
-malloc_size_of_is_0!(cssparser::RGBA, cssparser::TokenSerializationType);
|
|
-
|
|
-#[cfg(feature = "url")]
|
|
-impl MallocSizeOf for url::Host {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- match *self {
|
|
- url::Host::Domain(ref s) => s.size_of(ops),
|
|
- _ => 0,
|
|
- }
|
|
- }
|
|
-}
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::BorderRadius);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::BorderStyle);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::BoxShadowClipMode);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::ClipAndScrollInfo);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::ColorF);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::ComplexClipRegion);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::ExtendMode);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::FilterOp);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::ExternalScrollId);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::FontInstanceKey);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::GradientStop);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::GlyphInstance);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::NinePatchBorder);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::ImageKey);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::ImageRendering);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::LineStyle);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::MixBlendMode);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::NormalBorder);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::RepeatMode);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::ScrollSensitivity);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::StickyOffsetBounds);
|
|
-#[cfg(feature = "webrender_api")]
|
|
-malloc_size_of_is_0!(webrender_api::TransformStyle);
|
|
-
|
|
-#[cfg(feature = "servo")]
|
|
-impl MallocSizeOf for keyboard_types::Key {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- match self {
|
|
- keyboard_types::Key::Character(ref s) => s.size_of(ops),
|
|
- _ => 0,
|
|
- }
|
|
- }
|
|
-}
|
|
-
|
|
-#[cfg(feature = "servo")]
|
|
-malloc_size_of_is_0!(keyboard_types::Modifiers);
|
|
-
|
|
-#[cfg(feature = "servo")]
|
|
-impl MallocSizeOf for xml5ever::QualName {
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.prefix.size_of(ops) + self.ns.size_of(ops) + self.local.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-#[cfg(feature = "servo")]
|
|
-malloc_size_of_is_0!(time::Duration);
|
|
-#[cfg(feature = "servo")]
|
|
-malloc_size_of_is_0!(time::Tm);
|
|
-
|
|
-#[cfg(feature = "servo")]
|
|
-impl<T> MallocSizeOf for hyper_serde::Serde<T>
|
|
-where
|
|
- for<'de> hyper_serde::De<T>: serde::Deserialize<'de>,
|
|
- for<'a> hyper_serde::Ser<'a, T>: serde::Serialize,
|
|
- T: MallocSizeOf,
|
|
-{
|
|
- fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
- self.0.size_of(ops)
|
|
- }
|
|
-}
|
|
-
|
|
-// Placeholder for unique case where internals of Sender cannot be measured.
|
|
-// malloc size of is 0 macro complains about type supplied!
|
|
-#[cfg(feature = "servo")]
|
|
-impl<T> MallocSizeOf for crossbeam_channel::Sender<T> {
|
|
- fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
|
- 0
|
|
- }
|
|
-}
|
|
-
|
|
-#[cfg(feature = "servo")]
|
|
-impl MallocSizeOf for hyper::StatusCode {
|
|
- fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
|
- 0
|
|
- }
|
|
-}
|
|
-
|
|
/// Measurable that defers to inner value and used to verify MallocSizeOf implementation in a
|
|
/// struct.
|
|
#[derive(Clone)]
|