* x64: enable VTune support by default After significant work in the `ittapi-rs` crate, this dependency should build without issue on Wasmtime's supported operating systems: Windows, Linux, and macOS. The difference in the release binary is <20KB, so this change makes `vtune` a default build feature. This change upgrades `ittapi-rs` to v0.2.0 and updates the documentation. * review: add configuration for defaults in more places * review: remove OS conditional compilation, add architecture * review: do not default vtune feature in wasmtime-jit
62 lines
1.8 KiB
Rust
62 lines
1.8 KiB
Rust
use crate::{demangling::demangle_function_name_or_index, CompiledModule};
|
|
use wasmtime_environ::{DefinedFuncIndex, EntityRef};
|
|
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(all(feature = "jitdump", target_os = "linux"))] {
|
|
#[path = "profiling/jitdump_linux.rs"]
|
|
mod jitdump;
|
|
} else {
|
|
#[path = "profiling/jitdump_disabled.rs"]
|
|
mod jitdump;
|
|
}
|
|
}
|
|
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(all(feature = "vtune", target_arch = "x86_64"))] {
|
|
#[path = "profiling/vtune.rs"]
|
|
mod vtune;
|
|
} else {
|
|
#[path = "profiling/vtune_disabled.rs"]
|
|
mod vtune;
|
|
}
|
|
}
|
|
|
|
pub use jitdump::JitDumpAgent;
|
|
pub use vtune::VTuneAgent;
|
|
|
|
/// Common interface for profiling tools.
|
|
pub trait ProfilingAgent: Send + Sync + 'static {
|
|
/// Notify the profiler of a new module loaded into memory
|
|
fn module_load(&self, module: &CompiledModule, dbg_image: Option<&[u8]>);
|
|
|
|
/// Notify the profiler about a single dynamically-generated trampoline (for host function)
|
|
/// that is being loaded now.`
|
|
fn load_single_trampoline(&self, name: &str, addr: *const u8, size: usize, pid: u32, tid: u32);
|
|
}
|
|
|
|
/// Default agent for unsupported profiling build.
|
|
#[derive(Debug, Default, Clone, Copy)]
|
|
pub struct NullProfilerAgent;
|
|
|
|
impl ProfilingAgent for NullProfilerAgent {
|
|
fn module_load(&self, _module: &CompiledModule, _dbg_image: Option<&[u8]>) {}
|
|
fn load_single_trampoline(
|
|
&self,
|
|
_name: &str,
|
|
_addr: *const u8,
|
|
_size: usize,
|
|
_pid: u32,
|
|
_tid: u32,
|
|
) {
|
|
}
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
fn debug_name(module: &CompiledModule, index: DefinedFuncIndex) -> String {
|
|
let index = module.module().func_index(index);
|
|
let mut debug_name = String::new();
|
|
demangle_function_name_or_index(&mut debug_name, module.func_name(index), index.index())
|
|
.unwrap();
|
|
debug_name
|
|
}
|