Skip to content

Commit 3c66318

Browse files
committed
Add UnwindAction::Unreachable
This also makes eval machine's `StackPopUnwind` redundant so that is replaced.
1 parent c251f34 commit 3c66318

File tree

6 files changed

+14
-20
lines changed

6 files changed

+14
-20
lines changed

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
951951
if this.machine.panic_on_unsupported {
952952
// message is slightly different here to make automated analysis easier
953953
let error_msg = format!("unsupported Miri functionality: {}", error_msg.as_ref());
954-
this.start_panic(error_msg.as_ref(), StackPopUnwind::Skip)?;
954+
this.start_panic(error_msg.as_ref(), mir::UnwindAction::Continue)?;
955955
Ok(())
956956
} else {
957957
throw_unsup_format!("{}", error_msg.as_ref());

src/machine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
834834
args: &[OpTy<'tcx, Provenance>],
835835
dest: &PlaceTy<'tcx, Provenance>,
836836
ret: Option<mir::BasicBlock>,
837-
unwind: StackPopUnwind,
837+
unwind: mir::UnwindAction,
838838
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
839839
ecx.find_mir_or_eval_fn(instance, abi, args, dest, ret, unwind)
840840
}
@@ -847,7 +847,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
847847
args: &[OpTy<'tcx, Provenance>],
848848
dest: &PlaceTy<'tcx, Provenance>,
849849
ret: Option<mir::BasicBlock>,
850-
_unwind: StackPopUnwind,
850+
_unwind: mir::UnwindAction,
851851
) -> InterpResult<'tcx> {
852852
ecx.call_dlsym(fn_val, abi, args, dest, ret)
853853
}
@@ -859,7 +859,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
859859
args: &[OpTy<'tcx, Provenance>],
860860
dest: &PlaceTy<'tcx, Provenance>,
861861
ret: Option<mir::BasicBlock>,
862-
unwind: StackPopUnwind,
862+
unwind: mir::UnwindAction,
863863
) -> InterpResult<'tcx> {
864864
ecx.call_intrinsic(instance, args, dest, ret, unwind)
865865
}

src/shims/foreign_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
258258
args: &[OpTy<'tcx, Provenance>],
259259
dest: &PlaceTy<'tcx, Provenance>,
260260
ret: Option<mir::BasicBlock>,
261-
unwind: StackPopUnwind,
261+
unwind: mir::UnwindAction,
262262
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
263263
let this = self.eval_context_mut();
264264
let link_name = this.item_link_name(def_id);

src/shims/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
2626
args: &[OpTy<'tcx, Provenance>],
2727
dest: &PlaceTy<'tcx, Provenance>,
2828
ret: Option<mir::BasicBlock>,
29-
_unwind: StackPopUnwind,
29+
_unwind: mir::UnwindAction,
3030
) -> InterpResult<'tcx> {
3131
let this = self.eval_context_mut();
3232

src/shims/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
3434
args: &[OpTy<'tcx, Provenance>],
3535
dest: &PlaceTy<'tcx, Provenance>,
3636
ret: Option<mir::BasicBlock>,
37-
unwind: StackPopUnwind,
37+
unwind: mir::UnwindAction,
3838
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
3939
let this = self.eval_context_mut();
4040
trace!("eval_fn_call: {:#?}, {:?}", instance, dest);
@@ -70,7 +70,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
7070
align_op: &OpTy<'tcx, Provenance>,
7171
dest: &PlaceTy<'tcx, Provenance>,
7272
ret: Option<mir::BasicBlock>,
73-
unwind: StackPopUnwind,
73+
unwind: mir::UnwindAction,
7474
) -> InterpResult<'tcx, bool> {
7575
let this = self.eval_context_mut();
7676
let ret = ret.unwrap();

src/shims/panic.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
5353
abi: Abi,
5454
link_name: Symbol,
5555
args: &[OpTy<'tcx, Provenance>],
56-
unwind: StackPopUnwind,
56+
unwind: mir::UnwindAction,
5757
) -> InterpResult<'tcx> {
5858
let this = self.eval_context_mut();
5959

@@ -106,7 +106,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
106106
&[data.into()],
107107
None,
108108
// Directly return to caller.
109-
StackPopCleanup::Goto { ret: Some(ret), unwind: StackPopUnwind::Skip },
109+
StackPopCleanup::Goto { ret: Some(ret), unwind: mir::UnwindAction::Continue },
110110
)?;
111111

112112
// We ourselves will return `0`, eventually (will be overwritten if we catch a panic).
@@ -157,7 +157,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
157157
&[catch_unwind.data.into(), payload.into()],
158158
None,
159159
// Directly return to caller of `try`.
160-
StackPopCleanup::Goto { ret: Some(catch_unwind.ret), unwind: StackPopUnwind::Skip },
160+
StackPopCleanup::Goto { ret: Some(catch_unwind.ret), unwind: mir::UnwindAction::Continue },
161161
)?;
162162

163163
// We pushed a new stack frame, the engine should not do any jumping now!
@@ -168,7 +168,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
168168
}
169169

170170
/// Start a panic in the interpreter with the given message as payload.
171-
fn start_panic(&mut self, msg: &str, unwind: StackPopUnwind) -> InterpResult<'tcx> {
171+
fn start_panic(&mut self, msg: &str, unwind: mir::UnwindAction) -> InterpResult<'tcx> {
172172
let this = self.eval_context_mut();
173173

174174
// First arg: message.
@@ -213,10 +213,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
213213
None,
214214
StackPopCleanup::Goto {
215215
ret: None,
216-
unwind: match unwind {
217-
Some(cleanup) => StackPopUnwind::Cleanup(cleanup),
218-
None => StackPopUnwind::Skip,
219-
},
216+
unwind,
220217
},
221218
)?;
222219
}
@@ -252,10 +249,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
252249
// Forward everything else to `panic` lang item.
253250
this.start_panic(
254251
msg.description(),
255-
match unwind {
256-
Some(cleanup) => StackPopUnwind::Cleanup(cleanup),
257-
None => StackPopUnwind::Skip,
258-
},
252+
unwind,
259253
)?;
260254
}
261255
}

0 commit comments

Comments
 (0)