@@ -1354,9 +1354,8 @@ impl Func {
13541354 let nparams = ty. params ( ) . len ( ) ;
13551355 val_vec. reserve ( nparams + ty. results ( ) . len ( ) ) ;
13561356
1357- let flat_params = ty. params ( ) . map ( |x| x. to_wasm_type ( ) . byte_size ( ) ) ;
1358-
1359- if !caller. store . 0 . replay_enabled ( ) {
1357+ let mut run_impl = |caller : & mut Caller < ' _ , T > , values_vec : & mut [ ValRaw ] | -> Result < ( ) > {
1358+ let flat_params = ty. params ( ) . map ( |x| x. to_wasm_type ( ) . byte_size ( ) ) ;
13601359 rr:: core_hooks:: record_validate_host_func_entry (
13611360 values_vec,
13621361 flat_params,
@@ -1382,13 +1381,26 @@ impl Func {
13821381
13831382 let flat_results = ty. results ( ) . map ( |x| x. to_wasm_type ( ) . byte_size ( ) ) ;
13841383 rr:: core_hooks:: record_host_func_return ( values_vec, flat_results, & mut caller. store . 0 ) ?;
1385- } else {
1384+ Ok ( ( ) )
1385+ } ;
1386+
1387+ let replay_impl = |caller : & mut Caller < ' _ , T > , values_vec : & mut [ ValRaw ] | -> Result < ( ) > {
1388+ let flat_params = ty. params ( ) . map ( |x| x. to_wasm_type ( ) . byte_size ( ) ) ;
13861389 rr:: core_hooks:: replay_validate_host_func_entry (
13871390 values_vec,
13881391 flat_params,
13891392 & mut caller. store . 0 ,
13901393 ) ?;
1391- rr:: core_hooks:: replay_host_func_return ( values_vec, & mut caller) ?;
1394+ rr:: core_hooks:: replay_host_func_return ( values_vec, caller) ?;
1395+ Ok ( ( ) )
1396+ } ;
1397+
1398+ if caller. store . 0 . replay_enabled ( ) {
1399+ // In replay mode, we skip execution of host functions and
1400+ // just replay the return value effects observed in the trace
1401+ replay_impl ( & mut caller, values_vec) ?;
1402+ } else {
1403+ run_impl ( & mut caller, values_vec) ?;
13921404 }
13931405
13941406 // Restore our `val_vec` back into the store so it's usable for the next
0 commit comments