mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Overhaul MallocSizeOf and related things.
This patch makes the MallocSizeOf stuff in Stylo work more like the HeapSizeOf stuff already in Servo, except better. In particular, it adds deriving support for MallocSizeOf, which will make it easier to improve coverage. The patch does the following. - Combines servo/components/style/stylesheets/memory.rs and the heapsize crate into a new crate, malloc_size_of. - Forks the heapsize_derive crate, calling it malloc_size_of, so that MallocSizeOf can be derived. - Both the new crates have MIT/Apache licenses, like heapsize, in case they are incorporated into heapsize in the future. - Renames the methods within MallocSizeOf and the related traits so they are more concise. - Removes MallocSizeOfWithGuard. - Adds `derive(MallocSizeOf)` to a lot of types, in some cases replacing an equivalent or almost-equivalent hand-written implementation. - Adds stuff so that Rc/Arc can be handled properly.
This commit is contained in:
parent
24b2d8d9cf
commit
32548e5312
44 changed files with 1188 additions and 486 deletions
|
@ -8,6 +8,8 @@ use context::{SharedStyleContext, StackLimitChecker};
|
|||
use dom::TElement;
|
||||
use invalidation::element::invalidator::InvalidationResult;
|
||||
use invalidation::element::restyle_hints::RestyleHint;
|
||||
#[cfg(feature = "gecko")]
|
||||
use malloc_size_of::MallocSizeOfOps;
|
||||
use properties::ComputedValues;
|
||||
use properties::longhands::display::computed_value as display;
|
||||
use rule_tree::StrongRuleNode;
|
||||
|
@ -16,8 +18,6 @@ use servo_arc::Arc;
|
|||
use shared_lock::StylesheetGuards;
|
||||
use std::fmt;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
#[cfg(feature = "gecko")]
|
||||
use stylesheets::SizeOfState;
|
||||
|
||||
bitflags! {
|
||||
flags RestyleFlags: u8 {
|
||||
|
@ -272,7 +272,7 @@ impl ElementStyles {
|
|||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
fn malloc_size_of_children_excluding_cvs(&self, _state: &mut SizeOfState) -> usize {
|
||||
fn size_of_excluding_cvs(&self, _ops: &mut MallocSizeOfOps) -> usize {
|
||||
// As the method name suggests, we don't measures the ComputedValues
|
||||
// here, because they are measured on the C++ side.
|
||||
|
||||
|
@ -453,8 +453,8 @@ impl ElementData {
|
|||
|
||||
/// 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);
|
||||
pub fn size_of_excluding_cvs(&self, ops: &mut MallocSizeOfOps) -> usize {
|
||||
let n = self.styles.size_of_excluding_cvs(ops);
|
||||
|
||||
// We may measure more fields in the future if DMD says it's worth it.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue