@@ -10,9 +10,11 @@ use std::mem::{self, MaybeUninit};
1010use std:: panic:: { self , AssertUnwindSafe } ;
1111use std:: ptr;
1212use std:: str;
13+ #[ cfg( feature = "gc" ) ]
14+ use wasmtime:: RootScope ;
1315use wasmtime:: {
14- AsContext , AsContextMut , Error , Extern , Func , Result , RootScope , StoreContext , StoreContextMut ,
15- Trap , Val , ValRaw ,
16+ AsContext , AsContextMut , Error , Extern , Func , Result , StoreContext , StoreContextMut , Trap , Val ,
17+ ValRaw ,
1618} ;
1719
1820#[ derive( Clone ) ]
@@ -351,13 +353,15 @@ pub unsafe extern "C" fn wasmtime_func_call(
351353 nresults : usize ,
352354 trap_ret : & mut * mut wasm_trap_t ,
353355) -> Option < Box < wasmtime_error_t > > {
354- let mut scope = RootScope :: new ( & mut store) ;
355- let mut params = mem:: take ( & mut scope. as_context_mut ( ) . data_mut ( ) . wasm_val_storage ) ;
356+ #[ cfg( feature = "gc" ) ]
357+ let mut store = RootScope :: new ( & mut store) ;
358+ let mut params = mem:: take ( & mut store. as_context_mut ( ) . data_mut ( ) . wasm_val_storage ) ;
359+
356360 let ( wt_params, wt_results) = translate_args (
357361 & mut params,
358362 crate :: slice_from_raw_parts ( args, nargs)
359363 . iter ( )
360- . map ( |i| i. to_val ( & mut scope ) ) ,
364+ . map ( |i| i. to_val ( & mut store ) ) ,
361365 nresults,
362366 ) ;
363367
@@ -366,16 +370,16 @@ pub unsafe extern "C" fn wasmtime_func_call(
366370 // can. As a result we catch panics here and transform them to traps to
367371 // allow the caller to have any insulation possible against Rust panics.
368372 let result = panic:: catch_unwind ( AssertUnwindSafe ( || {
369- func. call ( & mut scope , wt_params, wt_results)
373+ func. call ( & mut store , wt_params, wt_results)
370374 } ) ) ;
371375 match result {
372376 Ok ( Ok ( ( ) ) ) => {
373377 let results = crate :: slice_from_raw_parts_mut ( results, nresults) ;
374378 for ( slot, val) in results. iter_mut ( ) . zip ( wt_results. iter ( ) ) {
375- crate :: initialize ( slot, wasmtime_val_t:: from_val ( & mut scope , * val) ) ;
379+ crate :: initialize ( slot, wasmtime_val_t:: from_val ( & mut store , * val) ) ;
376380 }
377381 params. truncate ( 0 ) ;
378- scope . as_context_mut ( ) . data_mut ( ) . wasm_val_storage = params;
382+ store . as_context_mut ( ) . data_mut ( ) . wasm_val_storage = params;
379383 None
380384 }
381385 Ok ( Err ( trap) ) => store_err ( trap, trap_ret) ,
0 commit comments