11//! Global machine state as well as implementation of the interpreter engine
22//! `Machine` trait.
33
4- use std:: borrow:: Cow ;
54use std:: cell:: RefCell ;
65use std:: collections:: hash_map:: Entry ;
76use std:: fmt;
@@ -1086,40 +1085,33 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10861085 }
10871086 }
10881087
1089- fn adjust_allocation < ' b > (
1088+ fn init_alloc_extra (
10901089 ecx : & MiriInterpCx < ' tcx > ,
10911090 id : AllocId ,
1092- alloc : Cow < ' b , Allocation > ,
1093- kind : Option < MemoryKind > ,
1094- ) -> InterpResult < ' tcx , Cow < ' b , Allocation < Self :: Provenance , Self :: AllocExtra , Self :: Bytes > > >
1095- {
1096- let kind = kind. expect ( "we set our STATIC_KIND so this cannot be None" ) ;
1091+ kind : MemoryKind ,
1092+ size : Size ,
1093+ align : Align ,
1094+ ) -> InterpResult < ' tcx , Self :: AllocExtra > {
10971095 if ecx. machine . tracked_alloc_ids . contains ( & id) {
1098- ecx. emit_diagnostic ( NonHaltingDiagnostic :: CreatedAlloc (
1099- id,
1100- alloc. size ( ) ,
1101- alloc. align ,
1102- kind,
1103- ) ) ;
1096+ ecx. emit_diagnostic ( NonHaltingDiagnostic :: CreatedAlloc ( id, size, align, kind) ) ;
11041097 }
11051098
1106- let alloc = alloc. into_owned ( ) ;
11071099 let borrow_tracker = ecx
11081100 . machine
11091101 . borrow_tracker
11101102 . as_ref ( )
1111- . map ( |bt| bt. borrow_mut ( ) . new_allocation ( id, alloc . size ( ) , kind, & ecx. machine ) ) ;
1103+ . map ( |bt| bt. borrow_mut ( ) . new_allocation ( id, size, kind, & ecx. machine ) ) ;
11121104
1113- let race_alloc = ecx. machine . data_race . as_ref ( ) . map ( |data_race| {
1105+ let data_race = ecx. machine . data_race . as_ref ( ) . map ( |data_race| {
11141106 data_race:: AllocState :: new_allocation (
11151107 data_race,
11161108 & ecx. machine . threads ,
1117- alloc . size ( ) ,
1109+ size,
11181110 kind,
11191111 ecx. machine . current_span ( ) ,
11201112 )
11211113 } ) ;
1122- let buffer_alloc = ecx. machine . weak_memory . then ( weak_memory:: AllocState :: new_allocation) ;
1114+ let weak_memory = ecx. machine . weak_memory . then ( weak_memory:: AllocState :: new_allocation) ;
11231115
11241116 // If an allocation is leaked, we want to report a backtrace to indicate where it was
11251117 // allocated. We don't need to record a backtrace for allocations which are allowed to
@@ -1130,25 +1122,14 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
11301122 Some ( ecx. generate_stacktrace ( ) )
11311123 } ;
11321124
1133- let alloc: Allocation < Provenance , Self :: AllocExtra , Self :: Bytes > = alloc. adjust_from_tcx (
1134- & ecx. tcx ,
1135- AllocExtra {
1136- borrow_tracker,
1137- data_race : race_alloc,
1138- weak_memory : buffer_alloc,
1139- backtrace,
1140- } ,
1141- |ptr| ecx. global_root_pointer ( ptr) ,
1142- ) ?;
1143-
11441125 if matches ! ( kind, MemoryKind :: Machine ( kind) if kind. should_save_allocation_span( ) ) {
11451126 ecx. machine
11461127 . allocation_spans
11471128 . borrow_mut ( )
11481129 . insert ( id, ( ecx. machine . current_span ( ) , None ) ) ;
11491130 }
11501131
1151- Ok ( Cow :: Owned ( alloc ) )
1132+ Ok ( AllocExtra { borrow_tracker , data_race , weak_memory , backtrace } )
11521133 }
11531134
11541135 fn adjust_alloc_root_pointer (
@@ -1357,7 +1338,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
13571338 }
13581339
13591340 #[ inline( always) ]
1360- fn init_frame_extra (
1341+ fn init_frame (
13611342 ecx : & mut InterpCx < ' tcx , Self > ,
13621343 frame : Frame < ' tcx , Provenance > ,
13631344 ) -> InterpResult < ' tcx , Frame < ' tcx , Provenance , FrameExtra < ' tcx > > > {
0 commit comments