Skip to content

Commit 5612feb

Browse files
committed
add machine hook to handle calls to 'extra' function values
1 parent 1297a27 commit 5612feb

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/librustc_mir/const_eval.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,16 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
371371
}))
372372
}
373373

374+
fn call_extra_fn(
375+
_ecx: &mut InterpretCx<'mir, 'tcx, Self>,
376+
fn_val: !,
377+
_args: &[OpTy<'tcx>],
378+
_dest: Option<PlaceTy<'tcx>>,
379+
_ret: Option<mir::BasicBlock>,
380+
) -> InterpResult<'tcx> {
381+
match fn_val {}
382+
}
383+
374384
fn call_intrinsic(
375385
ecx: &mut InterpCx<'mir, 'tcx, Self>,
376386
instance: ty::Instance<'tcx>,

src/librustc_mir/interpret/machine.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ pub trait Machine<'mir, 'tcx>: Sized {
124124
ret: Option<mir::BasicBlock>,
125125
) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>>;
126126

127+
/// Execute `fn_val`. it is the hook's responsibility to advance the instruction
128+
/// pointer as appropriate.
129+
fn call_extra_fn(
130+
ecx: &mut InterpretCx<'mir, 'tcx, Self>,
131+
fn_val: Self::ExtraFnVal,
132+
args: &[OpTy<'tcx, Self::PointerTag>],
133+
dest: Option<PlaceTy<'tcx, Self::PointerTag>>,
134+
ret: Option<mir::BasicBlock>,
135+
) -> InterpResult<'tcx>;
136+
127137
/// Directly process an intrinsic without pushing a stack frame.
128138
/// If this returns successfully, the engine will take care of jumping to the next block.
129139
fn call_intrinsic(

src/librustc_mir/interpret/terminator.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
237237
) -> InterpResult<'tcx> {
238238
trace!("eval_fn_call: {:#?}", fn_val);
239239

240-
let instance = fn_val.as_instance()?;
240+
let instance = match fn_val {
241+
FnVal::Instance(instance) => instance,
242+
FnVal::Other(extra) => {
243+
return M::call_extra_fn(self, extra, args, dest, ret);
244+
}
245+
};
241246

242247
match instance.def {
243248
ty::InstanceDef::Intrinsic(..) => {

0 commit comments

Comments
 (0)