From 8ca41ccf9e4231db71357142648c2b441d2b791f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Sun, 21 May 2023 22:46:40 +0200 Subject: [PATCH] style: Replace the old profiler thread registration FFIs with the new API in servo Differential Revision: https://phabricator.services.mozilla.com/D116517 --- components/style/Cargo.toml | 1 + components/style/global_style_data.rs | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) 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);