inline the call method into interpret_start_points

This commit is contained in:
Oliver Schneider 2016-06-09 16:49:40 +02:00
parent fc935c10f8
commit 2dbd82d296
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46

View file

@ -135,18 +135,6 @@ impl<'a, 'tcx> GlobalEvalContext<'a, 'tcx> {
}
}
fn call(&mut self, mir: &'a mir::Mir<'tcx>, def_id: DefId) -> EvalResult<Option<Pointer>> {
let substs = self.tcx.mk_substs(subst::Substs::empty());
let return_ptr = self.alloc_ret_ptr(mir.return_ty, substs);
self.push_stack_frame(def_id, mir.span, CachedMir::Ref(mir), substs, None);
self.frame_mut().return_ptr = return_ptr;
self.run()?;
Ok(return_ptr)
}
fn alloc_ret_ptr(&mut self, output_ty: ty::FnOutput<'tcx>, substs: &'tcx Substs<'tcx>) -> Option<Pointer> {
match output_ty {
ty::FnConverging(ty) => {
@ -1423,12 +1411,18 @@ pub fn interpret_start_points<'a, 'tcx>(
debug!("Interpreting: {}", item.name);
let mut gecx = GlobalEvalContext::new(tcx, mir_map);
match gecx.call(mir, tcx.map.local_def_id(id)) {
Ok(Some(return_ptr)) => if log_enabled!(::log::LogLevel::Debug) {
gecx.memory.dump(return_ptr.alloc_id);
let substs = tcx.mk_substs(subst::Substs::empty());
let return_ptr = gecx.alloc_ret_ptr(mir.return_ty, substs);
gecx.push_stack_frame(tcx.map.local_def_id(id), mir.span, CachedMir::Ref(mir), substs, return_ptr);
match (gecx.run(), return_ptr) {
(Ok(()), Some(ptr)) => if log_enabled!(::log::LogLevel::Debug) {
gecx.memory.dump(ptr.alloc_id);
},
Ok(None) => warn!("diverging function returned"),
Err(e) => gecx.report(e),
(Ok(()), None) => warn!("diverging function returned"),
// FIXME: diverging functions can end up here in some future miri
(Err(e), _) => gecx.report(e),
}
}
}