script: Measure heap usage of various ignored fields (#38791)

These changes allow using MallocSizeOf/`#[conditional_malloc_size_of]`
on WebIDL callback values, and then fix a grab bag of places in the
script crate that previously ignored those values. There are also some
commits removing ignored fields that involved Arc/Rc that are not WebIDL
callbacks, since they are now easier to support with the
`#[conditional_malloc_size_of]` attribute.

Testing: Manual testing on about:memory for servo.org.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-08-20 04:43:58 -04:00 committed by GitHub
parent 604b6ea26d
commit 636e7211e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 44 additions and 38 deletions

View file

@ -614,28 +614,28 @@ impl CustomElementRegistryMethods<crate::DomTypeHolder> for CustomElementRegistr
#[derive(Clone, JSTraceable, MallocSizeOf)]
pub(crate) struct LifecycleCallbacks {
#[ignore_malloc_size_of = "Rc"]
#[conditional_malloc_size_of]
connected_callback: Option<Rc<Function>>,
#[ignore_malloc_size_of = "Rc"]
#[conditional_malloc_size_of]
disconnected_callback: Option<Rc<Function>>,
#[ignore_malloc_size_of = "Rc"]
#[conditional_malloc_size_of]
adopted_callback: Option<Rc<Function>>,
#[ignore_malloc_size_of = "Rc"]
#[conditional_malloc_size_of]
attribute_changed_callback: Option<Rc<Function>>,
#[ignore_malloc_size_of = "Rc"]
#[conditional_malloc_size_of]
form_associated_callback: Option<Rc<Function>>,
#[ignore_malloc_size_of = "Rc"]
#[conditional_malloc_size_of]
form_reset_callback: Option<Rc<Function>>,
#[ignore_malloc_size_of = "Rc"]
#[conditional_malloc_size_of]
form_disabled_callback: Option<Rc<Function>>,
#[ignore_malloc_size_of = "Rc"]
#[conditional_malloc_size_of]
form_state_restore_callback: Option<Rc<Function>>,
}
@ -657,7 +657,7 @@ pub(crate) struct CustomElementDefinition {
pub(crate) local_name: LocalName,
/// <https://html.spec.whatwg.org/multipage/#concept-custom-element-definition-constructor>
#[ignore_malloc_size_of = "Rc"]
#[conditional_malloc_size_of]
pub(crate) constructor: Rc<CustomElementConstructor>,
/// <https://html.spec.whatwg.org/multipage/#concept-custom-element-definition-observed-attributes>
@ -988,9 +988,9 @@ pub(crate) fn try_upgrade_element(element: &Element) {
#[derive(JSTraceable, MallocSizeOf)]
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
pub(crate) enum CustomElementReaction {
Upgrade(#[ignore_malloc_size_of = "Rc"] Rc<CustomElementDefinition>),
Upgrade(#[conditional_malloc_size_of] Rc<CustomElementDefinition>),
Callback(
#[ignore_malloc_size_of = "Rc"] Rc<Function>,
#[conditional_malloc_size_of] Rc<Function>,
#[ignore_malloc_size_of = "mozjs"] Box<[Heap<JSVal>]>,
),
}