servo: Merge #18404 - Measure PropertyDeclaration better (from nnethercote:measure-PropertyDeclaration); r=heycam
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 08 Sep 2017 00:22:05 -0500
changeset 429158 acc2857ea22a230832c1c7bdd677ac1dad69af32
parent 429157 5baccd396fc4eaf20827f40355772d004faddcfb
child 429159 c54babd134d3400891d83920bc71eb45243a1566
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #18404 - Measure PropertyDeclaration better (from nnethercote:measure-PropertyDeclaration); r=heycam This increases the style-sheets counts for gmail by about 30 MiB. <!-- Please describe your changes on the following line: --> r? @heycam --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because code is tested on the Gecko side. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: dfc38fabdcac0e027db3dc5425899004309fc68b
servo/components/style/properties/properties.mako.rs
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -33,17 +33,18 @@ use parser::ParserContext;
 use properties::animated_properties::AnimatableLonghand;
 #[cfg(feature = "gecko")] use properties::longhands::system_font::SystemFont;
 use selector_parser::PseudoElement;
 use selectors::parser::SelectorParseError;
 #[cfg(feature = "servo")] use servo_config::prefs::PREFS;
 use shared_lock::StylesheetGuards;
 use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError};
 use style_traits::{PropertyDeclarationParseError, StyleParseError, ValueParseError};
-use stylesheets::{CssRuleType, MallocSizeOf, MallocSizeOfFn, Origin, UrlExtraData};
+use stylesheets::{CssRuleType, MallocSizeOf, MallocSizeOfBox, MallocSizeOfFn, MallocSizeOfVec};
+use stylesheets::{Origin, UrlExtraData};
 #[cfg(feature = "servo")] use values::Either;
 use values::generics::text::LineHeight;
 use values::computed;
 use values::computed::NonNegativeAu;
 use rule_tree::{CascadeLevel, StrongRuleNode};
 use self::computed_value_flags::ComputedValueFlags;
 use style_adjuster::StyleAdjuster;
 #[cfg(feature = "servo")] use values::specified::BorderStyle;
@@ -1323,20 +1324,36 @@ impl ToCss for PropertyDeclaration {
             % if any(property.derived_from for property in data.longhands):
                 _ => Err(fmt::Error),
             % endif
         }
     }
 }
 
 impl MallocSizeOf for PropertyDeclaration {
-    fn malloc_size_of_children(&self, _malloc_size_of: MallocSizeOfFn) -> usize {
-        // The variants of PropertyDeclaration mostly (entirely?) contain
-        // scalars, so this is reasonable.
-        0
+    fn malloc_size_of_children(&self, malloc_size_of: MallocSizeOfFn) -> usize {
+        match *self {
+            % for property in data.longhands:
+                % if property.boxed and property.is_vector:
+                    <% raise Exception("this should not happen! not smart to box a vector here") %>
+                % elif property.boxed:
+                    PropertyDeclaration::${property.camel_case}(ref sv_box) => {
+                        sv_box.malloc_shallow_size_of_box(malloc_size_of)
+                    }
+                % elif property.is_vector:
+                    PropertyDeclaration::${property.camel_case}(ref sv_vec) => {
+                        sv_vec.0.malloc_shallow_size_of_vec(malloc_size_of)
+                    }
+                % endif
+            % endfor
+            PropertyDeclaration::CSSWideKeyword(..) => 0,
+            PropertyDeclaration::WithVariables(..) => 0,
+            PropertyDeclaration::Custom(..) => 0,
+            _ => 0,
+        }
     }
 }
 
 impl PropertyDeclaration {
     /// Given a property declaration, return the property declaration id.
     pub fn id(&self) -> PropertyDeclarationId {
         match *self {
             PropertyDeclaration::Custom(ref name, _) => {