diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 70219416452..782e677ea58 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -79,6 +79,7 @@ uluru = "2" unicode-bidi = "0.3" unicode-segmentation = "1.0" void = "1.0.2" +gecko-profiler = { path = "../../../tools/profiler/rust-api" } [build-dependencies] bindgen = { version = "0.62", optional = true, default-features = false } diff --git a/components/style/global_style_data.rs b/components/style/global_style_data.rs index 4e3d11b94b7..e08baa83b1d 100644 --- a/components/style/global_style_data.rs +++ b/components/style/global_style_data.rs @@ -10,6 +10,7 @@ use crate::gecko_bindings::bindings; use crate::parallel::STYLE_THREAD_STACK_SIZE_KB; use crate::shared_lock::SharedRwLock; use crate::thread_state; +use gecko_profiler; use parking_lot::{RwLock, RwLockReadGuard}; use rayon; use std::env; @@ -49,20 +50,16 @@ fn thread_startup(_index: usize) { thread_state::initialize_layout_worker_thread(); #[cfg(feature = "gecko")] unsafe { - use std::ffi::CString; - bindings::Gecko_SetJemallocThreadLocalArena(true); let name = thread_name(_index); - let name = CString::new(name).unwrap(); - // Gecko_RegisterProfilerThread copies the passed name here. - bindings::Gecko_RegisterProfilerThread(name.as_ptr()); + gecko_profiler::register_thread(&name); } } fn thread_shutdown(_: usize) { #[cfg(feature = "gecko")] unsafe { - bindings::Gecko_UnregisterProfilerThread(); + gecko_profiler::unregister_thread(); bindings::Gecko_SetJemallocThreadLocalArena(false); } ALIVE_WORKER_THREADS.fetch_sub(1, Ordering::Relaxed);