mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Report heap size of rule tree heap allocations as well.
Differential Revision: https://phabricator.services.mozilla.com/D33353
This commit is contained in:
parent
9721bd7d0d
commit
ef99ab1f08
1 changed files with 16 additions and 7 deletions
|
@ -14,8 +14,7 @@ use crate::properties::{Importance, LonghandIdSet, PropertyDeclarationBlock};
|
||||||
use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
|
use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
|
||||||
use crate::stylesheets::{Origin, StyleRule};
|
use crate::stylesheets::{Origin, StyleRule};
|
||||||
use crate::thread_state;
|
use crate::thread_state;
|
||||||
#[cfg(feature = "gecko")]
|
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps};
|
||||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use servo_arc::{Arc, ArcBorrow, ArcUnion, ArcUnionBorrow};
|
use servo_arc::{Arc, ArcBorrow, ArcUnion, ArcUnionBorrow};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
@ -46,7 +45,6 @@ use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
|
||||||
/// logs from http://logs.glob.uno/?c=mozilla%23servo&s=3+Apr+2017&e=3+Apr+2017#c644094
|
/// logs from http://logs.glob.uno/?c=mozilla%23servo&s=3+Apr+2017&e=3+Apr+2017#c644094
|
||||||
/// to se a discussion about the different memory orderings used here.
|
/// to se a discussion about the different memory orderings used here.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
|
||||||
pub struct RuleTree {
|
pub struct RuleTree {
|
||||||
root: StrongRuleNode,
|
root: StrongRuleNode,
|
||||||
}
|
}
|
||||||
|
@ -74,7 +72,6 @@ impl Drop for RuleTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
impl MallocSizeOf for RuleTree {
|
impl MallocSizeOf for RuleTree {
|
||||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||||
let mut n = 0;
|
let mut n = 0;
|
||||||
|
@ -83,9 +80,9 @@ impl MallocSizeOf for RuleTree {
|
||||||
|
|
||||||
while let Some(node) = stack.pop() {
|
while let Some(node) = stack.pop() {
|
||||||
n += unsafe { ops.malloc_size_of(node.ptr()) };
|
n += unsafe { ops.malloc_size_of(node.ptr()) };
|
||||||
unsafe {
|
let children = unsafe { (*node.ptr()).children.read() };
|
||||||
(*node.ptr()).children.read().each(|c| stack.push(c.clone()));
|
children.shallow_size_of(ops);
|
||||||
}
|
children.each(|c| stack.push(c.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
n
|
n
|
||||||
|
@ -769,6 +766,18 @@ enum RuleNodeChildren {
|
||||||
Map(Box<FxHashMap<ChildKey, WeakRuleNode>>),
|
Map(Box<FxHashMap<ChildKey, WeakRuleNode>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl MallocShallowSizeOf for RuleNodeChildren {
|
||||||
|
fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||||
|
match *self {
|
||||||
|
RuleNodeChildren::One(..) | RuleNodeChildren::Empty => 0,
|
||||||
|
RuleNodeChildren::Map(ref m) => {
|
||||||
|
// Want to account for both the box and the hashmap.
|
||||||
|
m.shallow_size_of(ops) + (**m).shallow_size_of(ops)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for RuleNodeChildren {
|
impl Default for RuleNodeChildren {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
RuleNodeChildren::Empty
|
RuleNodeChildren::Empty
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue