servo: Merge #18548 - Implement MallocSizeOf properly for SmallBitVec (from nnethercote:measure-smallbitvec); 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
- [ ] These changes do not require tests because: trivial, and tested on 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: 672eb18b64ca47f2dd2de72724319d76885dba9c

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 17890c5a5979daed15e7c5283e257bc7bc6c0408
This commit is contained in:
Nicholas Nethercote 2017-09-18 02:24:26 -05:00
Родитель 0c43717c52
Коммит ecf86690e7
1 изменённых файлов: 10 добавлений и 4 удалений

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

@ -381,6 +381,16 @@ impl<T: MallocSizeOf> MallocConditionalSizeOf for Arc<T> {
}
}
impl MallocSizeOf for smallbitvec::SmallBitVec {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
if let Some(ptr) = self.heap_ptr() {
unsafe { ops.malloc_size_of(ptr) }
} else {
0
}
}
}
impl<T: MallocSizeOf, U> MallocSizeOf for TypedSize2D<T, U> {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
let n = self.width.size_of(ops) + self.width.size_of(ops);
@ -425,7 +435,3 @@ size_of_is_0!(Range<f32>, Range<f64>);
size_of_is_0!(app_units::Au);
size_of_is_0!(cssparser::RGBA, cssparser::TokenSerializationType);
// XXX: once we upgrade smallbitvec to 1.0.4, use the new heap_ptr() method to
// implement this properly
size_of_is_0!(smallbitvec::SmallBitVec);