mirror of
https://github.com/servo/servo.git
synced 2025-08-14 01:45:33 +01:00
Measure the stylist during memory reporting.
This commit is contained in:
parent
f648e12935
commit
d880efcab3
14 changed files with 356 additions and 28 deletions
|
@ -43,7 +43,9 @@ use stylesheet_set::{OriginValidity, SheetRebuildKind, StylesheetSet, Stylesheet
|
|||
use stylesheets::{CounterStyleRule, FontFaceRule, FontFeatureValuesRule};
|
||||
use stylesheets::{CssRule, Origin, OriginSet, PerOrigin, PerOriginIter};
|
||||
#[cfg(feature = "gecko")]
|
||||
use stylesheets::{MallocSizeOf, MallocSizeOfFn};
|
||||
use stylesheets::{MallocEnclosingSizeOfFn, MallocSizeOf, MallocSizeOfBox, MallocSizeOfFn};
|
||||
#[cfg(feature = "gecko")]
|
||||
use stylesheets::{MallocSizeOfHash, MallocSizeOfVec};
|
||||
use stylesheets::StyleRule;
|
||||
use stylesheets::StylesheetInDocument;
|
||||
use stylesheets::UserAgentStylesheets;
|
||||
|
@ -360,6 +362,25 @@ impl DocumentCascadeData {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Measures heap usage.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn malloc_add_size_of_children(&self, malloc_size_of: MallocSizeOfFn,
|
||||
malloc_enclosing_size_of: MallocEnclosingSizeOfFn,
|
||||
sizes: &mut ServoStyleSetSizes) {
|
||||
self.per_origin.user_agent.malloc_add_size_of_children(malloc_size_of,
|
||||
malloc_enclosing_size_of, sizes);
|
||||
self.per_origin.user.malloc_add_size_of_children(malloc_size_of,
|
||||
malloc_enclosing_size_of, sizes);
|
||||
self.per_origin.author.malloc_add_size_of_children(malloc_size_of,
|
||||
malloc_enclosing_size_of, sizes);
|
||||
|
||||
for elem in self.precomputed_pseudo_element_decls.iter() {
|
||||
if let Some(ref elem) = *elem {
|
||||
sizes.mStylistPrecomputedPseudos += elem.malloc_shallow_size_of_vec(malloc_size_of);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A wrapper over a StylesheetSet that can be `Sync`, since it's only used and
|
||||
|
@ -1565,9 +1586,13 @@ impl Stylist {
|
|||
/// Measures heap usage.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn malloc_add_size_of_children(&self, malloc_size_of: MallocSizeOfFn,
|
||||
malloc_enclosing_size_of: MallocEnclosingSizeOfFn,
|
||||
sizes: &mut ServoStyleSetSizes) {
|
||||
// XXX: need to measure other fields
|
||||
self.cascade_data.malloc_add_size_of_children(malloc_size_of, malloc_enclosing_size_of,
|
||||
sizes);
|
||||
sizes.mStylistRuleTree += self.rule_tree.malloc_size_of_children(malloc_size_of);
|
||||
|
||||
// We may measure other fields in the future if DMD says it's worth it.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1620,6 +1645,17 @@ impl ExtraStyleData {
|
|||
self.counter_styles.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// Measure heap usage.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn malloc_size_of_children(&self, malloc_size_of: MallocSizeOfFn,
|
||||
malloc_enclosing_size_of: MallocEnclosingSizeOfFn) -> usize {
|
||||
let mut n = 0;
|
||||
n += self.font_faces.malloc_shallow_size_of_vec(malloc_size_of);
|
||||
n += self.font_feature_values.malloc_shallow_size_of_vec(malloc_size_of);
|
||||
n += self.counter_styles.malloc_shallow_size_of_hash(malloc_enclosing_size_of);
|
||||
n
|
||||
}
|
||||
}
|
||||
|
||||
/// SelectorMapEntry implementation for use in our revalidation selector map.
|
||||
|
@ -1913,6 +1949,38 @@ impl CascadeData {
|
|||
self.mapped_ids.clear();
|
||||
self.selectors_for_cache_revalidation.clear();
|
||||
}
|
||||
|
||||
/// Measures heap usage.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn malloc_add_size_of_children(&self, malloc_size_of: MallocSizeOfFn,
|
||||
malloc_enclosing_size_of: MallocEnclosingSizeOfFn,
|
||||
sizes: &mut ServoStyleSetSizes) {
|
||||
sizes.mStylistElementAndPseudosMaps +=
|
||||
self.element_map.malloc_size_of_children(malloc_enclosing_size_of);
|
||||
|
||||
for elem in self.pseudos_map.iter() {
|
||||
if let Some(ref elem) = *elem {
|
||||
sizes.mStylistElementAndPseudosMaps +=
|
||||
elem.malloc_shallow_size_of_box(malloc_size_of) +
|
||||
elem.malloc_size_of_children(malloc_enclosing_size_of)
|
||||
}
|
||||
}
|
||||
|
||||
sizes.mStylistOther +=
|
||||
self.animations.malloc_shallow_size_of_hash(malloc_enclosing_size_of);
|
||||
for val in self.animations.values() {
|
||||
sizes.mStylistOther += val.malloc_size_of_children(malloc_size_of);
|
||||
}
|
||||
|
||||
sizes.mStylistInvalidationMap +=
|
||||
self.invalidation_map.malloc_size_of_children(malloc_enclosing_size_of);
|
||||
|
||||
sizes.mStylistRevalidationSelectors +=
|
||||
self.selectors_for_cache_revalidation.malloc_size_of_children(malloc_enclosing_size_of);
|
||||
|
||||
sizes.mStylistOther +=
|
||||
self.effective_media_query_results.malloc_size_of_children(malloc_enclosing_size_of);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for CascadeData {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue