style: Add Gecko profiler labels for when the style threads are doing work.

Differential Revision: https://phabricator.services.mozilla.com/D30869
This commit is contained in:
Cameron McCormack 2019-05-14 05:00:45 +00:00 committed by Emilio Cobos Álvarez
parent 8dc7a25893
commit 3a22bb6c49
6 changed files with 112 additions and 0 deletions

View file

@ -104,3 +104,33 @@ macro_rules! define_keyword_type {
}
};
}
/// Place a Gecko profiler label on the stack.
///
/// The `label_type` argument must be the name of a variant of `ProfilerLabel`.
#[cfg(feature = "gecko_profiler")]
#[macro_export]
macro_rules! profiler_label {
($label_type:ident) => {
let mut _profiler_label: $crate::gecko_bindings::structs::AutoProfilerLabel = unsafe {
::std::mem::uninitialized()
};
let _profiler_label = if $crate::gecko::profiler::profiler_is_active() {
unsafe {
Some($crate::gecko::profiler::AutoProfilerLabel::new(
&mut _profiler_label,
$crate::gecko::profiler::ProfilerLabel::$label_type,
))
}
} else {
None
};
}
}
/// No-op when the Gecko profiler is not available.
#[cfg(not(feature = "gecko_profiler"))]
#[macro_export]
macro_rules! profiler_label {
($label_type:ident) => {}
}