@@ -15,11 +15,10 @@ use rustc_span::Symbol;
1515 target_env = "gnu" ,
1616 any( target_arch = "x86" , target_arch = "x86_64" , target_arch = "aarch64" )
1717 ) ) ,
18- path = "trace_stub .rs"
18+ path = "trace/stub .rs"
1919) ]
2020pub mod trace;
2121
22- use self :: trace:: Supervisor ;
2322use crate :: * ;
2423
2524impl < ' tcx > EvalContextExtPriv < ' tcx > for crate :: MiriInterpCx < ' tcx > { }
@@ -35,14 +34,13 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
3534 let this = self . eval_context_mut ( ) ;
3635 #[ cfg( target_os = "linux" ) ]
3736 let alloc = this. machine . allocator . as_ref ( ) . unwrap ( ) ;
38-
39- // SAFETY: We don't touch the machine memory past this point.
40- #[ cfg( target_os = "linux" ) ]
41- let guard = unsafe { Supervisor :: start_ffi ( alloc) } ;
37+ #[ cfg( not( target_os = "linux" ) ) ]
38+ // Placeholder value.
39+ let alloc = ( ) ;
4240
4341 // Call the function (`ptr`) with arguments `libffi_args`, and obtain the return value
4442 // as the specified primitive integer type
45- let res = ' res : {
43+ let ffi_fn = || {
4644 let scalar = match dest. layout . ty . kind ( ) {
4745 // ints
4846 ty:: Int ( IntTy :: I8 ) => {
@@ -93,15 +91,15 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
9391 // have the output_type `Tuple([])`.
9492 ty:: Tuple ( t_list) if ( * t_list) . deref ( ) . is_empty ( ) => {
9593 unsafe { ffi:: call :: < ( ) > ( ptr, libffi_args. as_slice ( ) ) } ;
96- break ' res interp_ok ( ImmTy :: uninit ( dest. layout ) ) ;
94+ return interp_ok ( ImmTy :: uninit ( dest. layout ) ) ;
9795 }
9896 ty:: RawPtr ( ..) => {
9997 let x = unsafe { ffi:: call :: < * const ( ) > ( ptr, libffi_args. as_slice ( ) ) } ;
10098 let ptr = Pointer :: new ( Provenance :: Wildcard , Size :: from_bytes ( x. addr ( ) ) ) ;
10199 Scalar :: from_pointer ( ptr, this)
102100 }
103101 _ =>
104- break ' res Err ( err_unsup_format ! (
102+ return Err ( err_unsup_format ! (
105103 "unsupported return type for native call: {:?}" ,
106104 link_name
107105 ) )
@@ -110,11 +108,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
110108 interp_ok ( ImmTy :: from_scalar ( scalar, dest. layout ) )
111109 } ;
112110
113- // SAFETY: We got the guard and stack pointer from start_ffi, and
114- // the allocator is the same
115- let events = unsafe { Supervisor :: end_ffi ( guard) } ;
116-
117- interp_ok ( ( res?, events) )
111+ trace:: do_ffi ( alloc, ffi_fn)
118112 }
119113
120114 /// Get the pointer to the function of the specified name in the shared object file,
0 commit comments