make some Frame fields more private
This commit is contained in:
parent
522af10ccc
commit
5783e73f46
6 changed files with 25 additions and 21 deletions
|
@ -61,10 +61,10 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> {
|
||||||
// Function and callsite information
|
// Function and callsite information
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// The MIR for the function called on this frame.
|
/// The MIR for the function called on this frame.
|
||||||
pub body: &'tcx mir::Body<'tcx>,
|
pub(super) body: &'tcx mir::Body<'tcx>,
|
||||||
|
|
||||||
/// The def_id and args of the current function.
|
/// The def_id and args of the current function.
|
||||||
pub instance: ty::Instance<'tcx>,
|
pub(super) instance: ty::Instance<'tcx>,
|
||||||
|
|
||||||
/// Extra data for the machine.
|
/// Extra data for the machine.
|
||||||
pub extra: Extra,
|
pub extra: Extra,
|
||||||
|
@ -73,7 +73,7 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> {
|
||||||
// Return place and locals
|
// Return place and locals
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Work to perform when returning from this function.
|
/// Work to perform when returning from this function.
|
||||||
pub return_to_block: StackPopCleanup,
|
return_to_block: StackPopCleanup,
|
||||||
|
|
||||||
/// The location where the result of the current stack frame should be written to,
|
/// The location where the result of the current stack frame should be written to,
|
||||||
/// and its layout in the caller.
|
/// and its layout in the caller.
|
||||||
|
@ -101,7 +101,7 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> {
|
||||||
/// frames without cleanup code).
|
/// frames without cleanup code).
|
||||||
///
|
///
|
||||||
/// Needs to be public because ConstProp does unspeakable things to it.
|
/// Needs to be public because ConstProp does unspeakable things to it.
|
||||||
pub loc: Either<mir::Location, Span>,
|
pub(super) loc: Either<mir::Location, Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Eq, PartialEq, Debug)] // Miri debug-prints these
|
#[derive(Clone, Copy, Eq, PartialEq, Debug)] // Miri debug-prints these
|
||||||
|
@ -269,6 +269,14 @@ impl<'tcx, Prov: Provenance, Extra> Frame<'tcx, Prov, Extra> {
|
||||||
self.loc
|
self.loc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn body(&self) -> &'tcx mir::Body<'tcx> {
|
||||||
|
self.body
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn instance(&self) -> ty::Instance<'tcx> {
|
||||||
|
self.instance
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the `SourceInfo` of the current instruction.
|
/// Return the `SourceInfo` of the current instruction.
|
||||||
pub fn current_source_info(&self) -> Option<&mir::SourceInfo> {
|
pub fn current_source_info(&self) -> Option<&mir::SourceInfo> {
|
||||||
self.loc.left().map(|loc| self.body.source_info(loc))
|
self.loc.left().map(|loc| self.body.source_info(loc))
|
||||||
|
|
|
@ -377,10 +377,6 @@ impl VisitProvenance for Frame<'_, Provenance, FrameExtra<'_>> {
|
||||||
return_place,
|
return_place,
|
||||||
locals,
|
locals,
|
||||||
extra,
|
extra,
|
||||||
body: _,
|
|
||||||
instance: _,
|
|
||||||
return_to_block: _,
|
|
||||||
loc: _,
|
|
||||||
// There are some private fields we cannot access; they contain no tags.
|
// There are some private fields we cannot access; they contain no tags.
|
||||||
..
|
..
|
||||||
} = self;
|
} = self;
|
||||||
|
|
|
@ -1105,12 +1105,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||||
// Make an attempt to get at the instance of the function this is inlined from.
|
// Make an attempt to get at the instance of the function this is inlined from.
|
||||||
let instance: Option<_> = try {
|
let instance: Option<_> = try {
|
||||||
let scope = frame.current_source_info()?.scope;
|
let scope = frame.current_source_info()?.scope;
|
||||||
let inlined_parent = frame.body.source_scopes[scope].inlined_parent_scope?;
|
let inlined_parent = frame.body().source_scopes[scope].inlined_parent_scope?;
|
||||||
let source = &frame.body.source_scopes[inlined_parent];
|
let source = &frame.body().source_scopes[inlined_parent];
|
||||||
source.inlined.expect("inlined_parent_scope points to scope without inline info").0
|
source.inlined.expect("inlined_parent_scope points to scope without inline info").0
|
||||||
};
|
};
|
||||||
// Fall back to the instance of the function itself.
|
// Fall back to the instance of the function itself.
|
||||||
let instance = instance.unwrap_or(frame.instance);
|
let instance = instance.unwrap_or(frame.instance());
|
||||||
// Now check the crate it is in. We could try to be clever here and e.g. check if this is
|
// Now check the crate it is in. We could try to be clever here and e.g. check if this is
|
||||||
// the same crate as `start_fn`, but that would not work for running std tests in Miri, so
|
// the same crate as `start_fn`, but that would not work for running std tests in Miri, so
|
||||||
// we'd need some more hacks anyway. So we just check the name of the crate. If someone
|
// we'd need some more hacks anyway. So we just check the name of the crate. If someone
|
||||||
|
@ -1350,9 +1350,9 @@ impl<'tcx> MiriMachine<'tcx> {
|
||||||
|
|
||||||
/// This is the source of truth for the `is_user_relevant` flag in our `FrameExtra`.
|
/// This is the source of truth for the `is_user_relevant` flag in our `FrameExtra`.
|
||||||
pub fn is_user_relevant(&self, frame: &Frame<'tcx, Provenance>) -> bool {
|
pub fn is_user_relevant(&self, frame: &Frame<'tcx, Provenance>) -> bool {
|
||||||
let def_id = frame.instance.def_id();
|
let def_id = frame.instance().def_id();
|
||||||
(def_id.is_local() || self.local_crates.contains(&def_id.krate))
|
(def_id.is_local() || self.local_crates.contains(&def_id.krate))
|
||||||
&& !frame.instance.def.requires_caller_location(self.tcx)
|
&& !frame.instance().def.requires_caller_location(self.tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1352,7 +1352,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
|
||||||
) -> InterpResult<'tcx, Frame<'tcx, Provenance, FrameExtra<'tcx>>> {
|
) -> InterpResult<'tcx, Frame<'tcx, Provenance, FrameExtra<'tcx>>> {
|
||||||
// Start recording our event before doing anything else
|
// Start recording our event before doing anything else
|
||||||
let timing = if let Some(profiler) = ecx.machine.profiler.as_ref() {
|
let timing = if let Some(profiler) = ecx.machine.profiler.as_ref() {
|
||||||
let fn_name = frame.instance.to_string();
|
let fn_name = frame.instance().to_string();
|
||||||
let entry = ecx.machine.string_cache.entry(fn_name.clone());
|
let entry = ecx.machine.string_cache.entry(fn_name.clone());
|
||||||
let name = entry.or_insert_with(|| profiler.alloc_string(&*fn_name));
|
let name = entry.or_insert_with(|| profiler.alloc_string(&*fn_name));
|
||||||
|
|
||||||
|
@ -1443,7 +1443,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
|
||||||
// tracing-tree can autoamtically annotate scope changes, but it gets very confused by our
|
// tracing-tree can autoamtically annotate scope changes, but it gets very confused by our
|
||||||
// concurrency and what it prints is just plain wrong. So we print our own information
|
// concurrency and what it prints is just plain wrong. So we print our own information
|
||||||
// instead. (Cc https://github.com/rust-lang/miri/issues/2266)
|
// instead. (Cc https://github.com/rust-lang/miri/issues/2266)
|
||||||
info!("Leaving {}", ecx.frame().instance);
|
info!("Leaving {}", ecx.frame().instance());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1473,7 +1473,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
|
||||||
// Needs to be done after dropping frame to show up on the right nesting level.
|
// Needs to be done after dropping frame to show up on the right nesting level.
|
||||||
// (Cc https://github.com/rust-lang/miri/issues/2266)
|
// (Cc https://github.com/rust-lang/miri/issues/2266)
|
||||||
if !ecx.active_thread_stack().is_empty() {
|
if !ecx.active_thread_stack().is_empty() {
|
||||||
info!("Continuing in {}", ecx.frame().instance);
|
info!("Continuing in {}", ecx.frame().instance());
|
||||||
}
|
}
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
@ -1486,7 +1486,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
|
||||||
let Some(Provenance::Concrete { alloc_id, .. }) = mplace.ptr().provenance else {
|
let Some(Provenance::Concrete { alloc_id, .. }) = mplace.ptr().provenance else {
|
||||||
panic!("after_local_allocated should only be called on fresh allocations");
|
panic!("after_local_allocated should only be called on fresh allocations");
|
||||||
};
|
};
|
||||||
let local_decl = &ecx.frame().body.local_decls[local];
|
let local_decl = &ecx.frame().body().local_decls[local];
|
||||||
let span = local_decl.source_info.span;
|
let span = local_decl.source_info.span;
|
||||||
ecx.machine.allocation_spans.borrow_mut().insert(alloc_id, (span, None));
|
ecx.machine.allocation_spans.borrow_mut().insert(alloc_id, (span, None));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -46,8 +46,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
for frame in this.active_thread_stack().iter().rev() {
|
for frame in this.active_thread_stack().iter().rev() {
|
||||||
// Match behavior of debuginfo (`FunctionCx::adjusted_span_and_dbg_scope`).
|
// Match behavior of debuginfo (`FunctionCx::adjusted_span_and_dbg_scope`).
|
||||||
let span = hygiene::walk_chain_collapsed(frame.current_span(), frame.body.span);
|
let span = hygiene::walk_chain_collapsed(frame.current_span(), frame.body().span);
|
||||||
data.push((frame.instance, span.lo()));
|
data.push((frame.instance(), span.lo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let ptrs: Vec<_> = data
|
let ptrs: Vec<_> = data
|
||||||
|
|
|
@ -48,7 +48,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||||
fn handle_miri_start_unwind(&mut self, payload: &OpTy<'tcx>) -> InterpResult<'tcx> {
|
fn handle_miri_start_unwind(&mut self, payload: &OpTy<'tcx>) -> InterpResult<'tcx> {
|
||||||
let this = self.eval_context_mut();
|
let this = self.eval_context_mut();
|
||||||
|
|
||||||
trace!("miri_start_unwind: {:?}", this.frame().instance);
|
trace!("miri_start_unwind: {:?}", this.frame().instance());
|
||||||
|
|
||||||
let payload = this.read_immediate(payload)?;
|
let payload = this.read_immediate(payload)?;
|
||||||
let thread = this.active_thread_mut();
|
let thread = this.active_thread_mut();
|
||||||
|
@ -124,7 +124,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||||
// and we are unwinding, so we should catch that.
|
// and we are unwinding, so we should catch that.
|
||||||
trace!(
|
trace!(
|
||||||
"unwinding: found catch_panic frame during unwinding: {:?}",
|
"unwinding: found catch_panic frame during unwinding: {:?}",
|
||||||
this.frame().instance
|
this.frame().instance()
|
||||||
);
|
);
|
||||||
|
|
||||||
// We set the return value of `try` to 1, since there was a panic.
|
// We set the return value of `try` to 1, since there was a panic.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue