mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Measure heap allocations hanging off selector components.
Bug: 1475191 Reviewed-by: emilio MozReview-Commit-ID: D7vZQ7v8owS
This commit is contained in:
parent
dd277be487
commit
a41127152b
5 changed files with 89 additions and 16 deletions
|
@ -693,6 +693,90 @@ impl MallocSizeOf for selectors::parser::AncestorHashes {
|
|||
}
|
||||
}
|
||||
|
||||
impl<Impl: selectors::parser::SelectorImpl> MallocSizeOf
|
||||
for selectors::parser::Selector<Impl>
|
||||
where
|
||||
Impl::NonTSPseudoClass: MallocSizeOf,
|
||||
Impl::PseudoElement: MallocSizeOf,
|
||||
{
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
let mut n = 0;
|
||||
|
||||
// It's OK to measure this ThinArc directly because it's the
|
||||
// "primary" reference. (The secondary references are on the
|
||||
// Stylist.)
|
||||
n += unsafe { ops.malloc_size_of(self.thin_arc_heap_ptr()) };
|
||||
for component in self.iter_raw_match_order() {
|
||||
n += component.size_of(ops);
|
||||
}
|
||||
|
||||
n
|
||||
}
|
||||
}
|
||||
|
||||
impl<Impl: selectors::parser::SelectorImpl> MallocSizeOf
|
||||
for selectors::parser::Component<Impl>
|
||||
where
|
||||
Impl::NonTSPseudoClass: MallocSizeOf,
|
||||
Impl::PseudoElement: MallocSizeOf,
|
||||
{
|
||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
use selectors::parser::Component;
|
||||
|
||||
match self {
|
||||
Component::AttributeOther(ref attr_selector) => {
|
||||
attr_selector.size_of(ops)
|
||||
}
|
||||
Component::Negation(ref components) => {
|
||||
components.size_of(ops)
|
||||
}
|
||||
Component::NonTSPseudoClass(ref pseudo) => {
|
||||
(*pseudo).size_of(ops)
|
||||
}
|
||||
Component::Slotted(ref selector) |
|
||||
Component::Host(Some(ref selector)) => {
|
||||
selector.size_of(ops)
|
||||
}
|
||||
Component::PseudoElement(ref pseudo) => {
|
||||
(*pseudo).size_of(ops)
|
||||
}
|
||||
Component::Combinator(..) |
|
||||
Component::ExplicitAnyNamespace |
|
||||
Component::ExplicitNoNamespace |
|
||||
Component::DefaultNamespace(..) |
|
||||
Component::Namespace(..) |
|
||||
Component::ExplicitUniversalType |
|
||||
Component::LocalName(..) |
|
||||
Component::ID(..) |
|
||||
Component::Class(..) |
|
||||
Component::AttributeInNoNamespaceExists { .. } |
|
||||
Component::AttributeInNoNamespace { .. } |
|
||||
Component::FirstChild |
|
||||
Component::LastChild |
|
||||
Component::OnlyChild |
|
||||
Component::Root |
|
||||
Component::Empty |
|
||||
Component::Scope |
|
||||
Component::NthChild(..) |
|
||||
Component::NthLastChild(..) |
|
||||
Component::NthOfType(..) |
|
||||
Component::NthLastOfType(..) |
|
||||
Component::FirstOfType |
|
||||
Component::LastOfType |
|
||||
Component::OnlyOfType |
|
||||
Component::Host(None) => 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Impl: selectors::parser::SelectorImpl> MallocSizeOf
|
||||
for selectors::attr::AttrSelectorWithNamespace<Impl>
|
||||
{
|
||||
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
impl MallocSizeOf for Void {
|
||||
#[inline]
|
||||
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue