mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
style: Use an explicit stack to measure rule tree memory usage.
A patch of mine that makes us measure the rule tree more often triggers this. Differential Revision: https://phabricator.services.mozilla.com/D26595
This commit is contained in:
parent
369acffea8
commit
ae32e4df40
1 changed files with 9 additions and 14 deletions
|
@ -75,8 +75,15 @@ impl Drop for RuleTree {
|
||||||
#[cfg(feature = "gecko")]
|
#[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 = unsafe { ops.malloc_size_of(self.root.ptr()) };
|
let mut n = 0;
|
||||||
n += self.root.get().size_of(ops);
|
let mut stack = SmallVec::<[_; 32]>::new();
|
||||||
|
stack.push(self.root.downgrade());
|
||||||
|
|
||||||
|
while let Some(node) = stack.pop() {
|
||||||
|
n += unsafe { ops.malloc_size_of(node.ptr()) };
|
||||||
|
stack.extend(unsafe { (*node.ptr()).iter_children() });
|
||||||
|
}
|
||||||
|
|
||||||
n
|
n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -947,18 +954,6 @@ impl RuleNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
impl MallocSizeOf for RuleNode {
|
|
||||||
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
|
|
||||||
let mut n = 0;
|
|
||||||
for child in self.iter_children() {
|
|
||||||
n += unsafe { ops.malloc_size_of(child.ptr()) };
|
|
||||||
n += unsafe { (*child.ptr()).size_of(ops) };
|
|
||||||
}
|
|
||||||
n
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct WeakRuleNode {
|
struct WeakRuleNode {
|
||||||
p: ptr::NonNull<RuleNode>,
|
p: ptr::NonNull<RuleNode>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue