Fix unwinding logic
This commit is contained in:
parent
8df4248c71
commit
4f25c91a05
3 changed files with 9 additions and 12 deletions
|
@ -584,7 +584,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
let frame = self.stack.pop().expect(
|
let frame = self.stack.pop().expect(
|
||||||
"tried to pop a stack frame, but there were none",
|
"tried to pop a stack frame, but there were none",
|
||||||
);
|
);
|
||||||
let stack_pop_info = M::stack_pop(self, frame.extra)?;
|
let stack_pop_info = M::stack_pop(self, frame.extra, unwinding)?;
|
||||||
match (unwinding, stack_pop_info) {
|
match (unwinding, stack_pop_info) {
|
||||||
(true, StackPopInfo::StartUnwinding) =>
|
(true, StackPopInfo::StartUnwinding) =>
|
||||||
bug!("Attempted to start unwinding while already unwinding!"),
|
bug!("Attempted to start unwinding while already unwinding!"),
|
||||||
|
@ -616,7 +616,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
// Now where do we jump next?
|
// Now where do we jump next?
|
||||||
|
|
||||||
// Determine if we leave this function normally or via unwinding.
|
// Determine if we leave this function normally or via unwinding.
|
||||||
let cur_unwinding = unwinding && stack_pop_info != StackPopInfo::StopUnwinding;
|
let cur_unwinding = match stack_pop_info {
|
||||||
|
StackPopInfo::StartUnwinding => true,
|
||||||
|
StackPopInfo::StopUnwinding => false,
|
||||||
|
_ => unwinding
|
||||||
|
};
|
||||||
|
|
||||||
trace!("StackPopCleanup: {:?} StackPopInfo: {:?} cur_unwinding = {:?}",
|
trace!("StackPopCleanup: {:?} StackPopInfo: {:?} cur_unwinding = {:?}",
|
||||||
frame.return_to_block, stack_pop_info, cur_unwinding);
|
frame.return_to_block, stack_pop_info, cur_unwinding);
|
||||||
if cur_unwinding {
|
if cur_unwinding {
|
||||||
|
|
|
@ -270,6 +270,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
|
||||||
fn stack_pop(
|
fn stack_pop(
|
||||||
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
|
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
|
||||||
_extra: Self::FrameExtra,
|
_extra: Self::FrameExtra,
|
||||||
|
_unwinding: bool
|
||||||
) -> InterpResult<'tcx, StackPopInfo> {
|
) -> InterpResult<'tcx, StackPopInfo> {
|
||||||
// By default, we do not support unwinding from panics
|
// By default, we do not support unwinding from panics
|
||||||
Ok(StackPopInfo::Normal)
|
Ok(StackPopInfo::Normal)
|
||||||
|
|
|
@ -30,7 +30,7 @@ use crate::interpret::{
|
||||||
self, InterpCx, ScalarMaybeUndef, Immediate, OpTy,
|
self, InterpCx, ScalarMaybeUndef, Immediate, OpTy,
|
||||||
StackPopCleanup, LocalValue, LocalState, AllocId, Frame,
|
StackPopCleanup, LocalValue, LocalState, AllocId, Frame,
|
||||||
Allocation, MemoryKind, ImmTy, Pointer, Memory, PlaceTy,
|
Allocation, MemoryKind, ImmTy, Pointer, Memory, PlaceTy,
|
||||||
StackPopInfo, Operand as InterpOperand,
|
Operand as InterpOperand,
|
||||||
};
|
};
|
||||||
use crate::const_eval::error_to_const_error;
|
use crate::const_eval::error_to_const_error;
|
||||||
use crate::transform::{MirPass, MirSource};
|
use crate::transform::{MirPass, MirSource};
|
||||||
|
@ -252,15 +252,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine {
|
||||||
fn stack_push(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
|
fn stack_push(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called immediately before a stack frame gets popped.
|
|
||||||
#[inline(always)]
|
|
||||||
fn stack_pop(
|
|
||||||
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
|
|
||||||
_extra: ()
|
|
||||||
) -> InterpResult<'tcx, StackPopInfo> {
|
|
||||||
Ok(StackPopInfo::Normal)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Const<'tcx> = OpTy<'tcx>;
|
type Const<'tcx> = OpTy<'tcx>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue