Bug 1959403 - Implement malloc_size_of for once_cell items (and preparing for 0.2.0 release) r=nical
Additionally that makes its `euclid` and `app_units` dependencies optional. Differential Revision: https://phabricator.services.mozilla.com/D244909
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -7724,7 +7724,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wr_malloc_size_of"
|
||||
version = "0.0.2"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"app_units",
|
||||
"euclid",
|
||||
|
||||
3
gfx/wr/Cargo.lock
generated
3
gfx/wr/Cargo.lock
generated
@@ -3497,10 +3497,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wr_malloc_size_of"
|
||||
version = "0.0.2"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"app_units",
|
||||
"euclid",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -46,7 +46,7 @@ smallvec = "1"
|
||||
time = "0.1"
|
||||
api = { version = "0.62.0", path = "../webrender_api", package = "webrender_api" }
|
||||
webrender_build = { version = "0.0.2", path = "../webrender_build" }
|
||||
malloc_size_of = { version = "0.0.2", path = "../wr_malloc_size_of", package = "wr_malloc_size_of" }
|
||||
malloc_size_of = { version = "0.2.0", path = "../wr_malloc_size_of", package = "wr_malloc_size_of" }
|
||||
glyph_rasterizer = { version = "0.1.0", path = "../wr_glyph_rasterizer", package = "wr_glyph_rasterizer", default-features = false }
|
||||
svg_fmt = "0.4"
|
||||
tracy-rs = "0.1.2"
|
||||
|
||||
@@ -23,6 +23,6 @@ serde = { version = "1.0", features = ["rc"] }
|
||||
serde_derive = "1.0"
|
||||
serde_bytes = "0.11"
|
||||
time = "0.1"
|
||||
malloc_size_of = { version = "0.0.2", path = "../wr_malloc_size_of", package = "wr_malloc_size_of" }
|
||||
malloc_size_of = { version = "0.2.0", path = "../wr_malloc_size_of", package = "wr_malloc_size_of" }
|
||||
peek-poke = { version = "0.3", path = "../peek-poke", features = ["extras"] }
|
||||
crossbeam-channel = "0.5"
|
||||
|
||||
@@ -17,7 +17,7 @@ gecko = ["firefox-on-glean", "glean"]
|
||||
[dependencies]
|
||||
api = { version = "0.62.0", path = "../webrender_api", package = "webrender_api" }
|
||||
euclid = { version = "0.22.0", features = ["serde"] }
|
||||
malloc_size_of = { version = "0.0.2", path = "../wr_malloc_size_of", package = "wr_malloc_size_of" }
|
||||
malloc_size_of = { version = "0.2.0", path = "../wr_malloc_size_of", package = "wr_malloc_size_of" }
|
||||
malloc_size_of_derive = "0.1"
|
||||
rayon = "1"
|
||||
smallvec = "1"
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
authors = ["The Servo Project Developers"]
|
||||
description = "Internal utility to measure memory usage in WebRender."
|
||||
name = "wr_malloc_size_of"
|
||||
version = "0.0.2"
|
||||
version = "0.2.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
[features]
|
||||
default = ["app_units", "euclid"]
|
||||
|
||||
[dependencies]
|
||||
app_units = "0.7"
|
||||
euclid = "0.22"
|
||||
app_units = { version = "0.7", optional = true }
|
||||
euclid = { version = "0.22", optional = true }
|
||||
once_cell = { version = "1.2.0", optional = true }
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
|
||||
//! A reduced fork of Firefox's malloc_size_of crate, for bundling with WebRender.
|
||||
|
||||
#[cfg(feature = "app_units")]
|
||||
extern crate app_units;
|
||||
#[cfg(feature = "euclid")]
|
||||
extern crate euclid;
|
||||
|
||||
use std::hash::{BuildHasher, Hash};
|
||||
@@ -320,36 +322,42 @@ impl MallocSizeOf for PathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "euclid")]
|
||||
impl<T: MallocSizeOf, Unit> MallocSizeOf for euclid::Length<T, Unit> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.0.size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "euclid")]
|
||||
impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::Scale<T, Src, Dst> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.0.size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "euclid")]
|
||||
impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Point2D<T, U> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.x.size_of(ops) + self.y.size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "euclid")]
|
||||
impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Rect<T, U> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.origin.size_of(ops) + self.size.size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "euclid")]
|
||||
impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Box2D<T, U> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.min.size_of(ops) + self.max.size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "euclid")]
|
||||
impl<T: MallocSizeOf, U> MallocSizeOf for euclid::SideOffsets2D<T, U> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.top.size_of(ops) +
|
||||
@@ -359,12 +367,14 @@ impl<T: MallocSizeOf, U> MallocSizeOf for euclid::SideOffsets2D<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "euclid")]
|
||||
impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Size2D<T, U> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.width.size_of(ops) + self.height.size_of(ops)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "euclid")]
|
||||
impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::Transform2D<T, Src, Dst> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.m11.size_of(ops) +
|
||||
@@ -376,6 +386,7 @@ impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::Transform2D<T, Src, Dst
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "euclid")]
|
||||
impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::Transform3D<T, Src, Dst> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.m11.size_of(ops) +
|
||||
@@ -397,6 +408,7 @@ impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::Transform3D<T, Src, Dst
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "euclid")]
|
||||
impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Vector2D<T, U> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
self.x.size_of(ops) + self.y.size_of(ops)
|
||||
@@ -448,4 +460,26 @@ malloc_size_of_is_0!(Range<u8>, Range<u16>, Range<u32>, Range<u64>, Range<usize>
|
||||
malloc_size_of_is_0!(Range<i8>, Range<i16>, Range<i32>, Range<i64>, Range<isize>);
|
||||
malloc_size_of_is_0!(Range<f32>, Range<f64>);
|
||||
|
||||
#[cfg(feature = "app_units")]
|
||||
malloc_size_of_is_0!(app_units::Au);
|
||||
|
||||
#[cfg(feature = "once_cell")]
|
||||
impl<T: MallocSizeOf, F: FnOnce() -> T> MallocSizeOf for once_cell::sync::Lazy<T, F> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
once_cell::sync::Lazy::get(self).map(|obj| obj.size_of(ops)).unwrap_or(0)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "once_cell")]
|
||||
impl<T: MallocSizeOf> MallocSizeOf for once_cell::sync::OnceCell<T> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
once_cell::sync::OnceCell::get(self).map(|obj| obj.size_of(ops)).unwrap_or(0)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "once_cell")]
|
||||
impl<T: MallocSizeOf, F: FnOnce() -> T> MallocSizeOf for &'static once_cell::sync::Lazy<T, F> {
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
once_cell::sync::Lazy::get(self).map(|obj| obj.size_of(ops)).unwrap_or(0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user