1
1
//! Global machine state as well as implementation of the interpreter engine
2
2
//! `Machine` trait.
3
3
4
- use std:: borrow:: Cow ;
5
4
use std:: cell:: RefCell ;
6
5
use std:: collections:: hash_map:: Entry ;
7
6
use std:: fmt;
@@ -1086,40 +1085,33 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
1086
1085
}
1087
1086
}
1088
1087
1089
- fn adjust_allocation < ' b > (
1088
+ fn init_alloc_extra (
1090
1089
ecx : & MiriInterpCx < ' tcx > ,
1091
1090
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 > {
1097
1095
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) ) ;
1104
1097
}
1105
1098
1106
- let alloc = alloc. into_owned ( ) ;
1107
1099
let borrow_tracker = ecx
1108
1100
. machine
1109
1101
. borrow_tracker
1110
1102
. 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 ) ) ;
1112
1104
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| {
1114
1106
data_race:: AllocState :: new_allocation (
1115
1107
data_race,
1116
1108
& ecx. machine . threads ,
1117
- alloc . size ( ) ,
1109
+ size,
1118
1110
kind,
1119
1111
ecx. machine . current_span ( ) ,
1120
1112
)
1121
1113
} ) ;
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) ;
1123
1115
1124
1116
// If an allocation is leaked, we want to report a backtrace to indicate where it was
1125
1117
// 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> {
1130
1122
Some ( ecx. generate_stacktrace ( ) )
1131
1123
} ;
1132
1124
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
-
1144
1125
if matches ! ( kind, MemoryKind :: Machine ( kind) if kind. should_save_allocation_span( ) ) {
1145
1126
ecx. machine
1146
1127
. allocation_spans
1147
1128
. borrow_mut ( )
1148
1129
. insert ( id, ( ecx. machine . current_span ( ) , None ) ) ;
1149
1130
}
1150
1131
1151
- Ok ( Cow :: Owned ( alloc ) )
1132
+ Ok ( AllocExtra { borrow_tracker , data_race , weak_memory , backtrace } )
1152
1133
}
1153
1134
1154
1135
fn adjust_alloc_root_pointer (
@@ -1357,7 +1338,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
1357
1338
}
1358
1339
1359
1340
#[ inline( always) ]
1360
- fn init_frame_extra (
1341
+ fn init_frame (
1361
1342
ecx : & mut InterpCx < ' tcx , Self > ,
1362
1343
frame : Frame < ' tcx , Provenance > ,
1363
1344
) -> InterpResult < ' tcx , Frame < ' tcx , Provenance , FrameExtra < ' tcx > > > {
0 commit comments