Skip to content

Commit f46b2df

Browse files
committed
Review feedback: error on registering profiling metadata when debug is enabled.
1 parent 1c70094 commit f46b2df

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

crates/wasmtime/src/runtime/instantiate.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! `CompiledModule` to allow compiling and instantiating to be done as separate
44
//! steps.
55
6-
use crate::code::EngineCode;
6+
use crate::{code::EngineCode, Engine};
77
use crate::prelude::*;
88
use crate::profiling_agent::ProfilingAgent;
99
use crate::runtime::vm::CompiledModuleId;
@@ -47,6 +47,7 @@ impl CompiledModule {
4747
/// The `profiler` argument here is used to inform JIT profiling runtimes
4848
/// about new code that is loaded.
4949
pub fn from_artifacts(
50+
engine: &Engine,
5051
engine_code: Arc<EngineCode>,
5152
info: CompiledModuleInfo,
5253
index: Arc<CompiledFunctionsTable>,
@@ -60,16 +61,20 @@ impl CompiledModule {
6061
index,
6162
func_names: info.func_names,
6263
};
63-
ret.register_profiling(profiler)?;
64+
ret.register_profiling(engine, profiler)?;
6465

6566
Ok(ret)
6667
}
6768

68-
fn register_profiling(&mut self, profiler: &dyn ProfilingAgent) -> Result<()> {
69+
fn register_profiling(&mut self, engine: &Engine, profiler: &dyn ProfilingAgent) -> Result<()> {
6970
// TODO-Bug?: "code_memory" is not exclusive for this module in the case of components,
7071
// so we may be registering the same code range multiple times here.
71-
//
72-
// TODO: register for each StoreCode.
72+
73+
if engine.tunables().debug_guest {
74+
// TODO(#12105): support this case.
75+
anyhow::bail!("Cannot register profiling when guest debugging is enabled");
76+
}
77+
7378
profiler.register_module(self.engine_code.image(), &|addr| {
7479
let idx = self.func_by_text_offset(addr)?;
7580
let idx = self.module.func_index(idx);

crates/wasmtime/src/runtime/module.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ impl Module {
532532
index: Arc<CompiledFunctionsTable>,
533533
serializable: bool,
534534
) -> Result<Self> {
535-
let module = CompiledModule::from_artifacts(code.clone(), info, index, engine.profiler())?;
535+
let module =
536+
CompiledModule::from_artifacts(engine, code.clone(), info, index, engine.profiler())?;
536537

537538
// Validate the module can be used with the current instance allocator.
538539
let offsets = VMOffsets::new(HostPtr, module.module());

0 commit comments

Comments
 (0)