servo: Merge #17242 - Reduce the size of ApplicableDeclarationBlock (from bzbarsky:smaller-decl-block); r=bholley
authorBoris Zbarsky <>
Thu, 08 Jun 2017 14:26:30 -0700
changeset 411201 16a2f50d486db9d24262b5888a4269ae81d56381
parent 411200 cff7d788936904e78a5b499ad2782fb4f21cf2b1
child 411202 cc4812a78c235db11fb2de247acec6c6ef1ff09b
push id7391
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 #17242 - Reduce the size of ApplicableDeclarationBlock (from bzbarsky:smaller-decl-block); r=bholley The level is a u8, so on 64-bit it packs nicely after the u32 specificity. <!-- Please describe your changes on the following line: --> --- <!-- 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 - [X] These changes fix <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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: Source-Revision: ca8961a93bd5dfb2680ed0cb73a5fcc0ce0f0fdb
--- a/servo/components/style/
+++ b/servo/components/style/
@@ -1519,19 +1519,19 @@ impl Rule {
     /// Turns this rule into an `ApplicableDeclarationBlock` for the given
     /// cascade level.
     pub fn to_applicable_declaration_block(&self,
                                            level: CascadeLevel)
                                            -> ApplicableDeclarationBlock {
         ApplicableDeclarationBlock {
             source: StyleSource::Style(self.style_rule.clone()),
-            level: level,
             source_order: self.source_order,
             specificity: self.specificity(),
+            level: level,
     /// Creates a new Rule.
     pub fn new(selector: Selector<SelectorImpl>,
                hashes: AncestorHashes,
                style_rule: Arc<Locked<StyleRule>>,
                source_order: usize)
@@ -1552,31 +1552,31 @@ impl Rule {
 /// This represents the declarations in a given declaration block for a given
 /// importance.
 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 #[derive(Debug, Clone, PartialEq)]
 pub struct ApplicableDeclarationBlock {
     /// The style source, either a style rule, or a property declaration block.
     #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")]
     pub source: StyleSource,
-    /// The cascade level this applicable declaration block is in.
-    pub level: CascadeLevel,
     /// The source order of this block.
     pub source_order: usize,
     /// The specificity of the selector this block is represented by.
     pub specificity: u32,
+    /// The cascade level this applicable declaration block is in.
+    pub level: CascadeLevel,
 impl ApplicableDeclarationBlock {
     /// Constructs an applicable declaration block from a given property
     /// declaration block and importance.
     pub fn from_declarations(declarations: Arc<Locked<PropertyDeclarationBlock>>,
                              level: CascadeLevel)
                              -> Self {
         ApplicableDeclarationBlock {
             source: StyleSource::Declarations(declarations),
-            level: level,
             source_order: 0,
             specificity: 0,
+            level: level,
--- a/servo/tests/unit/stylo/
+++ b/servo/tests/unit/stylo/
@@ -5,16 +5,17 @@
 use selectors::gecko_like_types as dummies;
 use servo_arc::Arc;
 use std::mem::{size_of, align_of};
 use style;
 use style::data::{ComputedStyle, ElementData, ElementStyles};
 use style::gecko::selector_parser as real;
 use style::properties::ComputedValues;
 use style::rule_tree::StrongRuleNode;
+use style::stylist::ApplicableDeclarationBlock;
 fn size_of_selectors_dummy_types() {
     assert_eq!(size_of::<dummies::PseudoClass>(), size_of::<real::NonTSPseudoClass>());
     assert_eq!(align_of::<dummies::PseudoClass>(), align_of::<real::NonTSPseudoClass>());
     assert_eq!(size_of::<dummies::PseudoElement>(), size_of::<real::PseudoElement>());
     assert_eq!(align_of::<dummies::PseudoElement>(), align_of::<real::PseudoElement>());
@@ -31,16 +32,18 @@ size_of_test!(test_size_of_rule, style::
 size_of_test!(test_size_of_option_arc_cv, Option<Arc<ComputedValues>>, 8);
 size_of_test!(test_size_of_option_rule_node, Option<StrongRuleNode>, 8);
 size_of_test!(test_size_of_computed_style, ComputedStyle, 32);
 size_of_test!(test_size_of_element_styles, ElementStyles, 48);
 size_of_test!(test_size_of_element_data, ElementData, 56);
 size_of_test!(test_size_of_property_declaration, style::properties::PropertyDeclaration, 32);
+size_of_test!(test_size_of_application_declaration_block, ApplicableDeclarationBlock, 32);
 // This is huge, but we allocate it on the stack and then never move it,
 // we only pass `&mut SourcePropertyDeclaration` references around.
 size_of_test!(test_size_of_parsed_declaration, style::properties::SourcePropertyDeclaration, 704);
 fn size_of_specified_values() {