diff options
author | Sean Joseph <sean.joseph@cengage.com> | 2020-11-26 10:43:30 -0500 |
---|---|---|
committer | Sean Joseph <sean.joseph@cengage.com> | 2020-11-26 10:43:30 -0500 |
commit | 3c8680f273760d88ef15ae6c1cece94539753337 (patch) | |
tree | 60a24f777bcd1d063226cf6cce7315ca7b4cbd24 /components/script/init.rs | |
parent | cf68cd16bda1c0b2547228112920289fd373f2bd (diff) | |
download | servo-3c8680f273760d88ef15ae6c1cece94539753337.tar.gz servo-3c8680f273760d88ef15ae6c1cece94539753337.zip |
Add back code to identify JSObjects that should be counted in memory profiling
Diffstat (limited to 'components/script/init.rs')
-rw-r--r-- | components/script/init.rs | 9 |
1 files changed, 9 insertions, 0 deletions
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)] @@ -50,6 +52,11 @@ fn perform_platform_specific_initialization() { 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 { proxyhandler::init(); @@ -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(); |