add machine hook to handle calls to 'extra' function values
This commit is contained in:
parent
1297a274a3
commit
5612feb513
3 changed files with 26 additions and 1 deletions
|
@ -371,6 +371,16 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
|||
}))
|
||||
}
|
||||
|
||||
fn call_extra_fn(
|
||||
_ecx: &mut InterpretCx<'mir, 'tcx, Self>,
|
||||
fn_val: !,
|
||||
_args: &[OpTy<'tcx>],
|
||||
_dest: Option<PlaceTy<'tcx>>,
|
||||
_ret: Option<mir::BasicBlock>,
|
||||
) -> InterpResult<'tcx> {
|
||||
match fn_val {}
|
||||
}
|
||||
|
||||
fn call_intrinsic(
|
||||
ecx: &mut InterpCx<'mir, 'tcx, Self>,
|
||||
instance: ty::Instance<'tcx>,
|
||||
|
|
|
@ -124,6 +124,16 @@ pub trait Machine<'mir, 'tcx>: Sized {
|
|||
ret: Option<mir::BasicBlock>,
|
||||
) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>>;
|
||||
|
||||
/// Execute `fn_val`. it is the hook's responsibility to advance the instruction
|
||||
/// pointer as appropriate.
|
||||
fn call_extra_fn(
|
||||
ecx: &mut InterpretCx<'mir, 'tcx, Self>,
|
||||
fn_val: Self::ExtraFnVal,
|
||||
args: &[OpTy<'tcx, Self::PointerTag>],
|
||||
dest: Option<PlaceTy<'tcx, Self::PointerTag>>,
|
||||
ret: Option<mir::BasicBlock>,
|
||||
) -> InterpResult<'tcx>;
|
||||
|
||||
/// Directly process an intrinsic without pushing a stack frame.
|
||||
/// If this returns successfully, the engine will take care of jumping to the next block.
|
||||
fn call_intrinsic(
|
||||
|
|
|
@ -237,7 +237,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
) -> InterpResult<'tcx> {
|
||||
trace!("eval_fn_call: {:#?}", fn_val);
|
||||
|
||||
let instance = fn_val.as_instance()?;
|
||||
let instance = match fn_val {
|
||||
FnVal::Instance(instance) => instance,
|
||||
FnVal::Other(extra) => {
|
||||
return M::call_extra_fn(self, extra, args, dest, ret);
|
||||
}
|
||||
};
|
||||
|
||||
match instance.def {
|
||||
ty::InstanceDef::Intrinsic(..) => {
|
||||
|
|
Loading…
Reference in a new issue