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();