diff --git a/Cargo.lock b/Cargo.lock index 7fab29c6be..c8fd80fb2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3514,6 +3514,7 @@ dependencies = [ "cranelift-native", "cranelift-wasm", "gimli", + "log", "more-asserts", "object", "target-lexicon", diff --git a/cranelift/codegen/src/timing.rs b/cranelift/codegen/src/timing.rs index 2a360a7d34..1613abb9fa 100644 --- a/cranelift/codegen/src/timing.rs +++ b/cranelift/codegen/src/timing.rs @@ -130,6 +130,13 @@ mod details { pass: [PassTime; NUM_PASSES], } + impl PassTimes { + /// Returns the total amount of time taken by all the passes measured. + pub fn total(&self) -> Duration { + self.pass.iter().map(|p| p.total - p.child).sum() + } + } + impl Default for PassTimes { fn default() -> Self { Self { diff --git a/crates/cranelift/Cargo.toml b/crates/cranelift/Cargo.toml index 331f660f79..6e76c0d9f0 100644 --- a/crates/cranelift/Cargo.toml +++ b/crates/cranelift/Cargo.toml @@ -12,6 +12,7 @@ edition = "2018" [dependencies] anyhow = "1.0" +log = "0.4" wasmtime-environ = { path = "../environ", version = "0.30.0" } cranelift-wasm = { path = "../../cranelift/wasm", version = "0.77.0" } cranelift-codegen = { path = "../../cranelift/codegen", version = "0.77.0" } diff --git a/crates/cranelift/src/compiler.rs b/crates/cranelift/src/compiler.rs index 6983945461..0f947605d0 100644 --- a/crates/cranelift/src/compiler.rs +++ b/crates/cranelift/src/compiler.rs @@ -194,6 +194,10 @@ impl wasmtime_environ::Compiler for Compiler { None }; + let timing = cranelift_codegen::timing::take_current(); + log::debug!("{:?} translated in {:?}", func_index, timing.total()); + log::trace!("{:?} timing info\n{}", func_index, timing); + let length = u32::try_from(code_buf.len()).unwrap(); Ok(Box::new(CompiledFunction { body: code_buf,