mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Introduce and start using the MallocSizeOf trait.
MallocSizeOf is similar to the existing HeapSizeOf trait from the heapsize crate. The only difference is that MallocSizeOf's malloc_size_of_children() function takes an additional MallocSizeOfFn argument, which is used to measure heap blocks. This extra argument makes MallocSizeOf match how Gecko's memory measurements work, and is required for Stylo to integrate with DMD. The patch also introduces a second trait, MallocSizeOfWithGuard, which is much the same as MallocSizeOf, but with a |guard| argument for the global style lock. Finally, the patch uses the new traits to measure a small amount of Stylo's memory usage.
This commit is contained in:
parent
4ec2e8b4c5
commit
6d5b1242db
5 changed files with 139 additions and 5 deletions
|
@ -16,6 +16,7 @@ use std::fmt;
|
|||
use std::slice::Iter;
|
||||
use style_traits::ToCss;
|
||||
use stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||
use stylesheets::{MallocSizeOf, MallocSizeOfFn};
|
||||
use super::*;
|
||||
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValueMap;
|
||||
|
||||
|
@ -46,6 +47,12 @@ pub enum Importance {
|
|||
Important,
|
||||
}
|
||||
|
||||
impl MallocSizeOf for Importance {
|
||||
fn malloc_size_of_children(&self, _malloc_size_of: MallocSizeOfFn) -> usize {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
impl Importance {
|
||||
/// Return whether this is an important declaration.
|
||||
pub fn important(self) -> bool {
|
||||
|
@ -70,6 +77,12 @@ pub struct PropertyDeclarationBlock {
|
|||
longhands: LonghandIdSet,
|
||||
}
|
||||
|
||||
impl MallocSizeOf for PropertyDeclarationBlock {
|
||||
fn malloc_size_of_children(&self, malloc_size_of: MallocSizeOfFn) -> usize {
|
||||
self.declarations.malloc_size_of_children(malloc_size_of)
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterator for PropertyDeclaration to be generated from PropertyDeclarationBlock.
|
||||
#[derive(Clone)]
|
||||
pub struct PropertyDeclarationIterator<'a> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue