Auto merge of #18310 - nnethercote:bug-1394729, r=heycam

Measure memory usage of Stylo's Rule Tree.

<!-- Please describe your changes on the following line: -->
This is for https://bugzilla.mozilla.org/show_bug.cgi?id=1394729, which was r=heycam.

---
<!-- 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 tests exist in Gecko.

<!-- 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. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18310)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-08-31 00:31:31 -05:00 committed by GitHub
commit d795ceae17
7 changed files with 126 additions and 10 deletions

View file

@ -77,7 +77,7 @@ use style::gecko_bindings::structs::{ServoStyleSheet, SheetParsingMode, nsIAtom,
use style::gecko_bindings::structs::{nsCSSFontFaceRule, nsCSSCounterStyleRule};
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
use style::gecko_bindings::structs::IterationCompositeOperation;
use style::gecko_bindings::structs::MallocSizeOf;
use style::gecko_bindings::structs::MallocSizeOf as GeckoMallocSizeOf;
use style::gecko_bindings::structs::OriginFlags;
use style::gecko_bindings::structs::OriginFlags_Author;
use style::gecko_bindings::structs::OriginFlags_User;
@ -86,6 +86,7 @@ use style::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
use style::gecko_bindings::structs::SeenPtrs;
use style::gecko_bindings::structs::ServoElementSnapshotTable;
use style::gecko_bindings::structs::ServoStyleSetSizes;
use style::gecko_bindings::structs::ServoTraversalFlags;
use style::gecko_bindings::structs::StyleRuleInclusion;
use style::gecko_bindings::structs::URLExtraData;
@ -771,7 +772,7 @@ pub extern "C" fn Servo_Element_ClearData(element: RawGeckoElementBorrowed) {
}
#[no_mangle]
pub extern "C" fn Servo_Element_SizeOfExcludingThisAndCVs(malloc_size_of: MallocSizeOf,
pub extern "C" fn Servo_Element_SizeOfExcludingThisAndCVs(malloc_size_of: GeckoMallocSizeOf,
seen_ptrs: *mut SeenPtrs,
element: RawGeckoElementBorrowed) -> usize {
let malloc_size_of = malloc_size_of.unwrap();
@ -1055,7 +1056,7 @@ pub extern "C" fn Servo_StyleSheet_Clone(
#[no_mangle]
pub extern "C" fn Servo_StyleSheet_SizeOfIncludingThis(
malloc_size_of: MallocSizeOf,
malloc_size_of: GeckoMallocSizeOf,
sheet: RawServoStyleSheetContentsBorrowed
) -> usize {
let global_style_data = &*GLOBAL_STYLE_DATA;
@ -3583,6 +3584,18 @@ pub extern "C" fn Servo_StyleSet_ResolveForDeclarations(
).into()
}
#[no_mangle]
pub extern "C" fn Servo_StyleSet_AddSizeOfExcludingThis(
malloc_size_of: GeckoMallocSizeOf,
sizes: *mut ServoStyleSetSizes,
raw_data: RawServoStyleSetBorrowed
) {
let data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
let malloc_size_of = malloc_size_of.unwrap();
let sizes = unsafe { sizes.as_mut() }.unwrap();
data.malloc_add_size_of_children(malloc_size_of, sizes);
}
#[no_mangle]
pub extern "C" fn Servo_StyleSet_MightHaveAttributeDependency(
raw_data: RawServoStyleSetBorrowed,