@@ -222,8 +222,6 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
222
222
return err ! ( MachineError ( "the evaluated program panicked" . to_string( ) ) ) ;
223
223
}
224
224
225
- //this.machine.unwinding = true;
226
-
227
225
// This part is tricky - we need to call BoxMeUp::box_me_up
228
226
// on the vtable.
229
227
//
@@ -287,12 +285,6 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
287
285
let temp_ptr = this. allocate ( dyn_ptr_layout, MiriMemoryKind :: UnwindHelper . into ( ) ) ;
288
286
this. machine . box_me_up_tmp_ptr = Some ( temp_ptr. clone ( ) ) ;
289
287
290
-
291
- // Keep track of our current frame
292
- // This allows us to step throgh the exection of 'box_me_up',
293
- // exiting when we get back to this frame
294
- let cur_frame = this. cur_frame ( ) ;
295
-
296
288
this. push_stack_frame (
297
289
box_me_up_fn,
298
290
box_me_up_mir. span ,
@@ -310,52 +302,6 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
310
302
let arg_0 = this. eval_place ( & mir:: Place :: Base ( mir:: PlaceBase :: Local ( args. next ( ) . unwrap ( ) ) ) ) ?;
311
303
this. write_scalar ( data_ptr, arg_0) ?;
312
304
313
- /*// Step through execution of 'box_me_up'
314
- // We know that we're finished when our stack depth
315
- // returns to where it was before.
316
- //
317
- // Note that everything will get completely screwed up
318
- // if 'box_me_up' panics. This is fine, since this
319
- // function should never panic, as it's part of the core
320
- // panic handling infrastructure
321
- //
322
- // Normally, we would just let Miri drive
323
- // the execution of this stack frame.
324
- // However, we need to access its return value
325
- // in order to properly unwind.
326
- //
327
- // When we 'return' from '__rustc_start_panic',
328
- // we need to be executing the panic catch handler.
329
- // Therefore, we take care all all of the unwinding logic
330
- // here, instead of letting the Miri main loop do it
331
- while this.cur_frame() != cur_frame {
332
- this.step()?;
333
- }
334
-
335
- // 'box_me_up' has finished. 'temp_ptr' now holds
336
- // a '*mut (dyn Any + Send)'
337
- // We want to split this into its consituient parts -
338
- // the data and vtable pointers - and store them back
339
- // into the panic handler frame
340
- let real_ret = this.read_immediate(temp_ptr.into())?;
341
- let real_ret_data = real_ret.to_scalar_ptr()?;
342
- let real_ret_vtable = real_ret.to_meta()?.expect("Expected fat pointer");
343
-
344
- // We're in panic unwind mode. We pop off stack
345
- // frames until one of two things happens: we reach
346
- // a frame with 'catch_panic' set, or we pop of all frames
347
- //
348
- // If we pop off all frames without encountering 'catch_panic',
349
- // we exit.
350
- //
351
- // If we encounter 'catch_panic', we continue execution at that
352
- // frame, filling in data from the panic
353
- //
354
- unwind_stack(this, real_ret_data, real_ret_vtable)?;
355
-
356
- this.memory_mut().deallocate(temp_ptr.to_ptr()?, None, MiriMemoryKind::UnwindHelper.into())?;
357
- this.dump_place(*dest.expect("dest is None!"));*/
358
-
359
305
return Ok ( None )
360
306
361
307
}
@@ -1165,85 +1111,3 @@ fn gen_random<'a, 'mir, 'tcx>(
1165
1111
this. memory_mut ( ) . get_mut ( ptr. alloc_id ) ?
1166
1112
. write_bytes ( tcx, ptr, & data)
1167
1113
}
1168
-
1169
- /// A helper method to unwind the stack.
1170
- ///
1171
- /// We execute the 'unwind' blocks associated with frame
1172
- /// terminators as we go along (these blocks are responsible
1173
- /// for dropping frame locals in the event of a panic)
1174
- ///
1175
- /// When we find our target frame, we write the panic payload
1176
- /// directly into its locals, and jump to it.
1177
- /// After that, panic handling is done - from the perspective
1178
- /// of the caller of '__rust_maybe_catch_panic', the function
1179
- /// has 'returned' normally, after which point Miri excecution
1180
- /// can proceeed normally.
1181
- fn unwind_stack < ' a , ' mir , ' tcx > (
1182
- this : & mut MiriEvalContext < ' a , ' mir , ' tcx > ,
1183
- payload_data_ptr : Scalar < Tag > ,
1184
- payload_vtable_ptr : Scalar < Tag >
1185
- ) -> EvalResult < ' tcx > {
1186
- while !this. stack ( ) . is_empty ( ) {
1187
- // When '__rust_maybe_catch_panic' is called, it marks is frame
1188
- // with 'catch_panic'. When we find this marker, we've found
1189
- // our target frame to jump to.
1190
- if let Some ( unwind_data) = this. frame_mut ( ) . extra . catch_panic . take ( ) {
1191
-
1192
- trace ! ( "unwinding: found target frame: {:?}" , this. frame( ) . span) ;
1193
-
1194
- let data_ptr = unwind_data. data_ptr . clone ( ) ;
1195
- let vtable_ptr = unwind_data. vtable_ptr . clone ( ) ;
1196
- let dest = unwind_data. dest . clone ( ) ;
1197
- let ret = unwind_data. ret . clone ( ) ;
1198
- drop ( unwind_data) ;
1199
-
1200
-
1201
- // Here, we write directly into the frame of the function
1202
- // that called '__rust_maybe_catch_panic'.
1203
- // (NOT the function that called '__rust_start_panic')
1204
-
1205
- this. write_scalar ( payload_data_ptr, data_ptr. into ( ) ) ?;
1206
- this. write_scalar ( payload_vtable_ptr, vtable_ptr. into ( ) ) ?;
1207
-
1208
- // We 'return' the value 1 from __rust_maybe_catch_panic,
1209
- // since there was a panic
1210
- this. write_scalar ( Scalar :: from_int ( 1 , dest. layout . size ) , dest) ?;
1211
-
1212
- // We're done - continue execution in the frame of the function
1213
- // that called '__rust_maybe_catch_panic,'
1214
- this. goto_block ( Some ( ret) ) ?;
1215
-
1216
- return Ok ( ( ) )
1217
- } else {
1218
- // This frame is above our target frame on the call stack.
1219
- // We pop it off the stack, running its 'unwind' block if applicable
1220
- trace ! ( "unwinding: popping frame: {:?}" , this. frame( ) . span) ;
1221
- let block = & this. frame ( ) . mir . basic_blocks ( ) [ this. frame ( ) . block ] ;
1222
-
1223
- // All frames in the call stack should be executing their terminators.,
1224
- // as that's the only way for a basic block to perform a function call
1225
- if let Some ( stmt) = block. statements . get ( this. frame ( ) . stmt ) {
1226
- panic ! ( "Unexpcted statement '{:?}' for frame {:?}" , stmt, this. frame( ) . span) ;
1227
- }
1228
-
1229
- // We're only interested in terminator types which allow for a cleanuup
1230
- // block (e.g. Call), and that also actually provide one
1231
- if let Some ( Some ( unwind) ) = block. terminator ( ) . unwind ( ) {
1232
- this. goto_block ( Some ( * unwind) ) ?;
1233
-
1234
- // Run the 'unwind' block until we encounter
1235
- // a 'Resume', which indicates that the block
1236
- // is done.
1237
- assert_eq ! ( this. run( ) ?, StepOutcome :: Resume ) ;
1238
- }
1239
-
1240
- // Pop this frame, and continue on to the next one
1241
- //this.pop_stack_frame()?;
1242
- //this.pop_stack_frame_unwind()?;
1243
- }
1244
- }
1245
-
1246
- // We should never get here:
1247
- // The 'start_fn' lang item should always install a panic handler
1248
- return err ! ( Unreachable ) ;
1249
- }
0 commit comments