diff --git a/Cargo.lock b/Cargo.lock index 65fa20485d0..11223a6fdf4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -327,10 +327,10 @@ version = "0.0.1" dependencies = [ "cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "nonzero 0.0.1", "offscreen_gl_context 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -580,7 +580,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "dtoa-short 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -714,11 +713,11 @@ name = "devtools_traits" version = "0.0.1" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "msg 0.0.1", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "servo_url 0.0.1", @@ -1099,12 +1098,12 @@ dependencies = [ "freetype 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "harfbuzz-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "msg 0.0.1", "net_traits 0.0.1", "ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1142,8 +1141,8 @@ dependencies = [ name = "gfx_traits" version = "0.0.1" dependencies = [ - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "range 0.0.1", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1244,7 +1243,6 @@ dependencies = [ name = "hashglobe" version = "0.1.0" dependencies = [ - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1257,16 +1255,6 @@ dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "heapsize_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "heartbeats-simple" version = "0.4.0" @@ -1514,11 +1502,11 @@ dependencies = [ "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "gfx_traits 0.0.1", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", "msg 0.0.1", "net_traits 0.0.1", "ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1562,7 +1550,6 @@ dependencies = [ "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.0.1", "gfx_traits 0.0.1", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "layout 0.0.1", @@ -1570,6 +1557,7 @@ dependencies = [ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", "metrics 0.0.1", "msg 0.0.1", "net_traits 0.0.1", @@ -1744,9 +1732,15 @@ dependencies = [ "cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", "hashglobe 0.1.0", + "js 0.1.6 (git+https://github.com/servo/rust-mozjs)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "servo_arc 0.0.1", "smallbitvec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "webrender_api 0.52.1 (git+https://github.com/servo/webrender)", + "xml5ever 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1763,8 +1757,6 @@ name = "markup5ever" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1914,8 +1906,8 @@ name = "msg" version = "0.0.1" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "nonzero 0.0.1", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "webrender_api 0.52.1 (git+https://github.com/servo/webrender)", @@ -2018,14 +2010,14 @@ name = "net_traits" version = "0.0.1" dependencies = [ "cookie 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "msg 0.0.1", "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2452,8 +2444,8 @@ dependencies = [ name = "range" version = "0.0.1" dependencies = [ - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2602,8 +2594,6 @@ dependencies = [ "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2614,6 +2604,8 @@ dependencies = [ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "metrics 0.0.1", "mime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2669,12 +2661,12 @@ dependencies = [ "cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "metrics 0.0.1", "msg 0.0.1", "net_traits 0.0.1", @@ -2715,12 +2707,12 @@ dependencies = [ "devtools_traits 0.0.1", "euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "msg 0.0.1", "net_traits 0.0.1", "profile_traits 0.0.1", @@ -2933,7 +2925,6 @@ dependencies = [ name = "servo_arc" version = "0.0.1" dependencies = [ - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "nodrop 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2979,7 +2970,8 @@ version = "0.0.1" dependencies = [ "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", ] [[package]] @@ -3011,8 +3003,8 @@ dependencies = [ name = "servo_url" version = "0.0.1" dependencies = [ - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of 0.0.1", + "malloc_size_of_derive 0.0.1", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "servo_rand 0.0.1", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3081,9 +3073,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "smallvec" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "stable_deref_trait" @@ -3096,7 +3085,6 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3143,8 +3131,6 @@ dependencies = [ "fallible 0.0.1", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "hashglobe 0.1.0", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3222,8 +3208,6 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.0.1", "selectors 0.19.0", @@ -3491,7 +3475,6 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3872,7 +3855,6 @@ dependencies = [ "checksum half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63d68db75012a85555434ee079e7e6337931f87a087ab2988becbadf64673a7f" "checksum harfbuzz-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "a2caaa66078fdfacea32db1351223697a1167ad2d4bbee6b8d4ca220ce5b10b3" "checksum heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c7593b1522161003928c959c20a2ca421c68e940d63d75573316a009e48a6d4" -"checksum heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "46f96d52fb1564059fc97b85ef6165728cc30198ab60073bf114c66c4c89bb5d" "checksum heartbeats-simple 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad003ce233955e9d95f2c69cde84e68302ba9ba4a673d351c9bff93c738aadc" "checksum heartbeats-simple-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e1a408c0011427cc0e0049f7861c70377819aedfc006e8c901b1c70fd98fb1a4" "checksum html5ever 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5bfb46978eb757a603b7dfe2dafb1c62cb4dee3428d8ac1de734d83d6b022d06" diff --git a/components/atoms/Cargo.toml b/components/atoms/Cargo.toml index ff149db72ab..5048cee3021 100644 --- a/components/atoms/Cargo.toml +++ b/components/atoms/Cargo.toml @@ -10,7 +10,7 @@ build = "build.rs" path = "lib.rs" [dependencies] -string_cache = {version = "0.6", features = ["heapsize"]} +string_cache = {version = "0.6"} [build-dependencies] string_cache_codegen = "0.4" diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml index 54db398a681..9e8be669ddf 100644 --- a/components/canvas_traits/Cargo.toml +++ b/components/canvas_traits/Cargo.toml @@ -12,10 +12,10 @@ path = "lib.rs" [dependencies] cssparser = "0.22.0" euclid = "0.15" -heapsize = "0.4" -heapsize_derive = "0.1" ipc-channel = "0.9" lazy_static = "0.2" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } nonzero = {path = "../nonzero"} offscreen_gl_context = { version = "0.11", features = ["serde"] } serde = "1.0" diff --git a/components/canvas_traits/canvas.rs b/components/canvas_traits/canvas.rs index 06194052b88..8600de36ebe 100644 --- a/components/canvas_traits/canvas.rs +++ b/components/canvas_traits/canvas.rs @@ -82,13 +82,13 @@ pub enum FromScriptMsg { SendPixels(IpcSender>>), } -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct CanvasGradientStop { pub offset: f64, pub color: RGBA, } -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct LinearGradientStyle { pub x0: f64, pub y0: f64, @@ -110,7 +110,7 @@ impl LinearGradientStyle { } } -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct RadialGradientStyle { pub x0: f64, pub y0: f64, @@ -165,7 +165,7 @@ pub enum FillOrStrokeStyle { Surface(SurfaceStyle), } -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum LineCapStyle { Butt = 0, Round = 1, @@ -185,7 +185,7 @@ impl FromStr for LineCapStyle { } } -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum LineJoinStyle { Round = 0, Bevel = 1, @@ -227,7 +227,7 @@ impl FromStr for RepetitionStyle { } } -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum CompositionStyle { SrcIn, SrcOut, @@ -281,7 +281,7 @@ impl CompositionStyle { } } -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum BlendingStyle { Multiply, Screen, @@ -347,7 +347,7 @@ impl BlendingStyle { } } -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum CompositionOrBlending { Composition(CompositionStyle), Blending(BlendingStyle), diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs index 4664a082fdd..f05a91f596a 100644 --- a/components/canvas_traits/lib.rs +++ b/components/canvas_traits/lib.rs @@ -9,10 +9,10 @@ extern crate cssparser; extern crate euclid; -extern crate heapsize; -#[macro_use] extern crate heapsize_derive; extern crate ipc_channel; #[macro_use] extern crate lazy_static; +extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; extern crate nonzero; extern crate offscreen_gl_context; #[macro_use] extern crate serde; diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index 9d53e93287f..42d19d4413c 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -64,7 +64,7 @@ pub struct WebGLCreateContextResult { pub share_mode: WebGLContextShareMode, } -#[derive(Clone, Copy, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, Serialize)] pub enum WebGLContextShareMode { /// Fast: a shared texture_id is used in WebRender. SharedTexture, @@ -73,10 +73,10 @@ pub enum WebGLContextShareMode { } /// Helper struct to send WebGLCommands to a specific WebGLContext. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct WebGLMsgSender { ctx_id: WebGLContextId, - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] sender: WebGLChan, } @@ -313,8 +313,8 @@ macro_rules! define_resource_id { } } - impl ::heapsize::HeapSizeOf for $name { - fn heap_size_of_children(&self) -> usize { 0 } + impl ::malloc_size_of::MallocSizeOf for $name { + fn size_of(&self, _ops: &mut ::malloc_size_of::MallocSizeOfOps) -> usize { 0 } } } } @@ -327,13 +327,10 @@ define_resource_id!(WebGLProgramId); define_resource_id!(WebGLShaderId); define_resource_id!(WebGLVertexArrayId); -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord)] +#[derive(PartialEq, PartialOrd, Serialize)] pub struct WebGLContextId(pub usize); -impl ::heapsize::HeapSizeOf for WebGLContextId { - fn heap_size_of_children(&self) -> usize { 0 } -} - #[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub enum WebGLError { InvalidEnum, diff --git a/components/devtools_traits/Cargo.toml b/components/devtools_traits/Cargo.toml index 323cd25f946..f722002daa8 100644 --- a/components/devtools_traits/Cargo.toml +++ b/components/devtools_traits/Cargo.toml @@ -11,11 +11,11 @@ path = "lib.rs" [dependencies] bitflags = "0.7" -heapsize = "0.4" -heapsize_derive = "0.1" hyper = "0.10" hyper_serde = "0.7" ipc-channel = "0.9" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } msg = {path = "../msg"} serde = "1.0" servo_url = {path = "../url"} diff --git a/components/devtools_traits/lib.rs b/components/devtools_traits/lib.rs index d703b27e625..1195ef8a987 100644 --- a/components/devtools_traits/lib.rs +++ b/components/devtools_traits/lib.rs @@ -14,10 +14,10 @@ #[macro_use] extern crate bitflags; -extern crate heapsize; -#[macro_use] extern crate heapsize_derive; extern crate hyper; extern crate ipc_channel; +extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; extern crate msg; #[macro_use] extern crate serde; extern crate servo_url; @@ -40,7 +40,7 @@ pub struct DevtoolsPageInfo { pub url: ServoUrl, } -#[derive(Clone, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub struct CSSError { pub filename: String, pub line: u32, @@ -144,7 +144,7 @@ pub struct TimelineMarker { pub end_stack: Option>, } -#[derive(Clone, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub enum TimelineMarkerType { Reflow, DOMEvent, @@ -355,5 +355,5 @@ impl PreciseTime { } } -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub struct WorkerId(pub u32); diff --git a/components/dom_struct/lib.rs b/components/dom_struct/lib.rs index 33801de8c8d..a955f00ce87 100644 --- a/components/dom_struct/lib.rs +++ b/components/dom_struct/lib.rs @@ -15,7 +15,7 @@ pub fn dom_struct(args: TokenStream, input: TokenStream) -> TokenStream { panic!("#[dom_struct] takes no arguments"); } let attributes = quote! { - #[derive(DenyPublicFields, DomObject, HeapSizeOf, JSTraceable)] + #[derive(DenyPublicFields, DomObject, JSTraceable, MallocSizeOf)] #[must_root] #[repr(C)] }; diff --git a/components/geometry/Cargo.toml b/components/geometry/Cargo.toml index 68da8f383f1..a1d0ec00a82 100644 --- a/components/geometry/Cargo.toml +++ b/components/geometry/Cargo.toml @@ -12,4 +12,5 @@ path = "lib.rs" [dependencies] app_units = "0.5" euclid = "0.15" -heapsize = "0.4" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } diff --git a/components/geometry/lib.rs b/components/geometry/lib.rs index c71b687e814..61ded7c67d3 100644 --- a/components/geometry/lib.rs +++ b/components/geometry/lib.rs @@ -4,7 +4,8 @@ extern crate app_units; extern crate euclid; -#[macro_use] extern crate heapsize; +extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; use app_units::{Au, MAX_AU, MIN_AU}; use euclid::{Point2D, Rect, Size2D}; @@ -24,11 +25,9 @@ use euclid::{Point2D, Rect, Size2D}; /// /// The ratio between DeviceIndependentPixel and DevicePixel for a given display be found by calling /// `servo::windowing::WindowMethods::hidpi_factor`. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, MallocSizeOf)] pub enum DeviceIndependentPixel {} -known_heap_size!(0, DeviceIndependentPixel); - // An Au is an "App Unit" and represents 1/60th of a CSS pixel. It was // originally proposed in 2002 as a standard unit of measure in Gecko. // See https://bugzilla.mozilla.org/show_bug.cgi?id=177805 for more info. diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index 405d9db5646..606d17c2908 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -21,12 +21,12 @@ fnv = "1.0" fontsan = {git = "https://github.com/servo/fontsan"} gfx_traits = {path = "../gfx_traits"} harfbuzz-sys = "0.1" -heapsize = "0.4" -heapsize_derive = "0.1" ipc-channel = "0.9" lazy_static = "0.2" libc = "0.2" log = "0.3.5" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } msg = {path = "../msg"} net_traits = {path = "../net_traits"} ordered-float = "0.4" diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index ceb7016f9f2..9915328ad5d 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -43,7 +43,7 @@ pub use style::dom::OpaqueNode; /// items that involve a blur. This ensures that the display item boundaries include all the ink. pub static BLUR_INFLATION_FACTOR: i32 = 3; -#[derive(Deserialize, HeapSizeOf, Serialize)] +#[derive(Deserialize, MallocSizeOf, Serialize)] pub struct DisplayList { pub list: Vec, } @@ -314,7 +314,7 @@ impl<'a> Iterator for DisplayListTraversal<'a> { /// Display list sections that make up a stacking context. Each section here refers /// to the steps in CSS 2.1 Appendix E. /// -#[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)] pub enum DisplayListSection { BackgroundAndBorders, BlockBackgroundsAndBorders, @@ -322,14 +322,14 @@ pub enum DisplayListSection { Outlines, } -#[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)] pub enum StackingContextType { Real, PseudoPositioned, PseudoFloat, } -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] /// Represents one CSS stacking context, which may or may not have a hardware layer. pub struct StackingContext { /// The ID of this StackingContext for uniquely identifying it. @@ -484,7 +484,7 @@ impl fmt::Debug for StackingContext { } } -#[derive(Clone, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub enum ClipScrollNodeType { ScrollFrame(ScrollSensitivity), StickyFrame(StickyFrameInfo), @@ -492,7 +492,7 @@ pub enum ClipScrollNodeType { } /// Defines a clip scroll node. -#[derive(Clone, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub struct ClipScrollNode { /// The WebRender clip id of this scroll root based on the source of this clip /// and information about the fragment. @@ -522,7 +522,7 @@ impl ClipScrollNode { /// One drawing command in the list. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub enum DisplayItem { SolidColor(Box), Text(Box), @@ -541,7 +541,7 @@ pub enum DisplayItem { } /// Information common to all display items. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct BaseDisplayItem { /// The boundaries of the display item, in layer coordinates. pub bounds: Rect, @@ -600,7 +600,7 @@ impl BaseDisplayItem { /// A clipping region for a display item. Currently, this can describe rectangles, rounded /// rectangles (for `border-radius`), or arbitrary intersections of the two. Arbitrary transforms /// are not supported because those are handled by the higher-level `StackingContext` abstraction. -#[derive(Clone, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub struct ClippingRegion { /// The main rectangular region. This does not include any corners. pub main: Rect, @@ -614,7 +614,7 @@ pub struct ClippingRegion { /// A complex clipping region. These don't as easily admit arbitrary intersection operations, so /// they're stored in a list over to the side. Currently a complex clipping region is just a /// rounded rectangle, but the CSS WGs will probably make us throw more stuff in here eventually. -#[derive(Clone, Debug, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub struct ComplexClippingRegion { /// The boundaries of the rectangle. pub rect: Rect, @@ -784,7 +784,7 @@ impl ComplexClippingRegion { /// Metadata attached to each display item. This is useful for performing auxiliary threads with /// the display list involving hit testing: finding the originating DOM node and determining the /// cursor to use when the element is hovered over. -#[derive(Clone, Copy, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, Serialize)] pub struct DisplayItemMetadata { /// The DOM node from which this display item originated. pub node: OpaqueNode, @@ -794,7 +794,7 @@ pub struct DisplayItemMetadata { } /// Paints a solid color. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct SolidColorDisplayItem { /// Fields common to all display items. pub base: BaseDisplayItem, @@ -804,13 +804,13 @@ pub struct SolidColorDisplayItem { } /// Paints text. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct TextDisplayItem { /// Fields common to all display items. pub base: BaseDisplayItem, /// The text run. - #[ignore_heap_size_of = "Because it is non-owning"] + #[ignore_malloc_size_of = "Because it is non-owning"] pub text_run: Arc, /// The range of text within the text run. @@ -826,7 +826,7 @@ pub struct TextDisplayItem { pub orientation: TextOrientation, } -#[derive(Clone, Deserialize, Eq, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)] pub enum TextOrientation { Upright, SidewaysLeft, @@ -834,13 +834,13 @@ pub enum TextOrientation { } /// Paints an image. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct ImageDisplayItem { pub base: BaseDisplayItem, pub webrender_image: WebRenderImageInfo, - #[ignore_heap_size_of = "Because it is non-owning"] + #[ignore_malloc_size_of = "Because it is non-owning"] pub image_data: Option>, /// The dimensions to which the image display item should be stretched. If this is smaller than @@ -857,14 +857,14 @@ pub struct ImageDisplayItem { pub image_rendering: image_rendering::T, } /// Paints an iframe. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct IframeDisplayItem { pub base: BaseDisplayItem, pub iframe: PipelineId, } /// Paints a gradient. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct Gradient { /// The start point of the gradient (computed during display list construction). pub start_point: Point2D, @@ -879,7 +879,7 @@ pub struct Gradient { pub repeating: bool, } -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct GradientDisplayItem { /// Fields common to all display item. pub base: BaseDisplayItem, @@ -889,7 +889,7 @@ pub struct GradientDisplayItem { } /// Paints a radial gradient. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct RadialGradient { /// The center point of the gradient. pub center: Point2D, @@ -904,7 +904,7 @@ pub struct RadialGradient { pub repeating: bool, } -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct RadialGradientDisplayItem { /// Fields common to all display item. pub base: BaseDisplayItem, @@ -914,7 +914,7 @@ pub struct RadialGradientDisplayItem { } /// A normal border, supporting CSS border styles. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct NormalBorder { /// Border colors. pub color: SideOffsets2D, @@ -929,7 +929,7 @@ pub struct NormalBorder { } /// A border that is made of image segments. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct ImageBorder { /// The image this border uses, border-image-source. pub image: WebRenderImageInfo, @@ -951,7 +951,7 @@ pub struct ImageBorder { } /// A border that is made of linear gradient -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct GradientBorder { /// The gradient info that this border uses, border-image-source. pub gradient: Gradient, @@ -961,7 +961,7 @@ pub struct GradientBorder { } /// A border that is made of radial gradient -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct RadialGradientBorder { /// The gradient info that this border uses, border-image-source. pub gradient: RadialGradient, @@ -971,7 +971,7 @@ pub struct RadialGradientBorder { } /// Specifies the type of border -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub enum BorderDetails { Normal(NormalBorder), Image(ImageBorder), @@ -980,7 +980,7 @@ pub enum BorderDetails { } /// Paints a border. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct BorderDisplayItem { /// Fields common to all display items. pub base: BaseDisplayItem, @@ -995,7 +995,7 @@ pub struct BorderDisplayItem { /// Information about the border radii. /// /// TODO(pcwalton): Elliptical radii. -#[derive(Clone, Copy, Debug, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub struct BorderRadii { pub top_left: Size2D, pub top_right: Size2D, @@ -1057,7 +1057,7 @@ impl BorderRadii where T: PartialEq + Zero + Clone { } /// Paints a line segment. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct LineDisplayItem { pub base: BaseDisplayItem, @@ -1065,12 +1065,12 @@ pub struct LineDisplayItem { pub color: ColorF, /// The line segment style. - #[ignore_heap_size_of = "enum type in webrender"] + #[ignore_malloc_size_of = "enum type in webrender"] pub style: webrender_api::LineStyle, } /// Paints a box shadow per CSS-BACKGROUNDS. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct BoxShadowDisplayItem { /// Fields common to all display items. pub base: BaseDisplayItem, @@ -1100,7 +1100,7 @@ pub struct BoxShadowDisplayItem { } /// Defines a text shadow that affects all items until the paired PopTextShadow. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct PushTextShadowDisplayItem { /// Fields common to all display items. pub base: BaseDisplayItem, @@ -1116,14 +1116,14 @@ pub struct PushTextShadowDisplayItem { } /// Defines a text shadow that affects all items until the next PopTextShadow. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct PopAllTextShadowsDisplayItem { /// Fields common to all display items. pub base: BaseDisplayItem, } /// Defines a stacking context. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct PushStackingContextItem { /// Fields common to all display items. pub base: BaseDisplayItem, @@ -1132,7 +1132,7 @@ pub struct PushStackingContextItem { } /// Defines a stacking context. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct PopStackingContextItem { /// Fields common to all display items. pub base: BaseDisplayItem, @@ -1141,7 +1141,7 @@ pub struct PopStackingContextItem { } /// Starts a group of items inside a particular scroll root. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct DefineClipScrollNodeItem { /// Fields common to all display items. pub base: BaseDisplayItem, @@ -1151,7 +1151,7 @@ pub struct DefineClipScrollNodeItem { } /// How a box shadow should be clipped. -#[derive(Clone, Copy, Debug, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum BoxShadowClipMode { /// No special clipping should occur. This is used for (shadowed) text decorations. None, @@ -1258,7 +1258,7 @@ impl fmt::Debug for DisplayItem { } } -#[derive(Clone, Copy, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, Serialize)] pub struct WebRenderImageInfo { pub width: u32, pub height: u32, diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index b5d2298d1f7..13c3d777579 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -7,7 +7,7 @@ use fnv::FnvHasher; use font::{Font, FontGroup, FontHandleMethods}; use font_cache_thread::FontCacheThread; use font_template::FontTemplateDescriptor; -use heapsize::HeapSizeOf; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use platform::font::FontHandle; use platform::font_context::FontContextHandle; use platform::font_template::FontTemplateData; @@ -232,10 +232,10 @@ impl FontContext { } } -impl HeapSizeOf for FontContext { - fn heap_size_of_children(&self) -> usize { +impl MallocSizeOf for FontContext { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { // FIXME(njn): Measure other fields eventually. - self.platform_handle.heap_size_of_children() + self.platform_handle.size_of(ops) } } diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index beaeba75f21..aa0c635bf53 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -35,14 +35,15 @@ extern crate gfx_traits; // shapers. For now, however, this is a hard dependency. extern crate harfbuzz_sys as harfbuzz; -extern crate heapsize; -#[macro_use] extern crate heapsize_derive; extern crate ipc_channel; #[macro_use] extern crate lazy_static; extern crate libc; #[macro_use] extern crate log; +#[cfg_attr(target_os = "windows", macro_use)] +extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; extern crate msg; extern crate net_traits; extern crate ordered_float; diff --git a/components/gfx/platform/freetype/font_context.rs b/components/gfx/platform/freetype/font_context.rs index 7f4c00f2afb..c7deea5adf8 100644 --- a/components/gfx/platform/freetype/font_context.rs +++ b/components/gfx/platform/freetype/font_context.rs @@ -8,7 +8,7 @@ use freetype::freetype::FT_Library; use freetype::freetype::FT_Memory; use freetype::freetype::FT_MemoryRec_; use freetype::freetype::FT_New_Library; -use heapsize::{HeapSizeOf, heap_size_of}; +use malloc_size_of::{malloc_size_of, MallocSizeOf, MallocSizeOfOps}; use std::mem; use std::os::raw::{c_long, c_void}; use std::ptr; @@ -31,7 +31,7 @@ extern fn ft_alloc(mem: FT_Memory, req_size: c_long) -> *mut c_void { mem::forget(vec); unsafe { - let actual_size = heap_size_of(ptr as *const _); + let actual_size = malloc_size_of(ptr as *const _); let user = (*mem).user as *mut User; (*user).size += actual_size; } @@ -41,7 +41,7 @@ extern fn ft_alloc(mem: FT_Memory, req_size: c_long) -> *mut c_void { extern fn ft_free(mem: FT_Memory, ptr: *mut c_void) { unsafe { - let actual_size = heap_size_of(ptr as *const _); + let actual_size = malloc_size_of(ptr as *const _); let user = (*mem).user as *mut User; (*user).size -= actual_size; @@ -55,7 +55,7 @@ extern fn ft_realloc(mem: FT_Memory, _cur_size: c_long, new_req_size: c_long, let old_actual_size; let mut vec; unsafe { - old_actual_size = heap_size_of(old_ptr as *const _); + old_actual_size = malloc_size_of(old_ptr as *const _); vec = Vec::::from_raw_parts(old_ptr as *mut u8, old_actual_size, old_actual_size); }; @@ -71,7 +71,7 @@ extern fn ft_realloc(mem: FT_Memory, _cur_size: c_long, new_req_size: c_long, mem::forget(vec); unsafe { - let new_actual_size = heap_size_of(new_ptr as *const _); + let new_actual_size = malloc_size_of(new_ptr as *const _); let user = (*mem).user as *mut User; (*user).size += new_actual_size; (*user).size -= old_actual_size; @@ -104,13 +104,13 @@ impl Drop for FreeTypeLibraryHandle { } } -impl HeapSizeOf for FreeTypeLibraryHandle { - fn heap_size_of_children(&self) -> usize { +impl MallocSizeOf for FreeTypeLibraryHandle { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { unsafe { (*self.user).size + - heap_size_of(self.ctx as *const _) + - heap_size_of(self.mem as *const _) + - heap_size_of(self.user as *const _) + ops.malloc_size_of(self.ctx as *const _) + + ops.malloc_size_of(self.mem as *const _) + + ops.malloc_size_of(self.user as *const _) } } } @@ -123,9 +123,9 @@ pub struct FontContextHandle { pub ctx: Rc, } -impl HeapSizeOf for FontContextHandle { - fn heap_size_of_children(&self) -> usize { - self.ctx.heap_size_of_children() +impl MallocSizeOf for FontContextHandle { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.ctx.size_of(ops) } } diff --git a/components/gfx/platform/macos/font_context.rs b/components/gfx/platform/macos/font_context.rs index e728b62aebd..358d4e5dfd4 100644 --- a/components/gfx/platform/macos/font_context.rs +++ b/components/gfx/platform/macos/font_context.rs @@ -2,9 +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 heapsize::HeapSizeOf; - -#[derive(Clone, Debug)] +#[derive(Clone, Debug, MallocSizeOf)] pub struct FontContextHandle { ctx: () } @@ -15,9 +13,3 @@ impl FontContextHandle { FontContextHandle { ctx: () } } } - -impl HeapSizeOf for FontContextHandle { - fn heap_size_of_children(&self) -> usize { - 0 - } -} diff --git a/components/gfx/platform/windows/font_context.rs b/components/gfx/platform/windows/font_context.rs index 26670bb7dd9..7d304ed138d 100644 --- a/components/gfx/platform/windows/font_context.rs +++ b/components/gfx/platform/windows/font_context.rs @@ -2,8 +2,6 @@ * 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 heapsize::HeapSizeOf; - #[derive(Clone, Debug)] pub struct FontContextHandle; @@ -14,8 +12,4 @@ impl FontContextHandle { } } -impl HeapSizeOf for FontContextHandle { - fn heap_size_of_children(&self) -> usize { - 0 - } -} +malloc_size_of_is_0!(FontContextHandle); diff --git a/components/gfx_traits/Cargo.toml b/components/gfx_traits/Cargo.toml index f9de4fc3088..8d558d19ba0 100644 --- a/components/gfx_traits/Cargo.toml +++ b/components/gfx_traits/Cargo.toml @@ -10,7 +10,7 @@ name = "gfx_traits" path = "lib.rs" [dependencies] -heapsize = "0.4" -heapsize_derive = "0.1" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } range = {path = "../range"} serde = "1.0" diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs index e6f6c124ec2..9688d90bbef 100644 --- a/components/gfx_traits/lib.rs +++ b/components/gfx_traits/lib.rs @@ -7,8 +7,8 @@ #![deny(unsafe_code)] -extern crate heapsize; -#[macro_use] extern crate heapsize_derive; +extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; #[macro_use] extern crate range; #[macro_use] extern crate serde; @@ -28,7 +28,7 @@ impl Epoch { } /// A unique ID for every stacking context. -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub struct StackingContextId( /// The identifier for this StackingContext, derived from the Flow's memory address /// and fragment type. As a space optimization, these are combined into a single word. @@ -53,7 +53,7 @@ int_range_index! { #[derive(Deserialize, Serialize)] #[doc = "An index that refers to a byte offset in a text run. This could \ point to the middle of a glyph."] - #[derive(HeapSizeOf)] + #[derive(MallocSizeOf)] struct ByteIndex(isize) } @@ -62,7 +62,7 @@ int_range_index! { /// This can only ever grow to maximum 4 entries. That's because we cram the value of this enum /// into the lower 2 bits of the `StackingContextId`, which otherwise contains a 32-bit-aligned /// heap address. -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub enum FragmentType { /// A StackingContext for the fragment body itself. FragmentBody, diff --git a/components/hashglobe/Cargo.toml b/components/hashglobe/Cargo.toml index cffb48919cf..6deb04a7531 100644 --- a/components/hashglobe/Cargo.toml +++ b/components/hashglobe/Cargo.toml @@ -11,7 +11,6 @@ readme = "README.md" [dependencies] libc = "0.2" -heapsize = "0.4" [dev-dependencies] rand = "0.3" diff --git a/components/hashglobe/src/fake.rs b/components/hashglobe/src/fake.rs index f83032d5a83..1d29296f000 100644 --- a/components/hashglobe/src/fake.rs +++ b/components/hashglobe/src/fake.rs @@ -14,7 +14,6 @@ //! These methods are a lie. They are not actually fallible. This is just to make //! it smooth to switch between hashmap impls in a codebase. -use heapsize::HeapSizeOf; use std::collections::HashMap as StdMap; use std::collections::HashSet as StdSet; use std::fmt; @@ -161,14 +160,6 @@ impl HashSet // Pass through trait impls // We can't derive these since the bounds are not obvious to the derive macro - -impl - HeapSizeOf for HashMap { - fn heap_size_of_children(&self) -> usize { - self.0.heap_size_of_children() - } -} - impl Default for HashMap { fn default() -> Self { HashMap(Default::default()) @@ -225,13 +216,6 @@ impl<'a, K, V, S> IntoIterator for &'a mut HashMap } } - -impl HeapSizeOf for HashSet { - fn heap_size_of_children(&self) -> usize { - self.0.heap_size_of_children() - } -} - impl Default for HashSet { fn default() -> Self { HashSet(Default::default()) diff --git a/components/hashglobe/src/lib.rs b/components/hashglobe/src/lib.rs index 480f3a540ea..254cb2b943d 100644 --- a/components/hashglobe/src/lib.rs +++ b/components/hashglobe/src/lib.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate heapsize; - pub mod alloc; pub mod diagnostic; pub mod hash_map; diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index 2becf6a5675..70903da2dbf 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -18,11 +18,11 @@ euclid = "0.15" fnv = "1.0" gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} -heapsize = "0.4" html5ever = "0.20.0" ipc-channel = "0.9" libc = "0.2" log = "0.3.5" +malloc_size_of = { path = "../malloc_size_of" } msg = {path = "../msg"} net_traits = {path = "../net_traits"} ordered-float = "0.4" diff --git a/components/layout/context.rs b/components/layout/context.rs index 76d32eebca9..bf148f4c1a1 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -8,7 +8,7 @@ use fnv::FnvHasher; use gfx::display_list::{WebRenderImageInfo, OpaqueNode}; use gfx::font_cache_thread::FontCacheThread; use gfx::font_context::FontContext; -use heapsize::HeapSizeOf; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use msg::constellation_msg::PipelineId; use net_traits::image_cache::{CanRequestImages, ImageCache, ImageState}; use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder}; @@ -42,10 +42,10 @@ pub fn with_thread_local_font_context(layout_context: &LayoutContext, f: F }) } -pub fn heap_size_of_persistent_local_context() -> usize { +pub fn malloc_size_of_persistent_local_context(ops: &mut MallocSizeOfOps) -> usize { FONT_CONTEXT_KEY.with(|r| { if let Some(ref context) = *r.borrow() { - context.heap_size_of_children() + context.size_of(ops) } else { 0 } diff --git a/components/layout/lib.rs b/components/layout/lib.rs index f9c3cbeda2b..f5e850c6da1 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -13,12 +13,12 @@ extern crate euclid; extern crate fnv; extern crate gfx; extern crate gfx_traits; -extern crate heapsize; #[macro_use] extern crate html5ever; extern crate ipc_channel; extern crate libc; #[macro_use] extern crate log; +extern crate malloc_size_of; extern crate msg; extern crate net_traits; extern crate ordered_float; diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml index 6108c9c2447..35336e133ca 100644 --- a/components/layout_thread/Cargo.toml +++ b/components/layout_thread/Cargo.toml @@ -19,7 +19,6 @@ euclid = "0.15" fnv = "1.0" gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} -heapsize = "0.4" html5ever = "0.20.0" ipc-channel = "0.9" layout = {path = "../layout"} @@ -27,6 +26,7 @@ layout_traits = {path = "../layout_traits"} lazy_static = "0.2" libc = "0.2" log = "0.3.5" +malloc_size_of = { path = "../malloc_size_of" } metrics = {path = "../metrics"} msg = {path = "../msg"} net_traits = {path = "../net_traits"} diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index ab3e620c16e..0010d66673c 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -13,7 +13,6 @@ extern crate euclid; extern crate fnv; extern crate gfx; extern crate gfx_traits; -extern crate heapsize; #[macro_use] extern crate html5ever; extern crate ipc_channel; @@ -25,6 +24,7 @@ extern crate lazy_static; extern crate libc; #[macro_use] extern crate log; +extern crate malloc_size_of; extern crate metrics; extern crate msg; extern crate net_traits; @@ -60,7 +60,6 @@ use gfx::font; use gfx::font_cache_thread::FontCacheThread; use gfx::font_context; use gfx_traits::{Epoch, node_id_from_clip_id}; -use heapsize::HeapSizeOf; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use layout::animation; @@ -68,7 +67,7 @@ use layout::construct::ConstructionResult; use layout::context::LayoutContext; use layout::context::RegisteredPainter; use layout::context::RegisteredPainters; -use layout::context::heap_size_of_persistent_local_context; +use layout::context::malloc_size_of_persistent_local_context; use layout::display_list_builder::ToGfxColor; use layout::flow::{self, Flow, ImmutableFlowUtils, MutableOwnedFlowUtils}; use layout::flow_ref::FlowRef; @@ -85,6 +84,7 @@ use layout::webrender_helpers::WebRenderDisplayListConverter; use layout::wrapper::LayoutNodeLayoutData; use layout_traits::LayoutThreadFactory; use libc::c_void; +use malloc_size_of::{malloc_size_of, MallocSizeOf, MallocSizeOfOps}; use metrics::{PaintTimeMetrics, ProfilerMetadataFactory}; use msg::constellation_msg::PipelineId; use msg::constellation_msg::TopLevelBrowsingContextId; @@ -773,6 +773,9 @@ impl LayoutThread { reports_chan: ReportsChan, possibly_locked_rw_data: &mut RwData<'a, 'b>) { let mut reports = vec![]; + // Servo uses vanilla jemalloc, which doesn't have a + // malloc_enclosing_size_of function. + let mut ops = MallocSizeOfOps::new(malloc_size_of, None, None); // FIXME(njn): Just measuring the display tree for now. let rw_data = possibly_locked_rw_data.lock(); @@ -781,20 +784,20 @@ impl LayoutThread { reports.push(Report { path: path![formatted_url, "layout-thread", "display-list"], kind: ReportKind::ExplicitJemallocHeapSize, - size: display_list.map_or(0, |sc| sc.heap_size_of_children()), + size: display_list.map_or(0, |sc| sc.size_of(&mut ops)), }); reports.push(Report { path: path![formatted_url, "layout-thread", "stylist"], kind: ReportKind::ExplicitJemallocHeapSize, - size: self.stylist.heap_size_of_children(), + size: self.stylist.size_of(&mut ops), }); // The LayoutThread has data in Persistent TLS... reports.push(Report { path: path![formatted_url, "layout-thread", "local-context"], kind: ReportKind::ExplicitJemallocHeapSize, - size: heap_size_of_persistent_local_context(), + size: malloc_size_of_persistent_local_context(&mut ops), }); reports_chan.send(reports); diff --git a/components/malloc_size_of/Cargo.toml b/components/malloc_size_of/Cargo.toml index b3c2faa0f05..afc92cf53a9 100644 --- a/components/malloc_size_of/Cargo.toml +++ b/components/malloc_size_of/Cargo.toml @@ -8,11 +8,22 @@ publish = false [lib] path = "lib.rs" +[target.'cfg(windows)'.dependencies] +kernel32-sys = "0.2.1" + +[features] +servo = ["js", "string_cache", "url", "webrender_api", "xml5ever"] + [dependencies] app_units = "0.5.5" cssparser = "0.22.0" euclid = "0.15" hashglobe = { path = "../hashglobe" } +js = { git = "https://github.com/servo/rust-mozjs", features = ["promises"], optional = true } servo_arc = { path = "../servo_arc" } smallbitvec = "1.0.3" smallvec = "0.4" +string_cache = { version = "0.6", optional = true } +url = { version = "1.2", optional = true } +webrender_api = { git = "https://github.com/servo/webrender", features = ["ipc"], optional = true } +xml5ever = { version = "0.10", optional = true } diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index b2aadc872a9..48350e6f840 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -10,28 +10,15 @@ //! A crate for measuring the heap usage of data structures in a way that //! integrates with Firefox's memory reporting, particularly the use of -//! mozjemalloc and DMD. -//! -//! This crate has a lot of overlap with the existing `heapsize` crate, and may -//! one day be merged into it. But for now, `heapsize` has the following -//! major shortcomings. -//! - It basically assumes that the `HeapSizeOf` trait can be used for every -//! type, which is not true. Sometimes more than a single size measurement -//! needs to be returned for a type, and sometimes additional synchronization -//! arguments (such as lock guards) need to be passed in. -//! - It has no proper way of measuring some common types, such as `HashSet` -//! and `HashMap`, that don't expose internal pointers. -//! - It has no proper way of handling values with multiple referents, such as -//! `Rc` and `Arc`. -//! -//! This crate solves those problems. +//! mozjemalloc and DMD. In particular, it has the following features. +//! - It isn't bound to a particular heap allocator. //! - It provides traits for both "shallow" and "deep" measurement, which gives -//! more flexibility in the cases where the traits can't be used. +//! flexibility in the cases where the traits can't be used. //! - It allows for measuring blocks even when only an interior pointer can be //! obtained for heap allocations, e.g. `HashSet` and `HashMap`. (This relies //! on the heap allocator having suitable support, which mozjemalloc has.) -//! - It allows handling of types like `Rc` and `Arc` by providing special -//! traits that are different to the ones for non-graph structures. +//! - It allows handling of types like `Rc` and `Arc` by providing traits that +//! are different to the ones for non-graph structures. //! //! Suggested uses are as follows. //! - When possible, use the `MallocSizeOf` trait. (Deriving support is @@ -60,11 +47,26 @@ extern crate app_units; extern crate cssparser; extern crate euclid; extern crate hashglobe; +#[cfg(feature = "servo")] +extern crate js; +#[cfg(target_os = "windows")] +extern crate kernel32; extern crate servo_arc; extern crate smallbitvec; extern crate smallvec; +#[cfg(feature = "servo")] +extern crate string_cache; +#[cfg(feature = "servo")] +extern crate url; +#[cfg(feature = "servo")] +extern crate webrender_api; +#[cfg(feature = "servo")] +extern crate xml5ever; +#[cfg(target_os = "windows")] +use kernel32::{GetProcessHeap, HeapSize, HeapValidate}; use std::hash::{BuildHasher, Hash}; +use std::mem::size_of; use std::ops::Range; use std::os::raw::c_void; @@ -79,8 +81,11 @@ pub struct MallocSizeOfOps { /// A function that returns the size of a heap allocation. size_of_op: VoidPtrToSizeFn, - /// Like `size_of_op`, but can take an interior pointer. - enclosing_size_of_op: VoidPtrToSizeFn, + /// Like `size_of_op`, but can take an interior pointer. Optional because + /// not all allocators support this operation. If it's not provided, some + /// memory measurements will actually be computed estimates rather than + /// real and accurate measurements. + enclosing_size_of_op: Option, /// Check if a pointer has been seen before, and remember it for next time. /// Useful when measuring `Rc`s and `Arc`s. Optional, because many places @@ -89,7 +94,8 @@ pub struct MallocSizeOfOps { } impl MallocSizeOfOps { - pub fn new(size_of: VoidPtrToSizeFn, malloc_enclosing_size_of: VoidPtrToSizeFn, + pub fn new(size_of: VoidPtrToSizeFn, + malloc_enclosing_size_of: Option, have_seen_ptr: Option>) -> Self { MallocSizeOfOps { size_of_op: size_of, @@ -121,10 +127,16 @@ impl MallocSizeOfOps { } } - /// Call `enclosing_size_of_op` on `ptr`, which must not be empty. + /// Is an `enclosing_size_of_op` available? + pub fn has_malloc_enclosing_size_of(&self) -> bool { + self.enclosing_size_of_op.is_some() + } + + /// Call `enclosing_size_of_op`, which must be available, on `ptr`, which + /// must not be empty. pub unsafe fn malloc_enclosing_size_of(&self, ptr: *const T) -> usize { assert!(!MallocSizeOfOps::is_empty(ptr)); - (self.enclosing_size_of_op)(ptr as *const c_void) + (self.enclosing_size_of_op.unwrap())(ptr as *const c_void) } /// Call `have_seen_ptr_op` on `ptr`. @@ -134,6 +146,33 @@ impl MallocSizeOfOps { } } +/// Get the size of a heap block. +#[cfg(not(target_os = "windows"))] +pub unsafe extern "C" fn malloc_size_of(ptr: *const c_void) -> usize { + // 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. + extern "C" { + #[cfg_attr(any(prefixed_jemalloc, target_os = "macos", target_os = "ios", target_os = "android"), + link_name = "je_malloc_usable_size")] + fn malloc_usable_size(ptr: *const c_void) -> usize; + } + malloc_usable_size(ptr) +} + +/// Get the size of a heap block. +#[cfg(target_os = "windows")] +pub unsafe extern "C" fn malloc_size_of(mut ptr: *const c_void) -> usize { + let heap = GetProcessHeap(); + + if HeapValidate(heap, 0, ptr) == 0 { + ptr = *(ptr as *const *const c_void).offset(-1); + } + + HeapSize(heap, 0, ptr) as usize +} + /// Trait for measuring the "deep" heap usage of a data structure. This is the /// most commonly-used of the traits. pub trait MallocSizeOf { @@ -188,6 +227,13 @@ impl MallocSizeOf for String { } } +impl<'a, T: ?Sized> MallocSizeOf for &'a T { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { + // Zero makes sense for a non-owning reference. + 0 + } +} + impl MallocShallowSizeOf for Box { fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { unsafe { ops.malloc_size_of(&**self) } @@ -200,12 +246,36 @@ impl MallocSizeOf for Box { } } -impl MallocSizeOf for (A, B) { +impl MallocSizeOf for () { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { + 0 + } +} + +impl MallocSizeOf for (T1, T2) + where T1: MallocSizeOf, T2: MallocSizeOf +{ fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { self.0.size_of(ops) + self.1.size_of(ops) } } +impl MallocSizeOf for (T1, T2, T3) + where T1: MallocSizeOf, T2: MallocSizeOf, T3: MallocSizeOf +{ + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.0.size_of(ops) + self.1.size_of(ops) + self.2.size_of(ops) + } +} + +impl MallocSizeOf for (T1, T2, T3, T4) + where T1: MallocSizeOf, T2: MallocSizeOf, T3: MallocSizeOf, T4: MallocSizeOf +{ + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.0.size_of(ops) + self.1.size_of(ops) + self.2.size_of(ops) + self.3.size_of(ops) + } +} + impl MallocSizeOf for Option { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { if let Some(val) = self.as_ref() { @@ -216,6 +286,38 @@ impl MallocSizeOf for Option { } } +impl MallocSizeOf for Result { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + match *self { + Ok(ref x) => x.size_of(ops), + Err(ref e) => e.size_of(ops), + } + } +} + +impl MallocSizeOf for std::cell::Cell { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.get().size_of(ops) + } +} + +impl MallocSizeOf for std::cell::RefCell { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.borrow().size_of(ops) + } +} + +impl<'a, B: ?Sized + ToOwned> MallocSizeOf for std::borrow::Cow<'a, B> + where B::Owned: MallocSizeOf +{ + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + match *self { + std::borrow::Cow::Borrowed(_) => 0, + std::borrow::Cow::Owned(ref b) => b.size_of(ops), + } + } +} + impl MallocSizeOf for [T] { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { let mut n = 0; @@ -242,6 +344,33 @@ impl MallocSizeOf for Vec { } } +impl MallocShallowSizeOf for std::collections::VecDeque { + fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + if ops.has_malloc_enclosing_size_of() { + if let Some(front) = self.front() { + // The front element is an interior pointer. + unsafe { ops.malloc_enclosing_size_of(&*front) } + } else { + // This assumes that no memory is allocated when the VecDeque is empty. + 0 + } + } else { + // An estimate. + self.capacity() * size_of::() + } + } +} + +impl MallocSizeOf for std::collections::VecDeque { + 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 + } +} + impl MallocShallowSizeOf for smallvec::SmallVec { fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { if self.spilled() { @@ -270,11 +399,16 @@ impl MallocShallowSizeOf for std::collections::HashSet S: BuildHasher { fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - // The first value from the iterator gives us an interior pointer. - // `ops.malloc_enclosing_size_of()` then gives us the storage size. - // This assumes that the `HashSet`'s contents (values and hashes) are - // all stored in a single contiguous heap allocation. - self.iter().next().map_or(0, |t| unsafe { ops.malloc_enclosing_size_of(t) }) + if ops.has_malloc_enclosing_size_of() { + // The first value from the iterator gives us an interior pointer. + // `ops.malloc_enclosing_size_of()` then gives us the storage size. + // This assumes that the `HashSet`'s contents (values and hashes) + // are all stored in a single contiguous heap allocation. + self.iter().next().map_or(0, |t| unsafe { ops.malloc_enclosing_size_of(t) }) + } else { + // An estimate. + self.capacity() * (size_of::() + size_of::()) + } } } @@ -297,7 +431,11 @@ impl MallocShallowSizeOf for hashglobe::hash_set::HashSet { fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { // See the implementation for std::collections::HashSet for details. - self.iter().next().map_or(0, |t| unsafe { ops.malloc_enclosing_size_of(t) }) + 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::() + size_of::()) + } } } @@ -314,13 +452,66 @@ impl MallocSizeOf for hashglobe::hash_set::HashSet } } +impl MallocShallowSizeOf for hashglobe::fake::HashSet + 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 MallocSizeOf for hashglobe::fake::HashSet + where T: Eq + Hash + MallocSizeOf, + S: BuildHasher, +{ + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + use std::ops::Deref; + self.deref().size_of(ops) + } +} + +impl MallocShallowSizeOf for std::collections::HashMap + 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::() + size_of::() + size_of::()) + } + } +} + +impl MallocSizeOf for std::collections::HashMap + 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 MallocShallowSizeOf for hashglobe::hash_map::HashMap where K: Eq + Hash, S: BuildHasher { fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { // See the implementation for std::collections::HashSet for details. - self.values().next().map_or(0, |v| unsafe { ops.malloc_enclosing_size_of(v) }) + 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::() + size_of::() + size_of::()) + } } } @@ -358,6 +549,34 @@ impl MallocSizeOf for hashglobe::diagnostic::DiagnosticHashMap } } +impl MallocShallowSizeOf for hashglobe::fake::HashMap + 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 MallocSizeOf for hashglobe::fake::HashMap + 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 MallocSizeOf for std::marker::PhantomData { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { + 0 + } +} + // XXX: we don't want MallocSizeOf to be defined for Rc and Arc. If negative // trait bounds are ever allowed, this code should be uncommented. // (We do have a compile-fail test for this: @@ -407,12 +626,86 @@ impl MallocSizeOf for smallbitvec::SmallBitVec { } } +impl MallocSizeOf for euclid::Length { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.0.size_of(ops) + } +} + +impl MallocSizeOf for euclid::ScaleFactor { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.0.size_of(ops) + } +} + +impl MallocSizeOf for euclid::TypedPoint2D { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.x.size_of(ops) + self.y.size_of(ops) + } +} + +impl MallocSizeOf for euclid::TypedRect { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.origin.size_of(ops) + self.size.size_of(ops) + } +} + +impl MallocSizeOf for euclid::TypedSideOffsets2D { + 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 MallocSizeOf for euclid::TypedSize2D { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { self.width.size_of(ops) + self.height.size_of(ops) } } +impl MallocSizeOf for euclid::TypedTransform2D { + 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 MallocSizeOf for euclid::TypedTransform3D { + 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 MallocSizeOf for euclid::TypedVector2D { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.x.size_of(ops) + self.y.size_of(ops) + } +} + +#[cfg(feature = "servo")] +impl MallocSizeOf for string_cache::Atom { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { + 0 + } +} + +// This is measured properly by the heap measurement implemented in +// SpiderMonkey. +#[cfg(feature = "servo")] +impl MallocSizeOf for js::jsapi::Heap { + 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( @@ -443,9 +736,57 @@ malloc_size_of_is_0!(u8, u16, u32, u64, usize); malloc_size_of_is_0!(i8, i16, i32, i64, isize); malloc_size_of_is_0!(f32, f64); +malloc_size_of_is_0!(std::sync::atomic::AtomicBool); +malloc_size_of_is_0!(std::sync::atomic::AtomicIsize, std::sync::atomic::AtomicUsize); + malloc_size_of_is_0!(Range, Range, Range, Range, Range); malloc_size_of_is_0!(Range, Range, Range, Range, Range); malloc_size_of_is_0!(Range, Range); malloc_size_of_is_0!(app_units::Au); + malloc_size_of_is_0!(cssparser::RGBA, cssparser::TokenSerializationType); + +#[cfg(feature = "servo")] +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 = "servo")] +malloc_size_of_is_0!(webrender_api::ClipAndScrollInfo); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::ClipId); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::ColorF); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::GradientStop); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::ImageKey); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::LocalClip); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::MixBlendMode); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::RepeatMode); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::ScrollPolicy); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::ScrollSensitivity); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::StickySideConstraint); +#[cfg(feature = "servo")] +malloc_size_of_is_0!(webrender_api::TransformStyle); + +#[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) + } +} diff --git a/components/msg/Cargo.toml b/components/msg/Cargo.toml index 0f1e39e8182..d39620fdacf 100644 --- a/components/msg/Cargo.toml +++ b/components/msg/Cargo.toml @@ -14,8 +14,8 @@ unstable = ["nonzero/unstable"] [dependencies] bitflags = "0.7" -heapsize = "0.4" -heapsize_derive = "0.1" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } nonzero = {path = "../nonzero"} serde = "1.0.14" webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 9eb1a9cf116..10d21917c79 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -18,7 +18,7 @@ pub enum KeyState { } //N.B. Based on the glutin key enum -#[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)] pub enum Key { Space, Apostrophe, @@ -217,14 +217,14 @@ impl PipelineNamespace { thread_local!(pub static PIPELINE_NAMESPACE: Cell> = Cell::new(None)); -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)] pub struct PipelineNamespaceId(pub u32); #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub struct PipelineIndex(pub NonZero); -known_heap_size!(0, PipelineIndex); +malloc_size_of_is_0!(PipelineIndex); -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)] pub struct PipelineId { pub namespace_id: PipelineNamespaceId, pub index: PipelineIndex @@ -276,9 +276,9 @@ impl fmt::Display for PipelineId { #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub struct BrowsingContextIndex(pub NonZero); -known_heap_size!(0, BrowsingContextIndex); +malloc_size_of_is_0!(BrowsingContextIndex); -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)] pub struct BrowsingContextId { pub namespace_id: PipelineNamespaceId, pub index: BrowsingContextIndex, @@ -305,7 +305,7 @@ impl fmt::Display for BrowsingContextId { thread_local!(pub static TOP_LEVEL_BROWSING_CONTEXT_ID: Cell> = Cell::new(None)); -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize)] pub struct TopLevelBrowsingContextId(BrowsingContextId); impl TopLevelBrowsingContextId { @@ -362,7 +362,7 @@ pub const TEST_BROWSING_CONTEXT_INDEX: BrowsingContextIndex = pub const TEST_BROWSING_CONTEXT_ID: BrowsingContextId = BrowsingContextId { namespace_id: TEST_NAMESPACE, index: TEST_BROWSING_CONTEXT_INDEX }; -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub enum FrameType { IFrame, MozBrowserIFrame, diff --git a/components/msg/lib.rs b/components/msg/lib.rs index 6181e2d3cc6..6b256d31df4 100644 --- a/components/msg/lib.rs +++ b/components/msg/lib.rs @@ -6,8 +6,8 @@ #[macro_use] extern crate bitflags; -#[macro_use] extern crate heapsize; -#[macro_use] extern crate heapsize_derive; +#[macro_use] extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; extern crate nonzero; #[macro_use] extern crate serde; extern crate webrender_api; diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index 79e4eaa4778..074cbfe7de4 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -38,7 +38,7 @@ servo-websocket = "0.19" threadpool = "1.0" time = "0.1.17" unicase = "1.4.0" -url = {version = "1.2", features = ["heap_size"]} +url = "1.2" uuid = {version = "0.5", features = ["v4"]} webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} diff --git a/components/net_traits/Cargo.toml b/components/net_traits/Cargo.toml index ccc080e5863..c7259c1f98e 100644 --- a/components/net_traits/Cargo.toml +++ b/components/net_traits/Cargo.toml @@ -11,19 +11,19 @@ path = "lib.rs" [dependencies] cookie = "0.6" -heapsize = "0.4" -heapsize_derive = "0.1" hyper = "0.10" hyper_serde = "0.7" image = "0.16" ipc-channel = "0.9" lazy_static = "0.2" log = "0.3.5" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } msg = {path = "../msg"} num-traits = "0.1.32" serde = "1.0" servo_config = {path = "../config"} servo_url = {path = "../url"} -url = {version = "1.2", features = ["heap_size"]} +url = "1.2" uuid = {version = "0.5", features = ["v4", "serde"]} webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} diff --git a/components/net_traits/image/base.rs b/components/net_traits/image/base.rs index 0c6e023cece..40b4d5d3c47 100644 --- a/components/net_traits/image/base.rs +++ b/components/net_traits/image/base.rs @@ -7,7 +7,7 @@ use piston_image::{self, DynamicImage, ImageFormat}; use std::fmt; use webrender_api; -#[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)] pub enum PixelFormat { /// Luminance channel only K8, @@ -19,14 +19,14 @@ pub enum PixelFormat { BGRA8, } -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct Image { pub width: u32, pub height: u32, pub format: PixelFormat, - #[ignore_heap_size_of = "Defined in ipc-channel"] + #[ignore_malloc_size_of = "Defined in ipc-channel"] pub bytes: IpcSharedMemory, - #[ignore_heap_size_of = "Defined in webrender_api"] + #[ignore_malloc_size_of = "Defined in webrender_api"] pub id: Option, } @@ -37,7 +37,7 @@ impl fmt::Debug for Image { } } -#[derive(Clone, Debug, Deserialize, Eq, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)] pub struct ImageMetadata { pub width: u32, pub height: u32, diff --git a/components/net_traits/image_cache.rs b/components/net_traits/image_cache.rs index 6fe86462a38..85db0793148 100644 --- a/components/net_traits/image_cache.rs +++ b/components/net_traits/image_cache.rs @@ -23,9 +23,9 @@ pub enum CanRequestImages { } /// Indicating either entire image or just metadata availability -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub enum ImageOrMetadataAvailable { - ImageAvailable(Arc, ServoUrl), + ImageAvailable(#[ignore_malloc_size_of = "Arc"] Arc, ServoUrl), MetadataAvailable(ImageMetadata), } @@ -60,14 +60,14 @@ impl ImageResponder { } /// The returned image. -#[derive(Clone, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub enum ImageResponse { /// The requested image was loaded. - Loaded(Arc, ServoUrl), + Loaded(#[ignore_malloc_size_of = "Arc"] Arc, ServoUrl), /// The request image metadata was loaded. MetadataLoaded(ImageMetadata), /// The requested image failed to load, so a placeholder was loaded instead. - PlaceholderLoaded(Arc, ServoUrl), + PlaceholderLoaded(#[ignore_malloc_size_of = "Arc"] Arc, ServoUrl), /// Neither the requested image nor the placeholder could be loaded. None, } @@ -81,7 +81,7 @@ pub enum ImageState { } /// The unique id for an image that has previously been requested. -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub struct PendingImageId(pub u64); #[derive(Debug, Deserialize, Serialize)] diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index 05b9b85b811..0c0b1148b7a 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -6,14 +6,14 @@ #![deny(unsafe_code)] extern crate cookie as cookie_rs; -extern crate heapsize; -#[macro_use] extern crate heapsize_derive; extern crate hyper; extern crate hyper_serde; extern crate image as piston_image; extern crate ipc_channel; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; +#[macro_use] extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; extern crate msg; extern crate num_traits; #[macro_use] extern crate serde; @@ -25,7 +25,6 @@ extern crate webrender_api; use cookie_rs::Cookie; use filemanager_thread::FileManagerThreadMsg; -use heapsize::HeapSizeOf; use hyper::Error as HyperError; use hyper::header::{ContentType, Headers, ReferrerPolicy as ReferrerPolicyHeader}; use hyper::http::RawStatus; @@ -60,7 +59,7 @@ pub mod image { /// A loading context, for context-specific sniffing, as defined in /// -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub enum LoadContext { Browsing, Image, @@ -73,13 +72,13 @@ pub enum LoadContext { CacheManifest, } -#[derive(Clone, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub struct CustomResponse { - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] #[serde(deserialize_with = "::hyper_serde::deserialize", serialize_with = "::hyper_serde::serialize")] pub headers: Headers, - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] #[serde(deserialize_with = "::hyper_serde::deserialize", serialize_with = "::hyper_serde::serialize")] pub raw_status: RawStatus, @@ -104,7 +103,7 @@ pub struct CustomResponseMediator { /// [Policies](https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-states) /// for providing a referrer header for a request -#[derive(Clone, Copy, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, Serialize)] pub enum ReferrerPolicy { /// "no-referrer" NoReferrer, @@ -310,11 +309,7 @@ impl IpcSend for ResourceThreads { } // Ignore the sub-fields -impl HeapSizeOf for ResourceThreads { - fn heap_size_of_children(&self) -> usize { - 0 - } -} +malloc_size_of_is_0!(ResourceThreads); #[derive(Clone, Copy, Deserialize, PartialEq, Serialize)] pub enum IncludeSubdomains { @@ -322,7 +317,7 @@ pub enum IncludeSubdomains { NotIncluded, } -#[derive(Deserialize, HeapSizeOf, Serialize)] +#[derive(Deserialize, MallocSizeOf, Serialize)] pub enum MessageData { Text(String), Binary(Vec), @@ -395,7 +390,7 @@ pub fn fetch_async(request: RequestInit, core_resource_thread: &CoreResourceT core_resource_thread.send(CoreResourceMsg::Fetch(request, action_sender)).unwrap(); } -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct ResourceCorsData { /// CORS Preflight flag pub preflight: bool, @@ -404,7 +399,7 @@ pub struct ResourceCorsData { } /// Metadata about a loaded resource, such as is obtained from HTTP headers. -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct Metadata { /// Final URL after redirects. pub final_url: ServoUrl, @@ -412,14 +407,14 @@ pub struct Metadata { /// Location URL from the response headers. pub location_url: Option>, - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] /// MIME type / subtype. pub content_type: Option>, /// Character set. pub charset: Option, - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] /// Headers pub headers: Option>, @@ -509,11 +504,11 @@ pub fn load_whole_resource(request: RequestInit, } /// An unique identifier to keep track of each load message in the resource handler -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub struct ResourceId(pub u32); /// Network errors that have to be exported out of the loaders -#[derive(Clone, Debug, Deserialize, Eq, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)] pub enum NetworkError { /// Could be any of the internal errors, like unsupported scheme, connection errors, etc. Internal(String), diff --git a/components/net_traits/request.rs b/components/net_traits/request.rs index 55a6a030a28..409ff756daa 100644 --- a/components/net_traits/request.rs +++ b/components/net_traits/request.rs @@ -10,7 +10,7 @@ use servo_url::{ImmutableOrigin, ServoUrl}; use std::default::Default; /// An [initiator](https://fetch.spec.whatwg.org/#concept-request-initiator) -#[derive(Clone, Copy, HeapSizeOf, PartialEq)] +#[derive(Clone, Copy, MallocSizeOf, PartialEq)] pub enum Initiator { None, Download, @@ -20,7 +20,7 @@ pub enum Initiator { } /// A request [type](https://fetch.spec.whatwg.org/#concept-request-type) -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum Type { None, Audio, @@ -33,7 +33,7 @@ pub enum Type { } /// A request [destination](https://fetch.spec.whatwg.org/#concept-request-destination) -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum Destination { None, Document, @@ -53,14 +53,14 @@ pub enum Destination { } /// A request [origin](https://fetch.spec.whatwg.org/#concept-request-origin) -#[derive(Clone, Debug, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum Origin { Client, Origin(ImmutableOrigin), } /// A [referer](https://fetch.spec.whatwg.org/#concept-request-referrer) -#[derive(Clone, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum Referrer { NoReferrer, /// Default referrer if nothing is specified @@ -69,7 +69,7 @@ pub enum Referrer { } /// A [request mode](https://fetch.spec.whatwg.org/#concept-request-mode) -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum RequestMode { Navigate, SameOrigin, @@ -79,7 +79,7 @@ pub enum RequestMode { } /// Request [credentials mode](https://fetch.spec.whatwg.org/#concept-request-credentials-mode) -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum CredentialsMode { Omit, CredentialsSameOrigin, @@ -87,7 +87,7 @@ pub enum CredentialsMode { } /// [Cache mode](https://fetch.spec.whatwg.org/#concept-request-cache-mode) -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum CacheMode { Default, NoStore, @@ -98,7 +98,7 @@ pub enum CacheMode { } /// [Service-workers mode](https://fetch.spec.whatwg.org/#request-service-workers-mode) -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum ServiceWorkersMode { All, Foreign, @@ -106,7 +106,7 @@ pub enum ServiceWorkersMode { } /// [Redirect mode](https://fetch.spec.whatwg.org/#concept-request-redirect-mode) -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum RedirectMode { Follow, Error, @@ -114,7 +114,7 @@ pub enum RedirectMode { } /// [Response tainting](https://fetch.spec.whatwg.org/#concept-request-response-tainting) -#[derive(Clone, Copy, HeapSizeOf, PartialEq)] +#[derive(Clone, Copy, MallocSizeOf, PartialEq)] pub enum ResponseTainting { Basic, CorsTainting, @@ -122,7 +122,7 @@ pub enum ResponseTainting { } /// [Window](https://fetch.spec.whatwg.org/#concept-request-window) -#[derive(Clone, Copy, HeapSizeOf, PartialEq)] +#[derive(Clone, Copy, MallocSizeOf, PartialEq)] pub enum Window { NoWindow, Client, // TODO: Environmental settings object @@ -135,16 +135,16 @@ pub enum CorsSettings { UseCredentials, } -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct RequestInit { #[serde(deserialize_with = "::hyper_serde::deserialize", serialize_with = "::hyper_serde::serialize")] - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] pub method: Method, pub url: ServoUrl, #[serde(deserialize_with = "::hyper_serde::deserialize", serialize_with = "::hyper_serde::serialize")] - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] pub headers: Headers, pub unsafe_request: bool, pub body: Option>, @@ -199,17 +199,17 @@ impl Default for RequestInit { /// A [Request](https://fetch.spec.whatwg.org/#concept-request) as defined by /// the Fetch spec. -#[derive(Clone, HeapSizeOf)] +#[derive(Clone, MallocSizeOf)] pub struct Request { /// - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] pub method: Method, /// pub local_urls_only: bool, /// pub sandboxed_storage_area_urls: bool, /// - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] pub headers: Headers, /// pub unsafe_request: bool, diff --git a/components/net_traits/response.rs b/components/net_traits/response.rs index a034067455b..f17279b93dd 100644 --- a/components/net_traits/response.rs +++ b/components/net_traits/response.rs @@ -13,7 +13,7 @@ use std::ascii::AsciiExt; use std::sync::{Arc, Mutex}; /// [Response type](https://fetch.spec.whatwg.org/#concept-response-type) -#[derive(Clone, Debug, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum ResponseType { Basic, Cors, @@ -24,7 +24,7 @@ pub enum ResponseType { } /// [Response termination reason](https://fetch.spec.whatwg.org/#concept-response-termination-reason) -#[derive(Clone, Copy, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, Serialize)] pub enum TerminationReason { EndUserAbort, Fatal, @@ -33,7 +33,7 @@ pub enum TerminationReason { /// The response body can still be pushed to after fetch /// This provides a way to store unfinished response bodies -#[derive(Clone, Debug, HeapSizeOf, PartialEq)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub enum ResponseBody { Empty, // XXXManishearth is this necessary, or is Done(vec![]) enough? Receiving(Vec), @@ -52,7 +52,7 @@ impl ResponseBody { /// [Cache state](https://fetch.spec.whatwg.org/#concept-response-cache-state) -#[derive(Clone, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub enum CacheState { None, Local, @@ -61,7 +61,7 @@ pub enum CacheState { } /// [Https state](https://fetch.spec.whatwg.org/#concept-response-https-state) -#[derive(Clone, Copy, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, Serialize)] pub enum HttpsState { None, Deprecated, @@ -74,31 +74,31 @@ pub enum ResponseMsg { Errored, } -#[derive(Clone, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct ResponseInit { pub url: ServoUrl, #[serde(deserialize_with = "::hyper_serde::deserialize", serialize_with = "::hyper_serde::serialize")] - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] pub headers: Headers, pub referrer: Option, pub location_url: Option>, } /// A [Response](https://fetch.spec.whatwg.org/#concept-response) as defined by the Fetch spec -#[derive(Clone, Debug, HeapSizeOf)] +#[derive(Clone, Debug, MallocSizeOf)] pub struct Response { pub response_type: ResponseType, pub termination_reason: Option, url: Option, pub url_list: Vec, /// `None` can be considered a StatusCode of `0`. - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] pub status: Option, pub raw_status: Option<(u16, Vec)>, - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] pub headers: Headers, - #[ignore_heap_size_of = "Mutex heap size undefined"] + #[ignore_malloc_size_of = "Mutex heap size undefined"] pub body: Arc>, pub cache_state: CacheState, pub https_state: HttpsState, diff --git a/components/net_traits/storage_thread.rs b/components/net_traits/storage_thread.rs index e338773a53a..12047d08443 100644 --- a/components/net_traits/storage_thread.rs +++ b/components/net_traits/storage_thread.rs @@ -5,7 +5,7 @@ use ipc_channel::ipc::IpcSender; use servo_url::ServoUrl; -#[derive(Clone, Copy, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, Serialize)] pub enum StorageType { Session, Local, diff --git a/components/profile_traits/mem.rs b/components/profile_traits/mem.rs index 3f134c15faf..7938950b77f 100644 --- a/components/profile_traits/mem.rs +++ b/components/profile_traits/mem.rs @@ -79,7 +79,7 @@ impl ProfilerChan { #[derive(Deserialize, Serialize)] pub enum ReportKind { /// A size measurement for an explicit allocation on the jemalloc heap. This should be used - /// for any measurements done via the `HeapSizeOf` trait. + /// for any measurements done via the `MallocSizeOf` trait. ExplicitJemallocHeapSize, /// A size measurement for an explicit allocation on the system heap. Only likely to be used diff --git a/components/range/Cargo.toml b/components/range/Cargo.toml index 1b2e0681286..cdfc0615266 100644 --- a/components/range/Cargo.toml +++ b/components/range/Cargo.toml @@ -11,7 +11,7 @@ name = "range" path = "lib.rs" [dependencies] -heapsize = "0.4" -heapsize_derive = "0.1" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } num-traits = "0.1.32" serde = "1.0" diff --git a/components/range/lib.rs b/components/range/lib.rs index d125c88f817..6088d006989 100644 --- a/components/range/lib.rs +++ b/components/range/lib.rs @@ -4,8 +4,8 @@ #![deny(unsafe_code)] -extern crate heapsize; -#[macro_use] extern crate heapsize_derive; +extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; extern crate num_traits; #[macro_use] extern crate serde; @@ -146,7 +146,7 @@ macro_rules! int_range_index { } /// A range of indices -#[derive(Clone, Copy, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, Serialize)] pub struct Range { begin: I, length: I, diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 7e0c4068cec..8c9e9613ede 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -44,9 +44,7 @@ euclid = "0.15" fnv = "1.0" gleam = "0.4" half = "1.0" -heapsize = "0.4" -heapsize_derive = "0.1" -html5ever = {version = "0.20", features = ["heap_size"]} +html5ever = "0.20" hyper = "0.10" hyper_serde = "0.7" image = "0.16" @@ -56,6 +54,8 @@ jstraceable_derive = {path = "../jstraceable_derive"} lazy_static = "0.2" libc = "0.2" log = "0.3.5" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } metrics = {path = "../metrics"} mitochondria = "1.1.2" mime = "0.2.1" @@ -89,7 +89,7 @@ style_traits = {path = "../style_traits"} swapper = "0.1" time = "0.1.12" unicode-segmentation = "1.1.0" -url = {version = "1.2", features = ["heap_size", "query_encoding"]} +url = {version = "1.2", features = ["query_encoding"]} utf-8 = "0.7" uuid = {version = "0.5", features = ["v4"]} xml5ever = {version = "0.10"} diff --git a/components/script/body.rs b/components/script/body.rs index bdeff81e163..21c4d49b58c 100644 --- a/components/script/body.rs +++ b/components/script/body.rs @@ -22,7 +22,7 @@ use std::rc::Rc; use std::str; use url::form_urlencoded; -#[derive(Clone, Copy, HeapSizeOf, JSTraceable)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf)] pub enum BodyType { Blob, FormData, diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs index f9a4325fbad..a50cea265fd 100644 --- a/components/script/document_loader.rs +++ b/components/script/document_loader.rs @@ -14,7 +14,7 @@ use net_traits::request::RequestInit; use servo_url::ServoUrl; use std::thread; -#[derive(Clone, Debug, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)] pub enum LoadType { Image(ServoUrl), Script(ServoUrl), @@ -40,7 +40,7 @@ impl LoadType { /// Canary value ensuring that manually added blocking loads (ie. ones that weren't /// created via DocumentLoader::fetch_async) are always removed by the time /// that the owner is destroyed. -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] pub struct LoadBlocker { /// The document whose load event is blocked by this object existing. @@ -81,7 +81,7 @@ impl Drop for LoadBlocker { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct DocumentLoader { resource_threads: ResourceThreads, blocking_loads: Vec, diff --git a/components/script/dom/bindings/cell.rs b/components/script/dom/bindings/cell.rs index 2235e3ac769..3ba4fad6c66 100644 --- a/components/script/dom/bindings/cell.rs +++ b/components/script/dom/bindings/cell.rs @@ -11,7 +11,7 @@ use style::thread_state; /// /// This extends the API of `std::cell::RefCell` to allow unsafe access in /// certain situations, with dynamic checking in debug builds. -#[derive(Clone, Debug, Default, HeapSizeOf, PartialEq)] +#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq)] pub struct DomRefCell { value: RefCell, } diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index d0b5e678db8..3251290f398 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2029,7 +2029,7 @@ def DOMClass(descriptor): # padding. protoList.extend(['PrototypeList::ID::Last'] * (descriptor.config.maxProtoChainLength - len(protoList))) prototypeChainString = ', '.join(protoList) - heapSizeOf = 'heap_size_of_raw_self_and_children::<%s>' % descriptor.concreteType + mallocSizeOf = 'malloc_size_of_including_raw_self::<%s>' % descriptor.concreteType if descriptor.isGlobal(): globals_ = camel_to_upper_snake(descriptor.name) else: @@ -2038,9 +2038,9 @@ def DOMClass(descriptor): DOMClass { interface_chain: [ %s ], type_id: %s, - heap_size_of: %s as unsafe fn(_) -> _, + malloc_size_of: %s as unsafe fn(&mut _, _) -> _, global: InterfaceObjectMap::%s, -}""" % (prototypeChainString, DOMClassTypeId(descriptor), heapSizeOf, globals_) +}""" % (prototypeChainString, DOMClassTypeId(descriptor), mallocSizeOf, globals_) class CGDOMJSClass(CGThing): @@ -4005,7 +4005,7 @@ class CGEnum(CGThing): ident = enum.identifier.name decl = """\ #[repr(usize)] -#[derive(JSTraceable, PartialEq, Copy, Clone, HeapSizeOf, Debug)] +#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)] pub enum %s { %s } @@ -5794,7 +5794,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries 'dom::bindings::weakref::WeakReferenceable', 'dom::windowproxy::WindowProxy', 'dom::globalscope::GlobalScope', - 'mem::heap_size_of_raw_self_and_children', + 'mem::malloc_size_of_including_raw_self', 'libc', 'servo_config::prefs::PREFS', 'std::borrow::ToOwned', diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs index 2cbbe2da647..9ff6aa92429 100644 --- a/components/script/dom/bindings/error.rs +++ b/components/script/dom/bindings/error.rs @@ -25,7 +25,7 @@ use libc::c_uint; use std::slice::from_raw_parts; /// DOM exceptions that can be thrown by a native DOM method. -#[derive(Clone, Debug, HeapSizeOf)] +#[derive(Clone, Debug, MallocSizeOf)] pub enum Error { /// IndexSizeError DOMException IndexSize, diff --git a/components/script/dom/bindings/iterable.rs b/components/script/dom/bindings/iterable.rs index 779695918c9..183c17a2578 100644 --- a/components/script/dom/bindings/iterable.rs +++ b/components/script/dom/bindings/iterable.rs @@ -22,7 +22,7 @@ use std::cell::Cell; use std::ptr; /// The values that an iterator will iterate over. -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub enum IteratorType { /// The keys of the iterable object. Keys, diff --git a/components/script/dom/bindings/num.rs b/components/script/dom/bindings/num.rs index f7604cfab20..79480574f4d 100644 --- a/components/script/dom/bindings/num.rs +++ b/components/script/dom/bindings/num.rs @@ -4,7 +4,7 @@ //! The `Finite` struct. -use heapsize::HeapSizeOf; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use num_traits::Float; use std::default::Default; use std::ops::Deref; @@ -41,9 +41,9 @@ impl Deref for Finite { } } -impl HeapSizeOf for Finite { - fn heap_size_of_children(&self) -> usize { - (**self).heap_size_of_children() +impl MallocSizeOf for Finite { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + (**self).size_of(ops) } } diff --git a/components/script/dom/bindings/reflector.rs b/components/script/dom/bindings/reflector.rs index 6a47b7d3c07..0fef0a30678 100644 --- a/components/script/dom/bindings/reflector.rs +++ b/components/script/dom/bindings/reflector.rs @@ -27,11 +27,11 @@ pub fn reflect_dom_object( /// A struct to store a reference to the reflector of a DOM object. #[allow(unrooted_must_root)] -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] #[must_root] // If you're renaming or moving this field, update the path in plugins::reflector as well pub struct Reflector { - #[ignore_heap_size_of = "defined and measured in rust-mozjs"] + #[ignore_malloc_size_of = "defined and measured in rust-mozjs"] object: Heap<*mut JSObject>, } diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index e2c474cafd5..636c14b4d5c 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -30,9 +30,9 @@ use dom::bindings::reflector::{DomObject, Reflector}; use dom::bindings::trace::JSTraceable; use dom::bindings::trace::trace_reflector; use dom::node::Node; -use heapsize::HeapSizeOf; use js::jsapi::{JSObject, JSTracer, Heap}; use js::rust::GCMethods; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use mitochondria::OnceCell; use nonzero::NonZero; use script_layout_interface::TrustedNodeAddress; @@ -157,12 +157,12 @@ impl DomRoot { } } -impl HeapSizeOf for DomRoot +impl MallocSizeOf for DomRoot where - T: DomObject + HeapSizeOf, + T: DomObject + MallocSizeOf, { - fn heap_size_of_children(&self) -> usize { - (**self).heap_size_of_children() + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + (**self).size_of(ops) } } @@ -317,8 +317,8 @@ pub struct Dom { // Dom is similar to Rc, in that it's not always clear how to avoid double-counting. // For now, we choose not to follow any such pointers. -impl HeapSizeOf for Dom { - fn heap_size_of_children(&self) -> usize { +impl MallocSizeOf for Dom { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { 0 } } @@ -516,9 +516,9 @@ impl MutDom { } } -impl HeapSizeOf for MutDom { - fn heap_size_of_children(&self) -> usize { - // See comment on HeapSizeOf for Dom. +impl MallocSizeOf for MutDom { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { + // See comment on MallocSizeOf for Dom. 0 } } @@ -635,9 +635,9 @@ impl Default for MutNullableDom { } } -impl HeapSizeOf for MutNullableDom { - fn heap_size_of_children(&self) -> usize { - // See comment on HeapSizeOf for Dom. +impl MallocSizeOf for MutNullableDom { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { + // See comment on MallocSizeOf for Dom. 0 } } @@ -678,9 +678,9 @@ impl Default for DomOnceCell { } } -impl HeapSizeOf for DomOnceCell { - fn heap_size_of_children(&self) -> usize { - // See comment on HeapSizeOf for Dom. +impl MallocSizeOf for DomOnceCell { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { + // See comment on MallocSizeOf for Dom. 0 } } diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs index b665b64da8a..af33f662ff7 100644 --- a/components/script/dom/bindings/str.rs +++ b/components/script/dom/bindings/str.rs @@ -19,7 +19,7 @@ use std::str; use std::str::{Bytes, FromStr}; /// Encapsulates the IDL `ByteString` type. -#[derive(Clone, Debug, Default, Eq, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Debug, Default, Eq, JSTraceable, MallocSizeOf, PartialEq)] pub struct ByteString(Vec); impl ByteString { @@ -78,7 +78,7 @@ impl ops::Deref for ByteString { /// A string that is constructed from a UCS-2 buffer by replacing invalid code /// points with the replacement character. -#[derive(Clone, Default, HeapSizeOf)] +#[derive(Clone, Default, MallocSizeOf)] pub struct USVString(pub String); @@ -153,7 +153,7 @@ pub fn is_token(s: &[u8]) -> bool { /// /// This type is currently `!Send`, in order to help with an independent /// experiment to store `JSString`s rather than Rust `String`s. -#[derive(Clone, Debug, Eq, Hash, HeapSizeOf, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd)] pub struct DOMString(String, PhantomData<*const ()>); impl DOMString { diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 5ecca038de9..2a23281c8fe 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -13,7 +13,6 @@ use dom::bindings::inheritance::TopTypeId; use dom::bindings::str::DOMString; use dom::bindings::trace::trace_object; use dom::windowproxy; -use heapsize::HeapSizeOf; use js; use js::JS_CALLEE; use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper}; @@ -32,6 +31,7 @@ use js::jsapi::{JS_StringHasLatin1Chars, MutableHandleValue, ObjectOpResult}; use js::jsval::{JSVal, UndefinedValue}; use js::rust::{GCMethods, ToString, get_object_class, is_dom_class}; use libc; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use std::ffi::CString; use std::os::raw::{c_char, c_void}; use std::ptr; @@ -40,14 +40,14 @@ use std::slice; /// Proxy handler for a WindowProxy. pub struct WindowProxyHandler(pub *const libc::c_void); -impl HeapSizeOf for WindowProxyHandler { - fn heap_size_of_children(&self) -> usize { +impl MallocSizeOf for WindowProxyHandler { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { // FIXME(#6907) this is a pointer to memory allocated by `new` in NewProxyHandler in rust-mozjs. 0 } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] /// Static data associated with a global object. pub struct GlobalStaticData { /// The WindowProxy proxy handler for this global. @@ -88,8 +88,8 @@ pub struct DOMClass { /// The type ID of that interface. pub type_id: TopTypeId, - /// The HeapSizeOf function wrapper for that interface. - pub heap_size_of: unsafe fn(*const c_void) -> usize, + /// The MallocSizeOf function wrapper for that interface. + pub malloc_size_of: unsafe fn(ops: &mut MallocSizeOfOps, *const c_void) -> usize, /// The `Globals` flag for this global interface, if any. pub global: InterfaceObjectMap::Globals, diff --git a/components/script/dom/bindings/weakref.rs b/components/script/dom/bindings/weakref.rs index 36eac4c4f32..2aa12490867 100644 --- a/components/script/dom/bindings/weakref.rs +++ b/components/script/dom/bindings/weakref.rs @@ -14,10 +14,10 @@ use dom::bindings::reflector::DomObject; use dom::bindings::root::DomRoot; use dom::bindings::trace::JSTraceable; -use heapsize::HeapSizeOf; use js::jsapi::{JSTracer, JS_GetReservedSlot, JS_SetReservedSlot}; use js::jsval::PrivateValue; use libc::c_void; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use nonzero::NonZero; use std::cell::{Cell, UnsafeCell}; use std::mem; @@ -110,8 +110,8 @@ impl Clone for WeakRef { } } -impl HeapSizeOf for WeakRef { - fn heap_size_of_children(&self) -> usize { +impl MallocSizeOf for WeakRef { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { 0 } } @@ -188,8 +188,8 @@ impl MutableWeakRef { } } -impl HeapSizeOf for MutableWeakRef { - fn heap_size_of_children(&self) -> usize { +impl MallocSizeOf for MutableWeakRef { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { 0 } } @@ -210,7 +210,7 @@ unsafe impl JSTraceable for MutableWeakRef { /// A vector of weak references. On tracing, the vector retains /// only references which still point to live objects. #[allow_unrooted_interior] -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] pub struct WeakRefVec { vec: Vec>, } diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index a436564f4f2..394efd4647d 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -69,7 +69,7 @@ impl BlobImpl { #[dom_struct] pub struct Blob { reflector_: Reflector, - #[ignore_heap_size_of = "No clear owner"] + #[ignore_malloc_size_of = "No clear owner"] blob_impl: DomRefCell, /// content-type string type_string: String, diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index f9ab60ec59c..44cf83df5d8 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -56,13 +56,13 @@ const OPTIONS_ERROR: &'static str = "Fields of 'options' conflict with each othe Either 'acceptAllDevices' member must be true, or 'filters' member must be set to a value."; const BT_DESC_CONVERSION_ERROR: &'static str = "Can't convert to an IDL value of type BluetoothPermissionDescriptor"; -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct AllowedBluetoothDevice { pub deviceId: DOMString, pub mayUseGATT: bool, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct BluetoothExtraPermissionData { allowed_devices: DomRefCell>, } diff --git a/components/script/dom/canvasgradient.rs b/components/script/dom/canvasgradient.rs index 6ae52be6764..ab6ad47d905 100644 --- a/components/script/dom/canvasgradient.rs +++ b/components/script/dom/canvasgradient.rs @@ -24,7 +24,7 @@ pub struct CanvasGradient { stops: DomRefCell>, } -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] pub enum CanvasGradientStyle { Linear(LinearGradientStyle), Radial(RadialGradientStyle), diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 69cf670efe4..cf6b92bc404 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -51,7 +51,7 @@ use std::sync::Arc; use unpremultiplytable::UNPREMULTIPLY_TABLE; #[must_root] -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] #[allow(dead_code)] enum CanvasFillOrStrokeStyle { Color(RGBA), @@ -63,12 +63,12 @@ enum CanvasFillOrStrokeStyle { #[dom_struct] pub struct CanvasRenderingContext2D { reflector_: Reflector, - #[ignore_heap_size_of = "Defined in ipc-channel"] + #[ignore_malloc_size_of = "Defined in ipc-channel"] ipc_renderer: IpcSender, /// For rendering contexts created by an HTML canvas element, this is Some, /// for ones created by a paint worklet, this is None. canvas: Option>, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] image_cache: Arc, /// Any missing image URLs. missing_image_urls: DomRefCell>, @@ -81,7 +81,7 @@ pub struct CanvasRenderingContext2D { } #[must_root] -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] struct CanvasContextState { global_alpha: f64, global_composition: CompositionOrBlending, diff --git a/components/script/dom/client.rs b/components/script/dom/client.rs index 94ddc15535f..7c68daecdb3 100644 --- a/components/script/dom/client.rs +++ b/components/script/dom/client.rs @@ -20,7 +20,7 @@ pub struct Client { active_worker: MutNullableDom, url: ServoUrl, frame_type: FrameType, - #[ignore_heap_size_of = "Defined in uuid"] + #[ignore_malloc_size_of = "Defined in uuid"] id: Uuid } diff --git a/components/script/dom/crypto.rs b/components/script/dom/crypto.rs index ac56e9f3ff6..1a13194151c 100644 --- a/components/script/dom/crypto.rs +++ b/components/script/dom/crypto.rs @@ -21,7 +21,7 @@ unsafe_no_jsmanaged_fields!(ServoRng); #[dom_struct] pub struct Crypto { reflector_: Reflector, - #[ignore_heap_size_of = "Defined in rand"] + #[ignore_malloc_size_of = "Defined in rand"] rng: DomRefCell, } diff --git a/components/script/dom/cssfontfacerule.rs b/components/script/dom/cssfontfacerule.rs index 3bc836897ea..8f2970abc39 100644 --- a/components/script/dom/cssfontfacerule.rs +++ b/components/script/dom/cssfontfacerule.rs @@ -17,7 +17,7 @@ use style::stylesheets::FontFaceRule; #[dom_struct] pub struct CSSFontFaceRule { cssrule: CSSRule, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] fontfacerule: Arc>, } diff --git a/components/script/dom/cssgroupingrule.rs b/components/script/dom/cssgroupingrule.rs index dec666c825e..21c744118ea 100644 --- a/components/script/dom/cssgroupingrule.rs +++ b/components/script/dom/cssgroupingrule.rs @@ -19,7 +19,7 @@ use style::stylesheets::CssRules as StyleCssRules; #[dom_struct] pub struct CSSGroupingRule { cssrule: CSSRule, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] rules: Arc>, rulelist: MutNullableDom, } diff --git a/components/script/dom/cssimportrule.rs b/components/script/dom/cssimportrule.rs index 373c230ee77..989917700ac 100644 --- a/components/script/dom/cssimportrule.rs +++ b/components/script/dom/cssimportrule.rs @@ -17,7 +17,7 @@ use style::stylesheets::ImportRule; #[dom_struct] pub struct CSSImportRule { cssrule: CSSRule, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] import_rule: Arc>, } diff --git a/components/script/dom/csskeyframerule.rs b/components/script/dom/csskeyframerule.rs index f62d73f0b46..63ec6e1d016 100644 --- a/components/script/dom/csskeyframerule.rs +++ b/components/script/dom/csskeyframerule.rs @@ -19,7 +19,7 @@ use style::stylesheets::keyframes_rule::Keyframe; #[dom_struct] pub struct CSSKeyframeRule { cssrule: CSSRule, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] keyframerule: Arc>, style_decl: MutNullableDom, } diff --git a/components/script/dom/csskeyframesrule.rs b/components/script/dom/csskeyframesrule.rs index 955f0c04fb5..7f1c212057d 100644 --- a/components/script/dom/csskeyframesrule.rs +++ b/components/script/dom/csskeyframesrule.rs @@ -24,7 +24,7 @@ use style::values::KeyframesName; #[dom_struct] pub struct CSSKeyframesRule { cssrule: CSSRule, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] keyframesrule: Arc>, rulelist: MutNullableDom, } diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index 3444d494f16..dc4a4c411a5 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -25,7 +25,7 @@ use style_traits::{PARSING_MODE_DEFAULT, ToCss}; #[dom_struct] pub struct CSSMediaRule { cssconditionrule: CSSConditionRule, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] mediarule: Arc>, medialist: MutNullableDom, } diff --git a/components/script/dom/cssnamespacerule.rs b/components/script/dom/cssnamespacerule.rs index 40047252680..f585f420732 100644 --- a/components/script/dom/cssnamespacerule.rs +++ b/components/script/dom/cssnamespacerule.rs @@ -18,7 +18,7 @@ use style::stylesheets::NamespaceRule; #[dom_struct] pub struct CSSNamespaceRule { cssrule: CSSRule, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] namespacerule: Arc>, } diff --git a/components/script/dom/cssrulelist.rs b/components/script/dom/cssrulelist.rs index 81b58afc0f8..1f800a6a0b4 100644 --- a/components/script/dom/cssrulelist.rs +++ b/components/script/dom/cssrulelist.rs @@ -37,7 +37,7 @@ impl From for Error { pub struct CSSRuleList { reflector_: Reflector, parent_stylesheet: Dom, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] rules: RulesSource, dom_rules: DomRefCell>> } diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index f7264d9f5d0..e20d4e82e3f 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -33,12 +33,12 @@ pub struct CSSStyleDeclaration { pseudo: Option, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] pub enum CSSStyleOwner { Element(Dom), CSSRule(Dom, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] Arc>), } @@ -154,7 +154,7 @@ impl CSSStyleOwner { } } -#[derive(HeapSizeOf, PartialEq)] +#[derive(MallocSizeOf, PartialEq)] pub enum CSSModificationAccess { ReadWrite, Readonly, diff --git a/components/script/dom/cssstylerule.rs b/components/script/dom/cssstylerule.rs index 7c73bbc58c3..0e9f001dc05 100644 --- a/components/script/dom/cssstylerule.rs +++ b/components/script/dom/cssstylerule.rs @@ -25,7 +25,7 @@ use style::stylesheets::{StyleRule, Origin}; #[dom_struct] pub struct CSSStyleRule { cssrule: CSSRule, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] stylerule: Arc>, style_decl: MutNullableDom, } diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs index de3d3cc0f6d..d393b1f3ff7 100644 --- a/components/script/dom/cssstylesheet.rs +++ b/components/script/dom/cssstylesheet.rs @@ -24,7 +24,7 @@ pub struct CSSStyleSheet { stylesheet: StyleSheet, owner: Dom, rulelist: MutNullableDom, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] style_stylesheet: Arc, origin_clean: Cell, } diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index 0f6a6530233..d9e3f8ac8a0 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -23,7 +23,7 @@ use style_traits::{PARSING_MODE_DEFAULT, ToCss}; #[dom_struct] pub struct CSSSupportsRule { cssconditionrule: CSSConditionRule, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] supportsrule: Arc>, } diff --git a/components/script/dom/cssviewportrule.rs b/components/script/dom/cssviewportrule.rs index 694636be323..89e523cdc39 100644 --- a/components/script/dom/cssviewportrule.rs +++ b/components/script/dom/cssviewportrule.rs @@ -17,7 +17,7 @@ use style::stylesheets::ViewportRule; #[dom_struct] pub struct CSSViewportRule { cssrule: CSSRule, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] viewportrule: Arc>, } diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index 319424a25ff..21276d8f5bb 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -47,12 +47,12 @@ pub struct CustomElementRegistry { window: Dom, - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] when_defined: DomRefCell>>, element_definition_is_running: Cell, - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] definitions: DomRefCell>>, } @@ -369,35 +369,35 @@ impl CustomElementRegistryMethods for CustomElementRegistry { } } -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] pub struct LifecycleCallbacks { - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] connected_callback: Option>, - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] disconnected_callback: Option>, - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] adopted_callback: Option>, - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] attribute_changed_callback: Option>, } -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] pub enum ConstructionStackEntry { Element(DomRoot), AlreadyConstructedMarker, } /// -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] pub struct CustomElementDefinition { pub name: LocalName, pub local_name: LocalName, - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] pub constructor: Rc, pub observed_attributes: Vec, @@ -580,15 +580,15 @@ pub fn try_upgrade_element(element: &Element) { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] pub enum CustomElementReaction { Upgrade( - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] Rc ), Callback( - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] Rc, Box<[Heap]> ), @@ -617,14 +617,14 @@ pub enum CallbackReaction { } /// -#[derive(Clone, Copy, Eq, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Eq, JSTraceable, MallocSizeOf, PartialEq)] enum BackupElementQueueFlag { Processing, NotProcessing, } /// -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] pub struct CustomElementReactionStack { stack: DomRefCell>, @@ -773,7 +773,7 @@ impl CustomElementReactionStack { } /// -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] struct ElementQueue { queue: DomRefCell>>, diff --git a/components/script/dom/customevent.rs b/components/script/dom/customevent.rs index e78ac74bd84..ee62fd2a854 100644 --- a/components/script/dom/customevent.rs +++ b/components/script/dom/customevent.rs @@ -22,7 +22,7 @@ use servo_atoms::Atom; #[dom_struct] pub struct CustomEvent { event: Event, - #[ignore_heap_size_of = "Defined in rust-mozjs"] + #[ignore_malloc_size_of = "Defined in rust-mozjs"] detail: Heap, } diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index 33f08793b56..a754bbc4c6a 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -80,15 +80,15 @@ enum MixedMessage { #[dom_struct] pub struct DedicatedWorkerGlobalScope { workerglobalscope: WorkerGlobalScope, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] receiver: Receiver<(TrustedWorkerAddress, WorkerScriptMsg)>, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] own_sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] timer_event_port: Receiver<(TrustedWorkerAddress, TimerEvent)>, - #[ignore_heap_size_of = "Trusted has unclear ownership like Dom"] + #[ignore_malloc_size_of = "Trusted has unclear ownership like Dom"] worker: DomRefCell>, - #[ignore_heap_size_of = "Can't measure trait objects"] + #[ignore_malloc_size_of = "Can't measure trait objects"] /// Sender to the parent thread. parent_sender: Box, } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index fd8bf37a897..09212135dd2 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -158,13 +158,13 @@ pub enum TouchEventResult { Forwarded, } -#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] pub enum IsHTMLDocument { HTMLDocument, NonHTMLDocument, } -#[derive(Debug, HeapSizeOf)] +#[derive(Debug, MallocSizeOf)] pub struct PendingRestyle { /// If this element had a state or attribute change since the last restyle, track /// the original condition of the element. @@ -187,10 +187,10 @@ impl PendingRestyle { } } -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] #[must_root] struct StyleSheetInDocument { - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] sheet: Arc, owner: Dom, } @@ -228,7 +228,7 @@ pub struct Document { is_html_document: bool, activity: Cell, url: DomRefCell, - #[ignore_heap_size_of = "defined in selectors"] + #[ignore_malloc_size_of = "defined in selectors"] quirks_mode: Cell, /// Caches for the getElement methods id_map: DomRefCell>>>, @@ -321,7 +321,7 @@ pub struct Document { /// target_element: MutNullableDom, /// - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] last_click_info: DomRefCell)>>, /// ignore_destructive_writes_counter: Cell, @@ -346,7 +346,7 @@ pub struct Document { form_id_listener_map: DomRefCell>>>, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct ImagesFilter; impl CollectionFilter for ImagesFilter { fn filter(&self, elem: &Element, _root: &Node) -> bool { @@ -354,7 +354,7 @@ impl CollectionFilter for ImagesFilter { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct EmbedsFilter; impl CollectionFilter for EmbedsFilter { fn filter(&self, elem: &Element, _root: &Node) -> bool { @@ -362,7 +362,7 @@ impl CollectionFilter for EmbedsFilter { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct LinksFilter; impl CollectionFilter for LinksFilter { fn filter(&self, elem: &Element, _root: &Node) -> bool { @@ -371,7 +371,7 @@ impl CollectionFilter for LinksFilter { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct FormsFilter; impl CollectionFilter for FormsFilter { fn filter(&self, elem: &Element, _root: &Node) -> bool { @@ -379,7 +379,7 @@ impl CollectionFilter for FormsFilter { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct ScriptsFilter; impl CollectionFilter for ScriptsFilter { fn filter(&self, elem: &Element, _root: &Node) -> bool { @@ -387,7 +387,7 @@ impl CollectionFilter for ScriptsFilter { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct AnchorsFilter; impl CollectionFilter for AnchorsFilter { fn filter(&self, elem: &Element, _root: &Node) -> bool { @@ -395,7 +395,7 @@ impl CollectionFilter for AnchorsFilter { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct AppletsFilter; impl CollectionFilter for AppletsFilter { fn filter(&self, elem: &Element, _root: &Node) -> bool { @@ -1978,7 +1978,7 @@ impl Document { } } -#[derive(HeapSizeOf, PartialEq)] +#[derive(MallocSizeOf, PartialEq)] pub enum DocumentSource { FromParser, NotFromParser, @@ -2092,7 +2092,7 @@ fn url_has_network_scheme(url: &ServoUrl) -> bool { } } -#[derive(Clone, Copy, Eq, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Eq, JSTraceable, MallocSizeOf, PartialEq)] pub enum HasBrowsingContext { No, Yes, @@ -3470,7 +3470,7 @@ impl DocumentMethods for Document { #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter unsafe fn NamedGetter(&self, _cx: *mut JSContext, name: DOMString) -> Option { - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] struct NamedElementFilter { name: Atom, } @@ -3945,10 +3945,10 @@ pub enum FocusEventType { /// If the page is observed to be using `requestAnimationFrame()` for non-animation purposes (i.e. /// without mutating the DOM), then we fall back to simple timeouts to save energy over video /// refresh. -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct FakeRequestAnimationFrameCallback { /// The document. - #[ignore_heap_size_of = "non-owning"] + #[ignore_malloc_size_of = "non-owning"] document: Trusted, } @@ -3959,11 +3959,11 @@ impl FakeRequestAnimationFrameCallback { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub enum AnimationFrameCallback { DevtoolsFramerateTick { actor_name: String }, FrameRequestCallback { - #[ignore_heap_size_of = "Rc is hard"] + #[ignore_malloc_size_of = "Rc is hard"] callback: Rc }, } @@ -3985,7 +3985,7 @@ impl AnimationFrameCallback { } } -#[derive(Default, HeapSizeOf, JSTraceable)] +#[derive(Default, JSTraceable, MallocSizeOf)] #[must_root] struct PendingInOrderScriptVec { scripts: DomRefCell>, @@ -4021,7 +4021,7 @@ impl PendingInOrderScriptVec { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] struct PendingScript { element: Dom, diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index 4e661dc52c7..e94689b242b 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -12,7 +12,7 @@ use dom::globalscope::GlobalScope; use dom_struct::dom_struct; #[repr(u16)] -#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable)] +#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)] pub enum DOMErrorName { IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR, HierarchyRequestError = DOMExceptionConstants::HIERARCHY_REQUEST_ERR, diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 595fe67e0eb..9045918d2f8 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -140,7 +140,7 @@ pub struct Element { attrs: DomRefCell>>, id_attribute: DomRefCell>, is: DomRefCell>, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] style_attribute: DomRefCell>>>, attr_list: MutNullableDom, class_list: MutNullableDom, @@ -149,12 +149,12 @@ pub struct Element { /// operations may require restyling this element or its descendants. The /// flags are not atomic, so the style system takes care of only set them /// when it has exclusive access to the element. - #[ignore_heap_size_of = "bitflags defined in rust-selectors"] + #[ignore_malloc_size_of = "bitflags defined in rust-selectors"] selector_flags: Cell, /// custom_element_reaction_queue: DomRefCell>, /// - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] custom_element_definition: DomRefCell>>, /// custom_element_state: Cell, @@ -176,7 +176,7 @@ impl fmt::Debug for DomRoot { } } -#[derive(HeapSizeOf, PartialEq)] +#[derive(MallocSizeOf, PartialEq)] pub enum ElementCreator { ParserCreated(u64), ScriptCreated, @@ -188,7 +188,7 @@ pub enum CustomElementCreationMode { } /// -#[derive(Clone, Copy, Eq, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Eq, JSTraceable, MallocSizeOf, PartialEq)] pub enum CustomElementState { Undefined, Failed, @@ -3025,7 +3025,7 @@ impl<'a> AttributeMutation<'a> { /// A holder for an element's "tag name", which will be lazily /// resolved and cached. Should be reset when the document /// owner changes. -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct TagName { ptr: DomRefCell>, } diff --git a/components/script/dom/errorevent.rs b/components/script/dom/errorevent.rs index 1703698d382..36d1f149293 100644 --- a/components/script/dom/errorevent.rs +++ b/components/script/dom/errorevent.rs @@ -27,7 +27,7 @@ pub struct ErrorEvent { filename: DomRefCell, lineno: Cell, colno: Cell, - #[ignore_heap_size_of = "Defined in rust-mozjs"] + #[ignore_malloc_size_of = "Defined in rust-mozjs"] error: Heap, } diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index e9313c742c6..607469ca6bd 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -294,7 +294,7 @@ impl EventMethods for Event { } } -#[derive(Clone, Copy, HeapSizeOf, PartialEq)] +#[derive(Clone, Copy, MallocSizeOf, PartialEq)] pub enum EventBubbles { Bubbles, DoesNotBubble @@ -318,7 +318,7 @@ impl From for bool { } } -#[derive(Clone, Copy, HeapSizeOf, PartialEq)] +#[derive(Clone, Copy, MallocSizeOf, PartialEq)] pub enum EventCancelable { Cancelable, NotCancelable @@ -344,7 +344,7 @@ impl From for bool { #[derive(Clone, Copy, Debug, Eq, JSTraceable, PartialEq)] #[repr(u16)] -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] pub enum EventPhase { None = EventConstants::NONE, Capturing = EventConstants::CAPTURING_PHASE, @@ -363,7 +363,7 @@ pub enum EventPhase { /// /// [msg]: https://doc.servo.org/script_traits/enum.ConstellationMsg.html#variant.KeyEvent /// -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub enum EventDefault { /// The default action of the event is allowed (constructor's default) Allowed, diff --git a/components/script/dom/eventsource.rs b/components/script/dom/eventsource.rs index dab9f46bb05..3be3f6035df 100644 --- a/components/script/dom/eventsource.rs +++ b/components/script/dom/eventsource.rs @@ -41,10 +41,10 @@ header! { (LastEventId, "Last-Event-ID") => [String] } const DEFAULT_RECONNECTION_TIME: u64 = 5000; -#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] struct GenerationId(u32); -#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] /// enum ReadyState { Connecting = 0, @@ -528,11 +528,11 @@ impl EventSourceMethods for EventSource { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct EventSourceTimeoutCallback { - #[ignore_heap_size_of = "Because it is non-owning"] + #[ignore_malloc_size_of = "Because it is non-owning"] event_source: Trusted, - #[ignore_heap_size_of = "Because it is non-owning"] + #[ignore_malloc_size_of = "Because it is non-owning"] action_sender: ipc::IpcSender, } diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index e5b8c86e71e..558610fc99f 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -32,7 +32,6 @@ use dom::virtualmethods::VirtualMethods; use dom::window::Window; use dom_struct::dom_struct; use fnv::FnvHasher; -use heapsize::HeapSizeOf; use js::jsapi::{CompileFunction, JS_GetFunctionObject, JSAutoCompartment}; use js::rust::{AutoObjectVectorWrapper, CompileOptionsWrapper}; use libc::{c_char, size_t}; @@ -48,11 +47,19 @@ use std::ops::{Deref, DerefMut}; use std::ptr; use std::rc::Rc; -#[derive(Clone, JSTraceable, PartialEq)] +#[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)] pub enum CommonEventHandler { - EventHandler(Rc), - ErrorEventHandler(Rc), - BeforeUnloadEventHandler(Rc), + EventHandler( + #[ignore_malloc_size_of = "Rc"] + Rc), + + ErrorEventHandler( + #[ignore_malloc_size_of = "Rc"] + Rc), + + BeforeUnloadEventHandler( + #[ignore_malloc_size_of = "Rc"] + Rc), } impl CommonEventHandler { @@ -65,14 +72,14 @@ impl CommonEventHandler { } } -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub enum ListenerPhase { Capturing, Bubbling, } /// -#[derive(Clone, JSTraceable, PartialEq)] +#[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)] struct InternalRawUncompiledHandler { source: DOMString, url: ServoUrl, @@ -80,7 +87,7 @@ struct InternalRawUncompiledHandler { } /// A representation of an event handler, either compiled or uncompiled raw source, or null. -#[derive(Clone, JSTraceable, PartialEq)] +#[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)] enum InlineEventListener { Uncompiled(InternalRawUncompiledHandler), Compiled(CommonEventHandler), @@ -110,19 +117,12 @@ impl InlineEventListener { } } -#[derive(Clone, JSTraceable, PartialEq)] +#[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)] enum EventListenerType { - Additive(Rc), + Additive(#[ignore_malloc_size_of = "Rc"] Rc), Inline(InlineEventListener), } -impl HeapSizeOf for EventListenerType { - fn heap_size_of_children(&self) -> usize { - // FIXME: Rc isn't HeapSizeOf and we can't ignore it due to #6870 and #6871 - 0 - } -} - impl EventListenerType { fn get_compiled_listener(&mut self, owner: &EventTarget, ty: &Atom) -> Option { @@ -225,14 +225,14 @@ impl CompiledEventListener { } } -#[derive(Clone, DenyPublicFields, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, DenyPublicFields, JSTraceable, MallocSizeOf, PartialEq)] /// A listener in a collection of event listeners. struct EventListenerEntry { phase: ListenerPhase, listener: EventListenerType } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] /// A mix of potentially uncompiled and compiled event listeners of the same type. struct EventListeners(Vec); diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index a2e211cc003..db5518116ef 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -39,7 +39,7 @@ use task::TaskCanceller; use task_source::TaskSource; use task_source::file_reading::{FileReadingTask, FileReadingTaskSource}; -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub enum FileReaderFunction { ReadAsText, ReadAsDataUrl, @@ -48,7 +48,7 @@ pub enum FileReaderFunction { pub type TrustedFileReader = Trusted; -#[derive(Clone, HeapSizeOf)] +#[derive(Clone, MallocSizeOf)] pub struct ReadMetaData { pub blobtype: String, pub label: Option, @@ -66,18 +66,18 @@ impl ReadMetaData { } } -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub struct GenerationId(u32); #[repr(u16)] -#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] pub enum FileReaderReadyState { Empty = FileReaderConstants::EMPTY, Loading = FileReaderConstants::LOADING, Done = FileReaderConstants::DONE, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub enum FileReaderResult { ArrayBuffer(Heap), String(DOMString), diff --git a/components/script/dom/gamepad.rs b/components/script/dom/gamepad.rs index 47605b7794e..99f52cb203f 100644 --- a/components/script/dom/gamepad.rs +++ b/components/script/dom/gamepad.rs @@ -35,7 +35,7 @@ pub struct Gamepad { axes: Heap<*mut JSObject>, buttons: Dom, pose: Option>, - #[ignore_heap_size_of = "Defined in rust-webvr"] + #[ignore_malloc_size_of = "Defined in rust-webvr"] hand: WebVRGamepadHand, display_id: u32 } diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index b226924bdef..0d3b9b47298 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -72,22 +72,22 @@ pub struct GlobalScope { console_timers: DomRefCell>, /// For providing instructions to an optional devtools server. - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] devtools_chan: Option>, /// For sending messages to the memory profiler. - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] mem_profiler_chan: mem::ProfilerChan, /// For sending messages to the time profiler. - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] time_profiler_chan: time::ProfilerChan, /// A handle for communicating messages to the constellation thread. - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] script_to_constellation_chan: ScriptToConstellationChan, - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] scheduler_chan: IpcSender, /// @@ -108,7 +108,7 @@ pub struct GlobalScope { /// same microtask queue. /// /// - #[ignore_heap_size_of = "Rc is hard"] + #[ignore_malloc_size_of = "Rc is hard"] microtask_queue: Rc, } diff --git a/components/script/dom/headers.rs b/components/script/dom/headers.rs index 9b8910bc893..5d152ab93bb 100644 --- a/components/script/dom/headers.rs +++ b/components/script/dom/headers.rs @@ -21,12 +21,12 @@ use std::str; pub struct Headers { reflector_: Reflector, guard: Cell, - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] header_list: DomRefCell } // https://fetch.spec.whatwg.org/#concept-headers-guard -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub enum Guard { Immutable, Request, diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index 70d16684bdd..feb9a3f1805 100755 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -30,7 +30,7 @@ use std::default::Default; use style::element_state::*; #[derive(Clone, Copy, JSTraceable, PartialEq)] -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] enum ButtonType { Submit, Reset, diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 916fcce9ab6..3e7de52fd29 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -42,7 +42,7 @@ const DEFAULT_WIDTH: u32 = 300; const DEFAULT_HEIGHT: u32 = 150; #[must_root] -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] pub enum CanvasContext { Context2d(Dom), WebGL(Dom), diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 19b756769bc..3da4503cb0e 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -26,7 +26,7 @@ pub trait CollectionFilter : JSTraceable { // An optional u32, using maxint to represent None. // It would be nicer just to use Option for this, but that would produce word // alignment issues since Option uses 33 bits. -#[derive(Clone, Copy, HeapSizeOf, JSTraceable)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf)] struct OptionU32 { bits: u32, } @@ -54,7 +54,7 @@ impl OptionU32 { pub struct HTMLCollection { reflector_: Reflector, root: Dom, - #[ignore_heap_size_of = "Contains a trait object; can't measure due to #6870"] + #[ignore_malloc_size_of = "Contains a trait object; can't measure due to #6870"] filter: Box, // We cache the version of the root node and all its decendents, // the length of the collection, and a cursor into the collection. @@ -119,7 +119,7 @@ impl HTMLCollection { -> DomRoot { // case 1 if qualified_name == local_name!("*") { - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] struct AllFilter; impl CollectionFilter for AllFilter { fn filter(&self, _elem: &Element, _root: &Node) -> bool { @@ -129,7 +129,7 @@ impl HTMLCollection { return HTMLCollection::create(window, root, Box::new(AllFilter)); } - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] struct HtmlDocumentFilter { qualified_name: LocalName, ascii_lower_qualified_name: LocalName, @@ -169,7 +169,7 @@ impl HTMLCollection { } pub fn by_qual_tag_name(window: &Window, root: &Node, qname: QualName) -> DomRoot { - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] struct TagNameNSFilter { qname: QualName } @@ -193,7 +193,7 @@ impl HTMLCollection { pub fn by_atomic_class_name(window: &Window, root: &Node, classes: Vec) -> DomRoot { - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] struct ClassNameFilter { classes: Vec } @@ -212,7 +212,7 @@ impl HTMLCollection { } pub fn children(window: &Window, root: &Node) -> DomRoot { - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] struct ElementChildFilter; impl CollectionFilter for ElementChildFilter { fn filter(&self, elem: &Element, root: &Node) -> bool { diff --git a/components/script/dom/htmldatalistelement.rs b/components/script/dom/htmldatalistelement.rs index 2352fa99bcf..43e2eaa4928 100644 --- a/components/script/dom/htmldatalistelement.rs +++ b/components/script/dom/htmldatalistelement.rs @@ -43,7 +43,7 @@ impl HTMLDataListElement { impl HTMLDataListElementMethods for HTMLDataListElement { // https://html.spec.whatwg.org/multipage/#dom-datalist-options fn Options(&self) -> DomRoot { - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] struct HTMLDataListOptionsFilter; impl CollectionFilter for HTMLDataListOptionsFilter { fn filter(&self, elem: &Element, _root: &Node) -> bool { diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs index bee8a41d4cd..81fc57dbce3 100644 --- a/components/script/dom/htmlfieldsetelement.rs +++ b/components/script/dom/htmlfieldsetelement.rs @@ -52,7 +52,7 @@ impl HTMLFieldSetElement { impl HTMLFieldSetElementMethods for HTMLFieldSetElement { // https://html.spec.whatwg.org/multipage/#dom-fieldset-elements fn Elements(&self) -> DomRoot { - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] struct ElementsFilter; impl CollectionFilter for ElementsFilter { fn filter<'a>(&self, elem: &'a Element, _root: &'a Node) -> bool { diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index ecca8998978..d99b101dd4a 100755 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -57,7 +57,7 @@ use style::attr::AttrValue; use style::str::split_html_space_chars; use task_source::TaskSource; -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub struct GenerationId(u32); #[dom_struct] @@ -166,7 +166,7 @@ impl HTMLFormElementMethods for HTMLFormElement { // https://html.spec.whatwg.org/multipage/#dom-form-elements fn Elements(&self) -> DomRoot { - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] struct ElementsFilter { form: DomRoot } @@ -235,13 +235,13 @@ impl HTMLFormElementMethods for HTMLFormElement { } } -#[derive(Clone, Copy, HeapSizeOf, PartialEq)] +#[derive(Clone, Copy, MallocSizeOf, PartialEq)] pub enum SubmittedFrom { FromForm, NotFromForm } -#[derive(Clone, Copy, HeapSizeOf)] +#[derive(Clone, Copy, MallocSizeOf)] pub enum ResetFrom { FromForm, NotFromForm @@ -674,14 +674,14 @@ impl HTMLFormElement { } } -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] pub enum FormDatumValue { #[allow(dead_code)] File(DomRoot), String(DOMString) } -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] pub struct FormDatum { pub ty: DOMString, pub name: DOMString, @@ -701,21 +701,21 @@ impl FormDatum { } } -#[derive(Clone, Copy, HeapSizeOf)] +#[derive(Clone, Copy, MallocSizeOf)] pub enum FormEncType { TextPlainEncoded, UrlEncoded, FormDataEncoded } -#[derive(Clone, Copy, HeapSizeOf)] +#[derive(Clone, Copy, MallocSizeOf)] pub enum FormMethod { FormGet, FormPost, FormDialog } -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] #[allow(dead_code)] pub enum FormSubmittableElement { ButtonElement(DomRoot), @@ -759,7 +759,7 @@ impl FormSubmittableElement { } } -#[derive(Clone, Copy, HeapSizeOf)] +#[derive(Clone, Copy, MallocSizeOf)] pub enum FormSubmitter<'a> { FormElement(&'a HTMLFormElement), InputElement(&'a HTMLInputElement), diff --git a/components/script/dom/htmlheadingelement.rs b/components/script/dom/htmlheadingelement.rs index 8420def4a84..5dbf23fa157 100644 --- a/components/script/dom/htmlheadingelement.rs +++ b/components/script/dom/htmlheadingelement.rs @@ -10,7 +10,7 @@ use dom::node::Node; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub enum HeadingLevel { Heading1, Heading2, diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 08d67b9eff3..697e32636b1 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -56,7 +56,7 @@ use style::attr::{AttrValue, LengthOrPercentageOrAuto}; use task_source::TaskSource; bitflags! { - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] flags SandboxAllowance: u8 { const ALLOW_NOTHING = 0x00, const ALLOW_SAME_ORIGIN = 0x01, diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 6f33849ad80..498930624c4 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -85,7 +85,7 @@ pub struct Descriptor { pub den: Option, } -#[derive(Clone, Copy, HeapSizeOf, JSTraceable)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf)] #[allow(dead_code)] enum State { Unavailable, @@ -100,19 +100,19 @@ pub struct Size { pub length: Length, } -#[derive(Clone, Copy, HeapSizeOf, JSTraceable)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf)] enum ImageRequestPhase { Pending, Current } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] struct ImageRequest { state: State, parsed_url: Option, source_url: Option, blocker: Option, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] image: Option>, metadata: Option, final_url: Option, @@ -695,7 +695,7 @@ impl HTMLImageElement { } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub enum ImageElementMicrotask { StableStateUpdateImageDataTask { elem: DomRoot, diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index ad82972d0e3..658c1917212 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -62,7 +62,7 @@ const PASSWORD_REPLACEMENT_CHAR: char = '●'; #[derive(Clone, Copy, JSTraceable, PartialEq)] #[allow(dead_code)] -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] enum InputType { InputSubmit, InputReset, @@ -93,7 +93,7 @@ pub struct HTMLInputElement { size: Cell, maxlength: Cell, minlength: Cell, - #[ignore_heap_size_of = "#7193"] + #[ignore_malloc_size_of = "#7193"] textinput: DomRefCell>, activation_state: DomRefCell, // https://html.spec.whatwg.org/multipage/#concept-input-value-dirty-flag @@ -105,7 +105,7 @@ pub struct HTMLInputElement { #[derive(JSTraceable)] #[must_root] -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] struct InputActivationState { indeterminate: bool, checked: bool, diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 2eb346a00c7..03353d70bc4 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -38,7 +38,7 @@ use style::stylesheets::{CssRuleType, Stylesheet}; use style_traits::PARSING_MODE_DEFAULT; use stylesheet_loader::{StylesheetLoader, StylesheetContextSource, StylesheetOwner}; -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub struct RequestGenerationId(u32); impl RequestGenerationId { @@ -51,7 +51,7 @@ impl RequestGenerationId { pub struct HTMLLinkElement { htmlelement: HTMLElement, rel_list: MutNullableDom, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] stylesheet: DomRefCell>>, cssom_stylesheet: MutNullableDom, diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index f264bde0206..daddcee4377 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -77,15 +77,15 @@ pub struct HTMLMediaElement { /// delaying_the_load_event_flag: DomRefCell>, /// - #[ignore_heap_size_of = "promises are hard"] + #[ignore_malloc_size_of = "promises are hard"] pending_play_promises: DomRefCell>>, /// Play promises which are soon to be fulfilled by a queued task. - #[ignore_heap_size_of = "promises are hard"] + #[ignore_malloc_size_of = "promises are hard"] in_flight_play_promises_queue: DomRefCell]>, ErrorResult)>>, } /// -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] #[repr(u8)] pub enum NetworkState { Empty = HTMLMediaElementConstants::NETWORK_EMPTY as u8, @@ -95,7 +95,7 @@ pub enum NetworkState { } /// -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq, PartialOrd)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq, PartialOrd)] #[repr(u8)] enum ReadyState { HaveNothing = HTMLMediaElementConstants::HAVE_NOTHING as u8, @@ -940,7 +940,7 @@ impl VirtualMethods for HTMLMediaElement { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub enum MediaElementMicrotask { ResourceSelectionTask { elem: DomRoot, diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 56f31be0964..f27161036e7 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -32,7 +32,7 @@ use style::stylesheets::{Stylesheet, StylesheetContents, CssRule, CssRules, Orig #[dom_struct] pub struct HTMLMetaElement { htmlelement: HTMLElement, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] stylesheet: DomRefCell>>, cssom_stylesheet: MutNullableDom, } diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index ce45e089fdc..d78e102d1da 100755 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -26,7 +26,7 @@ use std::default::Default; #[dom_struct] pub struct HTMLObjectElement { htmlelement: HTMLElement, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] image: DomRefCell>>, form_owner: MutNullableDom, } diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 1a21ce28a1c..31871104687 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -112,7 +112,7 @@ static SCRIPT_JS_MIMES: StaticStringVec = &[ "text/x-javascript", ]; -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct ClassicScript { text: DOMString, url: ServoUrl, diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index 75dea8d461e..3423db303e4 100755 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -37,7 +37,7 @@ use std::iter; use style::attr::AttrValue; use style::element_state::*; -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct OptionsFilter; impl CollectionFilter for OptionsFilter { fn filter<'a>(&self, elem: &'a Element, root: &'a Node) -> bool { diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index af01adfd9c5..ef25b52dbb3 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -31,7 +31,7 @@ use stylesheet_loader::{StylesheetLoader, StylesheetOwner}; #[dom_struct] pub struct HTMLStyleElement { htmlelement: HTMLElement, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] stylesheet: DomRefCell>>, cssom_stylesheet: MutNullableDom, /// diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index cda13a6496d..c475c3eee1d 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -36,7 +36,7 @@ pub struct HTMLTableElement { } #[allow(unrooted_must_root)] -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct TableRowFilter { sections: Vec>, } diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 0825bb70302..c15553faa75 100755 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -38,7 +38,7 @@ use textinput::{KeyReaction, Lines, SelectionDirection, TextInput}; #[dom_struct] pub struct HTMLTextAreaElement { htmlelement: HTMLElement, - #[ignore_heap_size_of = "#7193"] + #[ignore_malloc_size_of = "#7193"] textinput: DomRefCell>, placeholder: DomRefCell, // https://html.spec.whatwg.org/multipage/#concept-textarea-dirty diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index 237876ecdda..2d2a2391372 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -742,7 +742,7 @@ fn key_keycode(key: Key) -> u32 { } } -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] pub struct KeyEventProperties { pub key_string: Cow<'static, str>, pub code: &'static str, diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs index df59886226d..30d6ad9ed34 100644 --- a/components/script/dom/medialist.rs +++ b/components/script/dom/medialist.rs @@ -24,7 +24,7 @@ use style_traits::{PARSING_MODE_DEFAULT, ToCss}; pub struct MediaList { reflector_: Reflector, parent_stylesheet: Dom, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] media_queries: Arc>, } diff --git a/components/script/dom/mediaquerylist.rs b/components/script/dom/mediaquerylist.rs index 6252f9c5098..e89e7d4d744 100644 --- a/components/script/dom/mediaquerylist.rs +++ b/components/script/dom/mediaquerylist.rs @@ -118,7 +118,7 @@ impl MediaQueryListMethods for MediaQueryList { event_handler!(change, GetOnchange, SetOnchange); } -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] pub struct WeakMediaQueryListVec { cell: DomRefCell>, } diff --git a/components/script/dom/mutationobserver.rs b/components/script/dom/mutationobserver.rs index 9f8ba823bd1..5aee5adecd9 100644 --- a/components/script/dom/mutationobserver.rs +++ b/components/script/dom/mutationobserver.rs @@ -24,7 +24,7 @@ use std::rc::Rc; #[dom_struct] pub struct MutationObserver { reflector_: Reflector, - #[ignore_heap_size_of = "can't measure Rc values"] + #[ignore_malloc_size_of = "can't measure Rc values"] callback: Rc, record_queue: DomRefCell>>, } @@ -35,13 +35,13 @@ pub enum Mutation<'a> { prev: Option<&'a Node>, next: Option<&'a Node> }, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct RegisteredObserver { observer: DomRoot, options: ObserverOptions, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct ObserverOptions { attribute_old_value: bool, attributes: bool, diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 52641c37474..0186d9e6a67 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -56,10 +56,10 @@ use dom::virtualmethods::{VirtualMethods, vtable_for}; use dom::window::Window; use dom_struct::dom_struct; use euclid::{Point2D, Vector2D, Rect, Size2D}; -use heapsize::{HeapSizeOf, heap_size_of}; use html5ever::{Prefix, Namespace, QualName}; use js::jsapi::{JSContext, JSObject, JSRuntime}; use libc::{self, c_void, uintptr_t}; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use msg::constellation_msg::{BrowsingContextId, PipelineId}; use ref_slice::ref_slice; use script_layout_interface::{HTMLCanvasData, OpaqueStyleAndLayoutData, SVGSVGData}; @@ -147,7 +147,7 @@ pub struct Node { bitflags! { #[doc = "Flags for node items."] - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] pub flags NodeFlags: u16 { #[doc = "Specifies whether this node is in a document."] const IS_IN_DOC = 1 << 0, @@ -200,7 +200,7 @@ impl Drop for Node { /// suppress observers flag /// /// -#[derive(Clone, Copy, HeapSizeOf)] +#[derive(Clone, Copy, MallocSizeOf)] enum SuppressObserver { Suppressed, Unsuppressed @@ -1368,7 +1368,7 @@ impl Iterator for TreeIterator { } /// Specifies whether children must be recursively cloned or not. -#[derive(Clone, Copy, HeapSizeOf, PartialEq)] +#[derive(Clone, Copy, MallocSizeOf, PartialEq)] pub enum CloneChildrenFlag { CloneChildren, DoNotCloneChildren @@ -2531,7 +2531,7 @@ impl VirtualMethods for Node { } /// A summary of the changes that happened to a node. -#[derive(Clone, Copy, HeapSizeOf, PartialEq)] +#[derive(Clone, Copy, MallocSizeOf, PartialEq)] pub enum NodeDamage { /// The node's `style` attribute changed. NodeStyleDamaged, @@ -2704,11 +2704,11 @@ struct UniqueId { unsafe_no_jsmanaged_fields!(UniqueId); -impl HeapSizeOf for UniqueId { +impl MallocSizeOf for UniqueId { #[allow(unsafe_code)] - fn heap_size_of_children(&self) -> usize { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { if let &Some(ref uuid) = unsafe { &*self.cell.get() } { - unsafe { heap_size_of(&** uuid as *const Uuid as *const _) } + unsafe { ops.malloc_size_of(&** uuid) } } else { 0 } diff --git a/components/script/dom/nodeiterator.rs b/components/script/dom/nodeiterator.rs index 688f46e7df7..5897c4075c9 100644 --- a/components/script/dom/nodeiterator.rs +++ b/components/script/dom/nodeiterator.rs @@ -21,11 +21,11 @@ use std::rc::Rc; pub struct NodeIterator { reflector_: Reflector, root_node: Dom, - #[ignore_heap_size_of = "Defined in rust-mozjs"] + #[ignore_malloc_size_of = "Defined in rust-mozjs"] reference_node: MutDom, pointer_before_reference_node: Cell, what_to_show: u32, - #[ignore_heap_size_of = "Can't measure due to #6870"] + #[ignore_malloc_size_of = "Can't measure due to #6870"] filter: Filter, } diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index 86d8a2a951d..24165267480 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -12,7 +12,7 @@ use dom::window::Window; use dom_struct::dom_struct; use std::cell::Cell; -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] pub enum NodeListType { Simple(Vec>), @@ -109,11 +109,11 @@ impl NodeList { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] pub struct ChildrenList { node: Dom, - #[ignore_heap_size_of = "Defined in rust-mozjs"] + #[ignore_malloc_size_of = "Defined in rust-mozjs"] last_visited: MutNullableDom, last_index: Cell, } diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs index 8c74f86b7a7..61527c8dd9f 100644 --- a/components/script/dom/paintworkletglobalscope.rs +++ b/components/script/dom/paintworkletglobalscope.rs @@ -68,7 +68,7 @@ pub struct PaintWorkletGlobalScope { /// The worklet global for this object worklet_global: WorkletGlobalScope, /// The image cache - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] image_cache: Arc, /// paint_definitions: DomRefCell>>, @@ -464,7 +464,7 @@ pub enum PaintWorkletTask { /// /// This type is dangerous, because it contains uboxed `Heap` values, /// which can't be moved. -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] struct PaintDefinition { class_constructor: Heap, diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs index cb773c06e22..f491fbb7654 100644 --- a/components/script/dom/performance.rs +++ b/components/script/dom/performance.rs @@ -50,7 +50,7 @@ const INVALID_ENTRY_NAMES: &'static [&'static str] = &[ /// Implementation of a list of PerformanceEntry items shared by the /// Performance and PerformanceObserverEntryList interfaces implementations. -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct PerformanceEntryList { entries: DOMPerformanceEntryList, } @@ -101,7 +101,7 @@ impl IntoIterator for PerformanceEntryList { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct PerformanceObserver { observer: DomRoot, entry_types: Vec, diff --git a/components/script/dom/performanceobserver.rs b/components/script/dom/performanceobserver.rs index 06c243e7818..96ad99edf92 100644 --- a/components/script/dom/performanceobserver.rs +++ b/components/script/dom/performanceobserver.rs @@ -32,7 +32,7 @@ const VALID_ENTRY_TYPES: &'static [&'static str] = &[ #[dom_struct] pub struct PerformanceObserver { reflector_: Reflector, - #[ignore_heap_size_of = "can't measure Rc values"] + #[ignore_malloc_size_of = "can't measure Rc values"] callback: Rc, entries: DomRefCell, } diff --git a/components/script/dom/popstateevent.rs b/components/script/dom/popstateevent.rs index 218ed5d3af6..d485499cea5 100644 --- a/components/script/dom/popstateevent.rs +++ b/components/script/dom/popstateevent.rs @@ -22,7 +22,7 @@ use servo_atoms::Atom; #[dom_struct] pub struct PopStateEvent { event: Event, - #[ignore_heap_size_of = "Defined in rust-mozjs"] + #[ignore_malloc_size_of = "Defined in rust-mozjs"] state: Heap, } diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs index 51b7c1763af..ad8ee2adfeb 100644 --- a/components/script/dom/promise.rs +++ b/components/script/dom/promise.rs @@ -37,7 +37,7 @@ pub struct Promise { /// the SpiderMonkey GC, an explicit root for the reflector is stored while any /// native instance exists. This ensures that the reflector will never be GCed /// while native code could still interact with its native representation. - #[ignore_heap_size_of = "SM handles JS values"] + #[ignore_malloc_size_of = "SM handles JS values"] permanent_js_root: Heap, } diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 4ed9b4b30b4..d87589ccaa8 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -8,10 +8,10 @@ use dom::bindings::root::DomRoot; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; -use heapsize::HeapSizeOf; use js::jsapi::{JSContext, HandleValue}; +use malloc_size_of::MallocSizeOf; -pub trait Callback: JSTraceable + HeapSizeOf { +pub trait Callback: JSTraceable + MallocSizeOf { fn callback(&self, cx: *mut JSContext, v: HandleValue); } diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index c4699c7f8ff..f43c9e1922c 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -27,8 +27,8 @@ use dom::node::{Node, UnbindContext}; use dom::text::Text; use dom::window::Window; use dom_struct::dom_struct; -use heapsize::HeapSizeOf; use js::jsapi::JSTracer; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use std::cell::{Cell, UnsafeCell}; use std::cmp::{Ord, Ordering, PartialEq, PartialOrd}; @@ -933,7 +933,7 @@ impl RangeMethods for Range { } } -#[derive(DenyPublicFields, HeapSizeOf, JSTraceable)] +#[derive(DenyPublicFields, JSTraceable, MallocSizeOf)] #[must_root] pub struct BoundaryPoint { node: MutDom, @@ -1251,9 +1251,9 @@ impl WeakRangeVec { } #[allow(unsafe_code)] -impl HeapSizeOf for WeakRangeVec { - fn heap_size_of_children(&self) -> usize { - unsafe { (*self.cell.get()).heap_size_of_children() } +impl MallocSizeOf for WeakRangeVec { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + unsafe { (*self.cell.get()).size_of(ops) } } } diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs index a4bfbf96f83..a018467b46d 100644 --- a/components/script/dom/request.rs +++ b/components/script/dom/request.rs @@ -48,7 +48,7 @@ pub struct Request { body_used: Cell, headers: MutNullableDom, mime_type: DomRefCell>, - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] body_promise: DomRefCell, BodyType)>>, } diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs index ee4276e711a..e4af7f48187 100644 --- a/components/script/dom/response.rs +++ b/components/script/dom/response.rs @@ -36,7 +36,7 @@ pub struct Response { mime_type: DomRefCell>, body_used: Cell, /// `None` can be considered a StatusCode of `0`. - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] status: DomRefCell>, raw_status: DomRefCell)>>, response_type: DomRefCell, @@ -44,7 +44,7 @@ pub struct Response { url_list: DomRefCell>, // For now use the existing NetTraitsResponseBody enum body: DomRefCell, - #[ignore_heap_size_of = "Rc"] + #[ignore_malloc_size_of = "Rc"] body_promise: DomRefCell, BodyType)>>, } diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs index bd9de0db9f5..9cffa2c341d 100644 --- a/components/script/dom/serviceworkerglobalscope.rs +++ b/components/script/dom/serviceworkerglobalscope.rs @@ -71,13 +71,13 @@ impl ScriptChan for ServiceWorkerChan { #[dom_struct] pub struct ServiceWorkerGlobalScope { workerglobalscope: WorkerGlobalScope, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] receiver: Receiver, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] own_sender: Sender, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] timer_event_port: Receiver<()>, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] swmanager_sender: IpcSender, scope_url: ServoUrl, } diff --git a/components/script/dom/servoparser/async_html.rs b/components/script/dom/servoparser/async_html.rs index 2c4e71047b5..bbfa1da0a93 100644 --- a/components/script/dom/servoparser/async_html.rs +++ b/components/script/dom/servoparser/async_html.rs @@ -38,25 +38,25 @@ use style::context::QuirksMode as ServoQuirksMode; type ParseNodeId = usize; -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] pub struct ParseNode { id: ParseNodeId, qual_name: Option, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] enum NodeOrText { Node(ParseNode), Text(String), } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct Attribute { name: QualName, value: String, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] enum ParseOperation { GetTemplateContents { target: ParseNodeId, contents: ParseNodeId }, @@ -99,21 +99,21 @@ enum ParseOperation { Pop { node: ParseNodeId }, SetQuirksMode { - #[ignore_heap_size_of = "Defined in style"] + #[ignore_malloc_size_of = "Defined in style"] mode: ServoQuirksMode }, } -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] enum ToTokenizerMsg { // From HtmlTokenizer TokenizerResultDone { - #[ignore_heap_size_of = "Defined in html5ever"] + #[ignore_malloc_size_of = "Defined in html5ever"] updated_input: VecDeque> }, TokenizerResultScript { script: ParseNode, - #[ignore_heap_size_of = "Defined in html5ever"] + #[ignore_malloc_size_of = "Defined in html5ever"] updated_input: VecDeque> }, End, // Sent to Tokenizer to signify HtmlTokenizer's end method has returned @@ -122,10 +122,10 @@ enum ToTokenizerMsg { ProcessOperation(ParseOperation), } -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] enum ToHtmlTokenizerMsg { Feed { - #[ignore_heap_size_of = "Defined in html5ever"] + #[ignore_malloc_size_of = "Defined in html5ever"] input: VecDeque> }, End, @@ -165,15 +165,15 @@ fn create_buffer_queue(mut buffers: VecDeque>) -> BufferQueue // | | | |________| | // |_____________| |_______________| // -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] pub struct Tokenizer { document: Dom, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] receiver: Receiver, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] html_tokenizer_sender: Sender, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] nodes: HashMap>, url: ServoUrl, } @@ -495,7 +495,7 @@ fn run(sink: Sink, } } -#[derive(Default, HeapSizeOf, JSTraceable)] +#[derive(Default, JSTraceable, MallocSizeOf)] struct ParseNodeData { contents: Option, is_integration_point: bool, diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs index f6857fcd198..53dcc3fc7c6 100644 --- a/components/script/dom/servoparser/html.rs +++ b/components/script/dom/servoparser/html.rs @@ -28,10 +28,10 @@ use js::jsapi::JSTracer; use servo_url::ServoUrl; use std::io; -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] pub struct Tokenizer { - #[ignore_heap_size_of = "Defined in html5ever"] + #[ignore_malloc_size_of = "Defined in html5ever"] inner: HtmlTokenizer, Sink>>, } diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index f5f7943693e..08310326716 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -74,13 +74,13 @@ pub struct ServoParser { /// The document associated with this parser. document: Dom, /// Input received from network. - #[ignore_heap_size_of = "Defined in html5ever"] + #[ignore_malloc_size_of = "Defined in html5ever"] network_input: DomRefCell, /// Part of an UTF-8 code point spanning input chunks - #[ignore_heap_size_of = "Defined in html5ever"] + #[ignore_malloc_size_of = "Defined in html5ever"] incomplete_utf8: DomRefCell>, /// Input received from script. Used only to support document.write(). - #[ignore_heap_size_of = "Defined in html5ever"] + #[ignore_malloc_size_of = "Defined in html5ever"] script_input: DomRefCell, /// The tokenizer of this parser. tokenizer: DomRefCell, @@ -493,13 +493,13 @@ impl Iterator for FragmentParsingResult } } -#[derive(HeapSizeOf, JSTraceable, PartialEq)] +#[derive(JSTraceable, MallocSizeOf, PartialEq)] enum ParserKind { Normal, ScriptCreated, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[must_root] enum Tokenizer { Html(self::html::Tokenizer), @@ -742,7 +742,7 @@ fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText, Sink>>, } diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 62738fcf379..ce8bce56878 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -723,9 +723,9 @@ impl TestBindingMethods for TestBinding { p.append_native_handler(&handler); return p; - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] struct SimpleHandler { - #[ignore_heap_size_of = "Rc has unclear ownership semantics"] + #[ignore_malloc_size_of = "Rc has unclear ownership semantics"] handler: Rc, } impl SimpleHandler { @@ -804,9 +804,9 @@ impl TestBinding { pub unsafe fn condition_unsatisfied(_: *mut JSContext, _: HandleObject) -> bool { false } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct TestBindingCallback { - #[ignore_heap_size_of = "unclear ownership semantics"] + #[ignore_malloc_size_of = "unclear ownership semantics"] promise: TrustedPromise, value: DOMString, } diff --git a/components/script/dom/textdecoder.rs b/components/script/dom/textdecoder.rs index 26ba8047c6b..2bfe574c380 100644 --- a/components/script/dom/textdecoder.rs +++ b/components/script/dom/textdecoder.rs @@ -18,7 +18,7 @@ use std::borrow::ToOwned; #[dom_struct] pub struct TextDecoder { reflector_: Reflector, - #[ignore_heap_size_of = "Defined in rust-encoding"] + #[ignore_malloc_size_of = "Defined in rust-encoding"] encoding: EncodingRef, fatal: bool, } diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index c1d60c5a9f6..de5219a608f 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -23,7 +23,7 @@ pub struct TreeWalker { root_node: Dom, current_node: MutDom, what_to_show: u32, - #[ignore_heap_size_of = "function pointers and Rc are hard"] + #[ignore_malloc_size_of = "function pointers and Rc are hard"] filter: Filter } diff --git a/components/script/dom/urlhelper.rs b/components/script/dom/urlhelper.rs index d00189156f0..d98dcc438bf 100644 --- a/components/script/dom/urlhelper.rs +++ b/components/script/dom/urlhelper.rs @@ -7,7 +7,7 @@ use servo_url::ServoUrl; use std::borrow::ToOwned; use url::quirks; -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] pub struct UrlHelper; impl UrlHelper { diff --git a/components/script/dom/validitystate.rs b/components/script/dom/validitystate.rs index 3357c29a175..0178764c3d0 100755 --- a/components/script/dom/validitystate.rs +++ b/components/script/dom/validitystate.rs @@ -11,7 +11,7 @@ use dom::window::Window; use dom_struct::dom_struct; // https://html.spec.whatwg.org/multipage/#validity-states -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] #[allow(dead_code)] pub enum ValidityStatus { ValueMissing, diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index 4f012856c2c..d63e0f514e0 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -46,7 +46,7 @@ use webvr_traits::{WebVRDisplayData, WebVRDisplayEvent, WebVRFrameData, WebVRLay #[dom_struct] pub struct VRDisplay { eventtarget: EventTarget, - #[ignore_heap_size_of = "Defined in rust-webvr"] + #[ignore_malloc_size_of = "Defined in rust-webvr"] display: DomRefCell, depth_near: Cell, depth_far: Cell, @@ -55,19 +55,19 @@ pub struct VRDisplay { right_eye_params: MutDom, capabilities: MutDom, stage_params: MutNullableDom, - #[ignore_heap_size_of = "Defined in rust-webvr"] + #[ignore_malloc_size_of = "Defined in rust-webvr"] frame_data: DomRefCell, - #[ignore_heap_size_of = "Defined in rust-webvr"] + #[ignore_malloc_size_of = "Defined in rust-webvr"] layer: DomRefCell, layer_ctx: MutNullableDom, - #[ignore_heap_size_of = "Defined in rust-webvr"] + #[ignore_malloc_size_of = "Defined in rust-webvr"] next_raf_id: Cell, /// List of request animation frame callbacks - #[ignore_heap_size_of = "closures are hard"] + #[ignore_malloc_size_of = "closures are hard"] raf_callback_list: DomRefCell>)>>, // Compositor VRFrameData synchonization frame_data_status: Cell, - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "closures are hard"] frame_data_receiver: DomRefCell, ()>>>>, running_display_raf: Cell, paused: Cell, @@ -78,7 +78,7 @@ unsafe_no_jsmanaged_fields!(WebVRDisplayData); unsafe_no_jsmanaged_fields!(WebVRFrameData); unsafe_no_jsmanaged_fields!(WebVRLayer); -#[derive(Clone, Copy, Eq, HeapSizeOf, PartialEq)] +#[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq)] enum VRFrameDataStatus { Waiting, Synced, diff --git a/components/script/dom/vrdisplaycapabilities.rs b/components/script/dom/vrdisplaycapabilities.rs index 9721de0e1b6..ef1f1d7f275 100644 --- a/components/script/dom/vrdisplaycapabilities.rs +++ b/components/script/dom/vrdisplaycapabilities.rs @@ -14,7 +14,7 @@ use webvr_traits::WebVRDisplayCapabilities; #[dom_struct] pub struct VRDisplayCapabilities { reflector_: Reflector, - #[ignore_heap_size_of = "Defined in rust-webvr"] + #[ignore_malloc_size_of = "Defined in rust-webvr"] capabilities: DomRefCell } diff --git a/components/script/dom/vreyeparameters.rs b/components/script/dom/vreyeparameters.rs index f29d0230de5..b573d3d96b8 100644 --- a/components/script/dom/vreyeparameters.rs +++ b/components/script/dom/vreyeparameters.rs @@ -20,7 +20,7 @@ use webvr_traits::WebVREyeParameters; #[dom_struct] pub struct VREyeParameters { reflector_: Reflector, - #[ignore_heap_size_of = "Defined in rust-webvr"] + #[ignore_malloc_size_of = "Defined in rust-webvr"] parameters: DomRefCell, offset: Heap<*mut JSObject>, fov: Dom, diff --git a/components/script/dom/vrfieldofview.rs b/components/script/dom/vrfieldofview.rs index 3bcb80b3e2c..eb798bafc8a 100644 --- a/components/script/dom/vrfieldofview.rs +++ b/components/script/dom/vrfieldofview.rs @@ -15,7 +15,7 @@ use webvr_traits::WebVRFieldOfView; #[dom_struct] pub struct VRFieldOfView { reflector_: Reflector, - #[ignore_heap_size_of = "Defined in rust-webvr"] + #[ignore_malloc_size_of = "Defined in rust-webvr"] fov: DomRefCell } diff --git a/components/script/dom/vrstageparameters.rs b/components/script/dom/vrstageparameters.rs index a2a185fd6cc..fa545621001 100644 --- a/components/script/dom/vrstageparameters.rs +++ b/components/script/dom/vrstageparameters.rs @@ -19,7 +19,7 @@ use webvr_traits::WebVRStageParameters; #[dom_struct] pub struct VRStageParameters { reflector_: Reflector, - #[ignore_heap_size_of = "Defined in rust-webvr"] + #[ignore_malloc_size_of = "Defined in rust-webvr"] parameters: DomRefCell, transform: Heap<*mut JSObject>, } diff --git a/components/script/dom/webgl_extensions/extensions.rs b/components/script/dom/webgl_extensions/extensions.rs index 9b022ac7def..85559612471 100644 --- a/components/script/dom/webgl_extensions/extensions.rs +++ b/components/script/dom/webgl_extensions/extensions.rs @@ -13,9 +13,9 @@ use dom::bindings::trace::JSTraceable; use dom::webglrenderingcontext::WebGLRenderingContext; use fnv::{FnvHashMap, FnvHashSet}; use gleam::gl::GLenum; -use heapsize::HeapSizeOf; use js::jsapi::JSContext; use js::jsval::JSVal; +use malloc_size_of::MallocSizeOf; use ref_filter_map::ref_filter_map; use std::cell::Ref; use std::collections::HashMap; @@ -45,7 +45,7 @@ const DEFAULT_DISABLED_GET_PARAMETER_NAMES: [GLenum; 1] = [ ]; /// WebGL features that are enabled/disabled by WebGL Extensions. -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct WebGLExtensionFeatures { gl_extensions: FnvHashSet, disabled_tex_types: FnvHashSet, @@ -74,7 +74,7 @@ impl Default for WebGLExtensionFeatures { /// Handles the list of implemented, supported and enabled WebGL extensions. #[must_root] -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct WebGLExtensions { extensions: DomRefCell>>, features: DomRefCell, @@ -97,7 +97,7 @@ impl WebGLExtensions { } } - pub fn register(&self) { + pub fn register(&self) { let name = T::name().to_uppercase(); self.extensions.borrow_mut().insert(name, Box::new(TypedWebGLExtensionWrapper::::new())); } @@ -122,7 +122,7 @@ impl WebGLExtensions { pub fn is_enabled(&self) -> bool where - T: 'static + WebGLExtension + JSTraceable + HeapSizeOf + T: 'static + WebGLExtension + JSTraceable + MallocSizeOf { let name = T::name().to_uppercase(); self.extensions.borrow().get(&name).map_or(false, |ext| { ext.is_enabled() }) @@ -130,7 +130,7 @@ impl WebGLExtensions { pub fn get_dom_object(&self) -> Option> where - T: 'static + WebGLExtension + JSTraceable + HeapSizeOf + T: 'static + WebGLExtension + JSTraceable + MallocSizeOf { let name = T::name().to_uppercase(); self.extensions.borrow().get(&name).and_then(|extension| { @@ -224,15 +224,15 @@ impl WebGLExtensions { } // Helper structs -#[derive(Eq, Hash, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Eq, Hash, JSTraceable, MallocSizeOf, PartialEq)] struct TexFormatType(u32, u32); type WebGLQueryParameterFunc = Fn(*mut JSContext, &WebGLRenderingContext) -> Result; -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] struct WebGLQueryParameterHandler { - #[ignore_heap_size_of = "Closures are hard"] + #[ignore_malloc_size_of = "Closures are hard"] func: Box } diff --git a/components/script/dom/webgl_extensions/wrapper.rs b/components/script/dom/webgl_extensions/wrapper.rs index 49d698bf14c..1c10e692f51 100644 --- a/components/script/dom/webgl_extensions/wrapper.rs +++ b/components/script/dom/webgl_extensions/wrapper.rs @@ -7,13 +7,13 @@ use dom::bindings::reflector::DomObject; use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::trace::JSTraceable; use dom::webglrenderingcontext::WebGLRenderingContext; -use heapsize::HeapSizeOf; +use malloc_size_of::MallocSizeOf; use std::any::Any; use super::{WebGLExtension, WebGLExtensions}; /// Trait used internally by WebGLExtensions to store and /// handle the different WebGL extensions in a common list. -pub trait WebGLExtensionWrapper: JSTraceable + HeapSizeOf { +pub trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf { fn instance_or_init(&self, ctx: &WebGLRenderingContext, ext: &WebGLExtensions) @@ -26,7 +26,7 @@ pub trait WebGLExtensionWrapper: JSTraceable + HeapSizeOf { } #[must_root] -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct TypedWebGLExtensionWrapper { extension: MutNullableDom } @@ -42,7 +42,7 @@ impl TypedWebGLExtensionWrapper { } impl WebGLExtensionWrapper for TypedWebGLExtensionWrapper - where T: WebGLExtension + JSTraceable + HeapSizeOf + 'static { + where T: WebGLExtension + JSTraceable + MallocSizeOf + 'static { #[allow(unsafe_code)] fn instance_or_init(&self, ctx: &WebGLRenderingContext, @@ -82,7 +82,9 @@ impl WebGLExtensionWrapper for TypedWebGLExtensionWrapper } } -impl TypedWebGLExtensionWrapper where T: WebGLExtension + JSTraceable + HeapSizeOf + 'static { +impl TypedWebGLExtensionWrapper + where T: WebGLExtension + JSTraceable + MallocSizeOf + 'static +{ pub fn dom_object(&self) -> Option> { self.extension.get() } diff --git a/components/script/dom/webgl_validations/types.rs b/components/script/dom/webgl_validations/types.rs index 9271175b462..a2bdaa0de2f 100644 --- a/components/script/dom/webgl_validations/types.rs +++ b/components/script/dom/webgl_validations/types.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderi /// with gl constants. macro_rules! type_safe_wrapper { ($name: ident, $($variant:ident => $mod:ident::$constant:ident, )+) => { - #[derive(Clone, Copy, Debug, Eq, Hash, HeapSizeOf, JSTraceable, PartialEq)] + #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, MallocSizeOf, PartialEq)] #[repr(u32)] pub enum $name { $( diff --git a/components/script/dom/webglbuffer.rs b/components/script/dom/webglbuffer.rs index fc916f99a6c..68cae62429b 100644 --- a/components/script/dom/webglbuffer.rs +++ b/components/script/dom/webglbuffer.rs @@ -27,7 +27,7 @@ pub struct WebGLBuffer { // The Vertex Array Objects that are referencing this buffer vao_references: DomRefCell>>, pending_delete: Cell, - #[ignore_heap_size_of = "Defined in ipc-channel"] + #[ignore_malloc_size_of = "Defined in ipc-channel"] renderer: WebGLMsgSender, } diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index 1fcfbf83f51..c9165609cdb 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -19,7 +19,7 @@ use dom_struct::dom_struct; use std::cell::Cell; #[must_root] -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] enum WebGLFramebufferAttachment { Renderbuffer(Dom), Texture { texture: Dom, level: i32 }, @@ -34,7 +34,7 @@ pub struct WebGLFramebuffer { is_deleted: Cell, size: Cell>, status: Cell, - #[ignore_heap_size_of = "Defined in ipc-channel"] + #[ignore_malloc_size_of = "Defined in ipc-channel"] renderer: WebGLMsgSender, // The attachment points for textures and renderbuffers on this diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 58b4b51f645..98b788fc2ae 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -27,7 +27,7 @@ pub struct WebGLProgram { linked: Cell, fragment_shader: MutNullableDom, vertex_shader: MutNullableDom, - #[ignore_heap_size_of = "Defined in ipc-channel"] + #[ignore_malloc_size_of = "Defined in ipc-channel"] renderer: WebGLMsgSender, } diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index c1cc99955b4..feac4eed416 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -21,7 +21,7 @@ pub struct WebGLRenderbuffer { is_deleted: Cell, size: Cell>, internal_format: Cell>, - #[ignore_heap_size_of = "Defined in ipc-channel"] + #[ignore_malloc_size_of = "Defined in ipc-channel"] renderer: WebGLMsgSender, } diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 98076fa4889..514fac1e492 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -135,7 +135,7 @@ fn has_invalid_blend_constants(arg1: u32, arg2: u32) -> bool { /// Set of bitflags for texture unpacking (texImage2d, etc...) bitflags! { - #[derive(HeapSizeOf, JSTraceable)] + #[derive(JSTraceable, MallocSizeOf)] flags TextureUnpacking: u8 { const FLIP_Y_AXIS = 0x01, const PREMULTIPLY_ALPHA = 0x02, @@ -145,7 +145,7 @@ bitflags! { /// Information about the bound textures of a WebGL texture unit. #[must_root] -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct TextureUnitBindings { bound_texture_2d: MutNullableDom, bound_texture_cube_map: MutNullableDom, @@ -181,15 +181,15 @@ impl TextureUnitBindings { #[dom_struct] pub struct WebGLRenderingContext { reflector_: Reflector, - #[ignore_heap_size_of = "Channels are hard"] + #[ignore_malloc_size_of = "Channels are hard"] webgl_sender: WebGLMsgSender, - #[ignore_heap_size_of = "Defined in webrender"] + #[ignore_malloc_size_of = "Defined in webrender"] webrender_image: Cell>, share_mode: WebGLContextShareMode, - #[ignore_heap_size_of = "Defined in offscreen_gl_context"] + #[ignore_malloc_size_of = "Defined in offscreen_gl_context"] limits: GLLimits, canvas: Dom, - #[ignore_heap_size_of = "Defined in canvas_traits"] + #[ignore_malloc_size_of = "Defined in canvas_traits"] last_error: Cell>, texture_unpacking_settings: Cell, texture_unpacking_alignment: Cell, @@ -201,11 +201,11 @@ pub struct WebGLRenderingContext { bound_buffer_element_array: MutNullableDom, bound_attrib_buffers: DomRefCell>>, current_program: MutNullableDom, - #[ignore_heap_size_of = "Because it's small"] + #[ignore_malloc_size_of = "Because it's small"] current_vertex_attrib_0: Cell<(f32, f32, f32, f32)>, - #[ignore_heap_size_of = "Because it's small"] + #[ignore_malloc_size_of = "Because it's small"] current_scissor: Cell<(i32, i32, i32, i32)>, - #[ignore_heap_size_of = "Because it's small"] + #[ignore_malloc_size_of = "Because it's small"] current_clear_color: Cell<(f32, f32, f32, f32)>, extension_manager: WebGLExtensions, } diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index d2060b1756c..781db93c8f2 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -18,7 +18,7 @@ use dom_struct::dom_struct; use std::cell::Cell; use std::sync::{ONCE_INIT, Once}; -#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] pub enum ShaderCompilationStatus { NotCompiled, Succeeded, @@ -35,7 +35,7 @@ pub struct WebGLShader { is_deleted: Cell, attached_counter: Cell, compilation_status: Cell, - #[ignore_heap_size_of = "Defined in ipc-channel"] + #[ignore_malloc_size_of = "Defined in ipc-channel"] renderer: WebGLMsgSender, } diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index 6927fd10a48..1336718eb00 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -36,7 +36,7 @@ pub struct WebGLTexture { target: Cell>, is_deleted: Cell, /// Stores information about mipmap levels and cubemap faces. - #[ignore_heap_size_of = "Arrays are cumbersome"] + #[ignore_malloc_size_of = "Arrays are cumbersome"] image_info_array: DomRefCell<[ImageInfo; MAX_LEVEL_COUNT * MAX_FACE_COUNT]>, /// Face count can only be 1 or 6 face_count: Cell, @@ -44,7 +44,7 @@ pub struct WebGLTexture { // Store information for min and mag filters min_filter: Cell>, mag_filter: Cell>, - #[ignore_heap_size_of = "Defined in ipc-channel"] + #[ignore_malloc_size_of = "Defined in ipc-channel"] renderer: WebGLMsgSender, /// True if this texture is used for the DOMToTexture feature. attached_to_dom: Cell, @@ -394,7 +394,7 @@ impl Drop for WebGLTexture { } } -#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] pub struct ImageInfo { width: u32, height: u32, diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 11172c403cb..47d3a6f3668 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -41,7 +41,7 @@ use task::{TaskOnce, TaskCanceller}; use task_source::TaskSource; use task_source::networking::NetworkingTaskSource; -#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] enum WebSocketRequestState { Connecting = 0, Open = 1, @@ -104,7 +104,7 @@ pub struct WebSocket { ready_state: Cell, buffered_amount: Cell, clearing_buffer: Cell, //Flag to tell if there is a running thread to clear buffered_amount - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] sender: DomRefCell>>, binary_type: Cell, protocol: DomRefCell, //Subprotocol selected by server diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 9d2137911d7..6a62e124b92 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -127,14 +127,14 @@ use webrender_api::{ClipId, DocumentId}; use webvr_traits::WebVRMsg; /// Current state of the window object -#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] enum WindowState { Alive, Zombie, // Pipeline is closed, but the window hasn't been GCed yet. } /// Extra information concerning the reason for reflowing. -#[derive(Debug, HeapSizeOf)] +#[derive(Debug, MallocSizeOf)] pub enum ReflowReason { CachedPageNeededReflow, RefreshTick, @@ -161,24 +161,24 @@ pub enum ReflowReason { #[dom_struct] pub struct Window { globalscope: GlobalScope, - #[ignore_heap_size_of = "trait objects are hard"] + #[ignore_malloc_size_of = "trait objects are hard"] script_chan: MainThreadScriptChan, - #[ignore_heap_size_of = "task sources are hard"] + #[ignore_malloc_size_of = "task sources are hard"] dom_manipulation_task_source: DOMManipulationTaskSource, - #[ignore_heap_size_of = "task sources are hard"] + #[ignore_malloc_size_of = "task sources are hard"] user_interaction_task_source: UserInteractionTaskSource, - #[ignore_heap_size_of = "task sources are hard"] + #[ignore_malloc_size_of = "task sources are hard"] networking_task_source: NetworkingTaskSource, - #[ignore_heap_size_of = "task sources are hard"] + #[ignore_malloc_size_of = "task sources are hard"] history_traversal_task_source: HistoryTraversalTaskSource, - #[ignore_heap_size_of = "task sources are hard"] + #[ignore_malloc_size_of = "task sources are hard"] file_reading_task_source: FileReadingTaskSource, - #[ignore_heap_size_of = "task sources are hard"] + #[ignore_malloc_size_of = "task sources are hard"] performance_timeline_task_source: PerformanceTimelineTaskSource, navigator: MutNullableDom, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] image_cache: Arc, - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] image_cache_chan: Sender, window_proxy: MutNullableDom, document: MutNullableDom, @@ -196,7 +196,7 @@ pub struct Window { /// For sending timeline markers. Will be ignored if /// no devtools server devtools_markers: DomRefCell>, - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] devtools_marker_sender: DomRefCell>>>, /// Pending resize event, if any. @@ -209,22 +209,22 @@ pub struct Window { dom_static: GlobalStaticData, /// The JavaScript runtime. - #[ignore_heap_size_of = "Rc is hard"] + #[ignore_malloc_size_of = "Rc is hard"] js_runtime: DomRefCell>>, /// A handle for communicating messages to the layout thread. - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] layout_chan: Sender, /// A handle to perform RPC calls into the layout, quickly. - #[ignore_heap_size_of = "trait objects are hard"] + #[ignore_malloc_size_of = "trait objects are hard"] layout_rpc: Box, /// The current size of the window, in pixels. window_size: Cell>, /// A handle for communicating messages to the bluetooth thread. - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] bluetooth_thread: IpcSender, bluetooth_extra_permission_data: BluetoothExtraPermissionData, @@ -242,7 +242,7 @@ pub struct Window { pending_reflow_count: Cell, /// A channel for communicating results of async scripts back to the webdriver server - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] webdriver_script_chan: DomRefCell>>, /// The current state of the window object @@ -251,7 +251,7 @@ pub struct Window { current_viewport: Cell>, /// A flag to prevent async events from attempting to interact with this window. - #[ignore_heap_size_of = "defined in std"] + #[ignore_malloc_size_of = "defined in std"] ignore_further_async_events: DomRefCell>, error_reporter: CSSErrorReporter, @@ -265,11 +265,11 @@ pub struct Window { test_runner: MutNullableDom, /// A handle for communicating messages to the webvr thread, if available. - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] webgl_chan: WebGLChan, /// A handle for communicating messages to the webvr thread, if available. - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] webvr_chan: Option>, /// A map for storing the previous permission state read results. @@ -290,7 +290,7 @@ pub struct Window { /// paint_worklet: MutNullableDom, /// The Webrender Document id associated with this window. - #[ignore_heap_size_of = "defined in webrender_api"] + #[ignore_malloc_size_of = "defined in webrender_api"] webrender_document: DocumentId, } diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 4963b57c3aa..f397ef42148 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -36,12 +36,13 @@ pub type TrustedWorkerAddress = Trusted; #[dom_struct] pub struct Worker { eventtarget: EventTarget, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] /// Sender to the Receiver associated with the DedicatedWorkerGlobalScope /// this Worker created. sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>, + #[ignore_malloc_size_of = "Arc"] closing: Arc, - #[ignore_heap_size_of = "Defined in rust-mozjs"] + #[ignore_malloc_size_of = "Defined in rust-mozjs"] runtime: Arc>>, terminated: Cell, } diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index ca7e2c3b7a9..760f879b37e 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -73,19 +73,19 @@ pub struct WorkerGlobalScope { worker_id: WorkerId, worker_url: ServoUrl, - #[ignore_heap_size_of = "Arc"] + #[ignore_malloc_size_of = "Arc"] closing: Option>, - #[ignore_heap_size_of = "Defined in js"] + #[ignore_malloc_size_of = "Defined in js"] runtime: Runtime, location: MutNullableDom, navigator: MutNullableDom, - #[ignore_heap_size_of = "Defined in ipc-channel"] + #[ignore_malloc_size_of = "Defined in ipc-channel"] /// Optional `IpcSender` for sending the `DevtoolScriptControlMsg` /// to the server from within the worker from_devtools_sender: Option>, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] /// This `Receiver` will be ignored later if the corresponding /// `IpcSender` doesn't exist from_devtools_receiver: Receiver, diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs index ae122c8e0d5..7a608a189e1 100644 --- a/components/script/dom/worklet.rs +++ b/components/script/dom/worklet.rs @@ -151,7 +151,7 @@ impl WorkletMethods for Worklet { #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, PartialEq)] pub struct WorkletId(Uuid); -known_heap_size!(0, WorkletId); +malloc_size_of_is_0!(WorkletId); impl WorkletId { fn new() -> WorkletId { @@ -653,10 +653,10 @@ impl WorkletThread { } /// An executor of worklet tasks -#[derive(Clone, HeapSizeOf, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] pub struct WorkletExecutor { worklet_id: WorkletId, - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] primary_sender: Sender, } diff --git a/components/script/dom/workletglobalscope.rs b/components/script/dom/workletglobalscope.rs index 3dea747ee74..653c8e6468e 100644 --- a/components/script/dom/workletglobalscope.rs +++ b/components/script/dom/workletglobalscope.rs @@ -40,7 +40,7 @@ pub struct WorkletGlobalScope { /// The base URL for this worklet. base_url: ServoUrl, /// Sender back to the script thread - #[ignore_heap_size_of = "channels are hard"] + #[ignore_malloc_size_of = "channels are hard"] to_script_thread_sender: Sender, /// Worklet task executor executor: WorkletExecutor, @@ -155,7 +155,7 @@ pub struct WorkletGlobalScopeInit { } /// -#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable)] +#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)] pub enum WorkletGlobalScopeType { /// A servo-specific testing worklet Test, diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 2baa7351034..68a96ca38d6 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -73,7 +73,7 @@ use time; use timers::{OneshotTimerCallback, OneshotTimerHandle}; use url::Position; -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] enum XMLHttpRequestState { Unsent = 0, Opened = 1, @@ -82,7 +82,7 @@ enum XMLHttpRequestState { Done = 4, } -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub struct GenerationId(u32); /// Closure of required data for each async network event that comprises the @@ -131,20 +131,20 @@ pub struct XMLHttpRequest { response_type: Cell, response_xml: MutNullableDom, response_blob: MutNullableDom, - #[ignore_heap_size_of = "Defined in rust-mozjs"] + #[ignore_malloc_size_of = "Defined in rust-mozjs"] response_json: Heap, - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] response_headers: DomRefCell, - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] override_mime_type: DomRefCell>, - #[ignore_heap_size_of = "Defined in rust-encoding"] + #[ignore_malloc_size_of = "Defined in rust-encoding"] override_charset: DomRefCell>, // Associated concepts - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] request_method: DomRefCell, request_url: DomRefCell>, - #[ignore_heap_size_of = "Defined in hyper"] + #[ignore_malloc_size_of = "Defined in hyper"] request_headers: DomRefCell, request_body_len: Cell, sync: Cell, @@ -1243,7 +1243,7 @@ impl XMLHttpRequest { use std::fmt; // a dummy header so we can use headers.remove::() - #[derive(Clone, Debug, HeapSizeOf)] + #[derive(Clone, Debug, MallocSizeOf)] struct SetCookie2; impl Header for SetCookie2 { fn header_name() -> &'static str { @@ -1334,9 +1334,9 @@ impl XMLHttpRequest { } } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct XHRTimeoutCallback { - #[ignore_heap_size_of = "Because it is non-owning"] + #[ignore_malloc_size_of = "Because it is non-owning"] xhr: Trusted, generation_id: GenerationId, } diff --git a/components/script/lib.rs b/components/script/lib.rs index 5f33f1e1151..edf954d4c96 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -39,8 +39,6 @@ extern crate euclid; extern crate fnv; extern crate gleam; extern crate half; -#[macro_use] extern crate heapsize; -#[macro_use] extern crate heapsize_derive; #[macro_use] extern crate html5ever; #[macro_use] extern crate hyper; @@ -56,6 +54,8 @@ extern crate lazy_static; extern crate libc; #[macro_use] extern crate log; +#[macro_use] extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; extern crate metrics; #[macro_use] extern crate mime; diff --git a/components/script/mem.rs b/components/script/mem.rs index b40a78ec569..47491359a6d 100644 --- a/components/script/mem.rs +++ b/components/script/mem.rs @@ -6,24 +6,28 @@ use dom::bindings::conversions::get_dom_class; use dom::bindings::reflector::DomObject; -use heapsize::{HeapSizeOf, heap_size_of}; +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use std::os::raw::c_void; // This is equivalent to measuring a Box, except that DOM objects lose their // associated box in order to stash their pointers in a reserved slot of their // JS reflector. #[allow(unsafe_code)] -pub fn heap_size_of_self_and_children(obj: &T) -> usize { +pub fn malloc_size_of_including_self( + ops: &mut MallocSizeOfOps, obj: &T) -> usize +{ unsafe { let class = get_dom_class(obj.reflector().get_jsobject().get()).unwrap(); - (class.heap_size_of)(obj as *const T as *const c_void) + (class.malloc_size_of)(ops, obj as *const T as *const c_void) } } -/// Used by codegen to include the pointer to the `HeapSizeOf` implementation of each +/// Used by codegen to include the pointer to the `MallocSizeOf` implementation of each /// IDL interface. This way we don't have to find the most-derived interface of DOM /// objects by hand in code. #[allow(unsafe_code)] -pub unsafe fn heap_size_of_raw_self_and_children(obj: *const c_void) -> usize { - heap_size_of(obj) + (*(obj as *const T)).heap_size_of_children() +pub unsafe fn malloc_size_of_including_raw_self( + ops: &mut MallocSizeOfOps, obj: *const c_void) -> usize +{ + ops.malloc_size_of(obj) + (*(obj as *const T)).size_of(ops) } diff --git a/components/script/microtask.rs b/components/script/microtask.rs index 7560d97d883..8457a43b1b8 100644 --- a/components/script/microtask.rs +++ b/components/script/microtask.rs @@ -21,7 +21,7 @@ use std::mem; use std::rc::Rc; /// A collection of microtasks in FIFO order. -#[derive(Default, HeapSizeOf, JSTraceable)] +#[derive(Default, JSTraceable, MallocSizeOf)] pub struct MicrotaskQueue { /// The list of enqueued microtasks that will be invoked at the next microtask checkpoint. microtask_queue: DomRefCell>, @@ -29,7 +29,7 @@ pub struct MicrotaskQueue { performing_a_microtask_checkpoint: Cell, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub enum Microtask { Promise(EnqueuedPromiseCallback), MediaElement(MediaElementMicrotask), @@ -43,9 +43,9 @@ pub trait MicrotaskRunnable { } /// A promise callback scheduled to run during the next microtask checkpoint (#4283). -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct EnqueuedPromiseCallback { - #[ignore_heap_size_of = "Rc has unclear ownership"] + #[ignore_malloc_size_of = "Rc has unclear ownership"] pub callback: Rc, pub pipeline: PipelineId, } diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 1413a0c40dc..e5a9a0401aa 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -73,7 +73,8 @@ use js::jsapi::{JSAutoCompartment, JSContext, JS_SetWrapObjectCallbacks}; use js::jsapi::{JSTracer, SetWindowProxyClass}; use js::jsval::UndefinedValue; use js::rust::Runtime; -use mem::heap_size_of_self_and_children; +use malloc_size_of::{malloc_size_of, MallocSizeOfOps}; +use mem::malloc_size_of_including_self; use metrics::PaintTimeMetrics; use microtask::{MicrotaskQueue, Microtask}; use msg::constellation_msg::{BrowsingContextId, FrameType, PipelineId, PipelineNamespace, TopLevelBrowsingContextId}; @@ -1503,14 +1504,17 @@ impl ScriptThread { let mut path_seg = String::from("url("); let mut dom_tree_size = 0; let mut reports = vec![]; + // Servo uses vanilla jemalloc, which doesn't have a + // malloc_enclosing_size_of function. + let mut ops = MallocSizeOfOps::new(malloc_size_of, None, None); for (_, document) in self.documents.borrow().iter() { let current_url = document.url(); for child in document.upcast::().traverse_preorder() { - dom_tree_size += heap_size_of_self_and_children(&*child); + dom_tree_size += malloc_size_of_including_self(&mut ops, &*child); } - dom_tree_size += heap_size_of_self_and_children(document.window()); + dom_tree_size += malloc_size_of_including_self(&mut ops, document.window()); if reports.len() > 0 { path_seg.push_str(", "); diff --git a/components/script/textinput.rs b/components/script/textinput.rs index a2374cb6a82..3c533964b7d 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -22,7 +22,7 @@ pub enum Selection { NotSelected } -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub enum SelectionDirection { Forward, Backward, @@ -49,7 +49,7 @@ impl From for DOMString { } } -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub struct TextPoint { /// 0-based line number pub line: usize, @@ -58,7 +58,7 @@ pub struct TextPoint { } /// Encapsulated state for handling keyboard input in a single or multiline text input control. -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct TextInput { /// Current text input content, split across lines without trailing '\n' lines: Vec, @@ -68,7 +68,7 @@ pub struct TextInput { pub selection_begin: Option, /// Is this a multiline input? multiline: bool, - #[ignore_heap_size_of = "Can't easily measure this generic type"] + #[ignore_malloc_size_of = "Can't easily measure this generic type"] clipboard_provider: T, /// The maximum number of UTF-16 code units this text input is allowed to hold. /// diff --git a/components/script/timers.rs b/components/script/timers.rs index 1f69eca03ba..4bc4bf37fff 100644 --- a/components/script/timers.rs +++ b/components/script/timers.rs @@ -13,7 +13,6 @@ use dom::globalscope::GlobalScope; use dom::testbinding::TestBindingCallback; use dom::xmlhttprequest::XHRTimeoutCallback; use euclid::Length; -use heapsize::HeapSizeOf; use ipc_channel::ipc::IpcSender; use js::jsapi::{HandleValue, Heap}; use js::jsval::{JSVal, UndefinedValue}; @@ -27,15 +26,15 @@ use std::collections::HashMap; use std::default::Default; use std::rc::Rc; -#[derive(Clone, Copy, Debug, Eq, Hash, HeapSizeOf, JSTraceable, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)] pub struct OneshotTimerHandle(i32); -#[derive(DenyPublicFields, HeapSizeOf, JSTraceable)] +#[derive(DenyPublicFields, JSTraceable, MallocSizeOf)] pub struct OneshotTimers { js_timers: JsTimers, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] timer_event_chan: IpcSender, - #[ignore_heap_size_of = "Defined in std"] + #[ignore_malloc_size_of = "Defined in std"] scheduler_chan: IpcSender, next_timer_handle: Cell, timers: DomRefCell>, @@ -54,7 +53,7 @@ pub struct OneshotTimers { expected_event_id: Cell, } -#[derive(DenyPublicFields, HeapSizeOf, JSTraceable)] +#[derive(DenyPublicFields, JSTraceable, MallocSizeOf)] struct OneshotTimer { handle: OneshotTimerHandle, source: TimerSource, @@ -65,7 +64,7 @@ struct OneshotTimer { // This enum is required to work around the fact that trait objects do not support generic methods. // A replacement trait would have a method such as // `invoke(self: Box, this: &T, js_timers: &JsTimers);`. -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub enum OneshotTimerCallback { XhrTimeout(XHRTimeoutCallback), EventSourceTimeout(EventSourceTimeoutCallback), @@ -301,10 +300,10 @@ impl OneshotTimers { } } -#[derive(Clone, Copy, Eq, Hash, HeapSizeOf, JSTraceable, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Eq, Hash, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)] pub struct JsTimerHandle(i32); -#[derive(DenyPublicFields, HeapSizeOf, JSTraceable)] +#[derive(DenyPublicFields, JSTraceable, MallocSizeOf)] pub struct JsTimers { next_timer_handle: Cell, active_timers: DomRefCell>, @@ -314,7 +313,7 @@ pub struct JsTimers { min_duration: Cell>, } -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] struct JsTimerEntry { oneshot_handle: OneshotTimerHandle, } @@ -323,9 +322,9 @@ struct JsTimerEntry { // (ie. function value to invoke and all arguments to pass // to the function when calling it) // TODO: Handle rooting during invocation when movable GC is turned on -#[derive(HeapSizeOf, JSTraceable)] +#[derive(JSTraceable, MallocSizeOf)] pub struct JsTimerTask { - #[ignore_heap_size_of = "Because it is non-owning"] + #[ignore_malloc_size_of = "Because it is non-owning"] handle: JsTimerHandle, source: TimerSource, callback: InternalTimerCallback, @@ -335,7 +334,7 @@ pub struct JsTimerTask { } // Enum allowing more descriptive values for the is_interval field -#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub enum IsInterval { Interval, NonInterval, @@ -347,17 +346,14 @@ pub enum TimerCallback { FunctionTimerCallback(Rc), } -#[derive(Clone, JSTraceable)] +#[derive(Clone, JSTraceable, MallocSizeOf)] enum InternalTimerCallback { StringTimerCallback(DOMString), - FunctionTimerCallback(Rc, Rc]>>), -} - -impl HeapSizeOf for InternalTimerCallback { - fn heap_size_of_children(&self) -> usize { - // FIXME: Rc isn't HeapSizeOf and we can't ignore it due to #6870 and #6871 - 0 - } + FunctionTimerCallback( + #[ignore_malloc_size_of = "Rc"] + Rc, + #[ignore_malloc_size_of = "Rc"] + Rc]>>), } impl JsTimers { diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml index 47e47222c7d..087dc984e42 100644 --- a/components/script_layout_interface/Cargo.toml +++ b/components/script_layout_interface/Cargo.toml @@ -16,12 +16,12 @@ canvas_traits = {path = "../canvas_traits"} cssparser = "0.22.0" euclid = "0.15" gfx_traits = {path = "../gfx_traits"} -heapsize = "0.4" -heapsize_derive = "0.1" html5ever = "0.20.0" ipc-channel = "0.9" libc = "0.2" log = "0.3.5" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } metrics = {path = "../metrics"} msg = {path = "../msg"} net_traits = {path = "../net_traits"} diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs index 0216ca84543..4e17570f92d 100644 --- a/components/script_layout_interface/lib.rs +++ b/components/script_layout_interface/lib.rs @@ -14,13 +14,13 @@ extern crate canvas_traits; extern crate cssparser; extern crate euclid; extern crate gfx_traits; -extern crate heapsize; -#[macro_use] extern crate heapsize_derive; #[macro_use] extern crate html5ever; extern crate ipc_channel; extern crate libc; #[macro_use] extern crate log; +extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; extern crate metrics; extern crate msg; extern crate net_traits; @@ -72,11 +72,11 @@ impl StyleData { } } -#[derive(Clone, Copy, HeapSizeOf)] +#[derive(Clone, Copy, MallocSizeOf)] pub struct OpaqueStyleAndLayoutData { // NB: We really store a `StyleAndLayoutData` here, so be careful! - #[ignore_heap_size_of = "TODO(#6910) Box value that should be counted but \ - the type lives in layout"] + #[ignore_malloc_size_of = "TODO(#6910) Box value that should be counted but \ + the type lives in layout"] pub ptr: NonZero<*mut StyleData>, } @@ -84,7 +84,7 @@ pub struct OpaqueStyleAndLayoutData { unsafe impl Send for OpaqueStyleAndLayoutData {} /// Information that we need stored in each DOM node. -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] pub struct DomParallelInfo { /// The number of children remaining to process during bottom-up traversal. pub children_to_process: AtomicIsize, diff --git a/components/script_layout_interface/reporter.rs b/components/script_layout_interface/reporter.rs index 7f5acfef8c1..42adfa40d52 100644 --- a/components/script_layout_interface/reporter.rs +++ b/components/script_layout_interface/reporter.rs @@ -11,13 +11,13 @@ use servo_url::ServoUrl; use std::sync::{Mutex, Arc}; use style::error_reporting::{ParseErrorReporter, ContextualParseError}; -#[derive(Clone, HeapSizeOf)] +#[derive(Clone, MallocSizeOf)] pub struct CSSErrorReporter { pub pipelineid: PipelineId, // Arc+Mutex combo is necessary to make this struct Sync, // which is necessary to fulfill the bounds required by the // uses of the ParseErrorReporter trait. - #[ignore_heap_size_of = "Arc is defined in libstd"] + #[ignore_malloc_size_of = "Arc is defined in libstd"] pub script_chan: Arc>>, } diff --git a/components/script_traits/Cargo.toml b/components/script_traits/Cargo.toml index 88fb50c3384..274f8435d73 100644 --- a/components/script_traits/Cargo.toml +++ b/components/script_traits/Cargo.toml @@ -16,12 +16,12 @@ cookie = "0.6" devtools_traits = {path = "../devtools_traits"} euclid = "0.15" gfx_traits = {path = "../gfx_traits"} -heapsize = "0.4" -heapsize_derive = "0.1" hyper = "0.10" hyper_serde = "0.7" ipc-channel = "0.9" libc = "0.2" +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } msg = {path = "../msg"} net_traits = {path = "../net_traits"} profile_traits = {path = "../profile_traits"} @@ -31,6 +31,6 @@ servo_atoms = {path = "../atoms"} servo_url = {path = "../url"} style_traits = {path = "../style_traits", features = ["servo"]} time = "0.1.12" -url = {version = "1.2", features = ["heap_size"]} +url = "1.2" webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} webvr_traits = {path = "../webvr_traits"} diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 1b9beaf37ff..16c16b83ebe 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -15,13 +15,14 @@ extern crate cookie as cookie_rs; extern crate devtools_traits; extern crate euclid; extern crate gfx_traits; -extern crate heapsize; -#[macro_use] -extern crate heapsize_derive; extern crate hyper; extern crate hyper_serde; extern crate ipc_channel; extern crate libc; +#[macro_use] +extern crate malloc_size_of; +#[macro_use] +extern crate malloc_size_of_derive; extern crate msg; extern crate net_traits; extern crate profile_traits; @@ -42,7 +43,6 @@ use canvas_traits::webgl::WebGLPipeline; use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId}; use euclid::{Size2D, Length, Point2D, Vector2D, Rect, ScaleFactor, TypedSize2D}; use gfx_traits::Epoch; -use heapsize::HeapSizeOf; use hyper::header::Headers; use hyper::method::Method; use ipc_channel::{Error as IpcError}; @@ -81,11 +81,7 @@ pub use script_msg::{ServiceWorkerMsg, ScopeThings, SWManagerMsg, SWManagerSende #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub struct UntrustedNodeAddress(pub *const c_void); -impl HeapSizeOf for UntrustedNodeAddress { - fn heap_size_of_children(&self) -> usize { - 0 - } -} +malloc_size_of_is_0!(UntrustedNodeAddress); #[allow(unsafe_code)] unsafe impl Send for UntrustedNodeAddress {} @@ -225,7 +221,7 @@ pub enum DiscardBrowsingContext { /// /// * /// * -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub enum DocumentActivity { /// An inactive document Inactive, @@ -245,7 +241,7 @@ pub enum PaintMetricType { } /// The reason why the pipeline id of an iframe is being updated. -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] pub enum UpdatePipelineIdReason { /// The pipeline id is being updated due to a navigation. Navigation, @@ -420,7 +416,7 @@ pub enum MouseButton { } /// The types of mouse events -#[derive(Deserialize, HeapSizeOf, Serialize)] +#[derive(Deserialize, MallocSizeOf, Serialize)] pub enum MouseEventType { /// Mouse button clicked Click, @@ -448,7 +444,7 @@ pub enum CompositorEvent { } /// Touchpad pressure phase for `TouchpadPressureEvent`. -#[derive(Clone, Copy, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum TouchpadPressurePhase { /// Pressure before a regular click. BeforeClick, @@ -478,7 +474,7 @@ pub enum TimerSchedulerMsg { pub struct TimerEvent(pub TimerSource, pub TimerEventId); /// Describes the thread that requested the TimerEvent. -#[derive(Clone, Copy, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, Serialize)] pub enum TimerSource { /// The event was requested from a window (ScriptThread). FromWindow(PipelineId), @@ -487,14 +483,14 @@ pub enum TimerSource { } /// The id to be used for a `TimerEvent` is defined by the corresponding `TimerEventRequest`. -#[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)] pub struct TimerEventId(pub u32); /// Unit of measurement. -#[derive(Clone, Copy, HeapSizeOf)] +#[derive(Clone, Copy, MallocSizeOf)] pub enum Milliseconds {} /// Unit of measurement. -#[derive(Clone, Copy, HeapSizeOf)] +#[derive(Clone, Copy, MallocSizeOf)] pub enum Nanoseconds {} /// Amount of milliseconds. @@ -721,7 +717,7 @@ pub struct ScrollState { } /// Data about the window size. -#[derive(Clone, Copy, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Copy, Deserialize, MallocSizeOf, Serialize)] pub struct WindowSizeData { /// The size of the initial layout viewport, before parsing an /// @@ -732,7 +728,7 @@ pub struct WindowSizeData { } /// The type of window size change. -#[derive(Clone, Copy, Deserialize, Eq, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Copy, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)] pub enum WindowSizeType { /// Initial load. Initial, @@ -877,7 +873,7 @@ impl fmt::Debug for Painter { /// The result of executing paint code: the image together with any image URLs that need to be loaded. /// /// TODO: this should return a WR display list. -#[derive(Clone, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub struct DrawAPaintImageResult { /// The image height pub width: u32, diff --git a/components/servo_arc/Cargo.toml b/components/servo_arc/Cargo.toml index 51e4dcccc16..9a82346e68b 100644 --- a/components/servo_arc/Cargo.toml +++ b/components/servo_arc/Cargo.toml @@ -10,10 +10,9 @@ name = "servo_arc" path = "lib.rs" [features] -servo = ["serde", "heapsize"] +servo = ["serde"] [dependencies] -heapsize = {version = "0.4.0", optional = true} nodrop = {version = "0.1.8"} serde = {version = "1.0", optional = true} stable_deref_trait = "1.0.0" diff --git a/components/servo_arc/lib.rs b/components/servo_arc/lib.rs index 22d443a2db3..cc378e237d3 100644 --- a/components/servo_arc/lib.rs +++ b/components/servo_arc/lib.rs @@ -27,8 +27,6 @@ extern crate nodrop; #[cfg(feature = "servo")] extern crate serde; extern crate stable_deref_trait; -#[cfg(feature = "servo")] -use heapsize::HeapSizeOf; use nodrop::NoDrop; #[cfg(feature = "servo")] use serde::{Deserialize, Serialize}; @@ -476,15 +474,6 @@ impl AsRef for Arc { unsafe impl StableDeref for Arc {} unsafe impl CloneStableDeref for Arc {} -// This is what the HeapSize crate does for regular arc, but is questionably -// sound. See https://github.com/servo/heapsize/issues/37 -#[cfg(feature = "servo")] -impl HeapSizeOf for Arc { - fn heap_size_of_children(&self) -> usize { - (**self).heap_size_of_children() - } -} - #[cfg(feature = "servo")] impl<'de, T: Deserialize<'de>> Deserialize<'de> for Arc { diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 140c1b7d094..eb79cdbe40f 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -16,12 +16,11 @@ path = "lib.rs" doctest = false [features] -gecko = ["malloc_size_of", "malloc_size_of_derive", "nsstring_vendor", "num_cpus", +gecko = ["nsstring_vendor", "num_cpus", "style_traits/gecko", "fallible/known_system_malloc"] use_bindgen = ["bindgen", "regex", "toml"] -servo = ["serde", "heapsize", "heapsize_derive", - "style_traits/servo", "servo_atoms", "servo_config", "html5ever", - "cssparser/heapsize", "cssparser/serde", "encoding", "smallvec/heapsizeof", +servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever", + "cssparser/serde", "encoding", "malloc_size_of/servo", # FIXME: Uncomment when https://github.com/servo/servo/pull/16953 has landed: #"arrayvec/use_union" @@ -42,16 +41,14 @@ euclid = "0.15" fallible = { path = "../fallible" } fnv = "1.0" hashglobe = { path = "../hashglobe" } -heapsize = {version = "0.4", optional = true} -heapsize_derive = {version = "0.1", optional = true} itertools = "0.5" itoa = "0.3" html5ever = {version = "0.20", optional = true} lazy_static = "0.2" lru_cache = { path = "../lru_cache" } log = "0.3" -malloc_size_of = { path = "../malloc_size_of", optional=true } -malloc_size_of_derive = { path = "../malloc_size_of_derive", optional=true } +malloc_size_of = { path = "../malloc_size_of" } +malloc_size_of_derive = { path = "../malloc_size_of_derive" } matches = "0.1" nsstring_vendor = {path = "gecko_bindings/nsstring_vendor", optional = true} num_cpus = {version = "1.1.0", optional = true} diff --git a/components/style/applicable_declarations.rs b/components/style/applicable_declarations.rs index 0824b60a0a2..48597c33a10 100644 --- a/components/style/applicable_declarations.rs +++ b/components/style/applicable_declarations.rs @@ -36,9 +36,7 @@ const SOURCE_ORDER_MASK: u32 = (1 << SOURCE_ORDER_BITS) - 1; const SOURCE_ORDER_MAX: u32 = SOURCE_ORDER_MASK; /// Stores the source order of a block and the cascade level it belongs to. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Eq, PartialEq)] +#[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq)] struct SourceOrderAndCascadeLevel(u32); impl SourceOrderAndCascadeLevel { @@ -76,13 +74,10 @@ impl Debug for SourceOrderAndCascadeLevel { /// /// This represents the declarations in a given declaration block for a given /// importance. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct ApplicableDeclarationBlock { /// The style source, either a style rule, or a property declaration block. - #[cfg_attr(feature = "gecko", ignore_malloc_size_of = "contains Arcs")] - #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + #[ignore_malloc_size_of = "Arc"] pub source: StyleSource, /// The source order of the block, and the cascade level it belongs to. order_and_level: SourceOrderAndCascadeLevel, diff --git a/components/style/attr.rs b/components/style/attr.rs index 60757990c3f..7306b2e9e1d 100644 --- a/components/style/attr.rs +++ b/components/style/attr.rs @@ -27,7 +27,7 @@ use values::specified::Length; const UNSIGNED_LONG_MAX: u32 = 2147483647; #[derive(Clone, Copy, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum LengthOrPercentageOrAuto { Auto, Percentage(f32), @@ -35,7 +35,7 @@ pub enum LengthOrPercentageOrAuto { } #[derive(Clone, Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum AttrValue { String(String), TokenList(String, Vec), @@ -66,7 +66,7 @@ pub enum AttrValue { /// declaration block), but that avoids keeping a refcounted /// declarationblock for longer than needed. Declaration(String, - #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + #[ignore_malloc_size_of = "Arc"] Arc>) } @@ -596,7 +596,7 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto { /// A struct that uniquely identifies an element's attribute. #[derive(Clone, Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct AttrIdentifier { pub local_name: LocalName, pub name: LocalName, diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index d29d948fab1..90446ec02e7 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -41,9 +41,7 @@ pub fn parse_name(s: &str) -> Result<&str, ()> { /// /// We preserve the original CSS for serialization, and also the variable /// references to other custom property names. -#[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct VariableValue { css: String, diff --git a/components/style/dom.rs b/components/style/dom.rs index 766b217863f..e9405fdc767 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -44,7 +44,7 @@ use traversal_flags::{TraversalFlags, self}; /// data structures. Also, layout code tends to be faster when the DOM is not being accessed, for /// locality reasons. Using `OpaqueNode` enforces this invariant. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf, Deserialize, Serialize))] pub struct OpaqueNode(pub usize); impl OpaqueNode { diff --git a/components/style/element_state.rs b/components/style/element_state.rs index 7c7f5c5d07a..d6ecc3bf5a9 100644 --- a/components/style/element_state.rs +++ b/components/style/element_state.rs @@ -14,8 +14,7 @@ bitflags! { /// /// TODO(emilio): We really really want to use the NS_EVENT_STATE bindings /// for this. - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(MallocSizeOf)] pub flags ElementState: u64 { /// The mouse is down on this element. /// diff --git a/components/style/invalidation/element/invalidation_map.rs b/components/style/invalidation/element/invalidation_map.rs index bcc597330f1..1ee1358a91a 100644 --- a/components/style/invalidation/element/invalidation_map.rs +++ b/components/style/invalidation/element/invalidation_map.rs @@ -55,14 +55,12 @@ pub fn dir_selector_to_state(s: &[u16]) -> ElementState { /// This allows us to quickly scan through the dependency sites of all style /// rules and determine the maximum effect that a given state or attribute /// change may have on the style of elements in the document. -#[derive(Clone, Debug)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Debug, MallocSizeOf)] pub struct Dependency { /// The dependency selector. #[cfg_attr(feature = "gecko", ignore_malloc_size_of = "CssRules have primary refs, we measure there")] - #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + #[cfg_attr(feature = "servo", ignore_malloc_size_of = "Arc")] pub selector: Selector, /// The offset into the selector that we should match on. @@ -115,9 +113,7 @@ impl SelectorMapEntry for Dependency { /// The same, but for state selectors, which can track more exactly what state /// do they track. -#[derive(Clone, Debug)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Debug, MallocSizeOf)] pub struct StateDependency { /// The other dependency fields. pub dep: Dependency, @@ -139,9 +135,7 @@ impl SelectorMapEntry for StateDependency { /// In particular, we want to lookup as few things as possible to get the fewer /// selectors the better, so this looks up by id, class, or looks at the list of /// state/other attribute affecting selectors. -#[derive(Debug)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug, MallocSizeOf)] pub struct InvalidationMap { /// A map from a given class name to all the selectors with that class /// selector. diff --git a/components/style/invalidation/element/restyle_hints.rs b/components/style/invalidation/element/restyle_hints.rs index 94bab930732..06549e4fb0f 100644 --- a/components/style/invalidation/element/restyle_hints.rs +++ b/components/style/invalidation/element/restyle_hints.rs @@ -230,9 +230,7 @@ impl From for RestyleHint { } #[cfg(feature = "servo")] -impl ::heapsize::HeapSizeOf for RestyleHint { - fn heap_size_of_children(&self) -> usize { 0 } -} +malloc_size_of_is_0!(RestyleHint); /// Asserts that all replacement hints have a matching nsRestyleHint value. #[cfg(feature = "gecko")] diff --git a/components/style/invalidation/media_queries.rs b/components/style/invalidation/media_queries.rs index 9521e3cdc16..f9a7d47f49f 100644 --- a/components/style/invalidation/media_queries.rs +++ b/components/style/invalidation/media_queries.rs @@ -23,9 +23,7 @@ use stylesheets::{NestedRuleIterationCondition, Stylesheet, SupportsRule}; /// /// If this changes, though, we may need to remove the item from the cache if /// present before it goes away. -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)] pub struct MediaListKey(usize); impl MediaListKey { @@ -53,9 +51,7 @@ impl ToMediaListKey for MediaRule {} /// A struct that holds the result of a media query evaluation pass for the /// media queries that evaluated successfully. -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug, MallocSizeOf, PartialEq)] pub struct EffectiveMediaQueryResults { /// The set of media lists that matched last time. set: FnvHashSet, diff --git a/components/style/invalidation/stylesheets.rs b/components/style/invalidation/stylesheets.rs index 2e2abdf4960..17c9d9ce920 100644 --- a/components/style/invalidation/stylesheets.rs +++ b/components/style/invalidation/stylesheets.rs @@ -24,7 +24,7 @@ use stylesheets::{CssRule, StylesheetInDocument}; /// element is determined by whether the invalidation is stored in the /// StylesheetInvalidationSet's invalid_scopes or invalid_elements table. #[derive(Debug, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] enum Invalidation { /// An element with a given id. ID(Atom), @@ -75,7 +75,7 @@ impl Invalidation { /// /// TODO(emilio): We might be able to do the same analysis for media query /// changes too (or even selector changes?). -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct StylesheetInvalidationSet { /// The subtrees we know we have to restyle so far. invalid_scopes: FnvHashSet, diff --git a/components/style/lib.rs b/components/style/lib.rs index 00a83d1f39a..505bbb97e4b 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -50,8 +50,6 @@ extern crate fallible; extern crate fnv; #[cfg(feature = "gecko")] #[macro_use] pub mod gecko_string_cache; extern crate hashglobe; -#[cfg(feature = "servo")] extern crate heapsize; -#[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive; extern crate itertools; extern crate itoa; #[cfg(feature = "servo")] #[macro_use] extern crate html5ever; @@ -60,8 +58,8 @@ extern crate lazy_static; #[macro_use] extern crate log; extern crate lru_cache; -#[cfg(feature = "gecko")] #[macro_use] extern crate malloc_size_of; -#[cfg(feature = "gecko")] #[macro_use] extern crate malloc_size_of_derive; +#[macro_use] extern crate malloc_size_of; +#[macro_use] extern crate malloc_size_of_derive; #[allow(unused_extern_crates)] #[macro_use] extern crate matches; diff --git a/components/style/logical_geometry.rs b/components/style/logical_geometry.rs index dd6653d25f1..1e56fa8fa18 100644 --- a/components/style/logical_geometry.rs +++ b/components/style/logical_geometry.rs @@ -24,7 +24,7 @@ pub enum InlineBaseDirection { // TODO: improve the readability of the WritingMode serialization, refer to the Debug:fmt() bitflags!( - #[cfg_attr(feature = "servo", derive(HeapSizeOf, Serialize))] + #[cfg_attr(feature = "servo", derive(MallocSizeOf, Serialize))] pub flags WritingMode: u8 { const FLAG_RTL = 1 << 0, const FLAG_VERTICAL = 1 << 1, diff --git a/components/style/macros.rs b/components/style/macros.rs index a93f7f545e4..200fd61a8c4 100644 --- a/components/style/macros.rs +++ b/components/style/macros.rs @@ -47,9 +47,8 @@ macro_rules! define_numbered_css_keyword_enum { }; ($name: ident: $( $css: expr => $variant: ident = $value: expr ),+) => { #[allow(non_camel_case_types, missing_docs)] - #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] + #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Ord, PartialEq, PartialOrd)] + #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub enum $name { $( $variant = $value ),+ } @@ -103,9 +102,7 @@ macro_rules! add_impls_for_keyword_enum { macro_rules! define_keyword_type { ($name: ident, $css: expr) => { #[allow(missing_docs)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Animate, Clone, ComputeSquaredDistance, Copy, PartialEq)] + #[derive(Animate, Clone, ComputeSquaredDistance, Copy, MallocSizeOf, PartialEq)] #[derive(ToAnimatedZero, ToComputedValue, ToCss)] pub struct $name; diff --git a/components/style/media_queries.rs b/components/style/media_queries.rs index d2ecf0595bb..b77f7c85f84 100644 --- a/components/style/media_queries.rs +++ b/components/style/media_queries.rs @@ -26,7 +26,7 @@ pub use gecko::media_queries::{Device, Expression}; /// A type that encapsulates a media query list. #[derive(Clone, Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct MediaList { /// The list of media queries. pub media_queries: Vec, @@ -48,7 +48,7 @@ impl MediaList { } /// -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)] pub enum Qualifier { /// Hide a media query from legacy UAs: @@ -63,7 +63,7 @@ pub enum Qualifier { /// /// [mq]: https://drafts.csswg.org/mediaqueries/ #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct MediaQuery { /// The qualifier for this query. pub qualifier: Option, @@ -135,7 +135,7 @@ impl ToCss for MediaQuery { /// #[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum MediaQueryType { /// A media type that matches every device. All, @@ -164,7 +164,7 @@ impl MediaQueryType { /// #[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct MediaType(pub CustomIdent); impl MediaType { diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index 77e4ef96343..7053433f9d5 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -40,9 +40,7 @@ impl AnimationRules { } /// Whether a given declaration comes from CSS parsing, or from CSSOM. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)] pub enum DeclarationSource { /// The declaration was obtained from CSS parsing of sheets and such. Parsing, @@ -53,9 +51,7 @@ pub enum DeclarationSource { /// A declaration [importance][importance]. /// /// [importance]: https://drafts.csswg.org/css-cascade/#importance -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)] pub enum Importance { /// Indicates a declaration without `!important`. Normal, diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index d8f6b10f444..2abf80a0a9b 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -117,9 +117,7 @@ use values::computed::ComputedVecIter; /// The computed value, effectively a list of single values. - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] % if need_animatable or animation_value_type == "ComputedValue": #[derive(Animate, ComputeSquaredDistance)] % endif @@ -178,9 +176,7 @@ } /// The specified value of ${name}. - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct SpecifiedValue(pub Vec); impl ToCss for SpecifiedValue { @@ -950,9 +946,7 @@ pub type T = ::values::computed::${length_type}; } - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq, ToCss)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] pub struct SpecifiedValue(pub ${length_type}); % if length_type == "MozLength": diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 85adcabfe6b..422447d582d 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -77,9 +77,7 @@ pub fn nscsspropertyid_is_animatable(property: nsCSSPropertyID) -> bool { /// a shorthand with at least one transitionable longhand component, or an unsupported property. // NB: This needs to be here because it needs all the longhands generated // beforehand. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, Eq, Hash, PartialEq)] +#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)] pub enum TransitionProperty { /// All, any transitionable property changing should generate a transition. /// @@ -203,7 +201,7 @@ pub fn nscsspropertyid_is_transitionable(property: nsCSSPropertyID) -> bool { /// property. #[cfg(feature = "servo")] #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum AnimatedProperty { % for prop in data.longhands: % if prop.animatable: @@ -339,7 +337,7 @@ unsafe impl HasSimpleFFI for AnimationValueMap {} /// FIXME: We need to add a path for custom properties, but that's trivial after /// this (is a similar path to that of PropertyDeclaration). #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum AnimationValue { % for prop in data.longhands: % if prop.animatable: @@ -1190,7 +1188,7 @@ fn rotate_to_matrix(x: f32, y: f32, z: f32, a: Angle) -> ComputedMatrix { /// A 2d matrix for interpolation. #[derive(Clone, ComputeSquaredDistance, Copy, Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[allow(missing_docs)] // FIXME: We use custom derive for ComputeSquaredDistance. However, If possible, we should convert // the InnerMatrix2D into types with physical meaning. This custom derive computes the squared @@ -1202,18 +1200,18 @@ pub struct InnerMatrix2D { } /// A 2d translation function. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] pub struct Translate2D(f32, f32); /// A 2d scale function. #[derive(Clone, ComputeSquaredDistance, Copy, Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct Scale2D(f32, f32); /// A decomposed 2d matrix. #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct MatrixDecomposed2D { /// The translation function. pub translate: Translate2D, @@ -1497,33 +1495,33 @@ impl From for RawGeckoGfxMatrix4x4 { } /// A 3d translation. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] pub struct Translate3D(f32, f32, f32); /// A 3d scale function. #[derive(Clone, ComputeSquaredDistance, Copy, Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct Scale3D(f32, f32, f32); /// A 3d skew function. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Animate, Clone, Copy, Debug)] pub struct Skew(f32, f32, f32); /// A 3d perspective transformation. #[derive(Clone, ComputeSquaredDistance, Copy, Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct Perspective(f32, f32, f32, f32); /// A quaternion used to represent a rotation. #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct Quaternion(f64, f64, f64, f64); /// A decomposed 3d matrix. #[derive(Clone, ComputeSquaredDistance, Copy, Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct MatrixDecomposed3D { /// A translation function. pub translate: Translate3D, diff --git a/components/style/properties/longhand/background.mako.rs b/components/style/properties/longhand/background.mako.rs index 3cf41d5ca0a..069f272e4c1 100644 --- a/components/style/properties/longhand/background.mako.rs +++ b/components/style/properties/longhand/background.mako.rs @@ -52,9 +52,7 @@ ${helpers.predefined_type("background-image", "ImageLayer", "round" => Round, "no-repeat" => NoRepeat); - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq, ToCss)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] pub enum SpecifiedValue { RepeatX, RepeatY, @@ -64,9 +62,7 @@ ${helpers.predefined_type("background-image", "ImageLayer", pub mod computed_value { pub use super::RepeatKeyword; - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct T(pub RepeatKeyword, pub RepeatKeyword); } diff --git a/components/style/properties/longhand/border.mako.rs b/components/style/properties/longhand/border.mako.rs index 845a100f98e..7e33bb886f1 100644 --- a/components/style/properties/longhand/border.mako.rs +++ b/components/style/properties/longhand/border.mako.rs @@ -81,15 +81,11 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style', pub mod computed_value { use cssparser::RGBA; - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct T(pub Option>); } - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub enum SpecifiedValue { None, Colors(Vec), @@ -232,15 +228,11 @@ ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect", pub mod computed_value { pub use super::RepeatKeyword; - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq, ToCss)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] pub struct T(pub RepeatKeyword, pub RepeatKeyword); } - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq, ToCss)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] pub struct SpecifiedValue(pub RepeatKeyword, pub Option); diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index f7b34b78f54..a6d23949d75 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -162,9 +162,8 @@ } #[allow(non_camel_case_types)] - #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ToComputedValue)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] + #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue)] + #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub enum SpecifiedValue { % for value in values: ${to_rust_ident(value)}, @@ -460,9 +459,7 @@ ${helpers.predefined_type("transition-delay", pub use super::SpecifiedValue as T; } - #[derive(Clone, Debug, Eq, Hash, PartialEq, ToComputedValue)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue)] pub struct SpecifiedValue(pub Option); impl SpecifiedValue { @@ -555,9 +552,7 @@ ${helpers.predefined_type("animation-timing-function", } // https://drafts.csswg.org/css-animations/#animation-iteration-count - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq, ToCss, ToComputedValue)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToComputedValue)] pub enum SpecifiedValue { Number(f32), Infinite, @@ -689,9 +684,7 @@ ${helpers.predefined_type( use values::computed; use values::computed::{Length, LengthOrPercentage}; - #[derive(Clone, Copy, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq)] pub struct ComputedMatrix { pub m11: CSSFloat, pub m12: CSSFloat, pub m13: CSSFloat, pub m14: CSSFloat, pub m21: CSSFloat, pub m22: CSSFloat, pub m23: CSSFloat, pub m24: CSSFloat, @@ -699,9 +692,7 @@ ${helpers.predefined_type( pub m41: CSSFloat, pub m42: CSSFloat, pub m43: CSSFloat, pub m44: CSSFloat, } - #[derive(Clone, Copy, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq)] pub struct ComputedMatrixWithPercents { pub m11: CSSFloat, pub m12: CSSFloat, pub m13: CSSFloat, pub m14: CSSFloat, pub m21: CSSFloat, pub m22: CSSFloat, pub m23: CSSFloat, pub m24: CSSFloat, @@ -733,9 +724,7 @@ ${helpers.predefined_type( } } - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub enum ComputedOperation { Matrix(ComputedMatrix), // For `-moz-transform` matrix and matrix3d. @@ -767,9 +756,7 @@ ${helpers.predefined_type( count: computed::Integer }, } - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct T(pub Option>); } @@ -779,9 +766,7 @@ ${helpers.predefined_type( /// Multiple transform functions compose a transformation. /// /// Some transformations can be expressed by other more general functions. - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub enum SpecifiedOperation { /// Represents a 2D 2x3 matrix. Matrix(Matrix), @@ -970,9 +955,7 @@ ${helpers.predefined_type( } } - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct SpecifiedValue(Vec); impl ToCss for SpecifiedValue { @@ -1688,9 +1671,7 @@ ${helpers.predefined_type("transform-origin", } bitflags! { - #[derive(ToComputedValue)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(MallocSizeOf, ToComputedValue)] pub flags SpecifiedValue: u8 { const LAYOUT = 0x01, const STYLE = 0x02, @@ -1829,9 +1810,7 @@ ${helpers.single_keyword("-moz-orient", pub use super::SpecifiedValue as T; } - #[derive(Clone, Debug, PartialEq, ToComputedValue)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)] pub enum SpecifiedValue { Auto, AnimateableFeatures(Vec), diff --git a/components/style/properties/longhand/counters.mako.rs b/components/style/properties/longhand/counters.mako.rs index a5b54fab150..b7b9cc21f4d 100644 --- a/components/style/properties/longhand/counters.mako.rs +++ b/components/style/properties/longhand/counters.mako.rs @@ -36,9 +36,7 @@ #[cfg(feature = "gecko")] use values::specified::Attr; - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[derive(Clone, Debug, Eq, PartialEq, ToComputedValue)] + #[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)] pub enum ContentItem { /// Literal string content. String(String), @@ -98,9 +96,7 @@ } } - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, Eq, PartialEq, ToComputedValue)] + #[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)] pub enum T { Normal, None, @@ -249,9 +245,7 @@ use style_traits::ToCss; use values::CustomIdent; - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct T(pub Vec<(CustomIdent, i32)>); impl ToCss for T { diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 04d6c694a21..9cf3fd1b4fd 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -91,25 +91,22 @@ macro_rules! impl_gecko_keyword_conversions { use Atom; pub use self::FontFamily as SingleComputedValue; - #[derive(Clone, Debug, Eq, Hash, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] + #[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)] + #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub enum FontFamily { FamilyName(FamilyName), Generic(Atom), } - #[derive(Clone, Debug, Eq, Hash, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] + #[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)] + #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub struct FamilyName { pub name: Atom, pub syntax: FamilyNameSyntax, } - #[derive(Clone, Debug, Eq, Hash, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] + #[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)] + #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub enum FamilyNameSyntax { /// The family name was specified in a quoted form, e.g. "Font Name" /// or 'Font Name'. @@ -334,7 +331,7 @@ macro_rules! impl_gecko_keyword_conversions { } #[cfg(feature = "servo")] - #[derive(Clone, Debug, Eq, Hash, HeapSizeOf, PartialEq)] + #[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)] pub struct FontFamilyList(Vec); #[cfg(feature = "gecko")] @@ -460,7 +457,7 @@ macro_rules! impl_gecko_keyword_conversions { } #[derive(Clone, Debug, Eq, Hash, PartialEq)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct T(pub FontFamilyList); #[cfg(feature = "gecko")] @@ -625,9 +622,7 @@ ${helpers.single_keyword_system("font-variant-caps", use properties::longhands::system_font::SystemFont; - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)] + #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss)] pub enum SpecifiedValue { Normal, Bold, @@ -679,9 +674,9 @@ ${helpers.single_keyword_system("font-variant-caps", /// /// However, system fonts may provide other values. Pango /// may provide 350, 380, and 1000 (on top of the existing values), for example. - #[derive(Clone, ComputeSquaredDistance, Copy, Debug, Eq, Hash, PartialEq, ToCss)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] + #[derive(Clone, ComputeSquaredDistance, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, + ToCss)] + #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub struct T(pub u16); impl T { @@ -927,9 +922,7 @@ ${helpers.single_keyword_system("font-variant-caps", use properties::longhands::system_font::SystemFont; - #[derive(Clone, Copy, Debug, PartialEq, ToCss)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToCss)] pub enum SpecifiedValue { None, Number(specified::Number), @@ -976,9 +969,8 @@ ${helpers.single_keyword_system("font-variant-caps", use values::CSSFloat; use values::animated::{ToAnimatedValue, ToAnimatedZero}; - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, ToCss)] + #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, + ToCss)] pub enum T { #[animation(error)] None, @@ -1051,9 +1043,7 @@ ${helpers.single_keyword_system("font-variant-caps", pub use super::SpecifiedValue as T; } - #[derive(Clone, Debug, PartialEq, ToComputedValue)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)] pub struct SpecifiedValue { pub weight: bool, pub style: bool, @@ -1159,9 +1149,7 @@ ${helpers.single_keyword_system("font-kerning", use values::CustomIdent; - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub enum VariantAlternates { Stylistic(CustomIdent), Styleset(Box<[CustomIdent]>), @@ -1172,14 +1160,10 @@ ${helpers.single_keyword_system("font-kerning", HistoricalForms, } - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct VariantAlternatesList(pub Box<[VariantAlternates]>); - #[derive(Clone, Debug, PartialEq, ToCss)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] pub enum SpecifiedValue { Value(VariantAlternatesList), System(SystemFont) @@ -1268,7 +1252,7 @@ ${helpers.single_keyword_system("font-kerning", } bitflags! { - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub flags ParsingFlags: u8 { const NORMAL = 0, const HISTORICAL_FORMS = 0x01, @@ -1375,8 +1359,7 @@ macro_rules! exclusive_value { bitflags! { - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(MallocSizeOf)] pub flags VariantEastAsian: u16 { const NORMAL = 0, const JIS78 = 0x01, @@ -1521,8 +1504,7 @@ macro_rules! exclusive_value { bitflags! { - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(MallocSizeOf)] pub flags VariantLigatures: u16 { const NORMAL = 0, const NONE = 0x01, @@ -1681,8 +1663,7 @@ macro_rules! exclusive_value { bitflags! { - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(MallocSizeOf)] pub flags VariantNumeric: u8 { const NORMAL = 0, const LINING_NUMS = 0x01, @@ -1907,9 +1888,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- use style_traits::ToCss; use byteorder::{BigEndian, ByteOrder}; - #[derive(Clone, Debug, Eq, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq)] pub enum SpecifiedValue { Normal, Override(String), @@ -1965,9 +1944,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- // OpenType "language system" tag, so we should be able to compute // it and store it as a 32-bit integer // (see http://www.microsoft.com/typography/otspec/languagetags.htm). - #[derive(Clone, Copy, Debug, Eq, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq)] pub struct T(pub u32); } @@ -2074,9 +2051,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- } } - #[derive(Clone, Debug, PartialEq, ToComputedValue)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)] pub struct T(pub Atom); } @@ -2278,9 +2253,7 @@ ${helpers.single_keyword("-moz-math-variant", } } - #[derive(Clone, Debug, PartialEq, ToComputedValue)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)] /// text-zoom. Enable if true, disable if false pub struct T(pub bool); } @@ -2473,7 +2446,7 @@ ${helpers.single_keyword("-moz-math-variant", // dummy system font module that does nothing #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ToCss)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[cfg_attr(feature = "servo", derive(MallocSizeOf))] /// void enum for system font, can never exist pub enum SystemFont {} impl SystemFont { diff --git a/components/style/properties/longhand/inherited_box.mako.rs b/components/style/properties/longhand/inherited_box.mako.rs index 6b7ad377c02..56887723678 100644 --- a/components/style/properties/longhand/inherited_box.mako.rs +++ b/components/style/properties/longhand/inherited_box.mako.rs @@ -70,9 +70,7 @@ ${helpers.single_keyword("image-rendering", use std::f64::consts::PI; const TWO_PI: f64 = 2.0 * PI; - #[derive(Clone, Copy, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq)] pub struct SpecifiedValue { pub angle: Option, pub flipped: bool @@ -102,9 +100,7 @@ ${helpers.single_keyword("image-rendering", use style_traits::ToCss; use values::specified::Angle; - #[derive(Clone, Copy, Debug, Eq, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq)] pub enum Orientation { Angle0 = 0, Angle90, @@ -135,9 +131,7 @@ ${helpers.single_keyword("image-rendering", } } - #[derive(Clone, Copy, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq)] pub enum T { FromImage, AngleWithFlipped(Orientation, bool), diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs index 6b49c1ed5cc..5f1e41ba0da 100644 --- a/components/style/properties/longhand/inherited_svg.mako.rs +++ b/components/style/properties/longhand/inherited_svg.mako.rs @@ -166,9 +166,7 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", /// /// Higher priority values, i.e. the values specified first, /// will be painted first (and may be covered by paintings of lower priority) - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)] + #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)] pub struct SpecifiedValue(pub u8); impl SpecifiedValue { diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index e42830309d3..5416433bedd 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -285,9 +285,7 @@ ${helpers.predefined_type("word-spacing", use std::fmt; use style_traits::ToCss; - #[derive(Clone, Copy, Debug, Default, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, Default, MallocSizeOf, PartialEq)] pub struct SpecifiedValue { pub underline: bool, pub overline: bool, @@ -408,36 +406,29 @@ ${helpers.predefined_type( pub mod computed_value { - #[derive(Clone, Debug, PartialEq, ToCss)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf, ToComputedValue))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] + #[cfg_attr(feature = "servo", derive(ToComputedValue))] pub enum T { Keyword(KeywordValue), None, String(String), } - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct KeywordValue { pub fill: bool, pub shape: super::ShapeKeyword, } } - #[derive(Clone, Debug, PartialEq, ToCss)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] pub enum SpecifiedValue { Keyword(KeywordValue), None, String(String), } - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub enum KeywordValue { Fill(bool), Shape(ShapeKeyword), @@ -604,9 +595,7 @@ ${helpers.predefined_type( "left" => Left); add_impls_for_keyword_enum!(HorizontalWritingModeValue); - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq, ToComputedValue, ToCss)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] pub struct SpecifiedValue(pub HorizontalWritingModeValue, pub VerticalWritingModeValue); pub mod computed_value { diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index 8f9b8d9b103..4f3442da376 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -104,9 +104,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu pub mod computed_value { use values::specified::UrlOrNone; - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq, ToCss)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] pub struct T(pub UrlOrNone); // FIXME(nox): This is wrong, there are different types for specified @@ -146,9 +144,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu pub use self::computed_value::T as SpecifiedValue; pub mod computed_value { - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq, ToComputedValue)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)] pub struct T(pub Vec<(String, String)>); } diff --git a/components/style/properties/longhand/pointing.mako.rs b/components/style/properties/longhand/pointing.mako.rs index 858f6f10f73..3c7d693f302 100644 --- a/components/style/properties/longhand/pointing.mako.rs +++ b/components/style/properties/longhand/pointing.mako.rs @@ -21,9 +21,7 @@ #[cfg(feature = "gecko")] use values::specified::url::SpecifiedUrl; - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] + #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] pub enum Keyword { Auto, Cursor(Cursor), diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 45f7c077188..9a4ec5c4b3f 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -294,17 +294,13 @@ ${helpers.predefined_type("object-position", pub type SpecifiedValue = computed_value::T; pub mod computed_value { - #[derive(Clone, Copy, Debug, Eq, PartialEq, ToComputedValue)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)] pub enum AutoFlow { Row, Column, } - #[derive(Clone, Copy, Debug, Eq, PartialEq, ToComputedValue)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)] pub struct T { pub autoflow: AutoFlow, pub dense: bool, diff --git a/components/style/properties/longhand/table.mako.rs b/components/style/properties/longhand/table.mako.rs index 788805878b9..67c4e25accb 100644 --- a/components/style/properties/longhand/table.mako.rs +++ b/components/style/properties/longhand/table.mako.rs @@ -19,9 +19,7 @@ ${helpers.single_keyword("table-layout", "auto fixed", use std::fmt; use style_traits::ToCss; - #[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)] pub struct T(pub i32); impl ToCss for T { diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index d59063eba63..a88d5199797 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -19,18 +19,14 @@ use style_traits::ToCss; - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, Eq, PartialEq, ToCss)] + #[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss)] pub enum Side { Clip, Ellipsis, String(Box), } - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, Eq, PartialEq, ToCss)] + #[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss)] pub struct SpecifiedValue { pub first: Side, pub second: Option @@ -39,9 +35,7 @@ pub mod computed_value { pub use super::Side; - #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct T { // When the specified value only has one side, that's the "second" // side, and the sides are logical, so "second" means "end". The @@ -153,9 +147,7 @@ ${helpers.single_keyword("unicode-bidi", use style_traits::ToCss; bitflags! { - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(ToComputedValue)] + #[derive(MallocSizeOf, ToComputedValue)] pub flags SpecifiedValue: u8 { const NONE = 0, const UNDERLINE = 0x01, diff --git a/components/style/properties/longhand/ui.mako.rs b/components/style/properties/longhand/ui.mako.rs index 5976b01b288..5115e31d6f5 100644 --- a/components/style/properties/longhand/ui.mako.rs +++ b/components/style/properties/longhand/ui.mako.rs @@ -48,9 +48,7 @@ ${helpers.single_keyword("-moz-window-shadow", "none default menu tooltip sheet" use style_traits::ToCss; pub mod computed_value { - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)] + #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)] pub struct T(pub bool); } diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index e9bf69849c1..517b0a4e9ab 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -250,9 +250,7 @@ static ${name}: LonghandIdSet = LonghandIdSet { /// A set of longhand properties -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq)] pub struct LonghandIdSet { storage: [u32; (${len(data.longhands)} - 1 + 32) / 32] } @@ -400,9 +398,7 @@ impl PropertyDeclarationIdSet { } /// An enum to represent a CSS Wide keyword. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss)] pub enum CSSWideKeyword { /// The `initial` keyword. Initial, @@ -465,9 +461,7 @@ bitflags! { } /// An identifier for a given longhand property. -#[derive(Clone, Copy, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Copy, Eq, Hash, MallocSizeOf, PartialEq)] pub enum LonghandId { % for i, property in enumerate(data.longhands): /// ${property.name} @@ -731,9 +725,7 @@ impl LonghandId { } /// An identifier for a given shorthand property. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ToCss)] +#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss)] pub enum ShorthandId { % for property in data.shorthands: /// ${property.name} @@ -1022,7 +1014,7 @@ impl<'a, T: ToCss> ToCss for DeclaredValue<'a, T> { /// An identifier for a given property declaration, which can be either a /// longhand or a custom property. #[derive(Clone, Copy, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum PropertyDeclarationId<'a> { /// A longhand. Longhand(LonghandId), @@ -1810,12 +1802,10 @@ pub mod style_structs { % for style_struct in data.active_style_structs(): % if style_struct.name == "Font": - #[derive(Clone, Debug)] + #[derive(Clone, Debug, MallocSizeOf)] % else: - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq)] % endif - #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] /// The ${style_struct.name} style struct. pub struct ${style_struct.name} { % for longhand in style_struct.longhands: @@ -3575,7 +3565,7 @@ pub fn adjust_border_width(style: &mut StyleBuilder) { /// An identifier for a given alias property. #[derive(Clone, Copy, Eq, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum AliasId { % for i, property in enumerate(data.all_aliases()): /// ${property.name} diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index c7fbfcd3904..49c42a7f223 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -9,8 +9,6 @@ use applicable_declarations::ApplicableDeclarationList; #[cfg(feature = "gecko")] use gecko::selector_parser::PseudoElement; -#[cfg(feature = "servo")] -use heapsize::HeapSizeOf; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use properties::{Importance, LonghandIdSet, PropertyDeclarationBlock}; @@ -46,7 +44,7 @@ use thread_state; /// logs from http://logs.glob.uno/?c=mozilla%23servo&s=3+Apr+2017&e=3+Apr+2017#c644094 /// to se a discussion about the different memory orderings used here. #[derive(Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct RuleTree { root: StrongRuleNode, } @@ -463,7 +461,7 @@ const RULE_TREE_GC_INTERVAL: usize = 300; /// [1]: https://drafts.csswg.org/css-cascade/#cascade-origin #[repr(u8)] #[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum CascadeLevel { /// Normal User-Agent rules. UANormal = 0, @@ -827,10 +825,7 @@ pub struct StrongRuleNode { } #[cfg(feature = "servo")] -impl HeapSizeOf for StrongRuleNode { - fn heap_size_of_children(&self) -> usize { 0 } -} - +malloc_size_of_is_0!(StrongRuleNode); impl StrongRuleNode { fn new(n: Box) -> Self { diff --git a/components/style/selector_map.rs b/components/style/selector_map.rs index 9e0f01a2c9f..4d1ec302f15 100644 --- a/components/style/selector_map.rs +++ b/components/style/selector_map.rs @@ -94,9 +94,7 @@ pub trait SelectorMapEntry : Sized + Clone { /// * https://bugzilla.mozilla.org/show_bug.cgi?id=681755 /// /// TODO: Tune the initial capacity of the HashMap -#[derive(Debug)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug, MallocSizeOf)] pub struct SelectorMap { /// A hash from an ID to rules which contain that ID selector. pub id_hash: MaybeCaseInsensitiveHashMap>, @@ -465,9 +463,7 @@ fn find_bucket<'a>(mut iter: SelectorIter<'a, SelectorImpl>) -> Bucket<'a> { } /// Wrapper for PrecomputedHashMap that does ASCII-case-insensitive lookup in quirks mode. -#[derive(Debug)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug, MallocSizeOf)] pub struct MaybeCaseInsensitiveHashMap(PrecomputedDiagnosticHashMap); // FIXME(Manishearth) the 'static bound can be removed when diff --git a/components/style/selector_parser.rs b/components/style/selector_parser.rs index 85b4d09d758..55dba1e3a3b 100644 --- a/components/style/selector_parser.rs +++ b/components/style/selector_parser.rs @@ -35,7 +35,7 @@ pub use servo::restyle_damage::ServoRestyleDamage as RestyleDamage; pub use gecko::restyle_damage::GeckoRestyleDamage as RestyleDamage; /// Servo's selector parser. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct SelectorParser<'a> { /// The origin of the stylesheet we're parsing. pub stylesheet_origin: Origin, @@ -103,8 +103,7 @@ pub enum PseudoElementCascadeType { } /// A per-functional-pseudo map, from a given pseudo to a `T`. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(MallocSizeOf)] pub struct PerPseudoElementMap { entries: [Option; SIMPLE_PSEUDO_COUNT], } diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs index 9594247ef8e..ecdbf4aa9b3 100644 --- a/components/style/servo/media_queries.rs +++ b/components/style/servo/media_queries.rs @@ -27,7 +27,7 @@ use values::specified; /// is displayed in. /// /// This is the struct against which media queries are evaluated. -#[derive(HeapSizeOf)] +#[derive(MallocSizeOf)] pub struct Device { /// The current media type used by de device. media_type: MediaType, @@ -44,14 +44,14 @@ pub struct Device { /// other style being computed at the same time, given we need the style of /// the parent to compute everything else. So it is correct to just use /// a relaxed atomic here. - #[ignore_heap_size_of = "Pure stack type"] + #[ignore_malloc_size_of = "Pure stack type"] root_font_size: AtomicIsize, /// Whether any styles computed in the document relied on the root font-size /// by using rem units. - #[ignore_heap_size_of = "Pure stack type"] + #[ignore_malloc_size_of = "Pure stack type"] used_root_font_size: AtomicBool, /// Whether any styles computed in the document relied on the viewport size. - #[ignore_heap_size_of = "Pure stack type"] + #[ignore_malloc_size_of = "Pure stack type"] used_viewport_units: AtomicBool, } @@ -153,7 +153,7 @@ impl Device { /// /// Only `pub` for unit testing, please don't use it directly! #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum ExpressionKind { /// Width(Range), @@ -163,7 +163,7 @@ pub enum ExpressionKind { /// /// #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct Expression(pub ExpressionKind); impl Expression { @@ -240,7 +240,7 @@ impl ToCss for Expression { /// Only public for testing, implementation details of `Expression` may change /// for Stylo. #[derive(Clone, Copy, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum Range { /// At least the inner value. Min(T), diff --git a/components/style/servo/restyle_damage.rs b/components/style/servo/restyle_damage.rs index ca8a5ea0046..cec14dfb31f 100644 --- a/components/style/servo/restyle_damage.rs +++ b/components/style/servo/restyle_damage.rs @@ -8,7 +8,6 @@ #![deny(missing_docs)] use computed_values::display; -use heapsize::HeapSizeOf; use matching::{StyleChange, StyleDifference}; use properties::ComputedValues; use std::fmt; @@ -53,9 +52,7 @@ bitflags! { } } -impl HeapSizeOf for ServoRestyleDamage { - fn heap_size_of_children(&self) -> usize { 0 } -} +malloc_size_of_is_0!(ServoRestyleDamage); impl ServoRestyleDamage { /// Compute the `StyleDifference` (including the appropriate restyle damage) diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs index 719e76f42f2..bffb436cf1c 100644 --- a/components/style/servo/selector_parser.rs +++ b/components/style/servo/selector_parser.rs @@ -30,7 +30,7 @@ use style_traits::{ParseError, StyleParseErrorKind}; /// /// NB: If you add to this list, be sure to update `each_simple_pseudo_element` too. #[derive(Clone, Debug, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[allow(missing_docs)] #[repr(usize)] pub enum PseudoElement { @@ -251,7 +251,7 @@ pub type PseudoClassStringArg = Box; /// A non tree-structural pseudo-class. /// See https://drafts.csswg.org/selectors-4/#structural-pseudos #[derive(Clone, Debug, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[allow(missing_docs)] pub enum NonTSPseudoClass { Active, @@ -368,7 +368,7 @@ impl NonTSPseudoClass { /// The abstract struct we implement the selector parser implementation on top /// of. #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct SelectorImpl; impl ::selectors::SelectorImpl for SelectorImpl { @@ -601,7 +601,7 @@ impl DerefMut for SnapshotMap { /// Servo's version of an element snapshot. #[derive(Debug)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct ServoElementSnapshot { /// The stored state of the element. pub state: Option, diff --git a/components/style/servo/url.rs b/components/style/servo/url.rs index 0169ff9c884..6dc1d46d2aa 100644 --- a/components/style/servo/url.rs +++ b/components/style/servo/url.rs @@ -22,7 +22,7 @@ use values::computed::{Context, ToComputedValue, ComputedUrl}; /// /// However, this approach is still not necessarily optimal: See /// -#[derive(Clone, Debug, Deserialize, HeapSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub struct SpecifiedUrl { /// The original URI. This might be optional since we may insert computed /// values of images into the cascade directly, and we don't bother to @@ -30,6 +30,7 @@ pub struct SpecifiedUrl { /// /// Refcounted since cloning this should be cheap and data: uris can be /// really large. + #[ignore_malloc_size_of = "Arc"] original: Option>, /// The resolved value for the url, if valid. diff --git a/components/style/shared_lock.rs b/components/style/shared_lock.rs index 1e23ed8a12b..29b92b29d36 100644 --- a/components/style/shared_lock.rs +++ b/components/style/shared_lock.rs @@ -26,10 +26,10 @@ use stylesheets::Origin; /// but that may not be web-compatible and may need to be changed (at which /// point Servo could use AtomicRefCell too). #[derive(Clone)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct SharedRwLock { #[cfg(feature = "servo")] - #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + #[cfg_attr(feature = "servo", ignore_malloc_size_of = "Arc")] arc: Arc>, #[cfg(feature = "gecko")] diff --git a/components/style/stylesheet_set.rs b/components/style/stylesheet_set.rs index 0b5079a0751..fcecf46947a 100644 --- a/components/style/stylesheet_set.rs +++ b/components/style/stylesheet_set.rs @@ -12,7 +12,7 @@ use std::slice; use stylesheets::{Origin, OriginSet, OriginSetIterator, PerOrigin, StylesheetInDocument}; /// Entry for a StylesheetSet. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] struct StylesheetSetEntry where S: StylesheetInDocument + PartialEq + 'static, @@ -103,7 +103,7 @@ where /// The validity of the data in a given cascade origin. #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum OriginValidity { /// The origin is clean, all the data already there is valid, though we may /// have new sheets at the end. @@ -260,7 +260,7 @@ where } } -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] struct SheetCollection where S: StylesheetInDocument + PartialEq + 'static, @@ -366,7 +366,7 @@ where } /// The set of stylesheets effective for a given document. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct StylesheetSet where S: StylesheetInDocument + PartialEq + 'static, diff --git a/components/style/stylesheets/keyframes_rule.rs b/components/style/stylesheets/keyframes_rule.rs index a3e978326e3..d85b0e06ea6 100644 --- a/components/style/stylesheets/keyframes_rule.rs +++ b/components/style/stylesheets/keyframes_rule.rs @@ -96,9 +96,7 @@ impl DeepCloneWithLock for KeyframesRule { /// A number from 0 to 1, indicating the percentage of the animation when this /// keyframe should run. -#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd)] pub struct KeyframePercentage(pub f32); impl ::std::cmp::Ord for KeyframePercentage { @@ -260,16 +258,14 @@ impl DeepCloneWithLock for Keyframe { /// declarations to apply. /// /// TODO: Find a better name for this? -#[derive(Debug)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug, MallocSizeOf)] pub enum KeyframesStepValue { /// A step formed by a declaration block specified by the CSS. Declarations { /// The declaration block per se. #[cfg_attr(feature = "gecko", ignore_malloc_size_of = "XXX: Primary ref, measure if DMD says it's worthwhile")] - #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + #[cfg_attr(feature = "servo", ignore_malloc_size_of = "Arc")] block: Arc> }, /// A synthetic step computed from the current computed values at the time @@ -278,9 +274,7 @@ pub enum KeyframesStepValue { } /// A single step from a keyframe animation. -#[derive(Debug)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug, MallocSizeOf)] pub struct KeyframesStep { /// The percentage of the animation duration when this step starts. pub start_percentage: KeyframePercentage, @@ -350,9 +344,7 @@ impl KeyframesStep { /// of keyframes, in order. /// /// It only takes into account animable properties. -#[derive(Debug)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Debug, MallocSizeOf)] pub struct KeyframesAnimation { /// The difference steps of the animation. pub steps: Vec, diff --git a/components/style/stylesheets/origin.rs b/components/style/stylesheets/origin.rs index f19805b5d36..a64214691c0 100644 --- a/components/style/stylesheets/origin.rs +++ b/components/style/stylesheets/origin.rs @@ -12,7 +12,7 @@ use std::ops::BitOrAssign; /// #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[repr(u8)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub enum Origin { /// UserAgent = 1 << 0, @@ -40,7 +40,7 @@ impl Origin { bitflags! { /// A set of origins. This is equivalent to Gecko's OriginFlags. - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub flags OriginSet: u8 { /// const ORIGIN_USER_AGENT = Origin::UserAgent as u8, @@ -104,9 +104,7 @@ impl Iterator for OriginSetIterator { } /// An object that stores a `T` for each origin of the CSS cascade. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Debug, Default)] +#[derive(Debug, Default, MallocSizeOf)] pub struct PerOrigin { /// Data for `Origin::UserAgent`. pub user_agent: T, diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index 2c25d64e8c8..6fddada91d7 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -100,9 +100,7 @@ pub enum State { Body = 4, } -#[derive(Clone, Debug)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Debug, MallocSizeOf)] /// Vendor prefix. pub enum VendorPrefix { /// -moz prefix. diff --git a/components/style/stylesheets/stylesheet.rs b/components/style/stylesheets/stylesheet.rs index e8d22e19bb2..29ffbf1fa98 100644 --- a/components/style/stylesheets/stylesheet.rs +++ b/components/style/stylesheets/stylesheet.rs @@ -38,7 +38,7 @@ pub struct UserAgentStylesheets { /// A set of namespaces applying to a given stylesheet. /// /// The namespace id is used in gecko -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, MallocSizeOf)] #[allow(missing_docs)] pub struct Namespaces { pub default: Option<(Namespace, NamespaceId)>, @@ -275,9 +275,9 @@ impl StylesheetInDocument for Stylesheet { /// A simple wrapper over an `Arc`, with pointer comparison, and /// suitable for its use in a `StylesheetSet`. #[derive(Clone)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct DocumentStyleSheet( - #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + #[cfg_attr(feature = "servo", ignore_malloc_size_of = "Arc")] pub Arc ); diff --git a/components/style/stylesheets/viewport_rule.rs b/components/style/stylesheets/viewport_rule.rs index ec6d32f23fb..ddb91955e64 100644 --- a/components/style/stylesheets/viewport_rule.rs +++ b/components/style/stylesheets/viewport_rule.rs @@ -78,7 +78,7 @@ macro_rules! declare_viewport_descriptor_inner { $number_of_variants: expr ) => { #[derive(Clone, Debug, PartialEq)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[allow(missing_docs)] pub enum ViewportDescriptor { $( @@ -140,7 +140,7 @@ trait FromMeta: Sized { /// * http://dev.w3.org/csswg/css-device-adapt/#min-max-width-desc /// * http://dev.w3.org/csswg/css-device-adapt/#extend-to-zoom #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[allow(missing_docs)] pub enum ViewportLength { Specified(LengthOrPercentageOrAuto), @@ -231,7 +231,7 @@ struct ViewportRuleParser<'a, 'b: 'a> { } #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[allow(missing_docs)] pub struct ViewportDescriptorDeclaration { pub origin: Origin, @@ -330,7 +330,7 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for ViewportRuleParser<'a, 'b> { /// A `@viewport` rule. #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct ViewportRule { /// The declarations contained in this @viewport rule. pub declarations: Vec diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 324bf2301af..e40c1a7c842 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -182,11 +182,11 @@ impl UserAgentCascadeData { /// All the computed information for a stylesheet. #[derive(Default)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] struct DocumentCascadeData { #[cfg_attr( feature = "servo", - ignore_heap_size_of = "Arc, owned by UserAgentCascadeDataCache" + ignore_malloc_size_of = "Arc, owned by UserAgentCascadeDataCache" )] user_agent: Arc, user: CascadeData, @@ -338,7 +338,7 @@ impl DocumentCascadeData { /// A wrapper over a StylesheetSet that can be `Sync`, since it's only used and /// exposed via mutable methods in the `Stylist`. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] struct StylistStylesheetSet(StylesheetSet); // Read above to see why this is fine. unsafe impl Sync for StylistStylesheetSet {} @@ -370,7 +370,7 @@ impl ops::DerefMut for StylistStylesheetSet { /// /// This structure is effectively created once per pipeline, in the /// LayoutThread corresponding to that pipeline. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct Stylist { /// Device that the stylist is currently evaluating against. /// @@ -393,7 +393,7 @@ pub struct Stylist { stylesheets: StylistStylesheetSet, /// If true, the quirks-mode stylesheet is applied. - #[cfg_attr(feature = "servo", ignore_heap_size_of = "defined in selectors")] + #[cfg_attr(feature = "servo", ignore_malloc_size_of = "defined in selectors")] quirks_mode: QuirksMode, /// Selector maps for all of the style sheets in the stylist, after @@ -1517,7 +1517,7 @@ impl Stylist { /// This struct holds data which users of Stylist may want to extract /// from stylesheets which can be done at the same time as updating. #[derive(Debug, Default)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] pub struct ExtraStyleData { /// A list of effective font-face rules and their origin. #[cfg(feature = "gecko")] @@ -1783,7 +1783,7 @@ impl<'a> SelectorVisitor for StylistSelectorVisitor<'a> { /// /// FIXME(emilio): Consider renaming and splitting in `CascadeData` and /// `InvalidationData`? That'd make `clear_cascade_data()` clearer. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Debug)] struct CascadeData { /// Rules from stylesheets at this `CascadeData`'s origin. @@ -1808,7 +1808,7 @@ struct CascadeData { /// to avoid taking element snapshots when an irrelevant attribute changes. /// (We don't bother storing the namespace, since namespaced attributes /// are rare.) - #[cfg_attr(feature = "servo", ignore_heap_size_of = "just an array")] + #[cfg_attr(feature = "servo", ignore_malloc_size_of = "just an array")] attribute_dependencies: NonCountingBloomFilter, /// Whether `"style"` appears in an attribute selector. This is not common, @@ -1828,13 +1828,13 @@ struct CascadeData { /// hence in our selector maps). Used to determine when sharing styles is /// safe: we disallow style sharing for elements whose id matches this /// filter, and hence might be in one of our selector maps. - #[cfg_attr(feature = "servo", ignore_heap_size_of = "just an array")] + #[cfg_attr(feature = "servo", ignore_malloc_size_of = "just an array")] mapped_ids: NonCountingBloomFilter, /// Selectors that require explicit cache revalidation (i.e. which depend /// on state that is not otherwise visible to the cache, like attributes or /// tree-structural state like child index and pseudos). - #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + #[cfg_attr(feature = "servo", ignore_malloc_size_of = "Arc")] selectors_for_cache_revalidation: SelectorMap, /// Effective media query results cached from the last rebuild. @@ -2251,21 +2251,16 @@ impl Default for CascadeData { /// A rule, that wraps a style rule, but represents a single selector of the /// rule. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug)] +#[derive(Clone, Debug, MallocSizeOf)] pub struct Rule { /// The selector this struct represents. We store this and the /// any_{important,normal} booleans inline in the Rule to avoid /// pointer-chasing when gathering applicable declarations, which /// can ruin performance when there are a lot of rules. - #[cfg_attr(feature = "gecko", - ignore_malloc_size_of = "CssRules have primary refs, we measure there")] - #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + #[ignore_malloc_size_of = "CssRules have primary refs, we measure there"] pub selector: Selector, /// The ancestor hashes associated with the selector. - #[cfg_attr(feature = "servo", ignore_heap_size_of = "No heap data")] pub hashes: AncestorHashes, /// The source order this style rule appears in. Note that we only use @@ -2277,7 +2272,7 @@ pub struct Rule { #[cfg_attr(feature = "gecko", ignore_malloc_size_of = "Secondary ref. Primary ref is in StyleRule under Stylesheet.")] - #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] + #[cfg_attr(feature = "servo", ignore_malloc_size_of = "Arc")] pub style_rule: Arc>, } diff --git a/components/style/values/animated/color.rs b/components/style/values/animated/color.rs index 5c891709374..4674cca8bb9 100644 --- a/components/style/values/animated/color.rs +++ b/components/style/values/animated/color.rs @@ -11,7 +11,7 @@ use values::distance::{ComputeSquaredDistance, SquaredDistance}; /// /// Unlike in computed values, each component value may exceed the /// range `[0.0, 1.0]`. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Clone, Copy, Debug, PartialEq, ToAnimatedZero)] pub struct RGBA { /// The red component. @@ -70,7 +70,7 @@ impl ComputeSquaredDistance for RGBA { } #[allow(missing_docs)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Clone, Copy, Debug, PartialEq)] pub struct Color { pub color: RGBA, diff --git a/components/style/values/animated/effects.rs b/components/style/values/animated/effects.rs index 95a999db54b..e677d5a1a8e 100644 --- a/components/style/values/animated/effects.rs +++ b/components/style/values/animated/effects.rs @@ -28,7 +28,7 @@ pub type TextShadowList = ShadowList; /// An animated value for shadow lists. /// /// -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Clone, Debug, PartialEq)] pub struct ShadowList(Vec); @@ -36,7 +36,7 @@ pub struct ShadowList(Vec); pub type BoxShadow = GenericBoxShadow, Length, NonNegativeLength, Length>; /// An animated value for the `filter` property. -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Clone, Debug, PartialEq)] pub struct FilterList(pub Vec); diff --git a/components/style/values/computed/angle.rs b/components/style/values/computed/angle.rs index 0dd2b4261f2..fdaecf93ab1 100644 --- a/components/style/values/computed/angle.rs +++ b/components/style/values/computed/angle.rs @@ -14,9 +14,8 @@ use values::distance::{ComputeSquaredDistance, SquaredDistance}; /// A computed angle. #[animate(fallback = "Self::animate_fallback")] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] -#[derive(Animate, Clone, Copy, Debug, PartialEq)] +#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] +#[derive(Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq)] #[derive(PartialOrd, ToAnimatedZero)] pub enum Angle { /// An angle with degree unit. diff --git a/components/style/values/computed/color.rs b/components/style/values/computed/color.rs index 7adfa646d7e..6327e734626 100644 --- a/components/style/values/computed/color.rs +++ b/components/style/values/computed/color.rs @@ -14,9 +14,7 @@ use values::animated::color::{Color as AnimatedColor, RGBA as AnimatedRGBA}; /// the current foreground color (currentcolor keyword). /// Conceptually, the formula is "color * (1 - p) + currentcolor * p" /// where p is foreground_ratio. -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Copy, Debug, MallocSizeOf)] pub struct Color { /// RGBA color. pub color: RGBA, diff --git a/components/style/values/computed/font.rs b/components/style/values/computed/font.rs index 6d0571b8c0c..08d2a584f53 100644 --- a/components/style/values/computed/font.rs +++ b/components/style/values/computed/font.rs @@ -11,10 +11,8 @@ use values::animated::ToAnimatedValue; use values::computed::NonNegativeLength; use values::specified::font as specified; -#[derive(Animate, ComputeSquaredDistance, ToAnimatedZero)] +#[derive(Animate, ComputeSquaredDistance, MallocSizeOf, ToAnimatedZero)] #[derive(Clone, Copy, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] /// The computed value of font-size pub struct FontSize { /// The size. @@ -23,10 +21,8 @@ pub struct FontSize { pub keyword_info: Option, } -#[derive(Animate, ComputeSquaredDistance, ToAnimatedValue, ToAnimatedZero)] +#[derive(Animate, ComputeSquaredDistance, MallocSizeOf, ToAnimatedValue, ToAnimatedZero)] #[derive(Clone, Copy, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] /// Additional information for keyword-derived font sizes. pub struct KeywordInfo { /// The keyword used diff --git a/components/style/values/computed/image.rs b/components/style/values/computed/image.rs index a54ae2098a3..8972774aa77 100644 --- a/components/style/values/computed/image.rs +++ b/components/style/values/computed/image.rs @@ -51,9 +51,7 @@ pub type GradientKind = GenericGradientKind< >; /// A computed gradient line direction. -#[derive(Clone, Copy, Debug, PartialEq)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq)] pub enum LineDirection { /// An angle. Angle(Angle), diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index edc68ef9dcd..8cb69b65b17 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -66,9 +66,7 @@ impl ToComputedValue for specified::Length { } #[allow(missing_docs)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, PartialEq, ToAnimatedZero)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedZero)] pub struct CalcLengthOrPercentage { #[animation(constant)] pub clamping_mode: AllowedNumericType, @@ -294,10 +292,8 @@ impl ToComputedValue for specified::CalcLengthOrPercentage { #[allow(missing_docs)] #[animate(fallback = "Self::animate_fallback")] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[css(derive_debug)] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, PartialEq)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, MallocSizeOf, PartialEq)] #[derive(ToAnimatedZero, ToCss)] #[distance(fallback = "Self::compute_squared_distance_fallback")] pub enum LengthOrPercentage { @@ -452,10 +448,8 @@ impl ToComputedValue for specified::LengthOrPercentage { #[allow(missing_docs)] #[animate(fallback = "Self::animate_fallback")] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[css(derive_debug)] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, PartialEq, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, MallocSizeOf, PartialEq, ToCss)] #[distance(fallback = "Self::compute_squared_distance_fallback")] pub enum LengthOrPercentageOrAuto { Length(Length), @@ -549,7 +543,7 @@ impl ToComputedValue for specified::LengthOrPercentageOrAuto { #[allow(missing_docs)] #[animate(fallback = "Self::animate_fallback")] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[css(derive_debug)] #[derive(Animate, Clone, ComputeSquaredDistance, Copy, PartialEq, ToCss)] #[distance(fallback = "Self::compute_squared_distance_fallback")] @@ -684,9 +678,8 @@ impl NonNegativeLengthOrPercentage { } /// The computed `` value. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, PartialOrd)] +#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd)] #[derive(ToAnimatedValue, ToAnimatedZero)] pub struct CSSPixelLength(CSSFloat); @@ -850,7 +843,7 @@ pub type NonNegativeLengthOrNumber = Either for CSSFloat { } #[allow(missing_docs)] -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss)] pub enum NumberOrPercentage { Percentage(Percentage), Number(Number), @@ -468,7 +466,7 @@ pub type LengthOrPercentageOrNumber = Either; pub type NonNegativeLengthOrPercentageOrNumber = Either; #[allow(missing_docs)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[derive(Clone, ComputeSquaredDistance, Copy, Debug, PartialEq)] /// A computed cliprect for clip and image-region pub struct ClipRect { @@ -550,10 +548,10 @@ pub type ColorOrAuto = Either; /// The computed value of a CSS `url()`, resolved relative to the stylesheet URL. #[cfg(feature = "servo")] -#[derive(Clone, Debug, Deserialize, HeapSizeOf, PartialEq, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)] pub enum ComputedUrl { /// The `url()` was invalid or it wasn't specified by the user. - Invalid(Arc), + Invalid(#[ignore_malloc_size_of = "Arc"] Arc), /// The resolved `url()` relative to the stylesheet URL. Valid(ServoUrl), } diff --git a/components/style/values/computed/percentage.rs b/components/style/values/computed/percentage.rs index 6b54c6722c3..1bc28a13488 100644 --- a/components/style/values/computed/percentage.rs +++ b/components/style/values/computed/percentage.rs @@ -9,9 +9,8 @@ use style_traits::ToCss; use values::{CSSFloat, serialize_percentage}; /// A computed percentage. -#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, Default)] +#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, Default, MallocSizeOf)] #[derive(PartialEq, PartialOrd, ToAnimatedZero)] pub struct Percentage(pub CSSFloat); diff --git a/components/style/values/computed/time.rs b/components/style/values/computed/time.rs index 02da4f5a681..a90a0935a8e 100644 --- a/components/style/values/computed/time.rs +++ b/components/style/values/computed/time.rs @@ -9,9 +9,8 @@ use style_traits::ToCss; use values::CSSFloat; /// A computed `