style: Measure heap allocations hanging off selector components.

Bug: 1475191
Reviewed-by: emilio
MozReview-Commit-ID: D7vZQ7v8owS
This commit is contained in:
Cameron McCormack 2018-07-12 19:44:00 +10:00 committed by Emilio Cobos Álvarez
parent dd277be487
commit a41127152b
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 89 additions and 16 deletions

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// Gecko's pseudo-element definition.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
pub enum PseudoElement {
% for pseudo in PSEUDOS:
/// ${pseudo.value}

View file

@ -40,7 +40,7 @@ macro_rules! pseudo_class_name {
(bare: [$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*],
string: [$(($s_css:expr, $s_name:ident, $s_gecko_type:tt, $s_state:tt, $s_flags:tt),)*]) => {
/// Our representation of a non tree-structural pseudo-class.
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq)]
pub enum NonTSPseudoClass {
$(
#[doc = $css]

View file

@ -172,7 +172,7 @@ impl<T> PerPseudoElementMap<T> {
}
/// Values for the :dir() pseudo class
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq)]
pub enum Direction {
/// left-to-right semantic directionality
Ltr,

View file

@ -6,7 +6,7 @@
use cssparser::SourceLocation;
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps};
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
#[cfg(feature = "gecko")]
use malloc_size_of::MallocUnconditionalShallowSizeOf;
use properties::PropertyDeclarationBlock;
@ -50,20 +50,9 @@ impl StyleRule {
#[cfg(feature = "gecko")]
pub fn size_of(&self, guard: &SharedRwLockReadGuard, ops: &mut MallocSizeOfOps) -> usize {
let mut n = 0;
// We may add measurement of things hanging off the embedded Components
// later.
n += self.selectors.0.shallow_size_of(ops);
for selector in self.selectors.0.iter() {
// It's safe to measure this ThinArc directly because it's the
// "primary" reference. (The secondary references are on the
// Stylist.)
n += unsafe { ops.malloc_size_of(selector.thin_arc_heap_ptr()) };
}
n += self.selectors.0.size_of(ops);
n += self.block.unconditional_shallow_size_of(ops) +
self.block.read_with(guard).size_of(ops);
n
}
}