mirror of
https://github.com/servo/servo.git
synced 2025-08-08 23:15:33 +01:00
Replace all uses of the heapsize
crate with malloc_size_of
.
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`. `malloc_size_of` is better -- it handles various cases that `heapsize` does not -- so this patch changes Servo to use `malloc_size_of`. This patch makes the following changes to the `malloc_size_of` crate. - Adds `MallocSizeOf` trait implementations for numerous types, some built-in (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`). - Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't support that operation. - For `HashSet`/`HashMap`, falls back to a computed estimate when `enclosing_size_of_op` isn't available. - Adds an extern "C" `malloc_size_of` function that does the actual heap measurement; this is based on the same functions from the `heapsize` crate. This patch makes the following changes elsewhere. - Converts all the uses of `heapsize` to instead use `malloc_size_of`. - Disables the "heapsize"/"heap_size" feature for the external crates that provide it. - Removes the `HeapSizeOf` implementation from `hashglobe`. - Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of` doesn't derive those types, unlike `heapsize`.
This commit is contained in:
parent
421baa854e
commit
4506f0d30c
269 changed files with 1418 additions and 1521 deletions
|
@ -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 {
|
||||
/// <http://dev.w3.org/csswg/mediaqueries-3/#width>
|
||||
Width(Range<specified::Length>),
|
||||
|
@ -163,7 +163,7 @@ pub enum ExpressionKind {
|
|||
///
|
||||
/// <http://dev.w3.org/csswg/mediaqueries-3/#media1>
|
||||
#[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<T> {
|
||||
/// At least the inner value.
|
||||
Min(T),
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<str>;
|
|||
/// 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<ElementState>,
|
||||
|
|
|
@ -22,7 +22,7 @@ use values::computed::{Context, ToComputedValue, ComputedUrl};
|
|||
///
|
||||
/// However, this approach is still not necessarily optimal: See
|
||||
/// <https://bugzilla.mozilla.org/show_bug.cgi?id=1347435#c6>
|
||||
#[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<Arc<String>>,
|
||||
|
||||
/// The resolved value for the url, if valid.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue