mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35: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
|
@ -16,9 +16,7 @@ use style_traits::ToCss;
|
|||
/// An [image].
|
||||
///
|
||||
/// [image]: https://drafts.csswg.org/css-images/#image-values
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, PartialEq, ToComputedValue)]
|
||||
#[derive(Clone, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
pub enum Image<Gradient, MozImageRect, ImageUrl> {
|
||||
/// A `<url()>` image.
|
||||
Url(ImageUrl),
|
||||
|
@ -37,9 +35,7 @@ pub enum Image<Gradient, MozImageRect, ImageUrl> {
|
|||
|
||||
/// A CSS gradient.
|
||||
/// <https://drafts.csswg.org/css-images/#gradients>
|
||||
#[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 Gradient<LineDirection, Length, LengthOrPercentage, Position, Color, Angle> {
|
||||
/// Gradients can be linear or radial.
|
||||
pub kind: GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle>,
|
||||
|
@ -53,9 +49,7 @@ pub struct Gradient<LineDirection, Length, LengthOrPercentage, Position, Color,
|
|||
pub compat_mode: CompatMode,
|
||||
}
|
||||
|
||||
#[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)]
|
||||
/// Whether we used the modern notation or the compatibility `-webkit`, `-moz` prefixes.
|
||||
pub enum CompatMode {
|
||||
/// Modern syntax.
|
||||
|
@ -67,9 +61,7 @@ pub enum CompatMode {
|
|||
}
|
||||
|
||||
/// A gradient kind.
|
||||
#[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 enum GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle> {
|
||||
/// A linear gradient.
|
||||
Linear(LineDirection),
|
||||
|
@ -78,9 +70,7 @@ pub enum GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle
|
|||
}
|
||||
|
||||
/// A radial gradient's ending shape.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)]
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum EndingShape<Length, LengthOrPercentage> {
|
||||
/// A circular gradient.
|
||||
Circle(Circle<Length>),
|
||||
|
@ -89,9 +79,7 @@ pub enum EndingShape<Length, LengthOrPercentage> {
|
|||
}
|
||||
|
||||
/// A circle shape.
|
||||
#[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 enum Circle<Length> {
|
||||
/// A circle radius.
|
||||
Radius(Length),
|
||||
|
@ -100,9 +88,7 @@ pub enum Circle<Length> {
|
|||
}
|
||||
|
||||
/// An ellipse shape.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)]
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum Ellipse<LengthOrPercentage> {
|
||||
/// An ellipse pair of radii.
|
||||
Radii(LengthOrPercentage, LengthOrPercentage),
|
||||
|
@ -123,9 +109,7 @@ add_impls_for_keyword_enum!(ShapeExtent);
|
|||
|
||||
/// A gradient item.
|
||||
/// <https://drafts.csswg.org/css-images-4/#color-stop-syntax>
|
||||
#[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 GradientItem<Color, LengthOrPercentage> {
|
||||
/// A color stop.
|
||||
ColorStop(ColorStop<Color, LengthOrPercentage>),
|
||||
|
@ -135,9 +119,7 @@ pub enum GradientItem<Color, LengthOrPercentage> {
|
|||
|
||||
/// A color stop.
|
||||
/// <https://drafts.csswg.org/css-images/#typedef-color-stop-list>
|
||||
#[derive(Clone, Copy, PartialEq, ToComputedValue, ToCss)]
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub struct ColorStop<Color, LengthOrPercentage> {
|
||||
/// The color of this stop.
|
||||
pub color: Color,
|
||||
|
@ -148,13 +130,13 @@ pub struct ColorStop<Color, LengthOrPercentage> {
|
|||
/// Specified values for a paint worklet.
|
||||
/// <https://drafts.css-houdini.org/css-paint-api/>
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
pub struct PaintWorklet {
|
||||
/// The name the worklet was registered with.
|
||||
pub name: Atom,
|
||||
/// The arguments for the worklet.
|
||||
/// TODO: store a parsed representation of the arguments.
|
||||
#[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")]
|
||||
#[cfg_attr(feature = "servo", ignore_malloc_size_of = "Arc")]
|
||||
pub arguments: Vec<Arc<custom_properties::SpecifiedValue>>,
|
||||
}
|
||||
|
||||
|
@ -176,10 +158,8 @@ impl ToCss for PaintWorklet {
|
|||
///
|
||||
/// `-moz-image-rect(<uri>, top, right, bottom, left);`
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[css(comma, function)]
|
||||
#[derive(Clone, Debug, PartialEq, ToComputedValue, ToCss)]
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub struct MozImageRect<NumberOrPercentage, MozImageRectUrl> {
|
||||
pub url: MozImageRectUrl,
|
||||
pub top: NumberOrPercentage,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue