servo: Merge #18637 - Two small tweaks related to MallocSizeOf (from nnethercote:rename-add_size_of_children); r=emilio

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because tested on the Gecko side.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 81801ab8b4c76eb1fc69a6d31175c3a372dad93a

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 81c7ee7a5c7f6ea7cd13446c438bcfc6d760e7e6
This commit is contained in:
Nicholas Nethercote 2017-09-26 05:52:34 -05:00
Родитель 596a2c319b
Коммит a35d42324c
4 изменённых файлов: 19 добавлений и 21 удалений

Просмотреть файл

@ -39,8 +39,8 @@
//! - If you need an additional synchronization argument, provide a function //! - If you need an additional synchronization argument, provide a function
//! that is like the standard trait method, but with the extra argument. //! that is like the standard trait method, but with the extra argument.
//! - If you need multiple measurements for a type, provide a function named //! - If you need multiple measurements for a type, provide a function named
//! `add_size_of_children` that takes a mutable reference to a struct that //! `add_size_of` that takes a mutable reference to a struct that contains
//! contains the multiple measurement fields. //! the multiple measurement fields.
//! - When deep measurement (via `MallocSizeOf`) cannot be implemented for a //! - When deep measurement (via `MallocSizeOf`) cannot be implemented for a
//! type, shallow measurement (via `MallocShallowSizeOf`) in combination with //! type, shallow measurement (via `MallocShallowSizeOf`) in combination with
//! iteration can be a useful substitute. //! iteration can be a useful substitute.
@ -64,8 +64,6 @@ extern crate servo_arc;
extern crate smallbitvec; extern crate smallbitvec;
extern crate smallvec; extern crate smallvec;
use servo_arc::Arc;
use smallvec::{Array, SmallVec};
use std::hash::{BuildHasher, Hash}; use std::hash::{BuildHasher, Hash};
use std::ops::Range; use std::ops::Range;
use std::os::raw::c_void; use std::os::raw::c_void;
@ -244,7 +242,7 @@ impl<T: MallocSizeOf> MallocSizeOf for Vec<T> {
} }
} }
impl<A: Array> MallocShallowSizeOf for SmallVec<A> { impl<A: smallvec::Array> MallocShallowSizeOf for smallvec::SmallVec<A> {
fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
if self.spilled() { if self.spilled() {
unsafe { ops.malloc_size_of(self.as_ptr()) } unsafe { ops.malloc_size_of(self.as_ptr()) }
@ -254,8 +252,8 @@ impl<A: Array> MallocShallowSizeOf for SmallVec<A> {
} }
} }
impl<A> MallocSizeOf for SmallVec<A> impl<A> MallocSizeOf for smallvec::SmallVec<A>
where A: Array, where A: smallvec::Array,
A::Item: MallocSizeOf A::Item: MallocSizeOf
{ {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
@ -348,19 +346,19 @@ impl<K, V, S> MallocSizeOf for hashglobe::hash_map::HashMap<K, V, S>
//impl<T> !MallocSizeOf for Arc<T> { } //impl<T> !MallocSizeOf for Arc<T> { }
//impl<T> !MallocShallowSizeOf for Arc<T> { } //impl<T> !MallocShallowSizeOf for Arc<T> { }
impl<T> MallocUnconditionalShallowSizeOf for Arc<T> { impl<T> MallocUnconditionalShallowSizeOf for servo_arc::Arc<T> {
fn unconditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { fn unconditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
unsafe { ops.malloc_size_of(self.heap_ptr()) } unsafe { ops.malloc_size_of(self.heap_ptr()) }
} }
} }
impl<T: MallocSizeOf> MallocUnconditionalSizeOf for Arc<T> { impl<T: MallocSizeOf> MallocUnconditionalSizeOf for servo_arc::Arc<T> {
fn unconditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { fn unconditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
self.unconditional_shallow_size_of(ops) + (**self).size_of(ops) self.unconditional_shallow_size_of(ops) + (**self).size_of(ops)
} }
} }
impl<T> MallocConditionalShallowSizeOf for Arc<T> { impl<T> MallocConditionalShallowSizeOf for servo_arc::Arc<T> {
fn conditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { fn conditional_shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
if ops.have_seen_ptr(self.heap_ptr()) { if ops.have_seen_ptr(self.heap_ptr()) {
0 0
@ -370,7 +368,7 @@ impl<T> MallocConditionalShallowSizeOf for Arc<T> {
} }
} }
impl<T: MallocSizeOf> MallocConditionalSizeOf for Arc<T> { impl<T: MallocSizeOf> MallocConditionalSizeOf for servo_arc::Arc<T> {
fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { fn conditional_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
if ops.have_seen_ptr(self.heap_ptr()) { if ops.have_seen_ptr(self.heap_ptr()) {
0 0

Просмотреть файл

@ -181,8 +181,8 @@ impl PerDocumentStyleDataImpl {
} }
/// Measure heap usage. /// Measure heap usage.
pub fn add_size_of_children(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) { pub fn add_size_of(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) {
self.stylist.add_size_of_children(ops, sizes); self.stylist.add_size_of(ops, sizes);
} }
} }

Просмотреть файл

@ -174,7 +174,7 @@ struct UserAgentCascadeData {
impl UserAgentCascadeData { impl UserAgentCascadeData {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
fn add_size_of(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) { fn add_size_of(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) {
self.cascade_data.add_size_of_children(ops, sizes); self.cascade_data.add_size_of(ops, sizes);
sizes.mPrecomputedPseudos += self.precomputed_pseudo_element_decls.size_of(ops); sizes.mPrecomputedPseudos += self.precomputed_pseudo_element_decls.size_of(ops);
} }
} }
@ -329,9 +329,9 @@ impl DocumentCascadeData {
/// Measures heap usage. /// Measures heap usage.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub fn add_size_of_children(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) { pub fn add_size_of(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) {
self.user.add_size_of_children(ops, sizes); self.user.add_size_of(ops, sizes);
self.author.add_size_of_children(ops, sizes); self.author.add_size_of(ops, sizes);
} }
} }
@ -1530,8 +1530,8 @@ impl Stylist {
/// Measures heap usage. /// Measures heap usage.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub fn add_size_of_children(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) { pub fn add_size_of(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) {
self.cascade_data.add_size_of_children(ops, sizes); self.cascade_data.add_size_of(ops, sizes);
sizes.mRuleTree += self.rule_tree.size_of(ops); sizes.mRuleTree += self.rule_tree.size_of(ops);
// We may measure other fields in the future if DMD says it's worth it. // We may measure other fields in the future if DMD says it's worth it.
@ -2225,7 +2225,7 @@ impl CascadeData {
/// Measures heap usage. /// Measures heap usage.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub fn add_size_of_children(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) { pub fn add_size_of(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) {
sizes.mElementAndPseudosMaps += self.element_map.size_of(ops); sizes.mElementAndPseudosMaps += self.element_map.size_of(ops);
for elem in self.pseudos_map.iter() { for elem in self.pseudos_map.iter() {

Просмотреть файл

@ -3781,7 +3781,7 @@ pub extern "C" fn Servo_StyleSet_AddSizeOfExcludingThis(
malloc_enclosing_size_of.unwrap(), malloc_enclosing_size_of.unwrap(),
None); None);
let sizes = unsafe { sizes.as_mut() }.unwrap(); let sizes = unsafe { sizes.as_mut() }.unwrap();
data.add_size_of_children(&mut ops, sizes); data.add_size_of(&mut ops, sizes);
} }
#[no_mangle] #[no_mangle]