From 3c8680f273760d88ef15ae6c1cece94539753337 Mon Sep 17 00:00:00 2001 From: Sean Joseph Date: Thu, 26 Nov 2020 10:43:30 -0500 Subject: [PATCH] Add back code to identify JSObjects that should be counted in memory profiling --- components/script/init.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/script/init.rs b/components/script/init.rs index 823f045fad4..53d91fbdc66 100644 --- a/components/script/init.rs +++ b/components/script/init.rs @@ -3,8 +3,10 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::RegisterBindings; +use crate::dom::bindings::conversions::is_dom_proxy; use crate::dom::bindings::proxyhandler; use crate::script_runtime::JSEngineSetup; +use js::jsapi::JSObject; #[cfg(target_os = "linux")] #[allow(unsafe_code)] @@ -49,6 +51,11 @@ fn perform_platform_specific_initialization() { #[cfg(not(target_os = "linux"))] fn perform_platform_specific_initialization() {} +#[allow(unsafe_code)] +unsafe extern "C" fn is_dom_object(obj: *mut JSObject) -> bool { + !obj.is_null() && is_dom_proxy(obj) +} + #[allow(unsafe_code)] pub fn init() -> JSEngineSetup { unsafe { @@ -57,6 +64,8 @@ pub fn init() -> JSEngineSetup { // Create the global vtables used by the (generated) DOM // bindings to implement JS proxies. RegisterBindings::RegisterProxyHandlers(); + + js::glue::InitializeMemoryReporter(Some(is_dom_object)); } perform_platform_specific_initialization();