Bug 1904610 - Upstream Servo changes to malloc_size_of. r=emilio

`malloc_size_of` no longer needs to have support for hyper and
hyper_serde and it adds derives for `http` and `indexmap`. Derives are
added for a couple standard library types and finally Gecko-only data
types are guarded by a new `gecko` feature.

Differential Revision: https://phabricator.services.mozilla.com/D214840
This commit is contained in:
Martin Robinson
2024-06-26 10:41:40 +00:00
parent 0637724e87
commit 5fa2ec6182
3 changed files with 30 additions and 20 deletions

View File

@@ -13,8 +13,8 @@ servo = [
"accountable-refcell",
"content-security-policy",
"crossbeam-channel",
"hyper",
"hyper_serde",
"http",
"indexmap",
"keyboard-types",
"serde",
"serde_bytes",
@@ -25,6 +25,7 @@ servo = [
"webrender_api",
"xml5ever",
]
gecko = []
[dependencies]
accountable-refcell = { version = "0.2.0", optional = true }
@@ -34,8 +35,8 @@ crossbeam-channel = { version = "0.4", optional = true }
cssparser = "0.34"
dom = { path = "../../../dom/base/rust" }
euclid = "0.22"
hyper = { version = "0.12", optional = true }
hyper_serde = { version = "0.11", optional = true }
http = { version = "0.2", optional = true }
indexmap = { version = "2.2", optional = true }
keyboard-types = { version = "0.4.3", optional = true }
selectors = { path = "../selectors" }
serde = { version = "1.0.27", optional = true }

View File

@@ -56,9 +56,7 @@ extern crate crossbeam_channel;
extern crate cssparser;
extern crate euclid;
#[cfg(feature = "servo")]
extern crate hyper;
#[cfg(feature = "servo")]
extern crate hyper_serde;
extern crate http;
#[cfg(feature = "servo")]
extern crate keyboard_types;
extern crate selectors;
@@ -857,6 +855,7 @@ malloc_size_of_is_0!(std::sync::atomic::AtomicBool);
malloc_size_of_is_0!(std::sync::atomic::AtomicIsize);
malloc_size_of_is_0!(std::sync::atomic::AtomicUsize);
malloc_size_of_is_0!(std::num::NonZeroUsize);
malloc_size_of_is_0!(std::num::NonZeroU64);
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>);
@@ -866,6 +865,7 @@ malloc_size_of_is_0!(app_units::Au);
malloc_size_of_is_0!(cssparser::TokenSerializationType, cssparser::SourceLocation, cssparser::SourcePosition);
#[cfg(feature = "gecko")]
malloc_size_of_is_0!(dom::ElementState, dom::DocumentState);
malloc_size_of_is_0!(selectors::OpaqueElement);
@@ -950,18 +950,18 @@ impl MallocSizeOf for xml5ever::QualName {
malloc_size_of_is_0!(time::Duration);
#[cfg(feature = "servo")]
malloc_size_of_is_0!(time::Tm);
#[cfg(feature = "servo")]
impl<T> MallocSizeOf for hyper_serde::Serde<T>
where
for<'de> hyper_serde::De<T>: serde::Deserialize<'de>,
for<'a> hyper_serde::Ser<'a, T>: serde::Serialize,
T: MallocSizeOf,
{
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
self.0.size_of(ops)
}
}
malloc_size_of_is_0!(std::time::Duration);
#[cfg(feature = "servo")]
malloc_size_of_is_0!(std::time::SystemTime);
#[cfg(feature = "servo")]
malloc_size_of_is_0!(std::time::Instant);
#[cfg(feature = "servo")]
malloc_size_of_hash_set!(indexmap::IndexSet<T, S>);
#[cfg(feature = "servo")]
malloc_size_of_hash_map!(indexmap::IndexMap<K, V, S>);
#[cfg(feature = "servo")]
malloc_size_of_is_0!(http::StatusCode);
// Placeholder for unique case where internals of Sender cannot be measured.
// malloc size of is 0 macro complains about type supplied!
@@ -973,7 +973,7 @@ impl<T> MallocSizeOf for crossbeam_channel::Sender<T> {
}
#[cfg(feature = "servo")]
impl MallocSizeOf for hyper::StatusCode {
impl<T> MallocSizeOf for tokio::sync::mpsc::UnboundedSender<T> {
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
0
}

View File

@@ -17,7 +17,16 @@ path = "lib.rs"
doctest = false
[features]
gecko = ["nsstring", "serde", "style_traits/gecko", "bindgen", "regex", "toml", "mozbuild"]
gecko = [
"bindgen",
"malloc_size_of/gecko",
"mozbuild",
"nsstring",
"regex",
"serde",
"style_traits/gecko",
"toml"
]
servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever",
"cssparser/serde", "encoding_rs", "malloc_size_of/servo", "arrayvec/use_union",
"string_cache", "to_shmem/servo", "servo_arc/servo", "url"]