aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2016-01-30 15:06:31 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2016-02-04 22:03:32 +0100
commitcb5cd8d881c39f549381e078b44f341dea733e68 (patch)
tree2035bc256a114cd362a10cf7e8c461a7743f8209 /components
parent9932a5cf82a9fb109e7ac8b07e4f19535101ce44 (diff)
downloadservo-cb5cd8d881c39f549381e078b44f341dea733e68.tar.gz
servo-cb5cd8d881c39f549381e078b44f341dea733e68.zip
Say farewell to in-tree HeapSizeOf
Diffstat (limited to 'components')
-rw-r--r--components/canvas_traits/Cargo.toml4
-rw-r--r--components/canvas_traits/lib.rs4
-rw-r--r--components/compositing/Cargo.toml2
-rw-r--r--components/devtools_traits/Cargo.toml4
-rw-r--r--components/devtools_traits/lib.rs4
-rw-r--r--components/gfx/Cargo.toml6
-rw-r--r--components/gfx/display_list/mod.rs4
-rw-r--r--components/gfx/font_context.rs2
-rw-r--r--components/gfx/lib.rs2
-rw-r--r--components/gfx/platform/freetype/font_context.rs2
-rw-r--r--components/gfx/platform/macos/font_context.rs2
-rw-r--r--components/gfx_traits/Cargo.toml2
-rw-r--r--components/gfx_traits/lib.rs3
-rw-r--r--components/layout/Cargo.toml10
-rw-r--r--components/layout/context.rs2
-rw-r--r--components/layout/layout_thread.rs2
-rw-r--r--components/layout/lib.rs2
-rw-r--r--components/layout_traits/Cargo.toml2
-rw-r--r--components/msg/Cargo.toml6
-rw-r--r--components/msg/constellation_msg.rs1
-rw-r--r--components/msg/lib.rs3
-rw-r--r--components/net/Cargo.toml2
-rw-r--r--components/net_traits/Cargo.toml4
-rw-r--r--components/net_traits/image_cache_thread.rs1
-rw-r--r--components/net_traits/lib.rs7
-rw-r--r--components/plugins/Cargo.toml2
-rw-r--r--components/plugins/heap_size.rs82
-rw-r--r--components/plugins/lib.rs3
-rw-r--r--components/script/Cargo.toml12
-rw-r--r--components/script/cors.rs2
-rw-r--r--components/script/dom/bindings/error.rs1
-rw-r--r--components/script/dom/bindings/js.rs2
-rw-r--r--components/script/dom/bindings/str.rs1
-rw-r--r--components/script/dom/bindings/utils.rs2
-rw-r--r--components/script/dom/bindings/weakref.rs2
-rw-r--r--components/script/dom/crypto.rs1
-rw-r--r--components/script/dom/element.rs1
-rw-r--r--components/script/dom/eventtarget.rs2
-rw-r--r--components/script/dom/node.rs2
-rw-r--r--components/script/dom/range.rs2
-rw-r--r--components/script/dom/xmlhttprequest.rs3
-rw-r--r--components/script/lib.rs2
-rw-r--r--components/script/mem.rs2
-rw-r--r--components/script/textinput.rs1
-rw-r--r--components/script/timers.rs2
-rw-r--r--components/script_traits/Cargo.toml4
-rw-r--r--components/script_traits/lib.rs4
-rw-r--r--components/servo/Cargo.lock34
-rw-r--r--components/servo/Cargo.toml2
-rw-r--r--components/style/Cargo.toml10
-rw-r--r--components/style/custom_properties.rs1
-rw-r--r--components/style/font_face.rs1
-rw-r--r--components/style/lib.rs5
-rw-r--r--components/style/media_queries.rs1
-rw-r--r--components/style/stylesheets.rs1
-rw-r--r--components/style/viewport.rs1
-rw-r--r--components/style_traits/Cargo.toml9
-rw-r--r--components/style_traits/lib.rs2
-rw-r--r--components/util/Cargo.toml12
-rw-r--r--components/util/cursor.rs2
-rw-r--r--components/util/geometry.rs6
-rw-r--r--components/util/lib.rs4
-rw-r--r--components/util/logical_geometry.rs2
-rw-r--r--components/util/mem.rs360
-rw-r--r--components/util/non_geckolib.rs84
-rw-r--r--components/util/range.rs2
-rw-r--r--components/util/str.rs4
-rw-r--r--components/webdriver_server/Cargo.toml2
68 files changed, 150 insertions, 613 deletions
diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml
index b0985bdab63..83bb07f7076 100644
--- a/components/canvas_traits/Cargo.toml
+++ b/components/canvas_traits/Cargo.toml
@@ -35,7 +35,9 @@ path = "../plugins"
path = "../util"
[dependencies]
-cssparser = {version = "0.5.2", features = ["serde-serialization"]}
+cssparser = {version = "0.5.2", features = ["heap_size", "serde-serialization"]}
euclid = {version = "0.6.1", features = ["plugins"]}
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
serde_macros = "0.6"
diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs
index d54530b94fd..4dc0a5904f8 100644
--- a/components/canvas_traits/lib.rs
+++ b/components/canvas_traits/lib.rs
@@ -7,13 +7,14 @@
#![feature(custom_derive)]
#![feature(nonzero)]
#![feature(plugin)]
-#![plugin(serde_macros, plugins)]
+#![plugin(heapsize_plugin, plugins, serde_macros)]
extern crate azure;
extern crate core;
extern crate cssparser;
extern crate euclid;
extern crate gfx_traits;
+extern crate heapsize;
extern crate ipc_channel;
extern crate layers;
extern crate offscreen_gl_context;
@@ -40,7 +41,6 @@ use std::default::Default;
use std::fmt;
use std::str::FromStr;
use std::sync::mpsc::Sender;
-use util::mem::HeapSizeOf;
#[derive(Clone, Deserialize, Serialize)]
pub enum FillRule {
diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml
index 965547b82db..937bc11e3bb 100644
--- a/components/compositing/Cargo.toml
+++ b/components/compositing/Cargo.toml
@@ -91,7 +91,7 @@ gleam = "0.2"
euclid = {version = "0.6.1", features = ["plugins"]}
serde = "0.6"
serde_macros = "0.6"
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
[target.x86_64-apple-darwin.dependencies]
core-graphics = "0.2"
diff --git a/components/devtools_traits/Cargo.toml b/components/devtools_traits/Cargo.toml
index c0a282226f7..115ab732691 100644
--- a/components/devtools_traits/Cargo.toml
+++ b/components/devtools_traits/Cargo.toml
@@ -20,11 +20,13 @@ git = "https://github.com/servo/ipc-channel"
path = "../plugins"
[dependencies]
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
hyper = { version = "0.7", features = [ "serde-serialization" ] }
time = "0.1"
rustc-serialize = "0.3"
bitflags = "0.3"
serde = "0.6"
serde_macros = "0.6"
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
diff --git a/components/devtools_traits/lib.rs b/components/devtools_traits/lib.rs
index 81644badc44..8408a79b197 100644
--- a/components/devtools_traits/lib.rs
+++ b/components/devtools_traits/lib.rs
@@ -13,10 +13,11 @@
#![deny(unsafe_code)]
#![feature(custom_derive, plugin)]
-#![plugin(serde_macros, plugins)]
+#![plugin(heapsize_plugin, serde_macros)]
#[macro_use]
extern crate bitflags;
+extern crate heapsize;
extern crate hyper;
extern crate ipc_channel;
extern crate msg;
@@ -36,7 +37,6 @@ use std::net::TcpStream;
use time::Duration;
use time::Tm;
use url::Url;
-use util::mem::HeapSizeOf;
// Information would be attached to NewGlobal to be received and show in devtools.
// Extend these fields if we need more information.
diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml
index b7a4b1d2e7c..874e95d591a 100644
--- a/components/gfx/Cargo.toml
+++ b/components/gfx/Cargo.toml
@@ -14,6 +14,8 @@ bitflags = "0.3"
euclid = {version = "0.6.1", features = ["plugins"]}
fnv = "1.0"
harfbuzz-sys = "0.1"
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
lazy_static = "0.1"
libc = "0.2"
log = "0.3"
@@ -23,10 +25,10 @@ rustc-serialize = "0.3"
serde = "0.6"
serde_macros = "0.6"
smallvec = "0.1"
-string_cache = "0.2.7"
+string_cache = {version = "0.2.7", features = ["heap_size"]}
time = "0.1.12"
unicode-script = { version = "0.1", features = ["harfbuzz"] }
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
servo-skia = "0.20130412.0"
[dependencies.plugins]
diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs
index b6565753f36..96c953d3dfe 100644
--- a/components/gfx/display_list/mod.rs
+++ b/components/gfx/display_list/mod.rs
@@ -22,6 +22,7 @@ use euclid::approxeq::ApproxEq;
use euclid::num::Zero;
use euclid::{Matrix2D, Matrix4, Point2D, Rect, SideOffsets2D, Size2D};
use gfx_traits::{color, LayerId, LayerKind, ScrollPolicy};
+use heapsize::HeapSizeOf;
use msg::constellation_msg::PipelineId;
use net_traits::image::base::Image;
use paint_context::PaintContext;
@@ -41,7 +42,6 @@ use text::glyph::CharIndex;
use util::cursor::Cursor;
use util::geometry::MAX_RECT;
use util::linked_list::prepend_from;
-use util::mem::HeapSizeOf;
use util::opts;
use util::print_tree::PrintTree;
use util::range::Range;
@@ -1256,8 +1256,8 @@ pub struct GradientDisplayItem {
impl HeapSizeOf for GradientDisplayItem {
fn heap_size_of_children(&self) -> usize {
+ use heapsize::heap_size_of;
use libc::c_void;
- use util::mem::heap_size_of;
// We can't measure `stops` via Vec's HeapSizeOf implementation because GradientStop isn't
// defined in this module, and we don't want to import GradientStop into util::mem where
diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs
index 1011d40112b..6fc010fedf3 100644
--- a/components/gfx/font_context.rs
+++ b/components/gfx/font_context.rs
@@ -13,6 +13,7 @@ use font::SpecifiedFontStyle;
use font::{Font, FontGroup};
use font_cache_thread::FontCacheThread;
use font_template::FontTemplateDescriptor;
+use heapsize::HeapSizeOf;
use platform::font::FontHandle;
use platform::font_context::FontContextHandle;
use platform::font_template::FontTemplateData;
@@ -28,7 +29,6 @@ use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use string_cache::Atom;
use style::computed_values::{font_style, font_variant};
use util::cache::HashCache;
-use util::mem::HeapSizeOf;
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs
index 871e210f541..c0868ade6f8 100644
--- a/components/gfx/lib.rs
+++ b/components/gfx/lib.rs
@@ -16,6 +16,7 @@
#![feature(str_char)]
#![feature(unique)]
+#![plugin(heapsize_plugin)]
#![plugin(plugins)]
#![plugin(serde_macros)]
@@ -46,6 +47,7 @@ extern crate gfx_traits;
// shapers. For now, however, this is a hard dependency.
extern crate harfbuzz_sys as harfbuzz;
+extern crate heapsize;
extern crate ipc_channel;
extern crate layers;
#[macro_use]
diff --git a/components/gfx/platform/freetype/font_context.rs b/components/gfx/platform/freetype/font_context.rs
index 05cbd0675f6..1ed40300639 100644
--- a/components/gfx/platform/freetype/font_context.rs
+++ b/components/gfx/platform/freetype/font_context.rs
@@ -10,10 +10,10 @@ use freetype::freetype::FT_Library;
use freetype::freetype::FT_Memory;
use freetype::freetype::FT_New_Library;
use freetype::freetype::struct_FT_MemoryRec_;
+use heapsize::{HeapSizeOf, heap_size_of};
use libc::{c_long, c_void};
use std::ptr;
use std::rc::Rc;
-use util::mem::{HeapSizeOf, heap_size_of};
// We pass a |User| struct -- via an opaque |void*| -- to FreeType each time a new instance is
// created. FreeType passes it back to the ft_alloc/ft_realloc/ft_free callbacks. We use it to
diff --git a/components/gfx/platform/macos/font_context.rs b/components/gfx/platform/macos/font_context.rs
index e260f84b17b..e728b62aebd 100644
--- a/components/gfx/platform/macos/font_context.rs
+++ b/components/gfx/platform/macos/font_context.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use util::mem::HeapSizeOf;
+use heapsize::HeapSizeOf;
#[derive(Clone, Debug)]
pub struct FontContextHandle {
diff --git a/components/gfx_traits/Cargo.toml b/components/gfx_traits/Cargo.toml
index d6e132caa8f..0f7165f3494 100644
--- a/components/gfx_traits/Cargo.toml
+++ b/components/gfx_traits/Cargo.toml
@@ -26,5 +26,7 @@ path = "../util"
[dependencies]
euclid = {version = "0.6.1", features = ["plugins"]}
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
serde = "0.6"
serde_macros = "0.6"
diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs
index 980e850b014..84e74038e40 100644
--- a/components/gfx_traits/lib.rs
+++ b/components/gfx_traits/lib.rs
@@ -3,13 +3,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(custom_derive, plugin)]
-#![plugin(plugins, serde_macros)]
+#![plugin(heapsize_plugin, plugins, serde_macros)]
#![crate_name = "gfx_traits"]
#![crate_type = "rlib"]
extern crate azure;
extern crate euclid;
+extern crate heapsize;
extern crate layers;
extern crate msg;
extern crate serde;
diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml
index cbdbe3c9dc3..9c494dbc07c 100644
--- a/components/layout/Cargo.toml
+++ b/components/layout/Cargo.toml
@@ -56,19 +56,21 @@ git = "https://github.com/servo/ipc-channel"
[dependencies]
app_units = {version = "0.2", features = ["plugins"]}
bitflags = "0.3"
-cssparser = {version = "0.5.2", features = ["serde-serialization"]}
+cssparser = {version = "0.5.2", features = ["heap_size", "serde-serialization"]}
euclid = {version = "0.6.1", features = ["plugins"]}
fnv = "1.0"
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
libc = "0.2"
log = "0.3"
rustc-serialize = "0.3"
-selectors = "0.4.1"
+selectors = {version = "0.4.1", features = ["heap_size"]}
serde = "0.6"
serde_json = "0.5"
serde_macros = "0.6"
smallvec = "0.1"
-string_cache = "0.2.7"
+string_cache = {version = "0.2.7", features = ["heap_size"]}
time = "0.1"
unicode-bidi = "0.2"
unicode-script = { version = "0.1", features = ["harfbuzz"] }
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
diff --git a/components/layout/context.rs b/components/layout/context.rs
index 53bb036d09c..ca4ef0851dd 100644
--- a/components/layout/context.rs
+++ b/components/layout/context.rs
@@ -14,6 +14,7 @@ use fnv::FnvHasher;
use gfx::font_cache_thread::FontCacheThread;
use gfx::font_context::FontContext;
use gfx_traits::LayerId;
+use heapsize::HeapSizeOf;
use ipc_channel::ipc::{self, IpcSender};
use net_traits::image::base::Image;
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState};
@@ -27,7 +28,6 @@ use std::sync::{Arc, Mutex};
use style::context::{LocalStyleContext, SharedStyleContext, StyleContext};
use style::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
use url::Url;
-use util::mem::HeapSizeOf;
use util::opts;
struct LocalLayoutContext {
diff --git a/components/layout/layout_thread.rs b/components/layout/layout_thread.rs
index 206bfe4c82d..2b1950d88ce 100644
--- a/components/layout/layout_thread.rs
+++ b/components/layout/layout_thread.rs
@@ -28,6 +28,7 @@ use gfx::font_cache_thread::FontCacheThread;
use gfx::font_context;
use gfx::paint_thread::{LayoutToPaintMsg, PaintLayer};
use gfx_traits::{color, Epoch, LayerId, ScrollPolicy};
+use heapsize::HeapSizeOf;
use incremental::{LayoutDamageComputation, REFLOW, REFLOW_ENTIRE_DOCUMENT, REPAINT};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
@@ -73,7 +74,6 @@ use url::Url;
use util::geometry::MAX_RECT;
use util::ipc::OptionalIpcSender;
use util::logical_geometry::LogicalPoint;
-use util::mem::HeapSizeOf;
use util::opts;
use util::thread;
use util::thread_state;
diff --git a/components/layout/lib.rs b/components/layout/lib.rs
index cf0d2f18ea1..a3b78e8c4bd 100644
--- a/components/layout/lib.rs
+++ b/components/layout/lib.rs
@@ -17,6 +17,7 @@
#![deny(unsafe_code)]
+#![plugin(heapsize_plugin)]
#![plugin(plugins)]
extern crate app_units;
@@ -30,6 +31,7 @@ extern crate euclid;
extern crate fnv;
extern crate gfx;
extern crate gfx_traits;
+extern crate heapsize;
extern crate ipc_channel;
extern crate layout_traits;
extern crate libc;
diff --git a/components/layout_traits/Cargo.toml b/components/layout_traits/Cargo.toml
index 4729605b282..a2c4c2fba27 100644
--- a/components/layout_traits/Cargo.toml
+++ b/components/layout_traits/Cargo.toml
@@ -31,4 +31,4 @@ git = "https://github.com/servo/ipc-channel"
[dependencies]
serde = "0.6"
serde_macros = "0.6"
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
diff --git a/components/msg/Cargo.toml b/components/msg/Cargo.toml
index 599888015c8..129355c8ae6 100644
--- a/components/msg/Cargo.toml
+++ b/components/msg/Cargo.toml
@@ -22,10 +22,12 @@ path = "../plugins"
[dependencies]
bitflags = "0.3"
-cssparser = {version = "0.5.2", features = ["serde-serialization"]}
+cssparser = {version = "0.5.2", features = ["heap_size", "serde-serialization"]}
euclid = {version = "0.6.1", features = ["plugins"]}
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
hyper = { version = "0.7", features = [ "serde-serialization" ] }
rustc-serialize = "0.3.4"
serde = "0.6"
serde_macros = "0.6"
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs
index 2ce14039a15..adefb76010c 100644
--- a/components/msg/constellation_msg.rs
+++ b/components/msg/constellation_msg.rs
@@ -16,7 +16,6 @@ use std::cell::Cell;
use std::fmt;
use url::Url;
use util::geometry::{PagePx, ViewportPx};
-use util::mem::HeapSizeOf;
use webdriver_msg::{LoadStatus, WebDriverScriptCommand};
#[derive(Deserialize, Serialize)]
diff --git a/components/msg/lib.rs b/components/msg/lib.rs
index 3b5c99b8f3c..febf188fd77 100644
--- a/components/msg/lib.rs
+++ b/components/msg/lib.rs
@@ -3,11 +3,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(custom_attribute, custom_derive, plugin)]
-#![plugin(serde_macros, plugins)]
+#![plugin(heapsize_plugin, serde_macros, plugins)]
#[macro_use]
extern crate bitflags;
extern crate euclid;
+extern crate heapsize;
extern crate hyper;
extern crate ipc_channel;
extern crate layers;
diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml
index b0bb98b779f..0c5e34874d0 100644
--- a/components/net/Cargo.toml
+++ b/components/net/Cargo.toml
@@ -38,6 +38,6 @@ cookie = "0.2"
mime_guess = "1.1.1"
flate2 = "0.2.0"
uuid = "0.1.16"
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
websocket = "0.14.0"
immeta = "0.2"
diff --git a/components/net_traits/Cargo.toml b/components/net_traits/Cargo.toml
index f5db12de376..d41649797c1 100644
--- a/components/net_traits/Cargo.toml
+++ b/components/net_traits/Cargo.toml
@@ -20,11 +20,13 @@ git = "https://github.com/servo/ipc-channel"
path = "../plugins"
[dependencies]
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
hyper = { version = "0.7", features = [ "serde-serialization" ] }
image = "0.5.0"
log = "0.3"
serde = "0.6"
serde_macros = "0.6"
stb_image = "0.2"
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
websocket = "0.14.0"
diff --git a/components/net_traits/image_cache_thread.rs b/components/net_traits/image_cache_thread.rs
index 2381efbb997..8324bae8b23 100644
--- a/components/net_traits/image_cache_thread.rs
+++ b/components/net_traits/image_cache_thread.rs
@@ -6,7 +6,6 @@ use ipc_channel::ipc::{self, IpcSender};
use msg::constellation_msg::{Image, ImageMetadata};
use std::sync::Arc;
use url::Url;
-use util::mem::HeapSizeOf;
/// This is optionally passed to the image cache when requesting
/// and image, and returned to the specified event loop when the
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs
index 654a64e811c..45d01a9818d 100644
--- a/components/net_traits/lib.rs
+++ b/components/net_traits/lib.rs
@@ -9,8 +9,9 @@
#![feature(slice_patterns)]
#![feature(step_by)]
#![feature(custom_attribute)]
-#![plugin(serde_macros, plugins)]
+#![plugin(heapsize_plugin, serde_macros)]
+extern crate heapsize;
extern crate hyper;
extern crate image as piston_image;
extern crate ipc_channel;
@@ -32,7 +33,6 @@ use msg::constellation_msg::{PipelineId};
use serde::{Deserializer, Serializer};
use std::thread;
use url::Url;
-use util::mem::HeapSizeOf;
use websocket::header;
pub mod hosts;
@@ -69,6 +69,7 @@ pub enum LoadContext {
#[derive(Clone, Deserialize, Serialize, HeapSizeOf)]
pub struct LoadData {
pub url: Url,
+ #[ignore_heap_size_of = "Defined in hyper"]
pub method: Method,
#[ignore_heap_size_of = "Defined in hyper"]
/// Headers that will apply to the initial request only
@@ -297,6 +298,7 @@ pub struct Metadata {
/// Final URL after redirects.
pub final_url: Url,
+ #[ignore_heap_size_of = "Defined in hyper"]
/// MIME type / subtype.
pub content_type: Option<(ContentType)>,
@@ -307,6 +309,7 @@ pub struct Metadata {
/// Headers
pub headers: Option<Headers>,
+ #[ignore_heap_size_of = "Defined in hyper"]
/// HTTP Status
pub status: Option<RawStatus>,
}
diff --git a/components/plugins/Cargo.toml b/components/plugins/Cargo.toml
index 172a0d3adf3..d5d1f0246b0 100644
--- a/components/plugins/Cargo.toml
+++ b/components/plugins/Cargo.toml
@@ -17,7 +17,7 @@ rev = "9dca15de3e8ea266d3e7e868c0f358ed4fa5f195"
optional = true
[dependencies]
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
[features]
default = []
diff --git a/components/plugins/heap_size.rs b/components/plugins/heap_size.rs
deleted file mode 100644
index 0f8ea67fa62..00000000000
--- a/components/plugins/heap_size.rs
+++ /dev/null
@@ -1,82 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-//! Handles the auto-deriving for `#[derive(HeapSizeOf)]`
-//!
-//! This provides the `#[derive(HeapSizeOf)]` decorator, which
-//! generates a `HeapSizeOf` implementation that adds up
-//! calls to heap_size_of_children() for all the fields
-//! of a struct or enum variant.
-//!
-//! Fields marked `#[ignore_heap_size_of = "reason"]` will
-//! be ignored in this calculation. Providing a reason is compulsory.
-
-
-use syntax::ast::*;
-use syntax::attr::AttrMetaMethods;
-use syntax::codemap::Span;
-use syntax::ext::base::{Annotatable, ExtCtxt};
-use syntax::ext::build::AstBuilder;
-use syntax::ptr::P;
-use syntax_ext::deriving::generic::*;
-
-pub fn expand_heap_size(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem,
- item: &Annotatable, push: &mut FnMut(Annotatable)) {
- let trait_def = TraitDef {
- is_unsafe: false,
- span: span,
- attributes: Vec::new(),
- path: ty::Path::new(vec!("util", "mem", "HeapSizeOf")),
- additional_bounds: Vec::new(),
- generics: ty::LifetimeBounds::empty(),
- methods: vec![
- MethodDef {
- name: "heap_size_of_children",
- generics: ty::LifetimeBounds::empty(),
- explicit_self: ty::borrowed_explicit_self(),
- args: vec!(),
- ret_ty: ty::Literal(ty::Path::new_local("usize")),
- attributes: vec!(),
- is_unsafe: false,
- combine_substructure: combine_substructure(Box::new(heap_size_substructure))
- }
- ],
- associated_types: vec![],
- };
- trait_def.expand(cx, mitem, item, push)
-}
-
-/// Defines how the implementation for `heap_size_of_children()` is to be generated.
-fn heap_size_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
- let fields = match *substr.fields {
- Struct(ref fs) | EnumMatching(_, _, ref fs) => fs,
- _ => cx.span_bug(trait_span, "impossible substructure in `#[derive(HeapSizeOf)]`")
- };
-
- fields.iter().fold(cx.expr_usize(trait_span, 0), |acc, ref item| {
- if item.attrs.iter()
- .find(|ref a| {
- if a.check_name("ignore_heap_size_of") {
- match a.node.value.node {
- MetaNameValue(..) => (),
- _ => cx.span_err(a.span, "#[ignore_heap_size_of] \
- should have an explanation, \
- e.g. #[ignore_heap_size_of = \"\"]")
- }
- true
- } else {
- false
- }
- })
- .is_some() {
- acc
- } else {
- cx.expr_binary(item.span, BiAdd, acc,
- cx.expr_method_call(item.span,
- item.self_.clone(),
- substr.method_ident,
- Vec::new()))
- }
- })
-}
diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs
index b1d701e6aec..25181f2197c 100644
--- a/components/plugins/lib.rs
+++ b/components/plugins/lib.rs
@@ -36,8 +36,6 @@ use syntax::parse::token::intern;
// Public for documentation to show up
/// Handles the auto-deriving for `#[derive(JSTraceable)]`
pub mod jstraceable;
-/// Handles the auto-deriving for `#[derive(HeapSizeOf)]`
-pub mod heap_size;
pub mod lints;
/// Autogenerates implementations of Reflectable on DOM structs
pub mod reflector;
@@ -51,7 +49,6 @@ pub fn plugin_registrar(reg: &mut Registry) {
reg.register_syntax_extension(intern("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct));
reg.register_syntax_extension(intern("derive_JSTraceable"), MultiDecorator(box jstraceable::expand_jstraceable));
reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector));
- reg.register_syntax_extension(intern("derive_HeapSizeOf"), MultiDecorator(box heap_size::expand_heap_size));
reg.register_macro("to_lower", casing::expand_lower);
reg.register_macro("to_upper", casing::expand_upper);
reg.register_macro("url", url_plugin::expand_url);
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml
index 1f69a70d964..b06ae8e8e48 100644
--- a/components/script/Cargo.toml
+++ b/components/script/Cargo.toml
@@ -66,11 +66,13 @@ path = "../gfx_traits"
app_units = {version = "0.2", features = ["plugins"]}
bitflags = "0.3"
caseless = "0.1.0"
-cssparser = {version = "0.5.2", features = ["serde-serialization"]}
+cssparser = {version = "0.5.2", features = ["heap_size", "serde-serialization"]}
encoding = "0.2"
euclid = {version = "0.6.1", features = ["plugins"]}
fnv = "1.0"
-html5ever = {version = "0.4.2", features = ["unstable"]}
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
+html5ever = {version = "0.4.2", features = ["heap_size", "unstable"]}
hyper = { version = "0.7", features = [ "serde-serialization" ] }
image = "0.5.0"
libc = "0.2"
@@ -79,12 +81,12 @@ num = "0.1.24"
rand = "0.3"
ref_slice = "0.1.0"
rustc-serialize = "0.3"
-selectors = "0.4.1"
+selectors = {version = "0.4.1", features = ["heap_size"]}
serde = "0.6"
smallvec = "0.1"
-string_cache = {version = "0.2.7", features = ["unstable"]}
+string_cache = {version = "0.2.7", features = ["heap_size", "unstable"]}
time = "0.1.12"
unicase = "1.0"
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
uuid = "0.1.16"
websocket = "0.14.0"
diff --git a/components/script/cors.rs b/components/script/cors.rs
index 7bf5127a22e..e64583e0a58 100644
--- a/components/script/cors.rs
+++ b/components/script/cors.rs
@@ -27,7 +27,6 @@ use std::sync::{Arc, Mutex};
use time::{self, Timespec, now};
use unicase::UniCase;
use url::{SchemeData, Url};
-use util::mem::HeapSizeOf;
use util::thread::spawn_named;
/// Interface for network listeners concerned with CORS checks. Proper network requests
@@ -41,6 +40,7 @@ pub struct CORSRequest {
pub origin: Url,
pub destination: Url,
pub mode: RequestMode,
+ #[ignore_heap_size_of = "Defined in hyper"]
pub method: Method,
#[ignore_heap_size_of = "Defined in hyper"]
pub headers: Headers,
diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs
index 95f22e693e5..dafd14f58c9 100644
--- a/components/script/dom/bindings/error.rs
+++ b/components/script/dom/bindings/error.rs
@@ -14,7 +14,6 @@ use js::jsapi::{JSContext, JSObject, RootedValue};
use js::jsapi::{JS_IsExceptionPending, JS_ReportPendingException, JS_SetPendingException};
use js::jsapi::{JS_RestoreFrameChain, JS_SaveFrameChain};
use js::jsval::UndefinedValue;
-use util::mem::HeapSizeOf;
/// DOM exceptions that can be thrown by a native DOM method.
#[derive(Debug, Clone, HeapSizeOf)]
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs
index 6abf5f9b4e5..37d673f3c26 100644
--- a/components/script/dom/bindings/js.rs
+++ b/components/script/dom/bindings/js.rs
@@ -30,6 +30,7 @@ use dom::bindings::reflector::{Reflectable, Reflector};
use dom::bindings::trace::JSTraceable;
use dom::bindings::trace::trace_reflector;
use dom::node::Node;
+use heapsize::HeapSizeOf;
use js::jsapi::{Heap, JSObject, JSTracer};
use js::jsval::JSVal;
use layout_interface::TrustedNodeAddress;
@@ -40,7 +41,6 @@ use std::hash::{Hash, Hasher};
use std::mem;
use std::ops::Deref;
use std::ptr;
-use util::mem::HeapSizeOf;
use util::thread_state;
/// A traced reference to a DOM object
diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs
index df69bc77fd0..26c8568eadf 100644
--- a/components/script/dom/bindings/str.rs
+++ b/components/script/dom/bindings/str.rs
@@ -10,7 +10,6 @@ use std::hash::{Hash, Hasher};
use std::ops;
use std::str;
use std::str::FromStr;
-use util::mem::HeapSizeOf;
use util::str::is_token;
/// Encapsulates the IDL `ByteString` type.
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs
index d34d8f3f9f4..83e7a2e4cb2 100644
--- a/components/script/dom/bindings/utils.rs
+++ b/components/script/dom/bindings/utils.rs
@@ -13,6 +13,7 @@ use dom::bindings::inheritance::TopTypeId;
use dom::bindings::trace::trace_object;
use dom::browsingcontext;
use dom::window;
+use heapsize::HeapSizeOf;
use js;
use js::error::throw_type_error;
use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
@@ -36,7 +37,6 @@ use libc::{self, c_uint};
use std::default::Default;
use std::ffi::CString;
use std::ptr;
-use util::mem::HeapSizeOf;
use util::non_geckolib::jsstring_to_str;
/// Proxy handler for a WindowProxy.
diff --git a/components/script/dom/bindings/weakref.rs b/components/script/dom/bindings/weakref.rs
index e311d4a40bb..99adb8a0c02 100644
--- a/components/script/dom/bindings/weakref.rs
+++ b/components/script/dom/bindings/weakref.rs
@@ -15,6 +15,7 @@ use core::nonzero::NonZero;
use dom::bindings::js::Root;
use dom::bindings::reflector::Reflectable;
use dom::bindings::trace::JSTraceable;
+use heapsize::HeapSizeOf;
use js::jsapi::{JSTracer, JS_GetReservedSlot, JS_SetReservedSlot};
use js::jsval::PrivateValue;
use libc::c_void;
@@ -22,7 +23,6 @@ use std::cell::{Cell, UnsafeCell};
use std::iter::Iterator;
use std::mem;
use std::ops::{Deref, DerefMut, Drop};
-use util::mem::HeapSizeOf;
/// The index of the slot wherein a pointer to the weak holder cell is
/// stored for weak-referenceable bindings. We use slot 1 for holding it,
diff --git a/components/script/dom/crypto.rs b/components/script/dom/crypto.rs
index b8c595f3aa4..6e0351d37ee 100644
--- a/components/script/dom/crypto.rs
+++ b/components/script/dom/crypto.rs
@@ -20,6 +20,7 @@ no_jsmanaged_fields!(OsRng);
#[dom_struct]
pub struct Crypto {
reflector_: Reflector,
+ #[ignore_heap_size_of = "Defined in rand"]
rng: DOMRefCell<OsRng>,
}
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index d093380b008..3cdf3f6ba43 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -84,7 +84,6 @@ use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_sty
use style::selector_impl::{NonTSPseudoClass, ServoSelectorImpl};
use style::values::CSSFloat;
use style::values::specified::{self, CSSColor, CSSRGBA, LengthOrPercentage};
-use util::mem::HeapSizeOf;
use util::str::{DOMString, LengthOrPercentageOrAuto};
// TODO: Update focus state when the top-level browsing context gains or loses system focus,
diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs
index 48682ec2211..2cf9517d606 100644
--- a/components/script/dom/eventtarget.rs
+++ b/components/script/dom/eventtarget.rs
@@ -21,6 +21,7 @@ use dom::eventdispatcher::dispatch_event;
use dom::virtualmethods::VirtualMethods;
use dom::window::Window;
use fnv::FnvHasher;
+use heapsize::HeapSizeOf;
use js::jsapi::{CompileFunction, JS_GetFunctionObject, RootedValue};
use js::jsapi::{HandleObject, JSContext, RootedFunction};
use js::jsapi::{JSAutoCompartment, JSAutoRequest};
@@ -35,7 +36,6 @@ use std::rc::Rc;
use std::{intrinsics, ptr};
use string_cache::Atom;
use url::Url;
-use util::mem::HeapSizeOf;
use util::str::DOMString;
#[derive(PartialEq, Clone, JSTraceable)]
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 60046ff26b7..a50aad1a78e 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -46,6 +46,7 @@ use dom::text::Text;
use dom::virtualmethods::{VirtualMethods, vtable_for};
use dom::window::Window;
use euclid::rect::Rect;
+use heapsize::{HeapSizeOf, heap_size_of};
use js::jsapi::{JSContext, JSObject, JSRuntime};
use layout_interface::{LayoutChan, Msg};
use libc::{self, c_void, uintptr_t};
@@ -63,7 +64,6 @@ use std::iter::{self, FilterMap, Peekable};
use std::mem;
use string_cache::{Atom, Namespace, QualName};
use style::selector_impl::ServoSelectorImpl;
-use util::mem::{HeapSizeOf, heap_size_of};
use util::str::DOMString;
use util::thread_state;
use uuid::Uuid;
diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs
index 03db51ba0d8..6807a7a2d3c 100644
--- a/components/script/dom/range.rs
+++ b/components/script/dom/range.rs
@@ -23,10 +23,10 @@ use dom::document::Document;
use dom::documentfragment::DocumentFragment;
use dom::node::{Node, UnbindContext};
use dom::text::Text;
+use heapsize::HeapSizeOf;
use js::jsapi::JSTracer;
use std::cell::{Cell, UnsafeCell};
use std::cmp::{Ord, Ordering, PartialEq, PartialOrd};
-use util::mem::HeapSizeOf;
use util::str::DOMString;
#[dom_struct]
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index e6b7374ef39..59feddfcc22 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -62,7 +62,6 @@ use string_cache::Atom;
use time;
use timers::{ScheduledCallback, TimerHandle};
use url::Url;
-use util::mem::HeapSizeOf;
use util::str::DOMString;
pub type SendParam = BlobOrStringOrURLSearchParams;
@@ -127,11 +126,13 @@ pub struct XMLHttpRequest {
response_xml: MutNullableHeap<JS<Document>>,
#[ignore_heap_size_of = "Defined in hyper"]
response_headers: DOMRefCell<Headers>,
+ #[ignore_heap_size_of = "Defined in hyper"]
override_mime_type: DOMRefCell<Option<Mime>>,
#[ignore_heap_size_of = "Defined in rust-encoding"]
override_charset: DOMRefCell<Option<EncodingRef>>,
// Associated concepts
+ #[ignore_heap_size_of = "Defined in hyper"]
request_method: DOMRefCell<Method>,
request_url: DOMRefCell<Option<Url>>,
#[ignore_heap_size_of = "Defined in hyper"]
diff --git a/components/script/lib.rs b/components/script/lib.rs
index 6365c03c5b7..b857a00e122 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -26,6 +26,7 @@
#![doc = "The script crate contains all matters DOM."]
+#![plugin(heapsize_plugin)]
#![plugin(plugins)]
extern crate angle;
@@ -42,6 +43,7 @@ extern crate encoding;
extern crate euclid;
extern crate fnv;
extern crate gfx_traits;
+extern crate heapsize;
extern crate html5ever;
extern crate hyper;
extern crate image;
diff --git a/components/script/mem.rs b/components/script/mem.rs
index 113f03b8396..e276b1a5c3d 100644
--- a/components/script/mem.rs
+++ b/components/script/mem.rs
@@ -6,8 +6,8 @@
use dom::bindings::conversions::get_dom_class;
use dom::bindings::reflector::Reflectable;
+use heapsize::{HeapSizeOf, heap_size_of};
use libc::c_void;
-use util::mem::{HeapSizeOf, heap_size_of};
// This is equivalent to measuring a Box<T>, except that DOM objects lose their
// associated box in order to stash their pointers in a reserved slot of their
diff --git a/components/script/textinput.rs b/components/script/textinput.rs
index 5d533f0e419..02fb79e04a8 100644
--- a/components/script/textinput.rs
+++ b/components/script/textinput.rs
@@ -12,7 +12,6 @@ use std::borrow::ToOwned;
use std::cmp::{max, min};
use std::default::Default;
use std::usize;
-use util::mem::HeapSizeOf;
use util::str::DOMString;
#[derive(Copy, Clone, PartialEq)]
diff --git a/components/script/timers.rs b/components/script/timers.rs
index 7f608f98f46..1c1157d30ae 100644
--- a/components/script/timers.rs
+++ b/components/script/timers.rs
@@ -9,6 +9,7 @@ use dom::bindings::reflector::Reflectable;
use dom::bindings::trace::JSTraceable;
use dom::window::ScriptHelpers;
use euclid::length::Length;
+use heapsize::HeapSizeOf;
use ipc_channel::ipc::IpcSender;
use js::jsapi::{HandleValue, Heap, RootedValue};
use js::jsval::{JSVal, UndefinedValue};
@@ -19,7 +20,6 @@ use std::cell::Cell;
use std::cmp::{self, Ord, Ordering};
use std::default::Default;
use std::rc::Rc;
-use util::mem::HeapSizeOf;
use util::str::DOMString;
#[derive(JSTraceable, PartialEq, Eq, Copy, Clone, HeapSizeOf, Hash, PartialOrd, Ord, Debug)]
diff --git a/components/script_traits/Cargo.toml b/components/script_traits/Cargo.toml
index 12d68a325f7..8644762b7db 100644
--- a/components/script_traits/Cargo.toml
+++ b/components/script_traits/Cargo.toml
@@ -43,8 +43,10 @@ git = "https://github.com/servo/ipc-channel"
[dependencies]
app_units = {version = "0.2", features = ["plugins"]}
euclid = {version = "0.6.1", features = ["plugins"]}
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
libc = "0.2"
serde = "0.6"
serde_macros = "0.6"
time = "0.1.12"
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index 9229c626ab6..83761f20090 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -7,7 +7,7 @@
//! to depend on script.
#![feature(custom_derive, plugin)]
-#![plugin(plugins, serde_macros)]
+#![plugin(heapsize_plugin, plugins, serde_macros)]
#![deny(missing_docs)]
extern crate app_units;
@@ -15,6 +15,7 @@ extern crate canvas_traits;
extern crate devtools_traits;
extern crate euclid;
extern crate gfx_traits;
+extern crate heapsize;
extern crate ipc_channel;
extern crate libc;
extern crate msg;
@@ -50,7 +51,6 @@ use profile_traits::mem;
use std::any::Any;
use url::Url;
use util::ipc::OptionalOpaqueIpcSender;
-use util::mem::HeapSizeOf;
pub use script_msg::{LayoutMsg, ScriptMsg};
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 8c76ef7a896..344250b75b1 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -168,6 +168,8 @@ dependencies = [
"cssparser 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)",
"layers 0.2.1 (git+https://github.com/servo/rust-layers)",
"offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)",
@@ -334,6 +336,8 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -374,6 +378,8 @@ name = "devtools_traits"
version = "0.0.1"
dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)",
"msg 0.0.1",
@@ -630,6 +636,8 @@ dependencies = [
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype)",
"gfx_traits 0.0.1",
"harfbuzz-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)",
"layers 0.2.1 (git+https://github.com/servo/rust-layers)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -671,6 +679,8 @@ version = "0.0.1"
dependencies = [
"azure 0.4.0 (git+https://github.com/servo/rust-azure)",
"euclid 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"layers 0.2.1 (git+https://github.com/servo/rust-layers)",
"msg 0.0.1",
"plugins 0.0.1",
@@ -804,6 +814,8 @@ name = "html5ever"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"phf 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -964,6 +976,8 @@ dependencies = [
"fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx 0.0.1",
"gfx_traits 0.0.1",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)",
"layout_traits 0.0.1",
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1152,6 +1166,8 @@ dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)",
"layers 0.2.1 (git+https://github.com/servo/rust-layers)",
@@ -1222,6 +1238,8 @@ dependencies = [
name = "net_traits"
version = "0.0.1"
dependencies = [
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)",
@@ -1530,6 +1548,8 @@ dependencies = [
"euclid 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"html5ever 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1579,6 +1599,8 @@ dependencies = [
"devtools_traits 0.0.1",
"euclid 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)",
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
@@ -1602,6 +1624,8 @@ dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"quickersort 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1777,6 +1801,8 @@ version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"debug_unreachable 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_generator 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_shared 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1793,6 +1819,8 @@ dependencies = [
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1833,6 +1861,8 @@ version = "0.0.1"
dependencies = [
"cssparser 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1947,6 +1977,8 @@ version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1982,6 +2014,8 @@ dependencies = [
"cssparser 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"html5ever 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)",
diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml
index 21d767c93b0..b12bbb2312d 100644
--- a/components/servo/Cargo.toml
+++ b/components/servo/Cargo.toml
@@ -161,4 +161,4 @@ bitflags = "0.3"
env_logger = "0.3"
euclid = {version = "0.6.1", features = ["plugins"]}
libc = "0.2"
-url = {version = "0.5.4", features = ["serde_serialization", "query_encoding"]}
+url = {version = "0.5.4", features = ["heap_size", "serde_serialization", "query_encoding"]}
diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml
index 71e515c6d19..85a300d17d6 100644
--- a/components/style/Cargo.toml
+++ b/components/style/Cargo.toml
@@ -20,21 +20,23 @@ path = "../style_traits"
[dependencies]
app_units = {version = "0.2", features = ["plugins"]}
-cssparser = {version = "0.5.2", features = ["serde-serialization"]}
+cssparser = {version = "0.5.2", features = ["heap_size", "serde-serialization"]}
log = "0.3"
encoding = "0.2"
fnv = "1.0"
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
rustc-serialize = "0.3"
matches = "0.1"
bitflags = "0.3"
num = "0.1.24"
lazy_static = "0.1.10"
-selectors = { version = "0.4.1", features = ["unstable"] }
+selectors = {version = "0.4.1", features = ["heap_size", "unstable"]}
smallvec = "0.1"
-string_cache = "0.2.7"
+string_cache = {version = "0.2.7", features = ["heap_size"]}
euclid = {version = "0.6.1", features = ["plugins"]}
serde = "0.6"
serde_macros = "0.6"
time = "0.1"
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs
index af9a2c4e7da..26fc794afb3 100644
--- a/components/style/custom_properties.rs
+++ b/components/style/custom_properties.rs
@@ -10,7 +10,6 @@ use std::collections::{HashMap, HashSet};
use std::fmt;
use std::sync::Arc;
use string_cache::Atom;
-use util::mem::HeapSizeOf;
// Does not include the `--` prefix
pub type Name = Atom;
diff --git a/components/style/font_face.rs b/components/style/font_face.rs
index d42e0feb3e9..0810afac5a8 100644
--- a/components/style/font_face.rs
+++ b/components/style/font_face.rs
@@ -8,7 +8,6 @@ use parser::{ParserContext, log_css_error};
use properties::longhands::font_family::parse_one_family;
use std::ascii::AsciiExt;
use url::Url;
-use util::mem::HeapSizeOf;
#[derive(Clone, Debug, HeapSizeOf, PartialEq, Eq, Deserialize, Serialize)]
pub enum Source {
diff --git a/components/style/lib.rs b/components/style/lib.rs
index dee1d51efc6..6dbb7250ffc 100644
--- a/components/style/lib.rs
+++ b/components/style/lib.rs
@@ -11,9 +11,9 @@
#![feature(custom_derive)]
#![feature(plugin)]
-#![plugin(serde_macros)]
-#![plugin(serde_macros)]
+#![plugin(heapsize_plugin)]
#![plugin(plugins)]
+#![plugin(serde_macros)]
#![recursion_limit = "500"] // For match_ignore_ascii_case in PropertyDeclaration::parse
@@ -26,6 +26,7 @@ extern crate cssparser;
extern crate encoding;
extern crate euclid;
extern crate fnv;
+extern crate heapsize;
#[macro_use]
extern crate lazy_static;
#[macro_use]
diff --git a/components/style/media_queries.rs b/components/style/media_queries.rs
index 82b02cc9701..b19b4d81c7e 100644
--- a/components/style/media_queries.rs
+++ b/components/style/media_queries.rs
@@ -8,7 +8,6 @@ use euclid::size::{Size2D, TypedSize2D};
use properties::longhands;
use std::ascii::AsciiExt;
use util::geometry::ViewportPx;
-use util::mem::HeapSizeOf;
use values::specified;
diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs
index ce21cf68522..bc4008040c2 100644
--- a/components/style/stylesheets.rs
+++ b/components/style/stylesheets.rs
@@ -19,7 +19,6 @@ use std::iter::Iterator;
use std::slice;
use string_cache::{Atom, Namespace};
use url::Url;
-use util::mem::HeapSizeOf;
use viewport::ViewportRule;
diff --git a/components/style/viewport.rs b/components/style/viewport.rs
index e46d22c19b1..f50a2a5fb2b 100644
--- a/components/style/viewport.rs
+++ b/components/style/viewport.rs
@@ -18,7 +18,6 @@ use std::str::Chars;
use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom};
use stylesheets::Origin;
use util::geometry::ViewportPx;
-use util::mem::HeapSizeOf;
use values::computed::{Context, ToComputedValue};
use values::specified::{Length, LengthOrPercentageOrAuto, ViewportPercentageLength};
diff --git a/components/style_traits/Cargo.toml b/components/style_traits/Cargo.toml
index bc937f1ae94..4d4ce440488 100644
--- a/components/style_traits/Cargo.toml
+++ b/components/style_traits/Cargo.toml
@@ -14,14 +14,15 @@ path = "../util"
path = "../plugins"
[dependencies]
-cssparser = {version = "0.5.2", features = ["serde-serialization"]}
+cssparser = {version = "0.5.2", features = ["heap_size", "serde-serialization"]}
euclid = {version = "0.6.1", features = ["plugins"]}
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
lazy_static = "0.1.10"
log = "0.3"
num = "0.1.24"
rustc-serialize = "0.3"
-selectors = "0.4.1"
+selectors = {version = "0.4.1", features = ["heap_size"]}
serde = "0.6"
serde_macros = "0.6"
-url = "0.5.4"
-
+url = {version = "0.5.4", features = ["heap_size"]}
diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs
index 5a56874514d..9e65308207e 100644
--- a/components/style_traits/lib.rs
+++ b/components/style_traits/lib.rs
@@ -10,6 +10,7 @@
#![crate_type = "rlib"]
#![feature(custom_derive)]
#![feature(plugin)]
+#![plugin(heapsize_plugin)]
#![plugin(serde_macros)]
#![plugin(plugins)]
#![deny(unsafe_code)]
@@ -17,6 +18,7 @@
#[macro_use]
extern crate cssparser;
extern crate euclid;
+extern crate heapsize;
extern crate rustc_serialize;
extern crate serde;
extern crate util;
diff --git a/components/util/Cargo.toml b/components/util/Cargo.toml
index fcfe70db12c..6d5ef0714a8 100644
--- a/components/util/Cargo.toml
+++ b/components/util/Cargo.toml
@@ -47,10 +47,12 @@ git = "https://github.com/servo/ipc-channel"
[dependencies]
app_units = {version = "0.2", features = ["plugins"]}
bitflags = "0.3"
-cssparser = {version = "0.5.2", features = ["serde-serialization"]}
+cssparser = {version = "0.5.2", features = ["heap_size", "serde-serialization"]}
euclid = {version = "0.6.1", features = ["unstable", "plugins"]}
getopts = "0.2.11"
-html5ever = {version = "0.4.2", features = ["unstable"], optional = true}
+html5ever = {version = "0.4.2", features = ["heap_size", "unstable"], optional = true}
+heapsize = "0.2.5"
+heapsize_plugin = "0.1.2"
hyper = { version = "0.7", optional = true }
lazy_static = "0.1"
libc = "0.2"
@@ -59,12 +61,12 @@ num = "0.1.24"
num_cpus = "0.2.2"
rand = "0.3"
rustc-serialize = "0.3"
-selectors = "0.4.1"
+selectors = {version = "0.4.1", features = ["heap_size"]}
serde = "0.6"
serde_macros = "0.6"
smallvec = "0.1"
-string_cache = "0.2.7"
-url = {version = "0.5.4", features = ["serde_serialization"]}
+string_cache = {version = "0.2.7", features = ["heap_size"]}
+url = {version = "0.5.4", features = ["heap_size", "serde_serialization"]}
uuid = "0.1.17"
[target.x86_64-pc-windows-gnu.dependencies]
diff --git a/components/util/cursor.rs b/components/util/cursor.rs
index fa7ceb413c6..7f139fd498e 100644
--- a/components/util/cursor.rs
+++ b/components/util/cursor.rs
@@ -9,7 +9,7 @@ use std::ascii::AsciiExt;
macro_rules! define_cursor {
($( $css: expr => $variant: ident = $value: expr, )+) => {
- #[derive(Clone, Copy, PartialEq, Eq, Debug, Deserialize, Serialize)]
+ #[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, PartialEq, Serialize)]
#[repr(u8)]
pub enum Cursor {
$( $variant = $value ),+
diff --git a/components/util/geometry.rs b/components/util/geometry.rs
index 4af85d703c9..813cad3aa3d 100644
--- a/components/util/geometry.rs
+++ b/components/util/geometry.rs
@@ -23,7 +23,7 @@ use std::i32;
///
/// The ratio between ScreenPx and DevicePixel for a given display be found by calling
/// `servo::windowing::WindowMethods::hidpi_factor`.
-#[derive(Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug, HeapSizeOf)]
pub enum ScreenPx {}
/// One CSS "px" in the coordinate system of the "initial viewport":
@@ -35,7 +35,7 @@ pub enum ScreenPx {}
///
/// At the default zoom level of 100%, one PagePx is equal to one ScreenPx. However, if the
/// document is zoomed in or out then this scale may be larger or smaller.
-#[derive(RustcEncodable, Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug, HeapSizeOf)]
pub enum ViewportPx {}
/// One CSS "px" in the root coordinate system for the content document.
@@ -44,7 +44,7 @@ pub enum ViewportPx {}
/// This is the mobile-style "pinch zoom" that enlarges content without reflowing it. When the
/// viewport zoom is not equal to 1.0, then the layout viewport is no longer the same physical size
/// as the viewable area.
-#[derive(RustcEncodable, Debug, Copy, Clone)]
+#[derive(Clone, Copy, Debug, HeapSizeOf)]
pub enum PagePx {}
// In summary, the hierarchy of pixel units and the factors to convert from one to the next:
diff --git a/components/util/lib.rs b/components/util/lib.rs
index 660945d4c1a..61d99cb5a02 100644
--- a/components/util/lib.rs
+++ b/components/util/lib.rs
@@ -18,7 +18,7 @@
#![feature(step_trait)]
#![feature(zero_one)]
-#![plugin(plugins, serde_macros)]
+#![plugin(heapsize_plugin, plugins, serde_macros)]
extern crate alloc;
extern crate app_units;
@@ -30,6 +30,7 @@ extern crate bitflags;
extern crate cssparser;
extern crate euclid;
extern crate getopts;
+extern crate heapsize;
#[cfg(feature = "non-geckolib")]
extern crate html5ever;
#[cfg(feature = "non-geckolib")]
@@ -66,7 +67,6 @@ pub mod geometry;
pub mod ipc;
pub mod linked_list;
pub mod logical_geometry;
-#[macro_use] pub mod mem;
#[cfg(feature = "non-geckolib")]
pub mod non_geckolib;
pub mod opts;
diff --git a/components/util/logical_geometry.rs b/components/util/logical_geometry.rs
index 0c4372ce7f2..661ef0c6a65 100644
--- a/components/util/logical_geometry.rs
+++ b/components/util/logical_geometry.rs
@@ -11,7 +11,7 @@ use std::fmt::{self, Debug, Error, Formatter};
use std::ops::{Add, Sub};
bitflags!(
- #[derive(RustcEncodable)]
+ #[derive(HeapSizeOf, RustcEncodable)]
flags WritingMode: u8 {
const FLAG_RTL = 1 << 0,
const FLAG_VERTICAL = 1 << 1,
diff --git a/components/util/mem.rs b/components/util/mem.rs
deleted file mode 100644
index b5654b24123..00000000000
--- a/components/util/mem.rs
+++ /dev/null
@@ -1,360 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-//! Data structure measurement.
-
-use app_units::Au;
-use cssparser::Color as CSSParserColor;
-use cssparser::{RGBA, TokenSerializationType};
-use cursor::Cursor;
-use euclid::length::Length;
-use euclid::scale_factor::ScaleFactor;
-use euclid::{Matrix2D, Matrix4, Point2D, Rect, SideOffsets2D, Size2D};
-use geometry::{PagePx, ViewportPx};
-use libc::{c_void, size_t};
-use logical_geometry::WritingMode;
-use rand::OsRng;
-use range::Range;
-use selectors::parser::{Combinator, CompoundSelector, Selector, SimpleSelector, SelectorImpl};
-use std::cell::{Cell, RefCell};
-use std::collections::{HashMap, LinkedList};
-use std::hash::{BuildHasher, Hash};
-use std::mem::{size_of, transmute};
-use std::rc::Rc;
-use std::result::Result;
-use std::sync::Arc;
-use std::sync::atomic::{AtomicIsize, AtomicUsize};
-use str::{DOMString, LengthOrPercentageOrAuto};
-use string_cache::atom::Atom;
-use string_cache::namespace::{QualName, Namespace};
-use url;
-use uuid::Uuid;
-
-extern {
- // Get the size of a heap block.
- //
- // Ideally Rust would expose a function like this in std::rt::heap, which would avoid the
- // jemalloc dependence.
- //
- // The C prototype is `je_malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *ptr)`. On some
- // platforms `JEMALLOC_USABLE_SIZE_CONST` is `const` and on some it is empty. But in practice
- // this function doesn't modify the contents of the block that `ptr` points to, so we use
- // `*const c_void` here.
- fn je_malloc_usable_size(ptr: *const c_void) -> size_t;
-}
-
-// A wrapper for je_malloc_usable_size that handles `EMPTY` and returns `usize`.
-pub fn heap_size_of(ptr: *const c_void) -> usize {
- if ptr == ::alloc::heap::EMPTY as *const c_void {
- 0
- } else {
- unsafe { je_malloc_usable_size(ptr) as usize }
- }
-}
-
-// The simplest trait for measuring the size of heap data structures. More complex traits that
-// return multiple measurements -- e.g. measure text separately from images -- are also possible,
-// and should be used when appropriate.
-//
-pub trait HeapSizeOf {
- /// Measure the size of any heap-allocated structures that hang off this value, but not the
- /// space taken up by the value itself (i.e. what size_of::<T> measures, more or less); that
- /// space is handled by the implementation of HeapSizeOf for Box<T> below.
- fn heap_size_of_children(&self) -> usize;
-}
-
-// There are two possible ways to measure the size of `self` when it's on the heap: compute it
-// (with `::std::rt::heap::usable_size(::std::mem::size_of::<T>(), 0)`) or measure it directly
-// using the heap allocator (with `heap_size_of`). We do the latter, for the following reasons.
-//
-// * The heap allocator is the true authority for the sizes of heap blocks; its measurement is
-// guaranteed to be correct. In comparison, size computations are error-prone. (For example, the
-// `rt::heap::usable_size` function used in some of Rust's non-default allocator implementations
-// underestimate the true usable size of heap blocks, which is safe in general but would cause
-// under-measurement here.)
-//
-// * If we measure something that isn't a heap block, we'll get a crash. This keeps us honest,
-// which is important because unsafe code is involved and this can be gotten wrong.
-//
-// However, in the best case, the two approaches should give the same results.
-//
-impl<T: HeapSizeOf> HeapSizeOf for Box<T> {
- fn heap_size_of_children(&self) -> usize {
- // Measure size of `self`.
- heap_size_of(&**self as *const T as *const c_void) + (**self).heap_size_of_children()
- }
-}
-
-impl HeapSizeOf for String {
- fn heap_size_of_children(&self) -> usize {
- heap_size_of(self.as_ptr() as *const c_void)
- }
-}
-
-impl HeapSizeOf for DOMString {
- fn heap_size_of_children(&self) -> usize {
- heap_size_of(self.as_ptr() as *const c_void)
- }
-}
-
-impl<T: HeapSizeOf> HeapSizeOf for Option<T> {
- fn heap_size_of_children(&self) -> usize {
- match *self {
- None => 0,
- Some(ref x) => x.heap_size_of_children()
- }
- }
-}
-
-impl HeapSizeOf for url::Url {
- fn heap_size_of_children(&self) -> usize {
- // Using a struct pattern without `..` rather than `foo.bar` field access
- // makes sure this will be updated if a field is added.
- let &url::Url { ref scheme, ref scheme_data, ref query, ref fragment } = self;
- scheme.heap_size_of_children() +
- scheme_data.heap_size_of_children() +
- query.heap_size_of_children() +
- fragment.heap_size_of_children()
- }
-}
-
-impl HeapSizeOf for url::SchemeData {
- fn heap_size_of_children(&self) -> usize {
- match *self {
- url::SchemeData::Relative(ref data) => data.heap_size_of_children(),
- url::SchemeData::NonRelative(ref str) => str.heap_size_of_children()
- }
- }
-}
-
-impl HeapSizeOf for url::RelativeSchemeData {
- fn heap_size_of_children(&self) -> usize {
- // Using a struct pattern without `..` rather than `foo.bar` field access
- // makes sure this will be updated if a field is added.
- let &url::RelativeSchemeData { ref username, ref password, ref host,
- ref port, ref default_port, ref path } = self;
- username.heap_size_of_children() +
- password.heap_size_of_children() +
- host.heap_size_of_children() +
- port.heap_size_of_children() +
- default_port.heap_size_of_children() +
- path.heap_size_of_children()
- }
-}
-
-impl HeapSizeOf for url::Host {
- fn heap_size_of_children(&self) -> usize {
- match *self {
- url::Host::Domain(ref str) => str.heap_size_of_children(),
- url::Host::Ipv6(_) => 0,
- url::Host::Ipv4(_) => 0,
- }
- }
-}
-
-impl<T: HeapSizeOf, U: HeapSizeOf> HeapSizeOf for (T, U) {
- fn heap_size_of_children(&self) -> usize {
- self.0.heap_size_of_children() + self.1.heap_size_of_children()
- }
-}
-
-impl<T: HeapSizeOf> HeapSizeOf for Arc<T> {
- fn heap_size_of_children(&self) -> usize {
- (**self).heap_size_of_children()
- }
-}
-
-impl<T: HeapSizeOf> HeapSizeOf for RefCell<T> {
- fn heap_size_of_children(&self) -> usize {
- self.borrow().heap_size_of_children()
- }
-}
-
-impl<T: HeapSizeOf + Copy> HeapSizeOf for Cell<T> {
- fn heap_size_of_children(&self) -> usize {
- self.get().heap_size_of_children()
- }
-}
-
-impl<T: HeapSizeOf> HeapSizeOf for Vec<T> {
- fn heap_size_of_children(&self) -> usize {
- heap_size_of(self.as_ptr() as *const c_void) +
- self.iter().fold(0, |n, elem| n + elem.heap_size_of_children())
- }
-}
-
-impl<T> HeapSizeOf for Vec<Rc<T>> {
- fn heap_size_of_children(&self) -> usize {
- // The fate of measuring Rc<T> is still undecided, but we still want to measure
- // the space used for storing them.
- heap_size_of(self.as_ptr() as *const c_void)
- }
-}
-
-impl<K: HeapSizeOf, V: HeapSizeOf, S> HeapSizeOf for HashMap<K, V, S>
- where K: Eq + Hash, S: BuildHasher {
- fn heap_size_of_children(&self) -> usize {
- //TODO(#6908) measure actual bucket memory usage instead of approximating
- let size = self.capacity() * (size_of::<V>() + size_of::<K>());
- self.iter().fold(size, |n, (key, value)| {
- n + key.heap_size_of_children() + value.heap_size_of_children()
- })
- }
-}
-
-// FIXME(njn): We can't implement HeapSizeOf accurately for LinkedList because it requires access
-// to the private Node type. Eventually we'll want to add HeapSizeOf (or equivalent) to Rust
-// itself. In the meantime, we use the dirty hack of transmuting LinkedList into an identical type
-// (LinkedList2) and measuring that.
-impl<T: HeapSizeOf> HeapSizeOf for LinkedList<T> {
- fn heap_size_of_children(&self) -> usize {
- let list2: &LinkedList2<T> = unsafe { transmute(self) };
- list2.heap_size_of_children()
- }
-}
-
-struct LinkedList2<T> {
- _length: usize,
- list_head: Link<T>,
- _list_tail: Rawlink<Node<T>>,
-}
-
-type Link<T> = Option<Box<Node<T>>>;
-
-struct Rawlink<T> {
- _p: *mut T,
-}
-
-struct Node<T> {
- next: Link<T>,
- _prev: Rawlink<Node<T>>,
- value: T,
-}
-
-impl<T: HeapSizeOf> HeapSizeOf for Node<T> {
- // Unlike most heap_size_of_children() functions, this one does *not* measure descendents.
- // Instead, LinkedList2<T>::heap_size_of_children() handles that, so that it can use iteration
- // instead of recursion, which avoids potentially blowing the stack.
- fn heap_size_of_children(&self) -> usize {
- self.value.heap_size_of_children()
- }
-}
-
-impl<T: HeapSizeOf> HeapSizeOf for LinkedList2<T> {
- fn heap_size_of_children(&self) -> usize {
- let mut size = 0;
- let mut curr: &Link<T> = &self.list_head;
- while curr.is_some() {
- size += (*curr).heap_size_of_children();
- curr = &curr.as_ref().unwrap().next;
- }
- size
- }
-}
-
-// This is a basic sanity check. If the representation of LinkedList changes such that it becomes a
-// different size to LinkedList2, this will fail at compile-time.
-#[allow(dead_code)]
-unsafe fn linked_list2_check() {
- transmute::<LinkedList<i32>, LinkedList2<i32>>(panic!());
-}
-
-// Currently, types that implement the Drop type are larger than those that don't. Because
-// LinkedList implements Drop, LinkedList2 must also so that linked_list2_check() doesn't fail.
-impl<T> Drop for LinkedList2<T> {
- fn drop(&mut self) {}
-}
-
-/// For use on types defined in external crates
-/// with known heap sizes.
-#[macro_export]
-macro_rules! known_heap_size(
- ($size:expr, $($ty:ident),+) => (
- $(
- impl $crate::mem::HeapSizeOf for $ty {
- #[inline(always)]
- fn heap_size_of_children(&self) -> usize {
- $size
- }
- }
- )+
- );
- ($size: expr, $($ty:ident<$($gen:ident),+>),+) => (
- $(
- impl<$($gen: $crate::mem::HeapSizeOf),+> $crate::mem::HeapSizeOf for $ty<$($gen),+> {
- #[inline(always)]
- fn heap_size_of_children(&self) -> usize {
- $size
- }
- }
- )+
- );
-);
-
-impl<T: HeapSizeOf, U: HeapSizeOf> HeapSizeOf for Result<T, U> {
- fn heap_size_of_children(&self) -> usize {
- match *self {
- Result::Ok(ref ok) => ok.heap_size_of_children(),
- Result::Err(ref err) => err.heap_size_of_children()
- }
- }
-}
-
-impl HeapSizeOf for () {
- fn heap_size_of_children(&self) -> usize {
- 0
- }
-}
-
-impl<T: SelectorImpl> HeapSizeOf for Selector<T>
- where T::NonTSPseudoClass: HeapSizeOf,
- T::PseudoElement: HeapSizeOf {
- fn heap_size_of_children(&self) -> usize {
- let &Selector { ref compound_selectors, ref pseudo_element, ref specificity } = self;
- compound_selectors.heap_size_of_children() + pseudo_element.heap_size_of_children() +
- specificity.heap_size_of_children()
- }
-}
-
-impl<T: SelectorImpl> HeapSizeOf for CompoundSelector<T>
- where T::NonTSPseudoClass: HeapSizeOf {
- fn heap_size_of_children(&self) -> usize {
- let &CompoundSelector { ref simple_selectors, ref next } = self;
- simple_selectors.heap_size_of_children() + next.heap_size_of_children()
- }
-}
-
-impl<T: SelectorImpl> HeapSizeOf for SimpleSelector<T>
- where T::NonTSPseudoClass: HeapSizeOf {
- fn heap_size_of_children(&self) -> usize {
- match *self {
- SimpleSelector::Negation(ref vec) => vec.heap_size_of_children(),
- SimpleSelector::AttrIncludes(_, ref str) | SimpleSelector::AttrPrefixMatch(_, ref str) |
- SimpleSelector::AttrSubstringMatch(_, ref str) | SimpleSelector::AttrSuffixMatch(_, ref str)
- => str.heap_size_of_children(),
- SimpleSelector::AttrEqual(_, ref str, _) => str.heap_size_of_children(),
- SimpleSelector::AttrDashMatch(_, ref first, ref second)
- => first.heap_size_of_children() + second.heap_size_of_children(),
- SimpleSelector::NonTSPseudoClass(ref pseudo_class)
- => pseudo_class.heap_size_of_children(),
- // All other types come down to Atom, enum or i32, all 0
- _ => 0
- }
- }
-}
-
-known_heap_size!(0, u8, u16, u32, u64, usize);
-known_heap_size!(0, i8, i16, i32, i64, isize);
-known_heap_size!(0, bool, f32, f64);
-known_heap_size!(0, AtomicIsize, AtomicUsize);
-
-known_heap_size!(0, Rect<T>, Point2D<T>, Size2D<T>, Matrix2D<T>, SideOffsets2D<T>, Range<T>);
-known_heap_size!(0, Length<T, U>, ScaleFactor<T, U, V>);
-
-known_heap_size!(0, Au, WritingMode, CSSParserColor, RGBA, Cursor, Matrix4, QualName, Atom, Namespace);
-known_heap_size!(0, PagePx, ViewportPx, OsRng);
-known_heap_size!(0, TokenSerializationType, LengthOrPercentageOrAuto);
-
-known_heap_size!(0, Combinator, str);
-known_heap_size!(0, Uuid);
diff --git a/components/util/non_geckolib.rs b/components/util/non_geckolib.rs
index cb047a0ec18..ff09ca5c983 100644
--- a/components/util/non_geckolib.rs
+++ b/components/util/non_geckolib.rs
@@ -4,20 +4,10 @@
///! Miscellaneous Code which depends on large libraries that we don't
/// depend on in GeckoLib builds.
-
-use azure::azure_hl::Color;
-use html5ever::tree_builder::QuirksMode;
-use hyper::header::ContentType;
-use hyper::http::RawStatus;
-use hyper::method::Method;
-use hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value};
use js::conversions::{FromJSValConvertible, ToJSValConvertible, latin1_to_string};
-use js::jsapi::{JSContext, JSString, HandleValue, Heap, MutableHandleValue};
+use js::jsapi::{JSContext, JSString, HandleValue, MutableHandleValue};
use js::jsapi::{JS_GetTwoByteStringCharsAndLength, JS_StringHasLatin1Chars};
-use js::jsval::JSVal;
-use js::rust::{GCMethods, ToString};
-use layers::geometry::DevicePixel;
-use mem::HeapSizeOf;
+use js::rust::ToString;
use opts;
use std::char;
use std::ptr;
@@ -99,73 +89,3 @@ pub unsafe fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString
s
})
}
-
-// This is measured properly by the heap measurement implemented in SpiderMonkey.
-impl<T: Copy + GCMethods<T>> HeapSizeOf for Heap<T> {
- fn heap_size_of_children(&self) -> usize {
- 0
- }
-}
-
-impl HeapSizeOf for ContentType {
- fn heap_size_of_children(&self) -> usize {
- let &ContentType(ref mime) = self;
- mime.heap_size_of_children()
- }
-}
-
-impl HeapSizeOf for Method {
- fn heap_size_of_children(&self) -> usize {
- match *self {
- Method::Extension(ref str) => str.heap_size_of_children(),
- _ => 0
- }
- }
-}
-
-impl HeapSizeOf for Mime {
- fn heap_size_of_children(&self) -> usize {
- let &Mime(ref top_level, ref sub_level, ref vec) = self;
- top_level.heap_size_of_children() + sub_level.heap_size_of_children() +
- vec.heap_size_of_children()
- }
-}
-
-impl HeapSizeOf for TopLevel {
- fn heap_size_of_children(&self) -> usize {
- match *self {
- TopLevel::Ext(ref str) => str.heap_size_of_children(),
- _ => 0
- }
- }
-}
-
-impl HeapSizeOf for SubLevel {
- fn heap_size_of_children(&self) -> usize {
- match *self {
- SubLevel::Ext(ref str) => str.heap_size_of_children(),
- _ => 0
- }
- }
-}
-
-impl HeapSizeOf for Attr {
- fn heap_size_of_children(&self) -> usize {
- match *self {
- Attr::Ext(ref str) => str.heap_size_of_children(),
- _ => 0
- }
- }
-}
-
-impl HeapSizeOf for Value {
- fn heap_size_of_children(&self) -> usize {
- match *self {
- Value::Ext(ref str) => str.heap_size_of_children(),
- _ => 0
- }
- }
-}
-
-
-known_heap_size!(0, Color, DevicePixel, JSVal, QuirksMode, RawStatus);
diff --git a/components/util/range.rs b/components/util/range.rs
index 07e66b28a6f..8149a1f424c 100644
--- a/components/util/range.rs
+++ b/components/util/range.rs
@@ -136,7 +136,7 @@ macro_rules! int_range_index {
}
/// A range of indices
-#[derive(Clone, RustcEncodable, Copy, Deserialize, Serialize)]
+#[derive(Clone, Copy, Deserialize, HeapSizeOf, RustcEncodable, Serialize)]
pub struct Range<I> {
begin: I,
length: I,
diff --git a/components/util/str.rs b/components/util/str.rs
index dc3b8df1762..8ffcf67b0e9 100644
--- a/components/util/str.rs
+++ b/components/util/str.rs
@@ -16,7 +16,7 @@ use std::iter::{Filter, Peekable};
use std::ops::{Deref, DerefMut};
use std::str::{Bytes, CharIndices, FromStr, Split, from_utf8};
-#[derive(Clone, PartialOrd, Ord, PartialEq, Eq, Deserialize, Serialize, Hash, Debug)]
+#[derive(Clone, Debug, Deserialize, Eq, Hash, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)]
pub struct DOMString(String);
impl !Send for DOMString {}
@@ -220,7 +220,7 @@ pub fn parse_unsigned_integer<T: Iterator<Item=char>>(input: T) -> Option<u32> {
})
}
-#[derive(Copy, Clone, Debug, PartialEq)]
+#[derive(Clone, Copy, Debug, HeapSizeOf, PartialEq)]
pub enum LengthOrPercentageOrAuto {
Auto,
Percentage(f32),
diff --git a/components/webdriver_server/Cargo.toml b/components/webdriver_server/Cargo.toml
index d489479bc61..20e4ff5c7a4 100644
--- a/components/webdriver_server/Cargo.toml
+++ b/components/webdriver_server/Cargo.toml
@@ -31,5 +31,5 @@ log = "0.3"
hyper = "0.7"
rustc-serialize = "0.3.4"
regex = "0.1.33"
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
uuid = "0.1"