interpret: the MIR is actually at lifetime 'tcx
This commit is contained in:
parent
cdc509f7c0
commit
36d36a3e1f
13 changed files with 75 additions and 74 deletions
|
|
@ -354,7 +354,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
|||
|
||||
fn on_stack_pop(
|
||||
&self,
|
||||
frame: &Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>,
|
||||
frame: &Frame<'tcx, Provenance, FrameExtra<'tcx>>,
|
||||
) -> InterpResult<'tcx> {
|
||||
let this = self.eval_context_ref();
|
||||
let borrow_tracker = this.machine.borrow_tracker.as_ref().unwrap();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use std::time::{Duration, SystemTime};
|
|||
use either::Either;
|
||||
|
||||
use rustc_const_eval::CTRL_C_RECEIVED;
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_index::{Idx, IndexVec};
|
||||
|
|
@ -235,7 +236,7 @@ pub struct Thread<'mir, 'tcx> {
|
|||
thread_name: Option<Vec<u8>>,
|
||||
|
||||
/// The virtual call stack.
|
||||
stack: Vec<Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>>,
|
||||
stack: Vec<Frame<'tcx, Provenance, FrameExtra<'tcx>>>,
|
||||
|
||||
/// The function to call when the stack ran empty, to figure out what to do next.
|
||||
/// Conceptually, this is the interpreter implementation of the things that happen 'after' the
|
||||
|
|
@ -376,7 +377,7 @@ impl VisitProvenance for Thread<'_, '_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl VisitProvenance for Frame<'_, '_, Provenance, FrameExtra<'_>> {
|
||||
impl VisitProvenance for Frame<'_, Provenance, FrameExtra<'_>> {
|
||||
fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
|
||||
let Frame {
|
||||
return_place,
|
||||
|
|
@ -505,19 +506,18 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
|
|||
}
|
||||
|
||||
/// Borrow the stack of the active thread.
|
||||
pub fn active_thread_stack(&self) -> &[Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>] {
|
||||
pub fn active_thread_stack(&self) -> &[Frame<'tcx, Provenance, FrameExtra<'tcx>>] {
|
||||
&self.threads[self.active_thread].stack
|
||||
}
|
||||
|
||||
/// Mutably borrow the stack of the active thread.
|
||||
fn active_thread_stack_mut(
|
||||
&mut self,
|
||||
) -> &mut Vec<Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>> {
|
||||
fn active_thread_stack_mut(&mut self) -> &mut Vec<Frame<'tcx, Provenance, FrameExtra<'tcx>>> {
|
||||
&mut self.threads[self.active_thread].stack
|
||||
}
|
||||
pub fn all_stacks(
|
||||
&self,
|
||||
) -> impl Iterator<Item = (ThreadId, &[Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>])> {
|
||||
) -> impl Iterator<Item = (ThreadId, &[Frame<'tcx, Provenance, FrameExtra<'tcx>>])> + Captures<'mir>
|
||||
{
|
||||
self.threads.iter_enumerated().map(|(id, t)| (id, &t.stack[..]))
|
||||
}
|
||||
|
||||
|
|
@ -1099,15 +1099,21 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn active_thread_stack(&self) -> &[Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>] {
|
||||
fn active_thread_stack<'a>(&'a self) -> &'a [Frame<'tcx, Provenance, FrameExtra<'tcx>>]
|
||||
where
|
||||
'mir: 'a,
|
||||
{
|
||||
let this = self.eval_context_ref();
|
||||
this.machine.threads.active_thread_stack()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn active_thread_stack_mut(
|
||||
&mut self,
|
||||
) -> &mut Vec<Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>> {
|
||||
fn active_thread_stack_mut<'a>(
|
||||
&'a mut self,
|
||||
) -> &'a mut Vec<Frame<'tcx, Provenance, FrameExtra<'tcx>>>
|
||||
where
|
||||
'mir: 'a,
|
||||
{
|
||||
let this = self.eval_context_mut();
|
||||
this.machine.threads.active_thread_stack_mut()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1321,7 +1321,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
|
|||
self.stack()[frame_idx].current_span()
|
||||
}
|
||||
|
||||
fn stack(&self) -> &[Frame<'mir, 'tcx, Provenance, machine::FrameExtra<'tcx>>] {
|
||||
fn stack(&self) -> &[Frame<'tcx, Provenance, machine::FrameExtra<'tcx>>] {
|
||||
self.threads.active_thread_stack()
|
||||
}
|
||||
|
||||
|
|
@ -1330,7 +1330,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
|
|||
}
|
||||
|
||||
/// This is the source of truth for the `is_user_relevant` flag in our `FrameExtra`.
|
||||
pub fn is_user_relevant(&self, frame: &Frame<'mir, 'tcx, Provenance>) -> bool {
|
||||
pub fn is_user_relevant(&self, frame: &Frame<'tcx, Provenance>) -> bool {
|
||||
let def_id = frame.instance.def_id();
|
||||
(def_id.is_local() || self.local_crates.contains(&def_id.krate))
|
||||
&& !frame.instance.def.requires_caller_location(self.tcx)
|
||||
|
|
|
|||
|
|
@ -949,7 +949,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
|
|||
dest: &MPlaceTy<'tcx, Provenance>,
|
||||
ret: Option<mir::BasicBlock>,
|
||||
unwind: mir::UnwindAction,
|
||||
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
|
||||
) -> InterpResult<'tcx, Option<(&'tcx mir::Body<'tcx>, ty::Instance<'tcx>)>> {
|
||||
// For foreign items, try to see if we can emulate them.
|
||||
if ecx.tcx.is_foreign_item(instance.def_id()) {
|
||||
// An external function call that does not have a MIR body. We either find MIR elsewhere
|
||||
|
|
@ -1359,8 +1359,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
|
|||
#[inline(always)]
|
||||
fn init_frame_extra(
|
||||
ecx: &mut InterpCx<'mir, 'tcx, Self>,
|
||||
frame: Frame<'mir, 'tcx, Provenance>,
|
||||
) -> InterpResult<'tcx, Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>> {
|
||||
frame: Frame<'tcx, Provenance>,
|
||||
) -> InterpResult<'tcx, Frame<'tcx, Provenance, FrameExtra<'tcx>>> {
|
||||
// Start recording our event before doing anything else
|
||||
let timing = if let Some(profiler) = ecx.machine.profiler.as_ref() {
|
||||
let fn_name = frame.instance.to_string();
|
||||
|
|
@ -1391,13 +1391,13 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
|
|||
|
||||
fn stack<'a>(
|
||||
ecx: &'a InterpCx<'mir, 'tcx, Self>,
|
||||
) -> &'a [Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>] {
|
||||
) -> &'a [Frame<'tcx, Self::Provenance, Self::FrameExtra>] {
|
||||
ecx.active_thread_stack()
|
||||
}
|
||||
|
||||
fn stack_mut<'a>(
|
||||
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
|
||||
) -> &'a mut Vec<Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>> {
|
||||
) -> &'a mut Vec<Frame<'tcx, Self::Provenance, Self::FrameExtra>> {
|
||||
ecx.active_thread_stack_mut()
|
||||
}
|
||||
|
||||
|
|
@ -1444,7 +1444,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
|
|||
|
||||
fn before_stack_pop(
|
||||
ecx: &InterpCx<'mir, 'tcx, Self>,
|
||||
frame: &Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>,
|
||||
frame: &Frame<'tcx, Self::Provenance, Self::FrameExtra>,
|
||||
) -> InterpResult<'tcx> {
|
||||
// We want this *before* the return value copy, because the return place itself is protected
|
||||
// until we do `end_call` here.
|
||||
|
|
@ -1461,7 +1461,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
|
|||
#[inline(always)]
|
||||
fn after_stack_pop(
|
||||
ecx: &mut InterpCx<'mir, 'tcx, Self>,
|
||||
frame: Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>,
|
||||
frame: Frame<'tcx, Provenance, FrameExtra<'tcx>>,
|
||||
unwinding: bool,
|
||||
) -> InterpResult<'tcx, StackPopJump> {
|
||||
if frame.extra.is_user_relevant {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
|||
dest: &MPlaceTy<'tcx, Provenance>,
|
||||
ret: Option<mir::BasicBlock>,
|
||||
unwind: mir::UnwindAction,
|
||||
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
|
||||
) -> InterpResult<'tcx, Option<(&'tcx mir::Body<'tcx>, ty::Instance<'tcx>)>> {
|
||||
let this = self.eval_context_mut();
|
||||
let tcx = this.tcx.tcx;
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
|||
fn lookup_exported_symbol(
|
||||
&mut self,
|
||||
link_name: Symbol,
|
||||
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
|
||||
) -> InterpResult<'tcx, Option<(&'tcx mir::Body<'tcx>, ty::Instance<'tcx>)>> {
|
||||
let this = self.eval_context_mut();
|
||||
let tcx = this.tcx.tcx;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue