Remove trampoline, pass ret
and unwind
when handling intrinsics
This commit is contained in:
parent
607339f66a
commit
4ecb80d5d8
@ -39,9 +39,6 @@
|
||||
if #[cfg(miri)] {
|
||||
#[path = "miri.rs"]
|
||||
mod imp;
|
||||
// Export this at the root of the crate so that Miri
|
||||
// has a stable palce to look it up
|
||||
pub use imp::miri_panic_trampoline;
|
||||
} else if #[cfg(target_os = "emscripten")] {
|
||||
#[path = "emcc.rs"]
|
||||
mod imp;
|
||||
|
@ -21,8 +21,3 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
|
||||
fn rust_eh_personality() {
|
||||
unsafe { core::intrinsics::abort() }
|
||||
}
|
||||
|
||||
// A dummy helper function for Miri.
|
||||
// Used to push an empty stack frame when we start unwinding
|
||||
#[cfg(miri)]
|
||||
pub fn miri_panic_trampoline() {}
|
||||
|
@ -376,6 +376,8 @@ fn call_intrinsic(
|
||||
instance: ty::Instance<'tcx>,
|
||||
args: &[OpTy<'tcx>],
|
||||
dest: Option<PlaceTy<'tcx>>,
|
||||
_ret: Option<mir::BasicBlock>,
|
||||
_unwind: Option<mir::BasicBlock>
|
||||
) -> InterpResult<'tcx> {
|
||||
if ecx.emulate_intrinsic(span, instance, args, dest)? {
|
||||
return Ok(());
|
||||
|
@ -585,21 +585,17 @@ pub(super) fn pop_stack_frame(
|
||||
"tried to pop a stack frame, but there were none",
|
||||
);
|
||||
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!"),
|
||||
(false, StackPopInfo::StopUnwinding) =>
|
||||
bug!("Attempted to stop unwinding while there is no unwinding!"),
|
||||
_ => {}
|
||||
if let (false, StackPopInfo::StopUnwinding) = (unwinding, stack_pop_info) {
|
||||
bug!("Attempted to stop unwinding while there is no unwinding!");
|
||||
}
|
||||
|
||||
// Now where do we jump next?
|
||||
|
||||
// Determine if we leave this function normally or via unwinding.
|
||||
let cur_unwinding = match stack_pop_info {
|
||||
StackPopInfo::StartUnwinding => true,
|
||||
StackPopInfo::StopUnwinding => false,
|
||||
_ => unwinding
|
||||
let cur_unwinding = if let StackPopInfo::StopUnwinding = stack_pop_info {
|
||||
false
|
||||
} else {
|
||||
unwinding
|
||||
};
|
||||
|
||||
// Usually we want to clean up (deallocate locals), but in a few rare cases we don't.
|
||||
|
@ -20,10 +20,6 @@
|
||||
/// to provide further control over the popping of the stack frame
|
||||
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
|
||||
pub enum StackPopInfo {
|
||||
/// Indicates that we have just started unwinding
|
||||
/// as the result of panic
|
||||
StartUnwinding,
|
||||
|
||||
/// Indicates that no special handling should be
|
||||
/// done - we'll either return normally or unwind
|
||||
/// based on the terminator for the function
|
||||
@ -177,6 +173,8 @@ fn call_intrinsic(
|
||||
instance: ty::Instance<'tcx>,
|
||||
args: &[OpTy<'tcx, Self::PointerTag>],
|
||||
dest: Option<PlaceTy<'tcx, Self::PointerTag>>,
|
||||
ret: Option<mir::BasicBlock>,
|
||||
unwind: Option<mir::BasicBlock>,
|
||||
) -> InterpResult<'tcx>;
|
||||
|
||||
/// Called for read access to a foreign static item.
|
||||
|
@ -265,7 +265,7 @@ fn eval_fn_call(
|
||||
match instance.def {
|
||||
ty::InstanceDef::Intrinsic(..) => {
|
||||
let old_stack = self.cur_frame();
|
||||
M::call_intrinsic(self, span, instance, args, dest)?;
|
||||
M::call_intrinsic(self, span, instance, args, dest, ret, unwind)?;
|
||||
// No stack frame gets pushed, the main loop will just act as if the
|
||||
// call completed.
|
||||
if ret.is_some() {
|
||||
|
@ -164,6 +164,8 @@ fn call_intrinsic(
|
||||
_instance: ty::Instance<'tcx>,
|
||||
_args: &[OpTy<'tcx>],
|
||||
_dest: Option<PlaceTy<'tcx>>,
|
||||
_ret: Option<BasicBlock>,
|
||||
_unwind: Option<BasicBlock>
|
||||
) -> InterpResult<'tcx> {
|
||||
throw_unsup_format!("calling intrinsics isn't supported in ConstProp");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user