Add back code to identify JSObjects that should be counted in memory profiling

This commit is contained in:
Sean Joseph 2020-11-26 10:43:30 -05:00
parent cf68cd16bd
commit 3c8680f273

View file

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