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
31 lines
1.1 KiB
Rust
31 lines
1.1 KiB
Rust
use more_asserts::assert_gt;
|
|
use std::path::PathBuf;
|
|
use wasmtime_environ::settings;
|
|
use wasmtime_environ::settings::Configurable;
|
|
use wasmtime_environ::CacheConfig;
|
|
use wasmtime_jit::{instantiate, native, CompilationStrategy, Compiler, NullResolver};
|
|
|
|
const PATH_MODULE_RS2WASM_ADD_FUNC: &str = r"tests/wat/rs2wasm-add-func.wat";
|
|
|
|
/// Simple test reading a wasm-file and translating to binary representation.
|
|
#[test]
|
|
fn test_environ_translate() {
|
|
let path = PathBuf::from(PATH_MODULE_RS2WASM_ADD_FUNC);
|
|
let data = wat::parse_file(path).expect("expecting valid wat-file");
|
|
assert_gt!(data.len(), 0);
|
|
|
|
let mut flag_builder = settings::builder();
|
|
flag_builder.enable("enable_verifier").unwrap();
|
|
|
|
let isa_builder = native::builder();
|
|
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
|
|
|
|
let mut resolver = NullResolver {};
|
|
let cache_config = CacheConfig::new_cache_disabled();
|
|
let mut compiler = Compiler::new(isa, CompilationStrategy::Auto, cache_config);
|
|
unsafe {
|
|
let instance = instantiate(&mut compiler, &data, &mut resolver, false, None);
|
|
assert!(instance.is_ok());
|
|
}
|
|
}
|