script: Use conditional_malloc_size_of for Rc types on Window (#39589)

This allows measuring the size of these types conditionally rather than
ignoring them.

Testing: This modifies which things are measured by `MallocSizeOf` which
isn't covered by tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-09-30 18:03:34 +02:00 committed by GitHub
parent 0a1633c52a
commit 439558133f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View file

@ -312,7 +312,7 @@ pub(crate) struct Window {
dom_static: GlobalStaticData, dom_static: GlobalStaticData,
/// The JavaScript runtime. /// The JavaScript runtime.
#[ignore_malloc_size_of = "Rc<T> is hard"] #[conditional_malloc_size_of]
js_runtime: DomRefCell<Option<Rc<Runtime>>>, js_runtime: DomRefCell<Option<Rc<Runtime>>>,
/// The [`ViewportDetails`] of this [`Window`]'s frame. /// The [`ViewportDetails`] of this [`Window`]'s frame.
@ -429,7 +429,7 @@ pub(crate) struct Window {
/// A shared marker for the validity of any cached layout values. A value of true /// A shared marker for the validity of any cached layout values. A value of true
/// indicates that any such values remain valid; any new layout that invalidates /// indicates that any such values remain valid; any new layout that invalidates
/// those values will cause the marker to be set to false. /// those values will cause the marker to be set to false.
#[ignore_malloc_size_of = "Rc is hard"] #[conditional_malloc_size_of]
layout_marker: DomRefCell<Rc<Cell<bool>>>, layout_marker: DomRefCell<Rc<Cell<bool>>>,
/// <https://dom.spec.whatwg.org/#window-current-event> /// <https://dom.spec.whatwg.org/#window-current-event>
@ -446,7 +446,7 @@ pub(crate) struct Window {
endpoints_list: DomRefCell<Vec<ReportingEndpoint>>, endpoints_list: DomRefCell<Vec<ReportingEndpoint>>,
/// The window proxies the script thread knows. /// The window proxies the script thread knows.
#[ignore_malloc_size_of = "Rc"] #[conditional_malloc_size_of]
script_window_proxies: Rc<ScriptWindowProxies>, script_window_proxies: Rc<ScriptWindowProxies>,
/// Whether or not this [`Window`] has a pending screenshot readiness request. /// Whether or not this [`Window`] has a pending screenshot readiness request.

View file

@ -659,11 +659,14 @@ pub(crate) fn notify_about_rejected_promises(global: &GlobalScope) {
} }
} }
#[derive(JSTraceable)] #[derive(JSTraceable, MallocSizeOf)]
pub(crate) struct Runtime { pub(crate) struct Runtime {
#[ignore_malloc_size_of = "Type from mozjs"]
rt: RustRuntime, rt: RustRuntime,
/// Our actual microtask queue, which is preserved and untouched by the debugger when running debugger scripts. /// Our actual microtask queue, which is preserved and untouched by the debugger when running debugger scripts.
#[conditional_malloc_size_of]
pub(crate) microtask_queue: Rc<MicrotaskQueue>, pub(crate) microtask_queue: Rc<MicrotaskQueue>,
#[ignore_malloc_size_of = "Type from mozjs"]
job_queue: *mut JobQueue, job_queue: *mut JobQueue,
networking_task_src: Option<Box<SendableTaskSource>>, networking_task_src: Option<Box<SendableTaskSource>>,
} }