Skip to content

Commit 5900b32

Browse files
committed
unify call_intrinsic handling of intruction pointer with other machine hooks
1 parent 7bfed2e commit 5900b32

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

src/librustc_mir/interpret/machine.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
141141
/// Returns either the mir to use for the call, or `None` if execution should
142142
/// just proceed (which usually means this hook did all the work that the
143143
/// called function should usually have done). In the latter case, it is
144-
/// this hook's responsibility to call `goto_block(ret)` to advance the instruction pointer!
144+
/// this hook's responsibility to advance the instruction pointer!
145145
/// (This is to support functions like `__rust_maybe_catch_panic` that neither find a MIR
146146
/// nor just jump to `ret`, but instead push their own stack frame.)
147147
/// Passing `dest`and `ret` in the same `Option` proved very annoying when only one of them
@@ -155,7 +155,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
155155
unwind: Option<mir::BasicBlock>
156156
) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>>;
157157

158-
/// Execute `fn_val`. it is the hook's responsibility to advance the instruction
158+
/// Execute `fn_val`. It is the hook's responsibility to advance the instruction
159159
/// pointer as appropriate.
160160
fn call_extra_fn(
161161
ecx: &mut InterpCx<'mir, 'tcx, Self>,
@@ -165,8 +165,8 @@ pub trait Machine<'mir, 'tcx>: Sized {
165165
ret: Option<mir::BasicBlock>,
166166
) -> InterpResult<'tcx>;
167167

168-
/// Directly process an intrinsic without pushing a stack frame.
169-
/// If this returns successfully, the engine will take care of jumping to the next block.
168+
/// Directly process an intrinsic without pushing a stack frame. It is the hook's
169+
/// responsibility to advance the instruction pointer as appropriate.
170170
fn call_intrinsic(
171171
ecx: &mut InterpCx<'mir, 'tcx, Self>,
172172
span: Span,

src/librustc_mir/interpret/terminator.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -254,25 +254,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
254254
match instance.def {
255255
ty::InstanceDef::Intrinsic(..) => {
256256
assert!(caller_abi == Abi::RustIntrinsic || caller_abi == Abi::PlatformIntrinsic);
257-
258-
let old_stack = self.cur_frame();
259-
let old_bb = self.frame().block;
260-
M::call_intrinsic(self, span, instance, args, dest, ret, unwind)?;
261-
// No stack frame gets pushed, the main loop will just act as if the
262-
// call completed.
263-
if ret.is_some() {
264-
self.return_to_block(ret)?;
265-
} else {
266-
// If this intrinsic call doesn't have a ret block,
267-
// then the intrinsic implementation should have
268-
// changed the stack frame (otherwise, we'll end
269-
// up trying to execute this intrinsic call again)
270-
debug_assert!(self.cur_frame() != old_stack || self.frame().block != old_bb);
271-
}
272-
if let Some(dest) = dest {
273-
self.dump_place(*dest)
274-
}
275-
Ok(())
257+
return M::call_intrinsic(self, span, instance, args, dest, ret, unwind);
276258
}
277259
ty::InstanceDef::VtableShim(..) |
278260
ty::InstanceDef::ReifyShim(..) |

0 commit comments

Comments
 (0)