mirror of
https://github.com/servo/servo.git
synced 2025-08-08 15:05:35 +01:00
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:
commit
d795ceae17
7 changed files with 126 additions and 10 deletions
|
@ -7,8 +7,8 @@
|
|||
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
|
||||
use dom::TElement;
|
||||
use gecko_bindings::bindings::{self, RawServoStyleSet};
|
||||
use gecko_bindings::structs::{ServoStyleSheet, StyleSheetInfo, ServoStyleSheetInner};
|
||||
use gecko_bindings::structs::RawGeckoPresContextOwned;
|
||||
use gecko_bindings::structs::{RawGeckoPresContextOwned, ServoStyleSetSizes, ServoStyleSheet};
|
||||
use gecko_bindings::structs::{StyleSheetInfo, ServoStyleSheetInner};
|
||||
use gecko_bindings::structs::nsIDocument;
|
||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
||||
|
@ -16,7 +16,7 @@ use media_queries::{Device, MediaList};
|
|||
use properties::ComputedValues;
|
||||
use servo_arc::Arc;
|
||||
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
|
||||
use stylesheets::{PerOrigin, StylesheetContents, StylesheetInDocument};
|
||||
use stylesheets::{MallocSizeOfFn, PerOrigin, StylesheetContents, StylesheetInDocument};
|
||||
use stylist::{ExtraStyleData, Stylist};
|
||||
|
||||
/// Little wrapper to a Gecko style sheet.
|
||||
|
@ -184,6 +184,14 @@ impl PerDocumentStyleDataImpl {
|
|||
pub fn visited_styles_enabled(&self) -> bool {
|
||||
self.visited_links_enabled() && !self.is_private_browsing_enabled()
|
||||
}
|
||||
|
||||
/// Measures heap usage.
|
||||
pub fn malloc_add_size_of_children(&self, malloc_size_of: MallocSizeOfFn,
|
||||
sizes: &mut ServoStyleSetSizes) {
|
||||
self.stylist.malloc_add_size_of_children(malloc_size_of, sizes);
|
||||
|
||||
// We may measure more fields in the future if DMD says it's worth it.
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl HasFFI for PerDocumentStyleData {
|
||||
|
|
|
@ -61,6 +61,7 @@ use gecko_bindings::structs::SeenPtrs;
|
|||
use gecko_bindings::structs::ServoBundledURI;
|
||||
use gecko_bindings::structs::ServoElementSnapshot;
|
||||
use gecko_bindings::structs::ServoElementSnapshotTable;
|
||||
use gecko_bindings::structs::ServoStyleSetSizes;
|
||||
use gecko_bindings::structs::SheetParsingMode;
|
||||
use gecko_bindings::structs::StyleBasicShape;
|
||||
use gecko_bindings::structs::StyleBasicShapeType;
|
||||
|
@ -2067,6 +2068,11 @@ extern "C" {
|
|||
RawServoDeclarationBlockBorrowed)
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_AddSizeOfExcludingThis(malloc_size_of: MallocSizeOf,
|
||||
sizes: *mut ServoStyleSetSizes,
|
||||
set: RawServoStyleSetBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleContext_AddRef(ctx: ServoStyleContextBorrowed);
|
||||
}
|
||||
|
|
|
@ -5456,6 +5456,38 @@ pub mod root {
|
|||
"Alignment of field: " , stringify ! ( GeckoEffects )
|
||||
, "::" , stringify ! ( gecko ) ));
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy)]
|
||||
pub struct ServoStyleSetSizes {
|
||||
pub mStylistRuleTree: usize,
|
||||
pub mOther: usize,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_ServoStyleSetSizes() {
|
||||
assert_eq!(::std::mem::size_of::<ServoStyleSetSizes>() , 16usize ,
|
||||
concat ! (
|
||||
"Size of: " , stringify ! ( ServoStyleSetSizes ) ));
|
||||
assert_eq! (::std::mem::align_of::<ServoStyleSetSizes>() , 8usize
|
||||
, concat ! (
|
||||
"Alignment of " , stringify ! ( ServoStyleSetSizes )
|
||||
));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ServoStyleSetSizes ) ) .
|
||||
mStylistRuleTree as * const _ as usize } , 0usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
ServoStyleSetSizes ) , "::" , stringify ! (
|
||||
mStylistRuleTree ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ServoStyleSetSizes ) ) . mOther
|
||||
as * const _ as usize } , 8usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
ServoStyleSetSizes ) , "::" , stringify ! ( mOther )
|
||||
));
|
||||
}
|
||||
impl Clone for ServoStyleSetSizes {
|
||||
fn clone(&self) -> Self { *self }
|
||||
}
|
||||
#[repr(u8)]
|
||||
/// Enumeration that represents one of the two supported style system backends.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -5344,6 +5344,38 @@ pub mod root {
|
|||
"Alignment of field: " , stringify ! ( GeckoEffects )
|
||||
, "::" , stringify ! ( gecko ) ));
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy)]
|
||||
pub struct ServoStyleSetSizes {
|
||||
pub mStylistRuleTree: usize,
|
||||
pub mOther: usize,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_ServoStyleSetSizes() {
|
||||
assert_eq!(::std::mem::size_of::<ServoStyleSetSizes>() , 16usize ,
|
||||
concat ! (
|
||||
"Size of: " , stringify ! ( ServoStyleSetSizes ) ));
|
||||
assert_eq! (::std::mem::align_of::<ServoStyleSetSizes>() , 8usize
|
||||
, concat ! (
|
||||
"Alignment of " , stringify ! ( ServoStyleSetSizes )
|
||||
));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ServoStyleSetSizes ) ) .
|
||||
mStylistRuleTree as * const _ as usize } , 0usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
ServoStyleSetSizes ) , "::" , stringify ! (
|
||||
mStylistRuleTree ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ServoStyleSetSizes ) ) . mOther
|
||||
as * const _ as usize } , 8usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
ServoStyleSetSizes ) , "::" , stringify ! ( mOther )
|
||||
));
|
||||
}
|
||||
impl Clone for ServoStyleSetSizes {
|
||||
fn clone(&self) -> Self { *self }
|
||||
}
|
||||
#[repr(u8)]
|
||||
/// Enumeration that represents one of the two supported style system backends.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue