Rollup merge of #92551 - RalfJung:stack-pop-cleanup, r=oli-obk
rename StackPopClean::None to Root With https://github.com/rust-lang/rust/pull/90102, `StackPopClean::None` is now only used for the "root" frame of the stack, so adjust its name accordingly and add an assertion. r? `@oli-obk`
This commit is contained in:
commit
e525e6a507
@ -63,7 +63,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
|
|||||||
cid.instance,
|
cid.instance,
|
||||||
body,
|
body,
|
||||||
Some(&ret.into()),
|
Some(&ret.into()),
|
||||||
StackPopCleanup::None { cleanup: false },
|
StackPopCleanup::Root { cleanup: false },
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// The main interpreter loop.
|
// The main interpreter loop.
|
||||||
|
@ -156,11 +156,11 @@ pub enum StackPopCleanup {
|
|||||||
/// `ret` stores the block we jump to on a normal return, while `unwind`
|
/// `ret` stores the block we jump to on a normal return, while `unwind`
|
||||||
/// stores the block used for cleanup during unwinding.
|
/// stores the block used for cleanup during unwinding.
|
||||||
Goto { ret: Option<mir::BasicBlock>, unwind: StackPopUnwind },
|
Goto { ret: Option<mir::BasicBlock>, unwind: StackPopUnwind },
|
||||||
/// Just do nothing: Used by Main and for TLS hooks in miri.
|
/// The root frame of the stack: nowhere else to jump to.
|
||||||
/// `cleanup` says whether locals are deallocated. Static computation
|
/// `cleanup` says whether locals are deallocated. Static computation
|
||||||
/// wants them leaked to intern what they need (and just throw away
|
/// wants them leaked to intern what they need (and just throw away
|
||||||
/// the entire `ecx` when it is done).
|
/// the entire `ecx` when it is done).
|
||||||
None { cleanup: bool },
|
Root { cleanup: bool },
|
||||||
}
|
}
|
||||||
|
|
||||||
/// State of a local variable including a memoized layout
|
/// State of a local variable including a memoized layout
|
||||||
@ -849,7 +849,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
// because this is CTFE and the final value will be thoroughly validated anyway.
|
// because this is CTFE and the final value will be thoroughly validated anyway.
|
||||||
let cleanup = match return_to_block {
|
let cleanup = match return_to_block {
|
||||||
StackPopCleanup::Goto { .. } => true,
|
StackPopCleanup::Goto { .. } => true,
|
||||||
StackPopCleanup::None { cleanup, .. } => cleanup,
|
StackPopCleanup::Root { cleanup, .. } => cleanup,
|
||||||
};
|
};
|
||||||
|
|
||||||
if !cleanup {
|
if !cleanup {
|
||||||
@ -874,8 +874,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
// Follow the unwind edge.
|
// Follow the unwind edge.
|
||||||
let unwind = match return_to_block {
|
let unwind = match return_to_block {
|
||||||
StackPopCleanup::Goto { unwind, .. } => unwind,
|
StackPopCleanup::Goto { unwind, .. } => unwind,
|
||||||
StackPopCleanup::None { .. } => {
|
StackPopCleanup::Root { .. } => {
|
||||||
panic!("Encountered StackPopCleanup::None when unwinding!")
|
panic!("encountered StackPopCleanup::Root when unwinding!")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.unwind_to_block(unwind)
|
self.unwind_to_block(unwind)
|
||||||
@ -883,7 +883,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
// Follow the normal return edge.
|
// Follow the normal return edge.
|
||||||
match return_to_block {
|
match return_to_block {
|
||||||
StackPopCleanup::Goto { ret, .. } => self.return_to_block(ret),
|
StackPopCleanup::Goto { ret, .. } => self.return_to_block(ret),
|
||||||
StackPopCleanup::None { .. } => Ok(()),
|
StackPopCleanup::Root { .. } => {
|
||||||
|
assert!(
|
||||||
|
self.stack().is_empty(),
|
||||||
|
"only the topmost frame can have StackPopCleanup::Root"
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
|||||||
Instance::new(def_id, substs),
|
Instance::new(def_id, substs),
|
||||||
dummy_body,
|
dummy_body,
|
||||||
ret.as_ref(),
|
ret.as_ref(),
|
||||||
StackPopCleanup::None { cleanup: false },
|
StackPopCleanup::Root { cleanup: false },
|
||||||
)
|
)
|
||||||
.expect("failed to push initial stack frame");
|
.expect("failed to push initial stack frame");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user