Auto merge of #7097 - boghison:memtypes, r=jdm

Measure heap memory usage for more types. Fixes #6951

Also adds HeapSizeOf implementations/derive for some types. I've used "Cannot calculate Heap size" as a reason everywhere, because my imagination is rather limited. If you'd like me to change this message for specific types, please write something like this: "Trusted - Cannot calculate Heap size for Trusted" so that it would be easier for me to replace them through a script :)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7097)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-08-13 13:16:14 -06:00
commit a03616f379
175 changed files with 669 additions and 94 deletions

View file

@ -9,6 +9,7 @@ use dom::bindings::conversions::ToJSValConvertible;
use dom::bindings::global::GlobalRef;
use dom::domexception::{DOMException, DOMErrorName};
use util::mem::HeapSizeOf;
use util::str::DOMString;
use js::jsapi::{JSContext, JSObject, RootedValue};
@ -24,7 +25,7 @@ use std::ptr;
use std::mem;
/// DOM exceptions that can be thrown by a native DOM method.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, HeapSizeOf)]
pub enum Error {
/// IndexSizeError DOMException
IndexSize,

View file

@ -27,6 +27,8 @@ use js::jsapi::{GetGlobalForObjectCrossCompartment};
use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue};
use url::Url;
use util::mem::HeapSizeOf;
/// A freely-copyable reference to a rooted global object.
#[derive(Copy, Clone)]
pub enum GlobalRef<'a> {
@ -47,7 +49,7 @@ pub enum GlobalRoot {
/// A traced reference to a global object, for use in fields of traced Rust
/// structures.
#[derive(JSTraceable)]
#[derive(JSTraceable, HeapSizeOf)]
#[must_root]
pub enum GlobalField {
/// A field for a `Window` object.

View file

@ -463,4 +463,3 @@ impl<T: Reflectable> Drop for Root<T> {
unsafe { (*self.root_list).unroot(self); }
}
}

View file

@ -11,8 +11,10 @@ use std::ops;
use std::str;
use std::str::FromStr;
use util::mem::HeapSizeOf;
/// Encapsulates the IDL `ByteString` type.
#[derive(JSTraceable,Clone,Eq,PartialEq)]
#[derive(JSTraceable, Clone, Eq, PartialEq, HeapSizeOf)]
pub struct ByteString(Vec<u8>);
impl ByteString {