Fix unwinding logic
This commit is contained in:
parent
8df4248c71
commit
4f25c91a05
@ -584,7 +584,7 @@ pub(super) fn pop_stack_frame(
|
||||
let frame = self.stack.pop().expect(
|
||||
"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) {
|
||||
(true, StackPopInfo::StartUnwinding) =>
|
||||
bug!("Attempted to start unwinding while already unwinding!"),
|
||||
@ -616,7 +616,12 @@ pub(super) fn pop_stack_frame(
|
||||
// Now where do we jump next?
|
||||
|
||||
// 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 = {:?}",
|
||||
frame.return_to_block, stack_pop_info, cur_unwinding);
|
||||
if cur_unwinding {
|
||||
|
@ -270,6 +270,7 @@ fn retag(
|
||||
fn stack_pop(
|
||||
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
|
||||
_extra: Self::FrameExtra,
|
||||
_unwinding: bool
|
||||
) -> InterpResult<'tcx, StackPopInfo> {
|
||||
// By default, we do not support unwinding from panics
|
||||
Ok(StackPopInfo::Normal)
|
||||
|
@ -30,7 +30,7 @@
|
||||
self, InterpCx, ScalarMaybeUndef, Immediate, OpTy,
|
||||
StackPopCleanup, LocalValue, LocalState, AllocId, Frame,
|
||||
Allocation, MemoryKind, ImmTy, Pointer, Memory, PlaceTy,
|
||||
StackPopInfo, Operand as InterpOperand,
|
||||
Operand as InterpOperand,
|
||||
};
|
||||
use crate::const_eval::error_to_const_error;
|
||||
use crate::transform::{MirPass, MirSource};
|
||||
@ -252,15 +252,6 @@ fn before_terminator(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx
|
||||
fn stack_push(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
|
||||
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>;
|
||||
|
Loading…
Reference in New Issue
Block a user