diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index 7a76a46ac..0b7a3c037 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -222,13 +222,6 @@ pub fn read_module< let fcg = mcg .next_function(Arc::clone(&info)) .map_err(|x| LoadError::Codegen(format!("{:?}", x)))?; - middlewares - .run( - Some(fcg), - Event::Internal(InternalEvent::FunctionBegin(id as u32)), - &info.read().unwrap(), - ) - .map_err(|x| LoadError::Codegen(x))?; let info_read = info.read().unwrap(); let sig = info_read @@ -270,6 +263,13 @@ pub fn read_module< body_begun = true; fcg.begin_body(&info.read().unwrap()) .map_err(|x| LoadError::Codegen(format!("{:?}", x)))?; + middlewares + .run( + Some(fcg), + Event::Internal(InternalEvent::FunctionBegin(id as u32)), + &info.read().unwrap(), + ) + .map_err(|x| LoadError::Codegen(x))?; } middlewares .run(Some(fcg), Event::Wasm(op), &info.read().unwrap())