Remove trampoline, pass ret and unwind when handling intrinsics

This commit is contained in:
Aaron Hill 2019-11-05 00:06:05 -05:00
parent 607339f66a
commit 4ecb80d5d8
No known key found for this signature in database
GPG Key ID: B4087E510E98B164
7 changed files with 13 additions and 23 deletions

View File

@ -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;

View File

@ -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() {}

View File

@ -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(());

View File

@ -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.

View File

@ -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.

View File

@ -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() {

View File

@ -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");
}