@@ -20,8 +20,7 @@ mod ffi;
2020) ]
2121pub mod trace;
2222
23- use self :: ffi:: CArg ;
24- use crate :: shims:: native_lib:: ffi:: CPrimitive ;
23+ use self :: ffi:: { CArg , CPrimitive , FfiArg } ;
2524use crate :: * ;
2625
2726/// The final results of an FFI trace, containing every relevant event detected
@@ -83,7 +82,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
8382 link_name : Symbol ,
8483 dest : & MPlaceTy < ' tcx > ,
8584 ptr : CodePtr ,
86- libffi_args : Vec < ffi :: FfiArg < ' a > > ,
85+ libffi_args : Vec < FfiArg < ' a > > ,
8786 ) -> InterpResult < ' tcx , ( crate :: ImmTy < ' tcx > , Option < MemEvents > ) > {
8887 let this = self . eval_context_mut ( ) ;
8988 #[ cfg( target_os = "linux" ) ]
@@ -280,7 +279,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
280279 interp_ok ( ( ) )
281280 }
282281
283- /// Extract the value from the result of reading a scalar or mplace from the machine,
282+ /// Extract the value from the result of reading an operand from the machine
284283 /// and convert it to a `CArg`.
285284 fn op_to_carg ( & self , v : & OpTy < ' tcx > , tracing : bool ) -> InterpResult < ' tcx , CArg > {
286285 let this = self . eval_context_ref ( ) ;
@@ -316,7 +315,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
316315 } ;
317316
318317 // This relies on the `expose_provenance` in the `visit_reachable_allocs` callback
319- // below.
318+ // below to expose the actual interpreter-level allocation .
320319 CPrimitive :: RawPtr ( std:: ptr:: with_exposed_provenance_mut ( ptr. addr ( ) . bytes_usize ( ) ) )
321320 . into ( )
322321 }
@@ -332,21 +331,21 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
332331 // exposed recursively.
333332 let ptr = mplace. ptr ( ) ;
334333 // Make sure the provenance of this allocation is exposed;
335- // there must be one for this arg to be valid at all.
334+ // there must be one for this mplace to be valid at all.
335+ // The interpreter-level allocation itself is exposed in
336+ // visit_reachable_allocs.
336337 this. expose_provenance ( ptr. provenance . unwrap ( ) ) ?;
337338 // Then get the actual bytes.
338339 let id = this
339340 . alloc_id_from_addr (
340341 ptr. addr ( ) . bytes ( ) ,
341342 mplace. layout . size . bytes_usize ( ) . try_into ( ) . unwrap ( ) ,
342- /* only_exposed_allocations */ false ,
343+ /* only_exposed_allocations */ true ,
343344 )
344345 . unwrap ( ) ;
345346 let ptr_raw = this. get_alloc_bytes_unchecked_raw ( id) ?;
346- // Expose the allocation here so that the FFI code can access it.
347- std:: hint:: black_box ( ptr_raw. expose_provenance ( ) ) ;
348- // SAFETY: We know for sure that at ptr_raw there are initialised
349- // bytes as indicated by the layout size.
347+ // SAFETY: We know for sure that at ptr_raw the next layout.size bytes
348+ // are part of this allocation and initialised.
350349 unsafe {
351350 std:: slice:: from_raw_parts ( ptr_raw, mplace. layout . size . bytes_usize ( ) )
352351 . to_vec ( )
0 commit comments