Fix VTune build (#3219)
* Fix vtune build * Add vtune build to automation * don't allocate a different module id for each function
This commit is contained in:
1
.github/workflows/main.yml
vendored
1
.github/workflows/main.yml
vendored
@@ -132,6 +132,7 @@ jobs:
|
|||||||
- run: cargo check -p wasmtime --no-default-features --features wat
|
- run: cargo check -p wasmtime --no-default-features --features wat
|
||||||
- run: cargo check -p wasmtime --no-default-features --features lightbeam
|
- run: cargo check -p wasmtime --no-default-features --features lightbeam
|
||||||
- run: cargo check -p wasmtime --no-default-features --features jitdump
|
- run: cargo check -p wasmtime --no-default-features --features jitdump
|
||||||
|
- run: cargo check -p wasmtime --no-default-features --features vtune
|
||||||
- run: cargo check -p wasmtime --no-default-features --features cache
|
- run: cargo check -p wasmtime --no-default-features --features cache
|
||||||
- run: cargo check -p wasmtime --no-default-features --features async
|
- run: cargo check -p wasmtime --no-default-features --features async
|
||||||
- run: cargo check -p wasmtime --no-default-features --features uffd
|
- run: cargo check -p wasmtime --no-default-features --features uffd
|
||||||
|
|||||||
@@ -336,13 +336,13 @@ impl State {
|
|||||||
let rh = RecordHeader {
|
let rh = RecordHeader {
|
||||||
id: RecordId::JitCodeLoad as u32,
|
id: RecordId::JitCodeLoad as u32,
|
||||||
record_size: size_limit as u32 + name_len as u32 + len as u32,
|
record_size: size_limit as u32 + name_len as u32 + len as u32,
|
||||||
timestamp: timestamp,
|
timestamp,
|
||||||
};
|
};
|
||||||
|
|
||||||
let clr = CodeLoadRecord {
|
let clr = CodeLoadRecord {
|
||||||
header: rh,
|
header: rh,
|
||||||
pid: pid,
|
pid,
|
||||||
tid: tid,
|
tid,
|
||||||
virtual_address: addr as u64,
|
virtual_address: addr as u64,
|
||||||
address: addr as u64,
|
address: addr as u64,
|
||||||
size: len as u64,
|
size: len as u64,
|
||||||
@@ -435,8 +435,8 @@ impl State {
|
|||||||
|
|
||||||
let mut clr = CodeLoadRecord {
|
let mut clr = CodeLoadRecord {
|
||||||
header: record_header,
|
header: record_header,
|
||||||
pid: pid,
|
pid,
|
||||||
tid: tid,
|
tid,
|
||||||
virtual_address: 0,
|
virtual_address: 0,
|
||||||
address: 0,
|
address: 0,
|
||||||
size: 0,
|
size: 0,
|
||||||
|
|||||||
@@ -10,13 +10,11 @@
|
|||||||
use crate::ProfilingAgent;
|
use crate::ProfilingAgent;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use core::ptr;
|
use core::ptr;
|
||||||
use cranelift_entity::PrimaryMap;
|
|
||||||
use cranelift_wasm_types::DefinedFuncIndex;
|
|
||||||
use ittapi_rs::*;
|
use ittapi_rs::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::sync::Mutex;
|
use std::sync::{atomic, Mutex};
|
||||||
use wasmtime_environ::Module;
|
use wasmtime_environ::{DefinedFuncIndex, Module, PrimaryMap};
|
||||||
use wasmtime_runtime::VMFunctionBody;
|
use wasmtime_runtime::VMFunctionBody;
|
||||||
|
|
||||||
/// Interface for driving the ittapi for VTune support
|
/// Interface for driving the ittapi for VTune support
|
||||||
@@ -76,7 +74,7 @@ impl State {
|
|||||||
len: usize,
|
len: usize,
|
||||||
) -> () {
|
) -> () {
|
||||||
let mut jmethod = _iJIT_Method_Load {
|
let mut jmethod = _iJIT_Method_Load {
|
||||||
method_id: method_id,
|
method_id,
|
||||||
method_name: CString::new(method_name)
|
method_name: CString::new(method_name)
|
||||||
.expect("CString::new failed")
|
.expect("CString::new failed")
|
||||||
.into_raw(),
|
.into_raw(),
|
||||||
@@ -132,13 +130,17 @@ impl State {
|
|||||||
functions: &PrimaryMap<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
functions: &PrimaryMap<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
||||||
_dbg_image: Option<&[u8]>,
|
_dbg_image: Option<&[u8]>,
|
||||||
) -> () {
|
) -> () {
|
||||||
|
// Global counter for module ids.
|
||||||
|
static MODULE_ID: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
|
||||||
|
let global_module_id = MODULE_ID.fetch_add(1, atomic::Ordering::SeqCst);
|
||||||
|
|
||||||
for (idx, func) in functions.iter() {
|
for (idx, func) in functions.iter() {
|
||||||
let (addr, len) = unsafe { ((**func).as_ptr() as *const u8, (**func).len()) };
|
let (addr, len) = unsafe { ((**func).as_ptr() as *const u8, (**func).len()) };
|
||||||
let default_filename = "wasm_file";
|
let default_filename = "wasm_file";
|
||||||
let default_module_name = String::from("wasm_module");
|
let default_module_name = String::from("wasm_module");
|
||||||
let module_name = module.name.as_ref().unwrap_or(&default_module_name);
|
let module_name = module.name.as_ref().unwrap_or(&default_module_name);
|
||||||
let method_name = super::debug_name(module, idx);
|
let method_name = super::debug_name(module, idx);
|
||||||
let method_id = self.get_method_id(module.id, idx);
|
let method_id = self.get_method_id(global_module_id, idx);
|
||||||
println!(
|
println!(
|
||||||
"Event Load: ({}) {:?}::{:?} Addr:{:?}\n",
|
"Event Load: ({}) {:?}::{:?} Addr:{:?}\n",
|
||||||
method_id, module_name, method_name, addr
|
method_id, module_name, method_name, addr
|
||||||
|
|||||||
Reference in New Issue
Block a user