Overhaul ComputedValues measurement, and add style structs measurement.

This commit is contained in:
Nicholas Nethercote 2017-08-14 10:49:48 +10:00
parent 60c44b072c
commit 1a40101d2f
4 changed files with 77 additions and 44 deletions

View file

@ -16,7 +16,7 @@ use shared_lock::StylesheetGuards;
use std::fmt;
use std::ops::{Deref, DerefMut};
#[cfg(feature = "gecko")]
use stylesheets::{MallocSizeOfWithRepeats, SizeOfState};
use stylesheets::SizeOfState;
bitflags! {
flags RestyleFlags: u8 {
@ -261,6 +261,17 @@ impl ElementStyles {
pub fn is_display_none(&self) -> bool {
self.primary().get_box().clone_display() == display::T::none
}
#[cfg(feature = "gecko")]
fn malloc_size_of_children_excluding_cvs(&self, _state: &mut SizeOfState) -> usize {
// As the method name suggests, we don't measures the ComputedValues
// here, because they are measured on the C++ side.
// XXX: measure the EagerPseudoArray itself, but not the ComputedValues
// within it.
0
}
}
// We manually implement Debug for ElementStyles so that we can avoid the
@ -273,20 +284,6 @@ impl fmt::Debug for ElementStyles {
}
}
#[cfg(feature = "gecko")]
impl MallocSizeOfWithRepeats for ElementStyles {
fn malloc_size_of_children(&self, state: &mut SizeOfState) -> usize {
let mut n = 0;
if let Some(ref primary) = self.primary {
n += primary.malloc_size_of_children(state)
};
// We may measure more fields in the future if DMD says it's worth it.
n
}
}
/// Style system data associated with an Element.
///
/// In Gecko, this hangs directly off the Element. Servo, this is embedded
@ -436,12 +433,11 @@ impl ElementData {
pub fn clear_restyle_flags_and_damage(&mut self) {
self.restyle.clear_restyle_flags_and_damage();
}
}
#[cfg(feature = "gecko")]
impl MallocSizeOfWithRepeats for ElementData {
fn malloc_size_of_children(&self, state: &mut SizeOfState) -> usize {
let n = self.styles.malloc_size_of_children(state);
/// Measures memory usage.
#[cfg(feature = "gecko")]
pub fn malloc_size_of_children_excluding_cvs(&self, state: &mut SizeOfState) -> usize {
let n = self.styles.malloc_size_of_children_excluding_cvs(state);
// We may measure more fields in the future if DMD says it's worth it.