remove some frame parameters that are no longer needed
This commit is contained in:
parent
b888e895de
commit
4497990dff
6 changed files with 18 additions and 18 deletions
|
@ -648,7 +648,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn layout_of_local(
|
||||
pub(super) fn layout_of_local(
|
||||
&self,
|
||||
frame: &Frame<'mir, 'tcx, M::Provenance, M::FrameExtra>,
|
||||
local: mir::Local,
|
||||
|
@ -899,7 +899,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// Copy return value. Must of course happen *before* we deallocate the locals.
|
||||
let copy_ret_result = if !unwinding {
|
||||
let op = self
|
||||
.local_to_op(self.frame(), mir::RETURN_PLACE, None)
|
||||
.local_to_op(mir::RETURN_PLACE, None)
|
||||
.expect("return place should always be live");
|
||||
let dest = self.frame().return_place.clone();
|
||||
let err = if self.stack().len() == 1 {
|
||||
|
|
|
@ -13,9 +13,9 @@ use rustc_middle::{mir, ty};
|
|||
use rustc_target::abi::{self, Abi, HasDataLayout, Size};
|
||||
|
||||
use super::{
|
||||
alloc_range, from_known_layout, mir_assign_valid_types, CtfeProvenance, Frame, InterpCx,
|
||||
InterpResult, MPlaceTy, Machine, MemPlace, MemPlaceMeta, OffsetMode, PlaceTy, Pointer,
|
||||
Projectable, Provenance, Scalar,
|
||||
alloc_range, from_known_layout, mir_assign_valid_types, CtfeProvenance, InterpCx, InterpResult,
|
||||
MPlaceTy, Machine, MemPlace, MemPlaceMeta, OffsetMode, PlaceTy, Pointer, Projectable,
|
||||
Provenance, Scalar,
|
||||
};
|
||||
|
||||
/// An `Immediate` represents a single immediate self-contained Rust value.
|
||||
|
@ -633,17 +633,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Read from a local.
|
||||
/// Read from a local of the current frame.
|
||||
/// Will not access memory, instead an indirect `Operand` is returned.
|
||||
///
|
||||
/// This is public because it is used by [priroda](https://github.com/oli-obk/priroda) to get an
|
||||
/// OpTy from a local.
|
||||
pub fn local_to_op(
|
||||
&self,
|
||||
frame: &Frame<'mir, 'tcx, M::Provenance, M::FrameExtra>,
|
||||
local: mir::Local,
|
||||
layout: Option<TyAndLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
|
||||
let frame = self.frame();
|
||||
let layout = self.layout_of_local(frame, local, layout)?;
|
||||
let op = *frame.locals[local].access()?;
|
||||
if matches!(op, Operand::Immediate(_)) {
|
||||
|
@ -664,7 +664,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
Right((local, offset, locals_addr)) => {
|
||||
debug_assert!(place.layout.is_sized()); // only sized locals can ever be `Place::Local`.
|
||||
debug_assert_eq!(locals_addr, self.frame().locals_addr());
|
||||
let base = self.local_to_op(&self.frame(), local, None)?;
|
||||
let base = self.local_to_op(local, None)?;
|
||||
Ok(match offset {
|
||||
Some(offset) => base.offset(offset, place.layout, self)?,
|
||||
None => {
|
||||
|
@ -688,7 +688,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// here is not the entire place.
|
||||
let layout = if mir_place.projection.is_empty() { layout } else { None };
|
||||
|
||||
let mut op = self.local_to_op(self.frame(), mir_place.local, layout)?;
|
||||
let mut op = self.local_to_op(mir_place.local, layout)?;
|
||||
// Using `try_fold` turned out to be bad for performance, hence the loop.
|
||||
for elem in mir_place.projection.iter() {
|
||||
op = self.project(&op, elem)?
|
||||
|
|
|
@ -506,21 +506,21 @@ where
|
|||
Ok((mplace, len))
|
||||
}
|
||||
|
||||
/// Turn a local in the current frame into a place.
|
||||
pub fn local_to_place(
|
||||
&self,
|
||||
frame: usize,
|
||||
local: mir::Local,
|
||||
) -> InterpResult<'tcx, PlaceTy<'tcx, M::Provenance>> {
|
||||
// Other parts of the system rely on `Place::Local` never being unsized.
|
||||
// So we eagerly check here if this local has an MPlace, and if yes we use it.
|
||||
let frame_ref = &self.stack()[frame];
|
||||
let layout = self.layout_of_local(frame_ref, local, None)?;
|
||||
let frame = self.frame();
|
||||
let layout = self.layout_of_local(frame, local, None)?;
|
||||
let place = if layout.is_sized() {
|
||||
// We can just always use the `Local` for sized values.
|
||||
Place::Local { local, offset: None, locals_addr: frame_ref.locals_addr() }
|
||||
Place::Local { local, offset: None, locals_addr: frame.locals_addr() }
|
||||
} else {
|
||||
// Unsized `Local` isn't okay (we cannot store the metadata).
|
||||
match frame_ref.locals[local].access()? {
|
||||
match frame.locals[local].access()? {
|
||||
Operand::Immediate(_) => bug!(),
|
||||
Operand::Indirect(mplace) => Place::Ptr(*mplace),
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ where
|
|||
&self,
|
||||
mir_place: mir::Place<'tcx>,
|
||||
) -> InterpResult<'tcx, PlaceTy<'tcx, M::Provenance>> {
|
||||
let mut place = self.local_to_place(self.frame_idx(), mir_place.local)?;
|
||||
let mut place = self.local_to_place(mir_place.local)?;
|
||||
// Using `try_fold` turned out to be bad for performance, hence the loop.
|
||||
for elem in mir_place.projection.iter() {
|
||||
place = self.project(&place, elem)?
|
||||
|
|
|
@ -357,7 +357,7 @@ where
|
|||
Deref => self.deref_pointer(&base.to_op(self)?)?.into(),
|
||||
Index(local) => {
|
||||
let layout = self.layout_of(self.tcx.types.usize)?;
|
||||
let n = self.local_to_op(self.frame(), local, Some(layout))?;
|
||||
let n = self.local_to_op(local, Some(layout))?;
|
||||
let n = self.read_target_usize(&n)?;
|
||||
self.project_index(base, n)?
|
||||
}
|
||||
|
|
|
@ -631,7 +631,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
body.args_iter()
|
||||
.map(|local| (
|
||||
local,
|
||||
self.layout_of_local(self.frame(), local, None).unwrap().ty
|
||||
self.layout_of_local(self.frame(), local, None).unwrap().ty,
|
||||
))
|
||||
.collect::<Vec<_>>()
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue