mirror of
https://github.com/servo/servo.git
synced 2025-08-18 20:05:34 +01:00
Fix a panic in Stylo memory reporting.
`MallocSizeOfOps::enclosing_size_of_op` is an `Option<>` type, and the panic in question is caused by not providing a value in a case where it's needed for measuring a HashSet. HashMaps and HashSets are common enough that it makes sense to make `enclosing_size_of_op` non-optional, which this patch does.
This commit is contained in:
parent
280ccf685d
commit
09143e627b
3 changed files with 20 additions and 11 deletions
|
@ -783,13 +783,16 @@ pub extern "C" fn Servo_Element_ClearData(element: RawGeckoElementBorrowed) {
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_Element_SizeOfExcludingThisAndCVs(malloc_size_of: GeckoMallocSizeOf,
|
||||
malloc_enclosing_size_of:
|
||||
GeckoMallocSizeOf,
|
||||
seen_ptrs: *mut SeenPtrs,
|
||||
element: RawGeckoElementBorrowed) -> usize {
|
||||
let element = GeckoElement(element);
|
||||
let borrow = element.borrow_data();
|
||||
if let Some(data) = borrow {
|
||||
let have_seen_ptr = move |ptr| { unsafe { Gecko_HaveSeenPtr(seen_ptrs, ptr) } };
|
||||
let mut ops = MallocSizeOfOps::new(malloc_size_of.unwrap(), None,
|
||||
let mut ops = MallocSizeOfOps::new(malloc_size_of.unwrap(),
|
||||
malloc_enclosing_size_of.unwrap(),
|
||||
Some(Box::new(have_seen_ptr)));
|
||||
(*data).size_of_excluding_cvs(&mut ops)
|
||||
} else {
|
||||
|
@ -1089,11 +1092,14 @@ pub extern "C" fn Servo_StyleSheet_Clone(
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSheet_SizeOfIncludingThis(
|
||||
malloc_size_of: GeckoMallocSizeOf,
|
||||
malloc_enclosing_size_of: GeckoMallocSizeOf,
|
||||
sheet: RawServoStyleSheetContentsBorrowed
|
||||
) -> usize {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let mut ops = MallocSizeOfOps::new(malloc_size_of.unwrap(), None, None);
|
||||
let mut ops = MallocSizeOfOps::new(malloc_size_of.unwrap(),
|
||||
malloc_enclosing_size_of.unwrap(),
|
||||
None);
|
||||
StylesheetContents::as_arc(&sheet).size_of(&guard, &mut ops)
|
||||
}
|
||||
|
||||
|
@ -3753,7 +3759,8 @@ pub extern "C" fn Servo_StyleSet_AddSizeOfExcludingThis(
|
|||
) {
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||
let mut ops = MallocSizeOfOps::new(malloc_size_of.unwrap(),
|
||||
malloc_enclosing_size_of, None);
|
||||
malloc_enclosing_size_of.unwrap(),
|
||||
None);
|
||||
let sizes = unsafe { sizes.as_mut() }.unwrap();
|
||||
data.add_size_of_children(&mut ops, sizes);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue