Adds perf jitdump support (#360)
Patch adds support for the perf jitdump file specification. With this patch it should be possible to see profile data for code generated and maped at runtime. Specifically the patch adds support for the JIT_CODE_LOAD and the JIT_DEBUG_INFO record as described in the specification. Dumping jitfiles is enabled with the --jitdump flag. When the -g flag is also used there is an attempt to dump file and line number information where this option would be most useful when the WASM file already includes DWARF debug information. The generation of the jitdump files has been tested on only a few wasm files. This patch is expected to be useful/serviceable where currently there is no means for jit profiling, but future patches may benefit line mapping and add support for additional jitdump record types. Usage Example: Record sudo perf record -k 1 -e instructions:u target/debug/wasmtime -g --jitdump test.wasm Combine sudo perf inject -v -j -i perf.data -o perf.jit.data Report sudo perf report -i perf.jit.data -F+period,srcline
This commit is contained in:
@@ -5,6 +5,7 @@ use region;
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::{cmp, mem};
|
||||
use wasmtime_environ::{Compilation, CompiledFunction};
|
||||
use wasmtime_profiling::ProfilingAgent;
|
||||
use wasmtime_runtime::{Mmap, VMFunctionBody};
|
||||
|
||||
struct CodeMemoryEntry {
|
||||
@@ -230,4 +231,22 @@ impl CodeMemory {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Calls the module_load for a given ProfilerAgent. Includes
|
||||
/// all memory address and length for the given module.
|
||||
/// TODO: Properly handle the possibilities of multiple mmapped regions
|
||||
/// which may, amongst other things, influence being more specific about
|
||||
/// the module name.
|
||||
pub fn profiler_module_load(
|
||||
&mut self,
|
||||
profiler: &mut Box<dyn ProfilingAgent + Send>,
|
||||
module_name: &str,
|
||||
dbg_image: Option<&[u8]>,
|
||||
) -> () {
|
||||
for CodeMemoryEntry { mmap: m, table: _t } in &mut self.entries {
|
||||
if m.len() > 0 {
|
||||
profiler.module_load(module_name, m.as_ptr(), m.len(), dbg_image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user